diff options
| -rw-r--r-- | docs/site/media/themes/lapis_plain.png | bin | 54111 -> 0 bytes | |||
| -rw-r--r-- | docs/site/media/themes/themes.toml | 5 | ||||
| -rw-r--r-- | docs/typ/builtins-gui.json | 1 | ||||
| -rw-r--r-- | docs/typ/reference.typ | 2 | ||||
| -rw-r--r-- | docs/typ/themes.typ | 7 | ||||
| -rw-r--r-- | shaders/decor.frag.glsl | 22 | ||||
| -rw-r--r-- | shaders/prebuilt/decor.frag.spv | bin | 3772 -> 2176 bytes | |||
| -rw-r--r-- | shaders/prebuilt/ui.frag.spv | bin | 6188 -> 3184 bytes | |||
| -rw-r--r-- | shaders/prebuilt/ui.vert.spv | bin | 4072 -> 3848 bytes | |||
| -rw-r--r-- | shaders/ui.frag.glsl | 48 | ||||
| -rw-r--r-- | shaders/ui.vert.glsl | 16 | ||||
| -rw-r--r-- | src/colors.zig | 67 | ||||
| -rw-r--r-- | src/config.zig | 9 | ||||
| -rw-r--r-- | src/draw.zig | 18 | ||||
| -rw-r--r-- | src/gui/gui.zig | 535 | ||||
| -rw-r--r-- | src/surface.zig | 26 | ||||
| -rw-r--r-- | src/themes/lapis.zig | 27 | ||||
| -rw-r--r-- | src/themes/lapis_plain.zig | 81 | ||||
| -rw-r--r-- | test/process/window.zig | 2 | ||||
| -rw-r--r-- | test/snapshots/theme.golden | 2 | ||||
| -rw-r--r-- | test/snapshots/theme.snap | 7 | ||||
| -rw-r--r-- | test/snapshots/themesel.golden | 123 | ||||
| -rw-r--r-- | test/snapshots/themesel.snap | 9 |
23 files changed, 90 insertions, 917 deletions
diff --git a/docs/site/media/themes/lapis_plain.png b/docs/site/media/themes/lapis_plain.png Binary files differdeleted file mode 100644 index 7315c2a0..00000000 --- a/docs/site/media/themes/lapis_plain.png +++ /dev/null diff --git a/docs/site/media/themes/themes.toml b/docs/site/media/themes/themes.toml index ed45b075..59248eb4 100644 --- a/docs/site/media/themes/themes.toml +++ b/docs/site/media/themes/themes.toml @@ -88,11 +88,6 @@ file = "lapis.png" kind = "dark" [[theme]] -name = "lapis_plain" -file = "lapis_plain.png" -kind = "dark" - -[[theme]] name = "dark_plus" file = "dark_plus.png" kind = "dark" diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index 0c3396c5..aedbb3a6 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -78,7 +78,6 @@ {"name": "PagerColor", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A +Pager keeps its program's colours, on or off; for the next text paged."}, {"name": "Palette", "leader": "SPC t l", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "the C64 palette or the terminal's own 16"}, {"name": "Panes", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Pick an open pane by its name in a query pane under this one (SPC b b)."}, - {"name": "Parallax", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A theme's page pattern moves with the text at a quarter of its speed, on or off."}, {"name": "PdfFit", "leader": "SPC t z", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Fit the PDF page to the pane by width or by height, flipping between them (or to the one named, `width|height`)."}, {"name": "PdfSections", "leader": "SPC t s", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the PDF's sections in a pane, each a place to go."}, {"name": "PdfTint", "leader": "SPC t i", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Tint the PDF page to the theme, or show it as printed, stepping through them (or to the one named, `disabled|filtered|full`)."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index d9622e9c..dc8e1f36 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -460,7 +460,7 @@ padded in groups of eight matches. An invalid field rejects the whole line; a repeated field's last value wins. The settings survive #word("Dump") and #word("Restore"). Source analysis is cached for 64 files and 64 MiB. -*Effects.* #word("Motion") `off|crisp|smooth|bouncy|playful` (default `smooth`), #word("Parallax"), +*Effects.* #word("Motion") `off|crisp|smooth|bouncy|playful` (default `smooth`), #word("CursorBlink"), #word("GripWidth") `<50-300>`, the GUI's. No effect may lower the contrast of text, the selection or a focus indicator. diff --git a/docs/typ/themes.typ b/docs/typ/themes.typ index 6dc92b3b..d37ffe87 100644 --- a/docs/typ/themes.typ +++ b/docs/typ/themes.typ @@ -5,11 +5,9 @@ #word("Themes") (#key("SPC t t")) lists every theme as a word to click; #word("Theme") `<name>` sets one anywhere, and the same line in the startup file keeps it. #word("NextColor") steps through the themes in this order: the native themes first, then -`acme`, `lapis` and `lapis_plain`, the faithful ports, the legacy `helix` +`acme` and `lapis`, the faithful ports, the legacy `helix` and `dark`, and the palettes imported from helix and zed. `orchard` is the -default. `lapis` draws its ornament in the GUI; `lapis_plain` is the same -theme on flat grounds, keeping its framed and shadowed tags and its -file-name shadow. +default. #theme-gallery() @@ -123,5 +121,4 @@ take `null`, so older files stay valid: [`rule_px`], [pixel shells: the width of the rules between columns and panes and under the column and workspace tags, in logical pixels. Absent: 2], [`box_border`, `box_dirty`], [the grip as acme's button: a ring of `box_border` when unfocused, filled with `box_dirty` while unsaved. Absent: `box_dim`; `diagnostic_warning`, then `num`], [`rail_px`], [pixel shells: the scroll column's width at a 17px tagline, scaled with it. Absent: 12, acme's Scrollwid], - [`decor`], [pixel shells: a theme's ornament (lapis's): `page_dots`, `rail_checker`, `tag_border`, `tag_shadow`, `tag_stripe`, `title_shadow`, with their sizes; none of it touches a focus indicator. Absent: none], ) diff --git a/shaders/decor.frag.glsl b/shaders/decor.frag.glsl index 5a6ac458..71bb12e3 100644 --- a/shaders/decor.frag.glsl +++ b/shaders/decor.frag.glsl @@ -4,21 +4,16 @@ // pipeline blends (backgroundLayerBlend). Ink (a cursor) is drawn with the // opacity uniform at 1. // -// Flat: a hard-edged fill (a rule, a rail, a grip mark, a bar cursor). Its -// colour rides in the cell's ground (a_bg), its coverage in a_fg.r, so the -// result is the overlay pipeline's exactly. -// -// Checker (flag 0x08000000): two colours in squares, or in stripes, see main. +// A hard-edged fill (a rule, a rail, a grip mark, a bar cursor): its colour +// rides in the cell's ground (a_bg), its coverage in a_fg.r, so the result +// is the overlay pipeline's exactly. layout(std140, set = 3, binding = 0) uniform UiUniforms { float background_opacity; } u_ui; -layout(location = 0) in vec2 v_uv; layout(location = 1) in vec3 v_fg; layout(location = 2) in vec3 v_bg; -layout(location = 3) in vec2 v_cell_uv; -layout(location = 4) flat in uvec2 v_effect; layout(location = 5) flat in vec4 v_clip; layout(location = 0) out vec4 o_col; @@ -27,16 +22,5 @@ void main() { if (v_clip.z >= v_clip.x && (gl_FragCoord.x < v_clip.x || gl_FragCoord.x >= v_clip.z || gl_FragCoord.y < v_clip.y || gl_FragCoord.y >= v_clip.w)) discard; float opacity = clamp(u_ui.background_opacity, 0.0, 1.0); - // Checker (flag 0x08000000): squares of v_uv.x pixels from the quad's - // own corner, so it moves with its rail, in the ground's colour and the - // ink's (lapis's scroll track). - vec2 in_quad = v_cell_uv / max(vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)), vec2(1e-6)); - if ((v_effect.x & 0x08000000u) != 0u) { - ivec2 q = ivec2(floor(in_quad / max(v_uv.x, 1.0))); - // v_uv.y set: stripes across the quad (lapis's title bar), not squares. - int k = v_uv.y > 0.5 ? q.y : q.x + q.y; - o_col = vec4(((k & 1) == 0 ? v_bg : v_fg) * opacity, 1.0); - return; - } o_col = vec4(v_bg * opacity, v_fg.r); } diff --git a/shaders/prebuilt/decor.frag.spv b/shaders/prebuilt/decor.frag.spv Binary files differindex 6ec3fe61..0d5af9d2 100644 --- a/shaders/prebuilt/decor.frag.spv +++ b/shaders/prebuilt/decor.frag.spv diff --git a/shaders/prebuilt/ui.frag.spv b/shaders/prebuilt/ui.frag.spv Binary files differindex aa788c0b..91022fe2 100644 --- a/shaders/prebuilt/ui.frag.spv +++ b/shaders/prebuilt/ui.frag.spv diff --git a/shaders/prebuilt/ui.vert.spv b/shaders/prebuilt/ui.vert.spv Binary files differindex 4e90e521..ad132bf9 100644 --- a/shaders/prebuilt/ui.vert.spv +++ b/shaders/prebuilt/ui.vert.spv diff --git a/shaders/ui.frag.glsl b/shaders/ui.frag.glsl index 68bfe70b..7f70629a 100644 --- a/shaders/ui.frag.glsl +++ b/shaders/ui.frag.glsl @@ -3,26 +3,16 @@ // Sample the glyph atlas (R = coverage 0..1) and mix the cell's bg up to its fg // by that coverage. Output is PREMULTIPLIED: an opaque cell is unchanged. // WindowOpacity changes only the ground's coverage, never the glyph's ink. -// A cell whose background is the see-through ground (config.gui_transparent, -// a theme with no bg of its own) still contributes only its ink, at the ink's -// own coverage, so the compositor keeps the rest. layout(set = 2, binding = 0) uniform sampler2D u_atlas; layout(std140, set = 3, binding = 0) uniform UiUniforms { float background_opacity; - // A theme's ornament (colors.Decor): the page's dots (rgb, strength), - // their geometry (period, solid radius, faded radius, in pixels), and a - // file name's shadow (rgb, offset in pixels). - vec4 decor_dots; - vec4 decor_dot_geom; - vec4 decor_shadow; } u_ui; layout(location = 0) in vec2 v_uv; layout(location = 1) in vec3 v_fg; layout(location = 2) in vec3 v_bg; -layout(location = 3) in vec2 v_cell_uv; -layout(location = 4) flat in uvec2 v_effect; +layout(location = 4) flat in uint v_effect; layout(location = 5) flat in vec4 v_clip; layout(location = 0) out vec4 o_col; @@ -32,41 +22,15 @@ void main() { gl_FragCoord.y < v_clip.y || gl_FragCoord.y >= v_clip.w)) discard; float a = texture(u_atlas, v_uv).r; // A block cursor is foreground chrome even though its fill occupies the - // cell background: keep it visible at WindowOpacity 0. Otherwise a clear - // theme ground has no coverage and ordinary backgrounds use the setting. - // The high flags are shared with ui.vert.glsl and src/gui/gui.zig. - float bgA = (v_effect.x & 0x20000000u) != 0u ? 1.0 - : (v_effect.x & 0x40000000u) != 0u ? 0.0 - : clamp(u_ui.background_opacity, 0.0, 1.0); + // cell background: keep it visible at WindowOpacity 0. Otherwise the + // ground's coverage is the setting's. The flag is shared with + // ui.vert.glsl and src/gui/gui.zig. + float bgA = (v_effect & 0x20000000u) != 0u ? 1.0 : clamp(u_ui.background_opacity, 0.0, 1.0); // Ink over ground, both premultiplied: v_fg*a + (v_bg*bgA)*(1-a), which is // mix() with the ground already premultiplied. At bgA = 1 that is exactly // the mix(v_bg, v_fg, a) at alpha 1 this shader always wrote. - vec3 ground = v_bg; - // 0x10000000: the page's ground under a pane body, dotted (lapis): a - // dot every period pixels, fixed to the window, under the text. - if ((v_effect.x & 0x10000000u) != 0u) { - float period = u_ui.decor_dot_geom.x; - // v_effect.y: how far its pane's text has moved the dots (G13's - // parallax), in pixels, as a float's bits (0 without). - vec2 at = gl_FragCoord.xy - vec2(0.0, uintBitsToFloat(v_effect.y)); - vec2 d = mod(at, period) - 0.5 * period; - float dot_a = 1.0 - smoothstep(u_ui.decor_dot_geom.y, u_ui.decor_dot_geom.z, length(d)); - ground = mix(ground, u_ui.decor_dots.rgb, u_ui.decor_dots.a * dot_a); - } - vec4 under = vec4(ground * bgA, bgA); - // Derivatives outside any branch: a pixel's step in the atlas and in - // the cell, for the shadow's offset. - vec2 step_uv = vec2(dFdx(v_uv.x), dFdy(v_uv.y)) * u_ui.decor_shadow.a; - vec2 step_cell = vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)) * u_ui.decor_shadow.a; - // 0x08000000: a file name's letters cast a shadow down and right onto - // their own cell's ground (lapis), under the ink; what would fall past - // the cell's edge is not drawn. - if ((v_effect.x & 0x08000000u) != 0u) { - vec2 from = v_cell_uv - step_cell; - float s = all(greaterThanEqual(from, vec2(0.0))) ? texture(u_atlas, v_uv - step_uv).r : 0.0; - under = mix(under, vec4(u_ui.decor_shadow.rgb, 1.0), s); - } + vec4 under = vec4(v_bg * bgA, bgA); vec4 cell = vec4(mix(under.rgb, v_fg, a), mix(under.a, 1.0, a)); // FreeType's hinted grayscale bitmap is already the intended coverage. diff --git a/shaders/ui.vert.glsl b/shaders/ui.vert.glsl index 313070c6..e3532e68 100644 --- a/shaders/ui.vert.glsl +++ b/shaders/ui.vert.glsl @@ -9,11 +9,8 @@ layout(location = 0) in vec4 a_rect; // x0, y0, x1, y1 layout(location = 1) in vec4 a_uv_rect; // u0, v0, u1, v1 layout(location = 2) in vec3 a_fg; layout(location = 3) in vec3 a_bg; -// Flags, and the theme's dots' offset (G13's parallax) as a float's bits. -// The flags are the high bits of x: a see-through cell background, an -// opaque block-cursor fill, a dotted page ground (ui.frag.glsl) and a -// checker (decor) or a file name's shadow (ui). -layout(location = 4) in uvec2 a_effect; +// Flags, the high bits: an opaque block-cursor fill (ui.frag.glsl). +layout(location = 4) in uint a_effect; // A clip rectangle in target pixels (x0, y0, x1, y1): the fragment shader // drops what lies outside it. x1 < x0 is none. layout(location = 5) in vec4 a_clip; @@ -21,8 +18,7 @@ layout(location = 5) in vec4 a_clip; layout(location = 0) out vec2 v_uv; layout(location = 1) out vec3 v_fg; layout(location = 2) out vec3 v_bg; -layout(location = 3) out vec2 v_cell_uv; -layout(location = 4) flat out uvec2 v_effect; +layout(location = 4) flat out uint v_effect; layout(location = 5) flat out vec4 v_clip; void main() { @@ -32,27 +28,21 @@ void main() { if (corner == 0) { pos = vec2(a_rect.x, a_rect.y); uv = vec2(a_uv_rect.x, a_uv_rect.y); - v_cell_uv = vec2(0.0, 0.0); } else if (corner == 1) { pos = vec2(a_rect.z, a_rect.y); uv = vec2(a_uv_rect.z, a_uv_rect.y); - v_cell_uv = vec2(1.0, 0.0); } else if (corner == 2) { pos = vec2(a_rect.z, a_rect.w); uv = vec2(a_uv_rect.z, a_uv_rect.w); - v_cell_uv = vec2(1.0, 1.0); } else if (corner == 3) { pos = vec2(a_rect.x, a_rect.y); uv = vec2(a_uv_rect.x, a_uv_rect.y); - v_cell_uv = vec2(0.0, 0.0); } else if (corner == 4) { pos = vec2(a_rect.z, a_rect.w); uv = vec2(a_uv_rect.z, a_uv_rect.w); - v_cell_uv = vec2(1.0, 1.0); } else { pos = vec2(a_rect.x, a_rect.w); uv = vec2(a_uv_rect.x, a_uv_rect.w); - v_cell_uv = vec2(0.0, 1.0); } v_uv = uv; v_fg = a_fg; diff --git a/src/colors.zig b/src/colors.zig index 90ed7b76..aec2917f 100644 --- a/src/colors.zig +++ b/src/colors.zig @@ -110,7 +110,7 @@ test "every native theme's separators stand off its page, and its focus tint off } test "every faithful port meets pardes's chrome floors in its own colours, with nothing left to derive" { - const first = comptime indexOfTheme("lapis_plain") + 1; + const first = comptime indexOfTheme("lapis") + 1; const last = comptime indexOfTheme("helix"); for (themes[first..last]) |*th| { const chrome = ChromeTheme.fromTheme(th); @@ -277,42 +277,6 @@ pub fn mix(a: [3]u8, b: [3]u8) [3]u8 { return out; } -/// A theme's ornament, drawn by a pixel shell inside the chrome it already -/// has (docs/render-pipeline.md §10: no gaps between panes): the lapis -/// theme's. Sizes are logical pixels. None of it touches a focus indicator: -/// the dots lie on the page's own ground, the checker in the scroll track -/// (never its thumb), a tag's plaque inside its band beside its grip (and -/// the focused one only the more striking), and the shadow under a file -/// name's own letters. -pub const Decor = struct { - /// A dot grid on the page's ground, `page_dot_alpha` of 255 strong, a - /// dot one logical pixel across (fading out by a pixel and a half) every - /// `page_dot_px`, fixed to the window. - page_dots: ?[3]u8 = null, - page_dot_alpha: u8 = 0x22, - page_dot_px: u8 = 22, - /// A checker in the scroll track, squares of `rail_checker_px`, this - /// colour and the track's. - rail_checker: ?[3]u8 = null, - rail_checker_px: u8 = 3, - /// Every tag drawn as a raised plaque inside its own band (the site's - /// trail and title bars): a `tag_border` frame round the text, a hard - /// `tag_shadow` offset down and right by `tag_shadow_px`, both within - /// the band's rows and columns, never past them; the focused pane's - /// plaque striped `tag_stripe` and the tag's ground, `tag_stripe_px` - /// each, its words on plates of the ground. Column and workspace tags - /// take a quieter one (a one-pixel frame, a shadow of two, no stripes). - tag_border: ?[3]u8 = null, - tag_border_px: u8 = 2, - tag_shadow: ?[3]u8 = null, - tag_shadow_px: u8 = 5, - tag_stripe: ?[3]u8 = null, - tag_stripe_px: u8 = 2, - /// The file name's offset shadow, down and right, in a pane's tag. - title_shadow: ?[3]u8 = null, - title_shadow_px: u8 = 2, -}; - pub const Theme = struct { name: []const u8, bg: ?[3]u8, @@ -378,8 +342,6 @@ pub const Theme = struct { /// in pixels at a 17px tagline, the thumb one narrower (acme's 12px /// Scrollwid, the default). rail_px: ?u8 = null, - /// A pixel shell's ornament (Decor): lapis's. - decor: ?Decor = null, }; /// One family, its twelve backgrounds a theme each (`curated`). @@ -403,7 +365,6 @@ const curated = struct { pub const orchard_black = @import("themes/orchard_black.zig"); pub const acme = @import("themes/acme.zig"); pub const lapis = @import("themes/lapis.zig"); - pub const lapis_plain = @import("themes/lapis_plain.zig"); // Faithful ports of well-known themes, a family at a time (src/themes/ // <name>.zig says where each value came from): `theme_groups`. pub const dark_plus = @import("themes/dark_plus.zig"); @@ -483,15 +444,7 @@ fn fold(comptime C: type) [@typeInfo(C).@"struct".decl_names.len]Theme { var t: Theme = undefined; const source = @field(C, d).theme; for (theme_info.field_names, theme_info.field_types, theme_info.field_attrs) |name, T, attrs| { - @field(t, name) = if (T == ?Decor and @hasField(@TypeOf(source), name)) decor: { - // A nested literal is folded field by field too. - var decor: Decor = .{}; - const given = @field(source, name); - for (@typeInfo(Decor).@"struct".field_names) |g| if (@hasField(@TypeOf(given), g)) { - @field(decor, g) = @field(given, g); - }; - break :decor decor; - } else if (@hasField(@TypeOf(source), name)) + @field(t, name) = if (@hasField(@TypeOf(source), name)) @field(source, name) else if (attrs.defaultValue(T)) |value| value @@ -573,22 +526,6 @@ test "seoul256's twelve backgrounds ring in their order, after Catppuccin and be try std.testing.expectEqualStrings("zenbones_light", themes[first + names.len].name); } -test "lapis_plain is lapis on flat grounds, framed and shadowed as lapis" { - const lapis = themes[indexOfTheme("lapis")]; - const plain = themes[indexOfTheme("lapis_plain")]; - try std.testing.expectEqual(indexOfTheme("lapis") + 1, indexOfTheme("lapis_plain")); - var same = plain; - same.name = lapis.name; - same.decor = lapis.decor; - try std.testing.expectEqualDeep(lapis, same); - const decor = plain.decor.?; - try std.testing.expect(decor.page_dots == null and decor.tag_stripe == null); - try std.testing.expectEqualDeep(lapis.decor.?.tag_border, decor.tag_border); - try std.testing.expectEqualDeep(lapis.decor.?.tag_shadow, decor.tag_shadow); - try std.testing.expectEqualDeep(lapis.decor.?.title_shadow, decor.title_shadow); - try std.testing.expectEqualDeep(lapis.decor.?.rail_checker, decor.rail_checker); -} - /// Original and classic-inspired Pardes palettes precede retained imports. pub const native_theme_count = 15; diff --git a/src/config.zig b/src/config.zig index aea87230..3024fc5a 100644 --- a/src/config.zig +++ b/src/config.zig @@ -167,7 +167,6 @@ pub const leader_path = paths: { if (builtins.capabilities.window_blur) table.set(.WindowBlur, null); if (builtins.capabilities.ligatures) table.set(.Ligatures, null); if (builtins.capabilities.lift) table.set(.CursorBlink, null); - if (builtins.capabilities.lift) table.set(.Parallax, null); table.set(.ProgramEsc, null); table.set(.Motion, null); if (builtins.capabilities.lift) table.set(.GripWidth, null); @@ -724,9 +723,6 @@ pub const Runtime = struct { /// solid while typing and for half a second after, eased at each edge, /// solid again after ten idle seconds. cursor_blink: bool = true, - /// G13: a theme's page pattern under the bodies (lapis's dots) moves - /// with the text at a quarter of its speed, a pixel shell's. - parallax: bool = false, /// In a raw terminal, Esc goes to the program and Shift-Esc backs out /// (off, the default: Esc backs out and Shift-Esc is the program's). program_esc: bool = false, @@ -871,7 +867,7 @@ pub const Runtime = struct { /// The message timings a setting word sets, each in milliseconds. pub const MessageTime = enum { linger, fall, dissolve }; - pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, parallax, program_esc }; + pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, program_esc }; pub const Action = union(enum) { toggle: Toggle, @@ -917,7 +913,7 @@ pub const Runtime = struct { .grip_width => .lift, .toggle => |field| switch (field) { .ligatures => .ligatures, - .cursor_blink, .parallax => .lift, + .cursor_blink => .lift, else => null, }, else => null, @@ -937,7 +933,6 @@ pub const Runtime = struct { .{ .word = "MessageAnimation", .action = .{ .toggle = .message_animation }, .doc = "A message falls into its row and dissolves out of it, on or off." }, .{ .word = "Ligatures", .action = .{ .toggle = .ligatures }, .doc = "A font's programming ligatures draw across their cells, on or off." }, .{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .doc = "The cursor blinks, solid while typing, on or off." }, - .{ .word = "Parallax", .action = .{ .toggle = .parallax }, .doc = "A theme's page pattern moves with the text at a quarter of its speed, on or off." }, .{ .word = "ProgramEsc", .action = .{ .toggle = .program_esc }, .doc = "In a raw terminal, Esc goes to the program and Shift-Esc backs out, on; off (the default) swaps them." }, .{ .word = "Motion", .action = .motion, .doc = "How animations move: off, crisp, smooth, bouncy or playful." }, .{ .word = "GripWidth", .action = .grip_width, .doc = "The grip and scrollbar width, as a percent of the theme's rail." }, diff --git a/src/draw.zig b/src/draw.zig index 015d2def..d299b03f 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -373,25 +373,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { .grip_dirty = boxDirty(p), .tag_rule = p.theme().tag_rule, .rail_px = @intCast(@min(255, @as(u32, p.theme().rail_px orelse 12) * p.settings.grip_width / 100)), - .name_ink = chrome.tag_name_fg, - .active_name_ink = if (p.settings.focus_tint) chrome.tag_active_name_fg else chrome.tag_name_fg, - .fx = @as(u8, @intFromBool(p.settings.parallax)) << 3, }; - if (p.theme().decor) |decor| { - s.chrome.decor_dots = decor.page_dots; - s.chrome.decor_dot_alpha = decor.page_dot_alpha; - s.chrome.decor_dot_px = decor.page_dot_px; - s.chrome.decor_checker = decor.rail_checker; - s.chrome.decor_checker_px = decor.rail_checker_px; - s.chrome.decor_box_border = decor.tag_border; - s.chrome.decor_box_border_px = decor.tag_border_px; - s.chrome.decor_box_shadow = decor.tag_shadow; - s.chrome.decor_box_shadow_px = decor.tag_shadow_px; - s.chrome.decor_box_stripe = decor.tag_stripe; - s.chrome.decor_box_stripe_px = decor.tag_stripe_px; - s.chrome.decor_title = decor.title_shadow; - s.chrome.decor_title_px = decor.title_shadow_px; - } place(p, s); // Separators have their own role; a scrollbar need not frame the page. const whole = s.regions[0].rect; diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 24b15b35..4f82d246 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -425,10 +425,8 @@ const CellInstance = extern struct { br: f32, bg: f32, bb: f32, - /// The flags (the high bits, ui.vert.glsl), and the theme's dots' - /// offset (G13's parallax) as a float's bits. + /// The flags (the high bits, ui.vert.glsl). effect: u32 = 0, - serial: u32 = 0, /// A clip rectangle in target pixels; x1 < x0 is none (ui.vert.glsl). clip_x0: f32 = 0, clip_y0: f32 = 0, @@ -457,14 +455,7 @@ const ImageInstance = extern struct { v1: f32, }; -const clear_bg_bit: u32 = 0x4000_0000; const opaque_bg_bit: u32 = 0x2000_0000; -/// Decor that is a checker (decor.frag.glsl). -const checker_bit: u32 = 0x0800_0000; -/// A cell on the page's ground under the theme's dots, and a file name's -/// cell that casts the theme's shadow (ui.frag.glsl, Chrome.decor_*). -const dotted_bit: u32 = 0x1000_0000; -const title_bit: u32 = 0x0800_0000; const PreparedImage = struct { place: pardes.ImagePlace, @@ -472,9 +463,9 @@ const PreparedImage = struct { }; test "the shader instance ABI: the flags after the colours, the clip after them" { - try std.testing.expectEqual(@as(usize, 80), @sizeOf(CellInstance)); + try std.testing.expectEqual(@as(usize, 76), @sizeOf(CellInstance)); try std.testing.expectEqual(@as(usize, 56), @offsetOf(CellInstance, "effect")); - try std.testing.expectEqual(@as(usize, 64), @offsetOf(CellInstance, "clip_x0")); + try std.testing.expectEqual(@as(usize, 60), @offsetOf(CellInstance, "clip_x0")); try std.testing.expectEqual(@as(usize, 32), @sizeOf(ImageInstance)); } @@ -949,10 +940,6 @@ const Gui = struct { device: *c.SDL_GPUDevice, swapchain_format: c.SDL_GPUTextureFormat, pipeline: *c.SDL_GPUGraphicsPipeline, - /// The cell pipeline, blending premultiplied over what is drawn under: - /// for a frame with a theme's tag plaques, whose blank tag cells let - /// them show (tagPlaques). - pipeline_over: *c.SDL_GPUGraphicsPipeline, decor_pipeline: *c.SDL_GPUGraphicsPipeline, overlay_pipeline: *c.SDL_GPUGraphicsPipeline, image_pipeline: *c.SDL_GPUGraphicsPipeline, @@ -1283,9 +1270,6 @@ const Group = struct { image_count: u32 = 0, decor_start: u32 = 0, decor_count: u32 = 0, - /// The first `under_count` of the group's decor are drawn before its - /// cells, under them (a theme's tag plaques, whose cells let them show). - under_count: u32 = 0, }; /// The frame's draw groups, bottom to top: the page and the panes, the @@ -1562,7 +1546,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di const atlas_xfer = c.SDL_CreateGPUTransferBuffer(device, &ax_info) orelse return error.GpuCreate; const pipeline = try makePipeline(device, swapchain_format, vert_spv, frag_spv, 1, 1, cell_input, std.mem.zeroes(c.SDL_GPUColorTargetBlendState)); - const pipeline_over = try makePipeline(device, swapchain_format, vert_spv, frag_spv, 1, 1, cell_input, premultipliedBlend()); const decor_pipeline = try makePipeline(device, swapchain_format, vert_spv, decor_frag_spv, 0, 1, cell_input, backgroundLayerBlend()); const overlay_pipeline = try makePipeline(device, swapchain_format, overlay_vert_spv, overlay_frag_spv, 0, 1, overlay_input, backgroundLayerBlend()); const image_pipeline = try makePipeline(device, swapchain_format, image_vert_spv, image_frag_spv, 1, 1, image_input, backgroundLayerBlend()); @@ -1587,7 +1570,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di .device = device, .swapchain_format = swapchain_format, .pipeline = pipeline, - .pipeline_over = pipeline_over, .decor_pipeline = decor_pipeline, .overlay_pipeline = overlay_pipeline, .image_pipeline = image_pipeline, @@ -1629,7 +1611,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di // regrown to; the image ones are released below. defer { c.SDL_ReleaseGPUGraphicsPipeline(device, g.pipeline); - c.SDL_ReleaseGPUGraphicsPipeline(device, g.pipeline_over); c.SDL_ReleaseGPUGraphicsPipeline(device, g.decor_pipeline); c.SDL_ReleaseGPUGraphicsPipeline(device, g.overlay_pipeline); c.SDL_ReleaseGPUTexture(device, g.atlas_tex); @@ -5422,32 +5403,6 @@ fn renderFrame( // this frame against the last (the glide follows it from there). if (g.glide.pending) g.glide.measure(gpa, surface); if (g.glide.moving()) g.glide.advance(g.glide.now_ns, g.glide.motion); - cell_decor = CellDecor.of(chrome); - plaque_through_len = 0; - // G13: a body's dots follow its text at a quarter of its speed: its - // first line, and a glide's picture offset, in rows. - if (chrome.fx & 8 != 0 and chrome.decor_dots != null) for (surface.regionList()) |region| { - if (region.kind != .body or cell_decor.nbodies == cell_decor.bodies.len) continue; - var rows: f32 = @floatFromInt(region.line); - if (g.glide.moving() and g.glide.pane == region.owner) rows += g.glide.follow.offset; - const period = cell_decor.uniforms[4]; - cell_decor.bodies[cell_decor.nbodies] = bodyPixels(region, layout); - cell_decor.shifts[cell_decor.nbodies] = @mod(-rows * layout.h * 0.25, period); - cell_decor.nbodies += 1; - }; - // Plaques need an opaque window: with WindowOpacity under 100 the cells - // are drawn as they are, and the plaques not at all. - cell_decor.plaques_off = backgroundOpacity(g.applied_window_opacity) < 1; - if (chrome.decor_box_border != null and !cell_decor.plaques_off) { - cell_decor.grounds = .{ chrome.tag_bg, chrome.tag_focus_bg }; - for (surface.regionList()) |region| { - if (region.kind != .tag and region.kind != .column_tag and region.kind != .workspace_tag) continue; - if (cell_decor.nplaques == cell_decor.plaques.len) break; - const plaque = plaqueBox(g, chrome, surface.regionList(), region, layout, win_w, win_h) orelse continue; - cell_decor.plaques[cell_decor.nplaques] = plaque.band; - cell_decor.nplaques += 1; - } - } var groups: Groups = .{}; // While the cursor glides or blinks the cells' cursors are not drawn; // the focused one is the overlay's quad. One or the other every frame @@ -5592,25 +5547,6 @@ fn renderFrame( const scrolling: ?usize = if (g.glide.follow.offset != 0) g.glide.pane else g.scroll_pane; const held: u16 = if (scrolling) |id| if (core.panes[id]) |pane| pane.context_rows else 0 else 0; shifted = emitScrollRows(g, instances, cell_total, surface, layout, win_w, win_h, page, held); - // Over a theme's plaques a see-through cell with no ink blends to - // the plaque under it, so it draws nothing: its quad goes, and the - // cells are drawn unblended (a third of the GPU's frame at 4K) - // unless one see-through cell does have ink, or the page itself is - // see-through. - if (cell_decor.nplaques != 0) { - const space_u = @as(f32, @floatFromInt(g.space_slot.u)) / @as(f32, @floatFromInt(atlas_w)); - const space_v = @as(f32, @floatFromInt(g.space_slot.v)) / @as(f32, @floatFromInt(atlas_h)); - if (plaque_through_len > plaque_through.len) cell_decor.inked_clear = true; - for (plaque_through[0..@min(plaque_through_len, plaque_through.len)]) |at| { - const instance = &instances[at]; - // A grip's button takes its cell's ground back (emitSurfaceCell). - if (instance.effect & clear_bg_bit == 0) continue; - if (instance.u0 == space_u and instance.v0 == space_v) { - instance.x1 = instance.x0; - instance.y1 = instance.y0; - } else cell_decor.inked_clear = true; - } - } @memcpy(instances[cell_total + shifted ..][0..decor_len], g.decor.items); c.SDL_UnmapGPUTransferBuffer(g.device, g.vxfer.?); @@ -5631,18 +5567,9 @@ fn renderFrame( const whole = c.SDL_Rect{ .x = 0, .y = 0, .w = @intCast(sw), .h = @intCast(sh) }; const decor_base = cell_total + shifted; for (groups.items[0..groups.len], 0..) |group, index| { - if (group.under_count != 0 and g.vbuf != null) { - c.SDL_BindGPUGraphicsPipeline(rp, g.decor_pipeline); - pushLayerOpacity(cmd, rp, background_opacity); - const binding = c.SDL_GPUBufferBinding{ .buffer = g.vbuf.?, .offset = (decor_base + group.decor_start) * @sizeOf(CellInstance) }; - c.SDL_BindGPUVertexBuffers(rp, 0, &binding, 1); - c.SDL_DrawGPUPrimitives(rp, 6, group.under_count, 0, 0); - } const has_shifted = index == 0 and shifted != 0; if ((group.cell_count != 0 or has_shifted) and g.vbuf != null) { - // Blended over what is under: a theme's plaques show through - // blank tag cells. - c.SDL_BindGPUGraphicsPipeline(rp, if (cell_decor.inked_clear) g.pipeline_over else g.pipeline); + c.SDL_BindGPUGraphicsPipeline(rp, g.pipeline); const samp_binding = c.SDL_GPUTextureSamplerBinding{ .texture = g.atlas_tex, .sampler = g.atlas_sampler }; c.SDL_BindGPUFragmentSamplers(rp, 0, &samp_binding, 1); if (group.cell_count != 0) { @@ -5660,13 +5587,13 @@ fn renderFrame( } } if (group.image_count != 0) drawNativeImagesGpu(g, rp, group, whole); - if (group.decor_count > group.under_count and g.vbuf != null) { + if (group.decor_count != 0 and g.vbuf != null) { c.SDL_BindGPUGraphicsPipeline(rp, g.decor_pipeline); // Ink keeps its colour at any WindowOpacity. pushLayerOpacity(cmd, rp, if (index == groups.ink) 1 else background_opacity); - const binding = c.SDL_GPUBufferBinding{ .buffer = g.vbuf.?, .offset = (decor_base + group.decor_start + group.under_count) * @sizeOf(CellInstance) }; + const binding = c.SDL_GPUBufferBinding{ .buffer = g.vbuf.?, .offset = (decor_base + group.decor_start) * @sizeOf(CellInstance) }; c.SDL_BindGPUVertexBuffers(rp, 0, &binding, 1); - c.SDL_DrawGPUPrimitives(rp, 6, group.decor_count - group.under_count, 0, 0); + c.SDL_DrawGPUPrimitives(rp, 6, group.decor_count, 0, 0); } } drawOverlayGpu(g, cmd, rp, overlay_count); @@ -5898,9 +5825,6 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p const y = layer.viewport.y + @as(u16, @intCast(index)); const top = @as(f32, @floatFromInt(y)) * bh; emitInstance(g, instances, next.*, 0, y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, .body, (&background)[0..1], 0, null, false, page); - // A theme's plaque is drawn under the band: the band's own ground - // lets it show (tagPlaques). - if (cell_decor.nplaques != 0 and cell_decor.inPlaque(left + 0.5, top + 0.5)) plaqueThrough(instances, next.*); if (slide != 0) clipInstance(&instances[next.*], .{ -1e9, top, 1e9, 1e9 }, win_w, win_h); next.* += 1; const cells = layer.cells[index * layer.cols ..][0..layer.cols]; @@ -6067,13 +5991,6 @@ fn emitSurfaceCell( // this underlay at tagline height leaves page-colored gutters between // adjacent workspace, column and pane tags at TaglineSize < 100. emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .body, (&band_base)[0..1], 0, null, false, page); - // Over a theme's plaque the underlay lets it show (tagPlaques), - // in a grip's cell too where the plaque reaches into it past the - // button (which is drawn over the cells). - const cell_x = @as(f32, @floatFromInt(col)) * body_layout.w + body_layout.x_off; - const cell_y = @as(f32, @floatFromInt(row)) * body_layout.h + body_layout.y_off + 0.5; - if (cell_decor.nplaques != 0 and cell_decor.inPlaque(if (here.grip) cell_x + body_layout.w - 0.5 else cell_x + 0.5, cell_y)) - plaqueThrough(instances, next.*); next.* += 1; // Tag glyphs keep their font size inside a full physical-width grip. // A pane's grip cells are the cell shells' form (a dirty `*`): the @@ -6134,7 +6051,6 @@ fn emitSurfaceCell( base.bg = own[1]; base.bb = own[2]; } - base.effect &= ~clear_bg_bit; clipInstance(base, .{ b[0], -1e9, b[2], 1e9 }, win_w, win_h); // Over it, only its own glyph; the band round it and the ring // are decor (gripDecor). @@ -6144,12 +6060,10 @@ fn emitSurfaceCell( instances[next.*].v0 = @as(f32, @floatFromInt(g.space_slot.v)) / atlas_h; instances[next.*].v1 = @as(f32, @floatFromInt(g.space_slot.v + g.tagline_height)) / atlas_h; } - // Its ground is the fill again (a see-through ground would be - // written, not blended, in an opaque window). + // Its ground is the fill again. instances[next.*].br = base.br; instances[next.*].bg = base.bg; instances[next.*].bb = base.bb; - instances[next.*].effect &= ~clear_bg_bit; clipInstance(&instances[next.*], b, win_w, win_h); } else if (inset > 0) { instances[next.*].x0 += @as(f32, @floatFromInt(inset)) / win_w * 2; @@ -6334,27 +6248,6 @@ fn emitInstance( // A block cursor is foreground UI ink, even though its color is carried // in the reversed cell background. Keep it visible at WindowOpacity 0. if (is_cursor) instances[idx].effect |= opaque_bg_bit; - // The theme's ornament (cell_decor): dots on the page's own ground, a - // shadow under a file name's letters. Never on a cursor. - if (!is_cursor) { - // A blank cell on a tag's ground inside a plaque: the plaque shows. - if (cell_decor.nplaques != 0 and resolved.role == .tagline and cellCodepoint(&line[at]) == ' ' and - (std.mem.eql(u8, &resolved.bg, &cell_decor.grounds[0]) or std.mem.eql(u8, &resolved.bg, &cell_decor.grounds[1])) and - (cell_decor.inPlaque(px0 + 0.5, py0 + 0.5) or cell_decor.inPlaque(px0 + layout.w - 0.5, py0 + 0.5))) - plaqueThrough(instances, idx); - if (cell_decor.dots) |dotted| { - if (std.mem.eql(u8, &resolved.bg, &dotted)) { - instances[idx].effect |= dotted_bit; - // G13: the dots under a body move with its text, a quarter - // as far; the serial slot carries it (the shader reads it - // as the dots' offset alone). - instances[idx].serial = @bitCast(cell_decor.parallaxAt(px0 + 0.5, py0 + 0.5)); - } - } - if (cell_decor.title) |inks| { - if (resolved.role == .tagline and (std.mem.eql(u8, &resolved.fg, &inks[0]) or std.mem.eql(u8, &resolved.fg, &inks[1]))) instances[idx].effect |= title_bit; - } - } } test "block cursor alone overrides transparent cell background" { @@ -6367,125 +6260,6 @@ test "block cursor alone overrides transparent cell background" { } } -test "lapis dots only the page's own ground and shadows only a file name, never a cursor" { - var g = testGui(10, 20, 8, 16); - const page: [3]u8 = .{ 0x0a, 0x10, 0x30 }; - const name: [3]u8 = .{ 0xe8, 0xc4, 0x6a }; - var chrome: pardes.Chrome = .{ .page = page, .decor_dots = .{ 1, 2, 3 }, .decor_dot_alpha = 0x22, .decor_title = .{ 4, 5, 6 }, .name_ink = name, .active_name_ink = name }; - cell_decor = CellDecor.of(&chrome); - defer cell_decor = .{}; - const on_page: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = .{ 200, 200, 200 } }, .bg = .{ .rgb = page } } }; - const selected: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = .{ 0, 0, 0 } }, .bg = .{ .rgb = name } } }; - const title: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = name }, .bg = .{ .rgb = .{ 0x0f, 0x1a, 0x4a } }, .font_role = .tagline } }; - const plain_tag: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = .{ 0x9a, 0xa6, 0xd9 } }, .bg = .{ .rgb = .{ 0x0f, 0x1a, 0x4a } }, .font_role = .tagline } }; - var instances: [1]CellInstance = undefined; - const Case = struct { cell: pardes.Cell, role: pardes.FontRole, cursor: bool, dotted: bool, shadowed: bool }; - for ([_]Case{ - .{ .cell = on_page, .role = .body, .cursor = false, .dotted = true, .shadowed = false }, - .{ .cell = on_page, .role = .body, .cursor = true, .dotted = false, .shadowed = false }, - .{ .cell = selected, .role = .body, .cursor = false, .dotted = false, .shadowed = false }, - .{ .cell = title, .role = .tagline, .cursor = false, .dotted = false, .shadowed = true }, - .{ .cell = title, .role = .tagline, .cursor = true, .dotted = false, .shadowed = false }, - .{ .cell = plain_tag, .role = .tagline, .cursor = false, .dotted = false, .shadowed = false }, - }) |case| { - emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, case.role, (&case.cell)[0..1], 0, null, case.cursor, page); - try std.testing.expectEqual(case.dotted, instances[0].effect & dotted_bit != 0); - try std.testing.expectEqual(case.shadowed, instances[0].effect & title_bit != 0); - } - // A theme without decor marks nothing. - chrome = .{ .page = page }; - cell_decor = CellDecor.of(&chrome); - emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, .body, (&on_page)[0..1], 0, null, false, page); - try std.testing.expectEqual(@as(u32, 0), instances[0].effect & (dotted_bit | title_bit)); -} - -test "lapis plaques stay in their tag's band, clear of every grip; only the focused one is striped" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.newShell(1, ""); - try std.testing.expect(pardes.layout.splitColumn(core, 0, 1, false)); - try std.testing.expect(core.executeBuiltinLine(0, "Theme lapis")); - for (0..40) |_| core.update(.tick); - core.sync(); - const s = try core.render(core.scratch.allocator()); - try std.testing.expect(s.chrome.decor_box_border != null and s.chrome.decor_checker != null and s.chrome.decor_dots != null and s.chrome.decor_title != null); - var g = testGui(16, 32, 12, 22); - defer g.decor.deinit(gpa); - display_scale = 1; - var groups: Groups = .{}; - try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true); - const layout = fixedCellLayout(&g); - const under = g.decor.items[groups.items[0].decor_start..][0..groups.items[0].under_count]; - try std.testing.expect(under.len != 0); - var stripes: usize = 0; - var shadows: usize = 0; - for (under) |item| { - const r: [4]f32 = .{ (item.x0 + 1) / 2 * 1280, (1 - item.y0) / 2 * 768, (item.x1 + 1) / 2 * 1280, (1 - item.y1) / 2 * 768 }; - // Inside one tag's band, whole: never on a body, a grip or the - // next pane. A box stacked under another tag's lays its top frame - // over their shared edge, its own width up into the band above. - const home = for (s.regionList()) |region| { - if (region.kind != .tag and region.kind != .column_tag and region.kind != .workspace_tag) continue; - const band = plaqueBox(&g, &s.chrome, s.regionList(), region, layout, 1280, 768) orelse continue; - if (r[0] >= band.band[0] - 0.01 and r[1] >= band.band[1] - band.border - 0.01 and r[2] <= band.band[2] + 0.01 and r[3] <= band.band[3] + 0.01) break region; - } else return error.PlaqueOutsideItsBand; - // Clear of every grip's button: a plaque starts flush against it, - // in the gap between it and the text. - for (s.regionList()) |grip| { - if (grip.kind != .grip and grip.kind != .column_grip) continue; - const column = scrollColumn(&g, &s.chrome, grip.rect.x, layout); - const gx0 = column[0]; - const gx1 = column[1]; - const gy0 = @as(f32, @floatFromInt(grip.rect.y)) * 32; - const gy1 = @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * 32; - try std.testing.expect(r[2] <= gx0 + 0.01 or r[0] >= gx1 - 0.01 or r[3] <= gy0 + 0.01 or r[1] >= gy1 - 0.01); - } - if (item.effect & checker_bit != 0) { - try std.testing.expect(home.kind == .tag and home.active); - stripes += 1; - } - const rgb: [3]u8 = .{ @intFromFloat(@round(item.br * 255)), @intFromFloat(@round(item.bg * 255)), @intFromFloat(@round(item.bb * 255)) }; - if (std.mem.eql(u8, &rgb, &s.chrome.decor_box_shadow.?)) shadows += 1; - } - try std.testing.expectEqual(@as(usize, 1), stripes); - try std.testing.expect(shadows >= 2); - // Stacked boxes share an edge and line up: a column's box spans its - // first pane's across, runs down to the edge that pane's frame lies - // over, and no shadow reaches the next column. - var stacks: usize = 0; - for (s.regionList()) |column| { - if (column.kind != .column_tag) continue; - const upper = plaqueBox(&g, &s.chrome, s.regionList(), column, layout, 1280, 768).?; - for (s.regionList()) |tag| { - if (tag.kind != .tag or tag.rect.y != column.rect.y + column.rect.h or tag.rect.x + tag.rect.w != column.rect.x + column.rect.w) continue; - const lower = plaqueBox(&g, &s.chrome, s.regionList(), tag, layout, 1280, 768).?; - try std.testing.expectEqual(upper.box[0], lower.box[0]); - // Flush against the grips' buttons, which line up too. - const grip = for (s.regionList()) |part| { - if (part.kind == .grip and part.owner == tag.owner) break part; - } else unreachable; - try std.testing.expectEqual(scrollColumn(&g, &s.chrome, grip.rect.x, layout)[1], lower.box[0]); - try std.testing.expectEqual(upper.box[2], lower.box[2]); - try std.testing.expectEqual(upper.band[3], upper.box[3]); - try std.testing.expectEqual(lower.band[1] - lower.border, lower.box[1]); - try std.testing.expectEqual(@as(f32, 0), upper.shadow[1]); - if (lower.band[2] < 1280) try std.testing.expect(lower.box[2] + lower.shadow[0] < lower.band[2]); - stacks += 1; - } - } - try std.testing.expectEqual(@as(usize, 2), stacks); - // The scroll track is chequered. - var checkers: usize = 0; - for (g.decor.items[groups.items[0].decor_start + groups.items[0].under_count ..]) |item| checkers += @intFromBool(item.effect & checker_bit != 0); - try std.testing.expect(checkers >= 1); - // No other theme draws any of it. - try std.testing.expect(core.executeBuiltinLine(0, "Theme forge")); - for (0..40) |_| core.update(.tick); - const plain = try core.render(core.scratch.allocator()); - try std.testing.expect(plain.chrome.decor_box_border == null and plain.chrome.decor_checker == null and plain.chrome.decor_dots == null and plain.chrome.decor_title == null); -} - fn cellCodepoint(cell: *const pardes.Cell) u32 { const grapheme = cell.grapheme(); return if (cell.default or grapheme.len == 0) ' ' else firstCp(grapheme); @@ -6785,7 +6559,6 @@ fn testGui(cell_w: u32, cell_h: u32, tagline_width: u32, tagline_height: u32) Gu .device = undefined, .swapchain_format = undefined, .pipeline = undefined, - .pipeline_over = undefined, .decor_pipeline = undefined, .overlay_pipeline = undefined, .image_pipeline = undefined, @@ -7276,7 +7049,7 @@ const cell_input: VertexInput = .{ .pitch = @sizeOf(CellInstance), .rate = c.SDL .{ .location = 1, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "u0") }, .{ .location = 2, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "fr") }, .{ .location = 3, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "br") }, - .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT2, .offset = @offsetOf(CellInstance, "effect") }, + .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT, .offset = @offsetOf(CellInstance, "effect") }, .{ .location = 5, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "clip_x0") }, } }; @@ -7329,20 +7102,6 @@ pub fn makePipeline( return c.SDL_CreateGPUGraphicsPipeline(device, &info) orelse error.GpuCreate; } -/// Premultiplied over: an opaque cell writes itself exactly, a see-through -/// one only its ink. -fn premultipliedBlend() c.SDL_GPUColorTargetBlendState { - var blend = std.mem.zeroes(c.SDL_GPUColorTargetBlendState); - blend.src_color_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE; - blend.dst_color_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; - blend.color_blend_op = c.SDL_GPU_BLENDOP_ADD; - blend.src_alpha_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE; - blend.dst_alpha_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; - blend.alpha_blend_op = c.SDL_GPU_BLENDOP_ADD; - blend.enable_blend = true; - return blend; -} - fn backgroundLayerBlend() c.SDL_GPUColorTargetBlendState { var blend = std.mem.zeroes(c.SDL_GPUColorTargetBlendState); blend.src_color_blendfactor = c.SDL_GPU_BLENDFACTOR_SRC_ALPHA; @@ -7672,24 +7431,6 @@ fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32, }); } -/// A checker (decor.frag.glsl): squares of `px` window pixels in `a` and -/// `b` from the quad's corner (lapis's scroll track); `stripes`, bands of -/// `px` across it instead (lapis's focused title bar), `a` first. -fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f32, a: [3]u8, b: [3]u8, px: f32, stripes: bool, win_w: f32, win_h: f32) !void { - const first = g.decor.items.len; - try addDecor(g, gpa, x0, y0, x1, y1, a, 1, win_w, win_h); - if (g.decor.items.len == first) return; - const instance = &g.decor.items[first]; - instance.u0 = px; - instance.u1 = px; - instance.v0 = if (stripes) 1 else 0; - instance.v1 = if (stripes) 1 else 0; - instance.fr = @as(f32, @floatFromInt(b[0])) / 255.0; - instance.fg = @as(f32, @floatFromInt(b[1])) / 255.0; - instance.fb = @as(f32, @floatFromInt(b[2])) / 255.0; - instance.effect |= checker_bit; -} - /// A body region in window pixels. fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 { return .{ @@ -7711,9 +7452,6 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g for (groups.items[0..groups.len], 0..) |*group, index| { group.decor_start = @intCast(g.decor.items.len); defer group.decor_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start; - // Under the cells: a theme's tag plaques. - if (index == 0) try tagPlaques(g, gpa, regions, chrome, layout, win_w, win_h); - group.under_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start; if (index == 0) { // The grips' buttons before any rule: the rules over their rows // cut them, and the band round them never covers a rule. @@ -7833,10 +7571,7 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti // the track edges it. const column = scrollColumn(g, chrome, rail.rect.x, layout); try addDecor(g, gpa, x0, y0, x0 + layout.w, y1, page, 1, win_w, win_h); - if (chrome.decor_checker) |gold| - try addPattern(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, gold, dp(@floatFromInt(@max(1, chrome.decor_checker_px))), false, win_w, win_h) - else - try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, win_w, win_h); + try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, win_w, win_h); if (rail.thumb_h != 0 and rail.thumb_span > 0) { // In pixels, not rows, and with the picture while it glides // or lags behind the core's rows (both in rows of the body). @@ -7899,235 +7634,11 @@ fn updateDisplayScale(window: *c.SDL_Window) void { display_scale = std.math.clamp(display_scale, 1, 4); } -/// A theme's ornament as the cell shader draws it (Chrome.decor_*), for the -/// frame being built: renderFrame sets it, writing a cell marks the cells -/// it falls on, and pushLayerOpacity hands the shader its colours and -/// sizes. ponytail: one window per process, as display_scale. -var cell_decor: CellDecor = .{}; -/// The cells this frame lets a plaque show through, by instance, for -/// renderFrame to drop the ones with no ink. Past its length the frame's -/// cells are blended instead. -var plaque_through: [16384]u32 = undefined; -var plaque_through_len: usize = 0; - -fn plaqueThrough(instances: [*]CellInstance, at: u32) void { - instances[at].effect |= clear_bg_bit; - if (plaque_through_len < plaque_through.len) plaque_through[plaque_through_len] = at; - plaque_through_len += 1; -} -const CellDecor = struct { - /// The page's ground, when the theme dots it. - dots: ?[3]u8 = null, - /// A file name's inks in a tag, when the theme shadows it. - title: ?[2][3]u8 = null, - /// UiUniforms after background_opacity (ui.frag.glsl): the dots' colour - /// and strength, their period and radii, the shadow's colour and offset. - uniforms: [12]f32 = @splat(0), - /// The tag plaques' bands (window pixels) and the tag grounds: a blank - /// tag cell there lets its plaque show through (tagPlaques). - plaques: [pardes.MAX_TAG_LAYERS][4]f32 = undefined, - nplaques: usize = 0, - grounds: [2][3]u8 = .{ .{ 0, 0, 0 }, .{ 0, 0, 0 } }, - plaques_off: bool = false, - /// A see-through cell over the plaques has ink of its own, so this - /// frame's cells are blended (renderFrame). - inked_clear: bool = false, - - /// G13: each body's rectangle and how far its dots have moved. - bodies: [pardes.MAX_PANES][4]f32 = undefined, - shifts: [pardes.MAX_PANES]f32 = undefined, - nbodies: usize = 0, - - fn parallaxAt(decor: *const CellDecor, x: f32, y: f32) f32 { - for (decor.bodies[0..decor.nbodies], decor.shifts[0..decor.nbodies]) |band, shift| - if (x >= band[0] and x < band[2] and y >= band[1] and y < band[3]) return shift; - return 0; - } - - fn inPlaque(decor: *const CellDecor, x: f32, y: f32) bool { - for (decor.plaques[0..decor.nplaques]) |band| - if (x >= band[0] and x < band[2] and y >= band[1] and y < band[3]) return true; - return false; - } - - fn of(chrome: *const pardes.Chrome) CellDecor { - var out: CellDecor = .{}; - if (chrome.decor_dots) |rgb| if (chrome.page) |page| { - out.dots = page; - out.uniforms[0..4].* = .{ unit(rgb[0]), unit(rgb[1]), unit(rgb[2]), unit(chrome.decor_dot_alpha) }; - out.uniforms[4..8].* = .{ dp(@floatFromInt(@max(2, chrome.decor_dot_px))), 0.75 * display_scale, 1.25 * display_scale, 0 }; - }; - if (chrome.decor_title) |rgb| { - out.title = .{ chrome.name_ink, chrome.active_name_ink }; - out.uniforms[8..12].* = .{ unit(rgb[0]), unit(rgb[1]), unit(rgb[2]), dp(@floatFromInt(@max(1, chrome.decor_title_px))) }; - } - return out; - } - - fn unit(v: u8) f32 { - return @as(f32, @floatFromInt(v)) / 255; - } -}; - /// A logical pixel size in the display's pixels: rounded, at least one. fn dp(logical: f32) f32 { return @max(1, @round(logical * display_scale)); } -/// A theme's tag plaques (Chrome.decor_box_*), drawn under the cells of -/// group `index`: each pane tag, and with the still panes the column and -/// workspace tags, becomes a framed box inside its own band with a hard -/// shadow down and right that stays inside the band too, so it never falls -/// on a body, a grip or the next pane. The focused pane's box is striped, -/// its words on plates of the tag's ground (their cells stay opaque; the -/// spaces between let the stripes through, emitInstance); a column or the -/// workspace takes a quieter box, a one-pixel frame and a two-pixel shadow. -fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, chrome: *const pardes.Chrome, layout: CellLayout, win_w: f32, win_h: f32) !void { - const border_rgb = chrome.decor_box_border orelse return; - if (cell_decor.plaques_off) return; - const page = chrome.page orelse bg_default; - // The workspace and column plaques first: a pane's plaque right under - // them shares their bottom edge (plaqueBox) and draws its frame last. - for ([_]bool{ false, true }) |panes| for (regions) |tag| { - const pane = tag.kind == .tag; - if (pane != panes) continue; - if (!pane and tag.kind != .column_tag and tag.kind != .workspace_tag) continue; - if (tag.rect.w == 0 or tag.rect.h == 0) continue; - const plaque = plaqueBox(g, chrome, regions, tag, layout, win_w, win_h) orelse continue; - const b = plaque.border; - const sh = plaque.shadow; - const fill = if (tag.active) chrome.tag_focus_bg else chrome.tag_bg; - // The band's own ground, then the shadow, the frame and the fill, - // each only where the ones over it leave it showing: all four are - // opaque, so that is the same picture drawn once, not four times. - const shadow: [4]f32 = .{ plaque.box[0] + sh[0], plaque.box[1] + sh[1], plaque.box[2] + sh[0], plaque.box[3] + sh[1] }; - const inner: [4]f32 = .{ plaque.box[0] + b, plaque.box[1] + b, plaque.box[2] - b, plaque.box[3] - b }; - try addDecorExcept(g, gpa, plaque.band, &.{ plaque.box, shadow }, page, win_w, win_h); - const shadow_rgb = chrome.decor_box_shadow orelse border_rgb; - try addDecorExcept(g, gpa, shadow, &.{plaque.box}, if (pane) shadow_rgb else mixRgb(shadow_rgb, page), win_w, win_h); - try addDecorExcept(g, gpa, plaque.box, &.{inner}, border_rgb, win_w, win_h); - if (pane and tag.active and chrome.decor_box_stripe != null) - try addPattern(g, gpa, inner[0], inner[1], inner[2], inner[3], chrome.decor_box_stripe.?, fill, dp(@floatFromInt(@max(1, chrome.decor_box_stripe_px))), true, win_w, win_h) - else - try addDecor(g, gpa, inner[0], inner[1], inner[2], inner[3], fill, 1, win_w, win_h); - }; -} - -/// Flat decor over `rect` (window pixels) less each of `holes`: up to four -/// strips round the first hole's part of it, each less the rest. -fn addDecorExcept(g: *Gui, gpa: std.mem.Allocator, rect: [4]f32, holes: []const [4]f32, rgb: [3]u8, win_w: f32, win_h: f32) std.mem.Allocator.Error!void { - if (rect[0] >= rect[2] or rect[1] >= rect[3]) return; - if (holes.len == 0) return addDecor(g, gpa, rect[0], rect[1], rect[2], rect[3], rgb, 1, win_w, win_h); - const hole = holes[0]; - const x0 = @max(rect[0], hole[0]); - const y0 = @max(rect[1], hole[1]); - const x1 = @min(rect[2], hole[2]); - const y1 = @min(rect[3], hole[3]); - if (x0 >= x1 or y0 >= y1) return addDecorExcept(g, gpa, rect, holes[1..], rgb, win_w, win_h); - for ([_][4]f32{ - .{ rect[0], rect[1], rect[2], y0 }, - .{ rect[0], y1, rect[2], rect[3] }, - .{ rect[0], y0, x0, y1 }, - .{ x1, y0, rect[2], y1 }, - }) |strip| try addDecorExcept(g, gpa, strip, holes[1..], rgb, win_w, win_h); -} - -test "decor less its holes covers each pixel of the rest once and none of the holes" { - const gpa = std.testing.allocator; - var g = testGui(1, 1, 1, 1); - defer g.decor.deinit(gpa); - const holes = [_][4]f32{ .{ 3, 2, 9, 6 }, .{ 5, 4, 12, 8 }, .{ 30, 30, 40, 40 } }; - try addDecorExcept(&g, gpa, .{ 1, 1, 11, 10 }, &holes, .{ 1, 2, 3 }, 16, 12); - for (0..12) |y| for (0..16) |x| { - const px: f32 = @as(f32, @floatFromInt(x)) + 0.5; - const py: f32 = @as(f32, @floatFromInt(y)) + 0.5; - var hits: usize = 0; - for (g.decor.items) |item| { - const r: [4]f32 = .{ (item.x0 + 1) / 2 * 16, (1 - item.y0) / 2 * 12, (item.x1 + 1) / 2 * 16, (1 - item.y1) / 2 * 12 }; - hits += @intFromBool(px > r[0] and px < r[2] and py > r[1] and py < r[3]); - } - const in_rect = px > 1 and px < 11 and py > 1 and py < 10; - const in_hole = for (holes) |h| { - if (px > h[0] and px < h[2] and py > h[1] and py < h[3]) break true; - } else false; - try std.testing.expectEqual(@as(usize, @intFromBool(in_rect and !in_hole)), hits); - }; -} - -const Plaque = struct { band: [4]f32, box: [4]f32, border: f32, shadow: [2]f32 }; - -/// A tag's plaque in window pixels: its band (the rows, from after the -/// grip to the end), the framed box round the tagline's text, and the -/// frame's and the shadow's widths, the shadow cut to what the band's slack -/// below the text and its right end leave. Null where there is no room. -/// Tags stacked on each other (the workspace's over the columns', a -/// column's over its first pane's) share one edge, the ruled one between -/// their bands: the upper box runs down to it and casts no shadow down, the -/// lower one's frame lies over it. Every box in a column spans the same -/// pixels across, right of the grips, its shadow short of the next column. -fn plaqueBox(g: *const Gui, chrome: *const pardes.Chrome, regions: []const pardes.Region, tag: pardes.Region, layout: CellLayout, win_w: f32, win_h: f32) ?Plaque { - const pane = tag.kind == .tag; - const first = tag.rect.y; - const last = tag.rect.y + tag.rect.h - 1; - // Flush against its grip's button, so the two read as one piece: the - // gap between button and text (the scroll gap) is the plaque's, and so - // is the cell before its text, so its frame is never under the first - // letter. A column's plaque starts where the pane's under it does. - const grip_kind: pardes.Region.Kind = if (tag.kind == .column_tag) .column_grip else .grip; - const x0 = for (regions) |grip| { - if (tag.kind != .workspace_tag and grip.kind == grip_kind and grip.owner == tag.owner) - break scrollColumn(g, chrome, grip.rect.x, layout)[1]; - } else @as(f32, @floatFromInt(tag.rect.x)) * layout.w; - const x1_cells = @as(f32, @floatFromInt(tag.rect.x + tag.rect.w)) * layout.w; - const window_edge = win_w - x1_cells < layout.w; - const x1 = if (window_edge) @max(x1_cells, win_w) else x1_cells; - const stacked_on = tagBandAt(regions, tag, .above); - const stacked_under = tagBandAt(regions, tag, .below); - const row_top = @as(f32, @floatFromInt(first)) * layout.h; - const row_bottom = @as(f32, @floatFromInt(last + 1)) * layout.h; - const text_top = row_top + @as(f32, @floatFromInt(taglineBandOffset(first, win_h, g.cell_h, g.tagline_height))); - const text_bottom = @as(f32, @floatFromInt(last)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(last, win_h, g.cell_h, g.tagline_height) + g.tagline_height)); - const border = @min(if (pane) dp(@floatFromInt(@max(1, chrome.decor_box_border_px))) else dp(1), @floor(text_top - row_top)); - if (border < 1) return null; - // The shadow's full offset to the right; down, what the slack under the - // text leaves (a pixel or three at a tagline under the body's size). - const want: f32 = if (pane) dp(@floatFromInt(chrome.decor_box_shadow_px)) else dp(2); - const drop = if (stacked_under) 0 else std.math.clamp(@floor(row_bottom - text_bottom - border), 0, want); - // Every box ends where a pane's does, short of the next column's rule - // by a pane frame's width past its shadow, so no shadow meets the rule - // and a column's box lines up with its panes'; the window's edge needs - // no gap. - const pane_shadow = dp(@floatFromInt(chrome.decor_box_shadow_px)); - const gap = @max(0, pane_shadow - want) + if (window_edge) 0 else dp(@floatFromInt(@max(1, chrome.decor_box_border_px))); - if (x1 - x0 < 4 * border + want + gap) return null; - return .{ - .band = .{ x0, row_top, x1, row_bottom }, - .box = .{ - x0, - if (stacked_on) row_top - border else text_top - border, - x1 - want - gap, - if (stacked_under) row_bottom else text_bottom + border, - }, - .border = border, - .shadow = .{ want, drop }, - }; -} - -/// Whether another tag's band (the workspace's, a column's, a pane's) meets -/// `tag`'s right above or below it, across some of its width. -fn tagBandAt(regions: []const pardes.Region, tag: pardes.Region, side: enum { above, below }) bool { - for (regions) |other| { - if (other.kind != .tag and other.kind != .column_tag and other.kind != .workspace_tag) continue; - if (other.rect.h == 0 or std.meta.eql(other.rect, tag.rect)) continue; - const meets = switch (side) { - .above => other.rect.y + other.rect.h == tag.rect.y, - .below => tag.rect.y + tag.rect.h == other.rect.y, - }; - if (meets and other.rect.x < tag.rect.x + tag.rect.w and tag.rect.x < other.rect.x + other.rect.w) return true; - } - return false; -} - /// The two short bars on each row of a grip with no mode glyph there, /// centered in its anchor. fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, cells: []const pardes.Cell, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void { @@ -8142,13 +7653,7 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce const left = @as(f32, @floatFromInt(grip.rect.x)) * layout.w; const right = @as(f32, @floatFromInt(grip.rect.x + grip.rect.w)) * layout.w; try addDecor(g, gpa, left, button[1], button[0], button[3], band, 1, win_w, win_h); - // Right of it, a theme's plaque starts flush against it (plaqueBox). - const plaqued = chrome.decor_box_border != null and !cell_decor.plaques_off; - if (!plaqued) try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, win_w, win_h); - // Its cells over the plaque's reach are let through (emitInstance): - // under the button's row, the band goes on as far as the plaque. - if (plaqued and grip.rect.h > 1) - try addDecor(g, gpa, left, button[3], button[2], @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h, band, 1, win_w, win_h); + try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, win_w, win_h); if (grip.kind != .grip) continue; // acme's button ring, two pixels (ButtonBorder) inside the button: // the focused one's in its own fill. An unfocused dirty one keeps a @@ -8453,31 +7958,18 @@ test "decor is read from the regions" { try std.testing.expectEqual(@as(u32, 0), groups.items[groups.notices].decor_count); } -test "a body tells its first line, and lapis's dots under it move a quarter as far" { +test "a body tells its first line" { const gpa = std.testing.allocator; const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); defer core.deinit(); const pane = try core.setTestFile(std.mem.asBytes(&@as([80][5]u8, @splat("line\n".*)))); pane.scrollBy(8); - try std.testing.expect(core.executeBuiltinLine(0, "Theme lapis")); - core.settings.parallax = true; - for (0..40) |_| core.update(.tick); core.sync(); const s = try core.render(core.scratch.allocator()); const body = for (s.regionList()) |region| { if (region.kind == .body) break region; } else return error.NoBody; try std.testing.expectEqual(@as(i32, 8), body.line); - try std.testing.expect(s.chrome.fx & 8 != 0); - // The shift the cell shader is handed: a quarter of 8 rows of 20 px, - // upward, within the dots' period. - var decor = CellDecor.of(&s.chrome); - const period = decor.uniforms[4]; - decor.bodies[0] = .{ 0, 0, 800, 480 }; - decor.shifts[0] = @mod(-8.0 * 20.0 * 0.25, period); - decor.nbodies = 1; - try std.testing.expectApproxEqAbs(@mod(-40.0, period), decor.parallaxAt(10, 10), 1e-4); - try std.testing.expectEqual(@as(f32, 0), decor.parallaxAt(900, 10)); } const CursorBox = struct { x0: f32, y0: f32, x1: f32, y1: f32, rgb: [3]u8, bar: bool }; @@ -8635,8 +8127,7 @@ fn uploadOverlayGpu(g: *Gui, cmd: *c.SDL_GPUCommandBuffer, vertex_count: u32) bo } fn pushLayerOpacity(cmd: *c.SDL_GPUCommandBuffer, pass: ?*c.SDL_GPURenderPass, opacity: f32) void { - var uniforms = [4]f32{ opacity, 0, 0, 0 } ++ @as([12]f32, @splat(0)); - uniforms[4..].* = cell_decor.uniforms; + const uniforms = [4]f32{ opacity, 0, 0, 0 }; c.SDL_PushGPUFragmentUniformData(cmd, 0, &uniforms, @sizeOf(@TypeOf(uniforms))); // The source alpha is geometric/image coverage, not window opacity. Its // alpha contribution is multiplied by this constant separately, so a diff --git a/src/surface.zig b/src/surface.zig index 6e383841..998e3230 100644 --- a/src/surface.zig +++ b/src/surface.zig @@ -246,8 +246,7 @@ pub const Region = struct { /// A notice's index in its pane's `notices`. notice: u8 = 0, /// A body's view: the first line it shows (a file's scroll, a - /// terminal's grid offset), for what a pixel shell moves with the text - /// (G13's parallax). + /// terminal's grid offset). line: i32 = 0, /// Cells the column-move rail takes off the right edge while it runs /// there: layers and pixel shells stop short of them, the grid does not. @@ -307,29 +306,6 @@ pub const Chrome = struct { /// The scroll column's width, button and scrollbar alike, in pixels at /// a 17px tagline (acme's 12 at its font); a pixel shell scales it. rail_px: u8 = 12, - /// The theme's ornament (colors.Decor), a pixel shell's alone: the dot - /// grid on the page, the scroll track's checker, the tags' plaques - /// (frame, shadow, the focused one's stripes) and the file name's shadow, each null when the theme has none, sizes - /// in logical pixels. `name_ink` and `active_name_ink` are the file - /// name's colours in a tag, which the shadow goes under. - decor_dots: ?[3]u8 = null, - decor_dot_alpha: u8 = 0, - decor_dot_px: u8 = 22, - decor_checker: ?[3]u8 = null, - decor_checker_px: u8 = 3, - decor_box_border: ?[3]u8 = null, - decor_box_border_px: u8 = 2, - decor_box_shadow: ?[3]u8 = null, - decor_box_shadow_px: u8 = 5, - decor_box_stripe: ?[3]u8 = null, - decor_box_stripe_px: u8 = 2, - decor_title: ?[3]u8 = null, - decor_title_px: u8 = 2, - name_ink: [3]u8 = .{ 0, 0, 0 }, - active_name_ink: [3]u8 = .{ 0, 0, 0 }, - /// A pixel shell's small effects: bit 3 the page pattern's parallax - /// (G13, Parallax). - fx: u8 = 0, }; /// The canonical interface: what a frame of pardes IS. The tui shell writes diff --git a/src/themes/lapis.zig b/src/themes/lapis.zig index 46623fc2..95fc86bd 100644 --- a/src/themes/lapis.zig +++ b/src/themes/lapis.zig @@ -1,14 +1,7 @@ //! Lapis: 0x4200.cafe's illuminated manuscript (web/theme/lapis.css) as a //! pardes theme. Ultramarine vellum, gold leaf and vermilion rubrics: the //! page is lapis-deep, the tags lapis with their names in gold, the text -//! vellum. The site's ornament comes with it as the theme's `decor`, drawn -//! inside the existing chrome (docs/render-pipeline.md §10, decision 1): -//! a gold dot grid on the page under the pane bodies, a gold and lapis -//! checker in the scroll column, every tag a gold-framed plaque with the -//! trail's hard vermilion shadow (inside its own band: in a tiled layout a -//! shadow past it would fall on the next pane or its grip, and no ornament -//! may cover a focus indicator), the focused one striped like the code -//! window's title bar, and the file name's vermilion offset shadow. +//! vellum. pub const theme = .{ .name = "lapis", // --lapis-deep, --vellum @@ -53,24 +46,6 @@ pub const theme = .{ .diagnostic_warning = .{ 0xe8, 0xc4, 0x6a }, .diagnostic_info = .{ 0x9a, 0xc6, 0xff }, .diagnostic_hint = .{ 0xa8, 0xe0, 0xc0 }, - .decor = .{ - .page_dots = .{ 0xe8, 0xc4, 0x6a }, - // #e8c46a22 on the site: a dot a pixel and a half across every 22. - .page_dot_alpha = 0x22, - .page_dot_px = 22, - .rail_checker = .{ 0xe8, 0xc4, 0x6a }, - .rail_checker_px = 3, - // The trail: a 2px gold frame and a 5px vermilion shadow; the code - // window's title bar: gold and lapis stripes of 2px. - .tag_border = .{ 0xe8, 0xc4, 0x6a }, - .tag_border_px = 2, - .tag_shadow = .{ 0xd4, 0x41, 0x2f }, - .tag_shadow_px = 5, - .tag_stripe = .{ 0xe8, 0xc4, 0x6a }, - .tag_stripe_px = 2, - .title_shadow = .{ 0xd4, 0x41, 0x2f }, - .title_shadow_px = 2, - }, .palette = .{ .{ 0x0a, 0x10, 0x30 }, .{ 0xff, 0x6a, 0x4a }, diff --git a/src/themes/lapis_plain.zig b/src/themes/lapis_plain.zig deleted file mode 100644 index 5b4c48dd..00000000 --- a/src/themes/lapis_plain.zig +++ /dev/null @@ -1,81 +0,0 @@ -//! Lapis plain: lapis (src/themes/lapis.zig) with flat grounds. The page -//! under the text is lapis-deep with no dot grid, and the focused tag's -//! plaque is its tint with no gold stripes behind its words; the rest is -//! lapis's own: every colour, the gold frames and vermilion shadows of the -//! tag plaques, the gold rules, the checker in the scroll column and the -//! file name's vermilion offset shadow. -pub const theme = .{ - .name = "lapis_plain", - // --lapis-deep, --vellum - .bg = .{ 0x0a, 0x10, 0x30 }, - .fg = .{ 0xee, 0xe6, 0xd2 }, - // A gold highlight in lapis ink, as the directory's current entry. - .sel_bg = .{ 0xe8, 0xc4, 0x6a }, - .sel_fg = .{ 0x0f, 0x1a, 0x4a }, - // --lapis, --vellum-dim - .tag_bg = .{ 0x0f, 0x1a, 0x4a }, - .tag_fg = .{ 0x9a, 0xa6, 0xd9 }, - .tag_name_fg = .{ 0xe8, 0xc4, 0x6a }, - .tag_active_name_fg = .{ 0xf2, 0xd2, 0x80 }, - // The plaques' hover lapis, taken a step further: 1.5:1 off the tag. - .tag_active_bg = .{ 0x25, 0x39, 0x7d }, - .tag_active_fg = .{ 0xee, 0xe6, 0xd2 }, - .box = .{ 0xe8, 0xc4, 0x6a }, - .box_dim = .{ 0x3a, 0x4a, 0x8a }, - .box_border = .{ 0x9a, 0xa6, 0xd9 }, - .box_dirty = .{ 0xff, 0x6a, 0x4a }, - .column_box = .{ 0xff, 0x6a, 0x4a }, - .column_box_dim = .{ 0x8a, 0x3a, 0x3a }, - // Rubrics: vermilion keywords, gilded strings, the code window's green - // for numbers, vellum-dim comments. - .kw = .{ 0xff, 0x6a, 0x4a }, - .str = .{ 0xe8, 0xc4, 0x6a }, - .num = .{ 0xe7, 0xff, 0xe0 }, - .comment = .{ 0x9a, 0xa6, 0xd9 }, - .lineno = .{ 0x5a, 0x6a, 0xa8 }, - .lineno_active = .{ 0x6a, 0x7a, 0xb8 }, - // --lapis-ink under a gold thumb (the page's scrollbar-color). - .scroll_track = .{ 0x05, 0x0a, 0x24 }, - .scroll_thumb = .{ 0xe8, 0xc4, 0x6a }, - // Gold rules, a vermilion hairline between a tag and its text. - .border = .{ 0xe8, 0xc4, 0x6a }, - // An empty column is the page, not a slab of gold leaf. - .empty_col = .{ 0x0a, 0x10, 0x30 }, - .tag_rule = .{ 0xd4, 0x41, 0x2f }, - .search_bg = .{ 0x6a, 0x2a, 0x1c }, - .search_fg = .{ 0xff, 0xd0, 0xb0 }, - .diagnostic_error = .{ 0xff, 0x6a, 0x4a }, - .diagnostic_warning = .{ 0xe8, 0xc4, 0x6a }, - .diagnostic_info = .{ 0x9a, 0xc6, 0xff }, - .diagnostic_hint = .{ 0xa8, 0xe0, 0xc0 }, - .decor = .{ - .rail_checker = .{ 0xe8, 0xc4, 0x6a }, - .rail_checker_px = 3, - // The trail: a 2px gold frame and a 5px vermilion shadow; the - // focused plaque filled flat. - .tag_border = .{ 0xe8, 0xc4, 0x6a }, - .tag_border_px = 2, - .tag_shadow = .{ 0xd4, 0x41, 0x2f }, - .tag_shadow_px = 5, - .title_shadow = .{ 0xd4, 0x41, 0x2f }, - .title_shadow_px = 2, - }, - .palette = .{ - .{ 0x0a, 0x10, 0x30 }, - .{ 0xff, 0x6a, 0x4a }, - .{ 0xa8, 0xe0, 0xc0 }, - .{ 0xe8, 0xc4, 0x6a }, - .{ 0x9a, 0xc6, 0xff }, - .{ 0xd8, 0xa0, 0xe8 }, - .{ 0x8a, 0xd8, 0xd8 }, - .{ 0xee, 0xe6, 0xd2 }, - .{ 0x9a, 0xa6, 0xd9 }, - .{ 0xff, 0x9a, 0x6a }, - .{ 0xc8, 0xf0, 0xd8 }, - .{ 0xff, 0xde, 0x90 }, - .{ 0xc0, 0xdc, 0xff }, - .{ 0xe8, 0xc0, 0xf4 }, - .{ 0xb0, 0xec, 0xec }, - .{ 0xff, 0xf8, 0xe8 }, - }, -}; diff --git a/test/process/window.zig b/test/process/window.zig index 144013e1..3a64d910 100644 --- a/test/process/window.zig +++ b/test/process/window.zig @@ -29,7 +29,7 @@ fn paneWith(f: *process.Files, word: []const u8) !u32 { } const motions = [_][]const u8{ "off", "crisp", "smooth", "bouncy", "playful" }; -const themes = [_][]const u8{ "lapis", "lapis_plain", "forge", "acme", "dusk", "daybreak" }; +const themes = [_][]const u8{ "lapis", "forge", "acme", "dusk", "daybreak" }; /// test/gui_monkey.py's: each Motion gets a random burst, then must /// settle with its process alive and no crash record. Two of them and 30 diff --git a/test/snapshots/theme.golden b/test/snapshots/theme.golden index 248cc477..3c6dbcbd 100644 --- a/test/snapshots/theme.golden +++ b/test/snapshots/theme.golden @@ -586,8 +586,6 @@ |28: 0-0 d,#e8c46a, 1-49 d,#0a1030, 50-50 d,#e8c46a, 51-99 d,#0a1030, |29: 0-0 d,#e8c46a, 1-49 d,#0a1030, 50-50 d,#e8c46a, 51-99 d,#0a1030, |30: 0-0 d,#e8c46a, 1-49 d,#0a1030, 50-50 d,#e8c46a, 51-99 d,#0a1030, -== snap lapis-plain grid=100x31 cursor=4,6 -== style lapis-plain grid=100x31 == snap dark-plus grid=100x31 cursor=4,6 == style dark-plus grid=100x31 |0: 0-1 d,#3c3c3c, 2-77 #a7a7a7,#3c3c3c, 78-86 #d4d4d4,#264f78, 87-99 #d4d4d4,#3c3c3c, diff --git a/test/snapshots/theme.snap b/test/snapshots/theme.snap index 780744d8..19176475 100644 --- a/test/snapshots/theme.snap +++ b/test/snapshots/theme.snap @@ -110,16 +110,11 @@ snapstyle lapis press middle @NextColor 1 release middle @NextColor 1 stable 700 10000 -snap lapis-plain -snapstyle lapis-plain -press middle @NextColor 1 -release middle @NextColor 1 -stable 700 10000 snap dark-plus snapstyle dark-plus press middle @NextColor 1 release middle @NextColor 1 stable 700 10000 -# After orchard_black: acme, lapis and lapis_plain, then the first faithful ports. +# After orchard_black: acme and lapis, then the first faithful ports. snap solarized-dark snapstyle solarized-dark diff --git a/test/snapshots/themesel.golden b/test/snapshots/themesel.golden index 5f614627..45fa202d 100644 --- a/test/snapshots/themesel.golden +++ b/test/snapshots/themesel.golden @@ -482,7 +482,7 @@ |27: 16 Theme orchard_black |28: 17 Theme acme |29: 18 Theme lapis -|30: 19 Theme lapis_plain +|30: 19 == style step-orchard-black grid=100x31 |0: 0-1 d,#1d2824, 2-99 #b2c3b8,#1d2824, |1: 0-1 d,#887455, 2-99 #becfc4,#314738, @@ -514,7 +514,7 @@ |27: 0-0 d,#111813, 1-1 d,#000000, 2-3 d,#000000,b 4-6 #616f64,#000000,b 7-99 #f2f8ef,#000000, |28: 0-0 d,#111813, 1-3 d,#000000, 4-6 #59675c,#000000, 7-99 #f2f8ef,#000000, |29: 0-0 d,#111813, 1-3 d,#000000, 4-6 #59675c,#000000, 7-99 #f2f8ef,#000000, -|30: 0-0 d,#111813, 1-3 d,#000000, 4-6 #59675c,#000000, 7-99 #f2f8ef,#000000, +|30: 0-0 d,#111813, 1-3 d,#000000, 4-99 #59675c,#000000, == snap step-acme grid=100x31 cursor=7,27 |17: 7 Theme atelier Theme |18: 8 Theme forge @@ -528,8 +528,8 @@ |26: 16 Theme orchard_black |27: 17 Theme acme |28: 18 Theme lapis -|29: 19 Theme lapis_plain -|30: 20 +|29: 19 +|30: 20 # Visual Studio Code == style step-acme grid=100x31 |0: 0-1 d,#eaffff, 2-99 #000000,#eaffff, |1: 0-1 d,#8888cc, 2-99 #000000,#eaffff, @@ -560,8 +560,8 @@ |26: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, |27: 0-0 d,#99994c, 1-1 d,#ffffea, 2-3 d,#ffffea,b 4-6 #999980,#ffffea,b 7-99 #000000,#ffffea, |28: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, -|29: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, -|30: 0-0 d,#99994c, 1-3 d,#ffffea, 4-99 #999980,#ffffea, +|29: 0-0 d,#99994c, 1-3 d,#ffffea, 4-99 #999980,#ffffea, +|30: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, == snap step-lapis grid=100x31 cursor=7,27 |17: 8 Theme forge Theme |18: 9 Theme lagoon @@ -574,9 +574,9 @@ |25: 16 Theme orchard_black |26: 17 Theme acme |27: 18 Theme lapis -|28: 19 Theme lapis_plain -|29: 20 -|30: 21 # Visual Studio Code +|28: 19 +|29: 20 # Visual Studio Code +|30: 21 Theme dark_plus == style step-lapis grid=100x31 |0: 0-1 d,#0f1a4a, 2-99 #9aa6d9,#0f1a4a, |1: 0-1 d,#8a3a3a, 2-99 #eee6d2,#25397d, @@ -606,43 +606,24 @@ |25: 0-0 d,#050a24, 1-3 d,#0a1030, 4-6 #5a6aa8,#0a1030, 7-99 #eee6d2,#0a1030, |26: 0-0 d,#050a24, 1-3 d,#0a1030, 4-6 #5a6aa8,#0a1030, 7-99 #eee6d2,#0a1030, |27: 0-0 d,#050a24, 1-1 d,#0a1030, 2-3 d,#0a1030,b 4-6 #6a7ab8,#0a1030,b 7-99 #eee6d2,#0a1030, -|28: 0-0 d,#050a24, 1-3 d,#0a1030, 4-6 #5a6aa8,#0a1030, 7-99 #eee6d2,#0a1030, -|29: 0-0 d,#050a24, 1-3 d,#0a1030, 4-99 #5a6aa8,#0a1030, -|30: 0-0 d,#050a24, 1-3 d,#0a1030, 4-6 #5a6aa8,#0a1030, 7-99 #eee6d2,#0a1030, -== snap step-lapis-plain grid=100x31 cursor=7,27 -|17: 9 Theme lagoon Theme -|18: 10 Theme solarium -|19: 11 Theme spectrum -|20: 12 Theme harvest -|21: 13 Theme clay -|22: 14 Theme forge_black -|23: 15 Theme forge_soft -|24: 16 Theme orchard_black -|25: 17 Theme acme -|26: 18 Theme lapis -|27: 19 Theme lapis_plain -|28: 20 -|29: 21 # Visual Studio Code -|30: 22 Theme dark_plus -== style step-lapis-plain grid=100x31 -|18: 0-0 d,#050a24, 1-3 d,#0a1030, 4-6 #5a6aa8,#0a1030, 7-99 #eee6d2,#0a1030, |28: 0-0 d,#050a24, 1-3 d,#0a1030, 4-99 #5a6aa8,#0a1030, |29: 0-0 d,#050a24, 1-3 d,#0a1030, 4-6 #5a6aa8,#0a1030, 7-99 #eee6d2,#0a1030, +|30: 0-0 d,#050a24, 1-3 d,#0a1030, 4-6 #5a6aa8,#0a1030, 7-99 #eee6d2,#0a1030, == snap step-dark-plus grid=100x31 cursor=7,27 -|17: 12 Theme harvest Theme -|18: 13 Theme clay -|19: 14 Theme forge_black -|20: 15 Theme forge_soft -|21: 16 Theme orchard_black -|22: 17 Theme acme -|23: 18 Theme lapis -|24: 19 Theme lapis_plain -|25: 20 -|26: 21 # Visual Studio Code -|27: 22 Theme dark_plus -|28: 23 -|29: 24 # Solarized -|30: 25 Theme solarized_dark +|17: 11 Theme spectrum Theme +|18: 12 Theme harvest +|19: 13 Theme clay +|20: 14 Theme forge_black +|21: 15 Theme forge_soft +|22: 16 Theme orchard_black +|23: 17 Theme acme +|24: 18 Theme lapis +|25: 19 +|26: 20 # Visual Studio Code +|27: 21 Theme dark_plus +|28: 22 +|29: 23 # Solarized +|30: 24 Theme solarized_dark == style step-dark-plus grid=100x31 |0: 0-1 d,#3c3c3c, 2-99 #a7a7a7,#3c3c3c, |1: 0-1 d,#458276, 2-99 #ffffff,#1e1e1e, @@ -676,20 +657,20 @@ |29: 0-3 d,#1e1e1e, 4-6 #858585,#1e1e1e, 7-99 #d4d4d4,#1e1e1e, |30: 0-3 d,#1e1e1e, 4-6 #858585,#1e1e1e, 7-99 #d4d4d4,#1e1e1e, == snap step-solarized-dark grid=100x31 cursor=7,27 -|17: 15 Theme forge_soft Theme -|18: 16 Theme orchard_black -|19: 17 Theme acme -|20: 18 Theme lapis -|21: 19 Theme lapis_plain -|22: 20 -|23: 21 # Visual Studio Code -|24: 22 Theme dark_plus -|25: 23 -|26: 24 # Solarized -|27: 25 Theme solarized_dark -|28: 26 Theme solarized_light -|29: 27 -|30: 28 # Dracula +|17: 14 Theme forge_black Theme +|18: 15 Theme forge_soft +|19: 16 Theme orchard_black +|20: 17 Theme acme +|21: 18 Theme lapis +|22: 19 +|23: 20 # Visual Studio Code +|24: 21 Theme dark_plus +|25: 22 +|26: 23 # Solarized +|27: 24 Theme solarized_dark +|28: 25 Theme solarized_light +|29: 26 +|30: 27 # Dracula == style step-solarized-dark grid=100x31 |0: 0-1 d,#657b83, 2-99 #01090b,#657b83, |1: 0-1 d,#758a41, 2-99 #073642,#93a1a1, @@ -756,20 +737,20 @@ |29: 0-3 d,#1e1e1e, 4-99 #858585,#1e1e1e, |30: 0-3 d,#1e1e1e, 4-6 #858585,#1e1e1e, 7-99 #d4d4d4,#1e1e1e, == snap tail grid=100x31 cursor=7,29 -|17: 305 Theme wolf_alabaster_dark -|18: 306 Theme wolf_alabaster_dark_bg -|19: 307 Theme wolf_alabaster_dark_mono -|20: 308 Theme wolf_alabaster_light -|21: 309 Theme wolf_alabaster_light_bg -|22: 310 Theme wolf_alabaster_light_mono -|23: 311 Theme yellowed -|24: 312 Theme yo -|25: 313 Theme yo_berry -|26: 314 Theme yo_light -|27: 315 Theme zed_onedark -|28: 316 Theme zed_onelight -|29: 317 Theme zenburn -|30: 318 +|17: 304 Theme wolf_alabaster_dark +|18: 305 Theme wolf_alabaster_dark_bg +|19: 306 Theme wolf_alabaster_dark_mono +|20: 307 Theme wolf_alabaster_light +|21: 308 Theme wolf_alabaster_light_bg +|22: 309 Theme wolf_alabaster_light_mono +|23: 310 Theme yellowed +|24: 311 Theme yo +|25: 312 Theme yo_berry +|26: 313 Theme yo_light +|27: 314 Theme zed_onedark +|28: 315 Theme zed_onelight +|29: 316 Theme zenburn +|30: 317 == snap picked grid=100x31 cursor=7,3 |16: 14 line 14 |17: 15 line 15 diff --git a/test/snapshots/themesel.snap b/test/snapshots/themesel.snap index 4c4d2baa..d54c328f 100644 --- a/test/snapshots/themesel.snap +++ b/test/snapshots/themesel.snap @@ -11,7 +11,7 @@ # and nothing to cancel: the row you ran is the theme you have. # # The whole ring is in the buffer, in sections: the fifteen native themes, -# acme, lapis and lapis_plain, the faithful ports a family at a time, the legacy helix and +# acme and lapis, the faithful ports a family at a time, the legacy helix and # dark, then everything exported from the vendored helix .toml and zed .json # files, sorted. The colors below are # read with snapstyle, so this proves the generated themes are real data and @@ -82,7 +82,7 @@ key tab stable 700 15000 snap step-clay snapstyle step-clay -# The three native contrast variants precede acme, lapis and lapis_plain, and then the first +# The three native contrast variants precede acme and lapis, and then the first # ported family's section. Its heading # and blank separator are not stops in the n/N command walk. key space j n @@ -113,11 +113,6 @@ snapstyle step-lapis key space j n key tab stable 700 15000 -snap step-lapis-plain -snapstyle step-lapis-plain -key space j n -key tab -stable 700 15000 snap step-dark-plus snapstyle step-dark-plus # across the Visual Studio Code section into Solarized: a section heading and |
