diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 02:04:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 02:27:51 -0300 |
| commit | 54cd21e1bd487276142e3b1d62f1556f05b7f978 (patch) | |
| tree | bf5e33338a9b393764ed65829f90d2191117c4c9 /dev/gui | |
| parent | df964ae2f14d21a4799d52a07abfe3b2bef3c65e (diff) | |
| download | pardes-54cd21e1bd487276142e3b1d62f1556f05b7f978.tar.gz pardes-54cd21e1bd487276142e3b1d62f1556f05b7f978.zip | |
gui, tui, macos, surface, draw: the frontends' colours from the chrome (the themes programme's L2e; DESIGN.md R1, R6, R11, R15, G1'): the window's one null page and text are colors.null_page and null_text (gui.zig's own bg_default and fg_default, the same values written twice, deleted; the tty's trail ink the same constant where it wrote #cccccc again); SGR faint in a window is its ink toward its own ground to the dim floor, 3.5:1 (R15; a terminal's faint on the page's text is the page's dim ink already, L2d's), where it was the ink at 60 % toward black, darker and stronger on a light page; InactiveDim's fade is worked out, not searched: luminance runs straight in linear light, which `blendLinear` mixes in, so the most of the setting that keeps a pair at its own contrast or 4.5 is one division (`fadeToward`, a hair inside the floor for the bytes' rounding), where each frame bisected every distinct (ink, paper) pair eight times into a 32-slot cache made again each frame (A7); the grips (G1', R6): a reading pane's button is ringed in the chrome's mode ink (`grip.mode`: sky, else mint, violet, paper, rose; 3:1 on both tag grounds), two logical pixels as acme's ButtonBorder, outside a pixel of band so its fill never touches it (an unfocused dirty one's gap, now a reading one's too), a held pane's ring the resting `grip.ring` and a focused one's `grip.focus`, dirty `grip.dirty`; the glyph and the mode's bars on a filled button (focused or dirty) in `grip.ink` (held 4.5:1 on every fill), on the band in the tag's own ink: gui.zig's inkOn (black or white past a luminance of 140, not WCAG) deleted; the window's rules: spines, column and stacked-pane rules in `rule` (R11), the topbar's in `rule` unless gui_topbar_pane_border_rgb, the tag rule `tag_rule` (half the tag toward the page in OKLab; acme's own #8888cc) where it was the sRGB average of the tag and the page, `rule_px` and `rail_px` the chrome's; surface.Chrome gains `grip_mode` and `grip_ink`, `tag_rule` is always given (null meant "mix it yourself"), and draw.zig fills them from `p.chrome()`; macOS: the two exports nothing reads, pardes_tagline_bg (the tag's ground, misnamed) and pardes_tag_active_bg, deleted with their header lines and ABI guards; the Mac's sixteen for an index are core/colors.zig's `xterm`, the gui's, where they were Tango (a window is handed a program's sixteen as the theme's own colours now, L2d, so an index under 16 reaches it only from elsewhere: one colour an index in every window); RUN (TEST FIRST): gui.zig "every pixel of a grip column is band, button or ring" asks the button's pixels in the chrome's fills, rings, mode ring and grip ink (it allowed the grid's old box and boxDirty colours and inkOn), over four sizes, focused or not, dirty or not, the first pane reading (Jumps walk): fails on the base by compile (the surface had no mode ring or grip ink), passes now; "InactiveDim fades the unfocused panes' rows alone, never below the text's floor" passes with the fade worked out (#e6e6e6 on black faded toward it, at least 4.5:1); acme's #8888cc tag rule and its 2 px rules and 18 px track as before; PICTURES (the S kit, before = the installed build, after = this tree's Debug gui, 26 px, `Jumps walk`): .scratch/themes/L2cde/png/: the Changes view (dark, neonotte84, orchard, acme), a terminal with `ls --color` and the sixteen, bright, backgrounds, faint, 256 and greys (dark, neonotte84), the grip's four states (held or reading, focused or not; 16 and 26 px; dark, neonotte84), InactiveDim 35 (dark, neonotte84); derived once: every colour these surfaces read is Chrome.of's (colors.zig, at the theme's change: finishThemeInitialization, setThemeIndex, previewTheme, loadThemeFile), handed to the window in surface.Chrome by draw.zig a frame as before; the fades (faint, InactiveDim) are a cell's arithmetic, as the 60 % and the blend were, with no search or cache left; NOT DONE: PDF hits (the PDF addon is handed fg, bg, sel and link through pa_view, the addon ABI 3.3; the theme's hit wants a field there, an ABI 3.4 with a version check: abi/pardes_addon.h, abi/addon.zig, core/Kind.zig, addons/fake, beyond this line's files), so test/image_harness.zig's helix tints are unchanged and not re-pinned; a mark's ink on a button is still pushed 4.5:1 against the fill a frame (it wants a severity ink per grip fill in Chrome: L2a's marks); the grid's frame and empty columns (draw.zig's fills) and the tag grounds the window lays under a tag (tag_bg, tag_focus_bg, tag_reading_bg) stay the old views' until L2a moves the grid; GATES: gui unit-test 1948/1952 (4 skipped; w2base 1947/1951, +1 the dark terminal test of L2d; its one failure the known BaselineHarnessMismatch); macOS: runtime/macos.zig built for this host and its ABI guard run (`unit-test -Dplatform=macos`, "pardes.h declares every export the way it is defined"), the Swift not compiled (no Darwin here); the tui suites on L2c+L2d+L2e: core-test 1123/1296 (173 skipped), shell-test 1344/1347 (3 skipped), pane-test 184/185 (1 skipped), behaviour-test 280/280 and --replay 20 seeds of 70 steps, 0 failures, process-test 0 of 147 failed (3 skipped, no golden moved by L2e), term-test 17/17, kitty-test 45/45; the dump and digest unchanged (no fuzz or soak); load 0.9 to 12.8
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'dev/gui')
| -rw-r--r-- | dev/gui/gui.zig | 155 |
1 files changed, 74 insertions, 81 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index a478db03..f572a7ce 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -45,8 +45,10 @@ const log = std.log.scoped(.gui); const font_ttf = @embedFile("AdwaitaMono-Regular.ttf"); -const bg_default = [3]u8{ 18, 18, 18 }; -const fg_default = [3]u8{ 204, 204, 204 }; +/// The page and text a window draws for a theme that leaves them to the +/// host (`dark`): the chrome's one null page (DESIGN.md R1). +const null_page = pardes.colors.null_page; +const null_text = pardes.colors.null_text; const p9_arrow_clr = [32]u8{ 0xFF, 0xFF, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0C, @@ -4017,7 +4019,7 @@ fn renderFrame( coverFrame(covered, surface.cols, surface.rows, surface.bodyLayers(), surface.tagLayers(), surface.regionList()); try buildDecor(g, gpa, surface, &groups, layout, win_w, win_h, cursors_shown); - const page = chrome.page orelse bg_default; + const page = chrome.page orelse null_page; const background_opacity = backgroundOpacity(g.applied_window_opacity); const clear: c.SDL_FColor = .{ .r = @as(f32, @floatFromInt(page[0])) / 255.0 * background_opacity, @@ -4163,13 +4165,13 @@ const taglineBandOffset = pardes.Layer.taglineBandOffset; /// in `line`, block or bar: shaping breaks around it. fn resolveCell(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, role: pardes.FontRole, is_cursor: bool, page: [3]u8) ResolvedCell { const cell = &line[at]; - var fg = fg_default; + var fg = null_text; var bg = page; var reverse = is_cursor; if (!cell.default) { const st = cell.style; fg = switch (st.fg) { - .default => fg_default, + .default => null_text, .index => |i| pardes.colors.xterm[i], .rgb => |rgb| rgb, }; @@ -4185,9 +4187,9 @@ fn resolveCell(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, ro // full opacity would expose text that the terminal concealed, so // cellSlot draws a concealed cell blank. } - if (st.dim) for (&fg) |*ch| { - ch.* = @intCast(@as(u16, ch.*) * 6 / 10); - }; + // SGR faint: the ink toward its ground to the dim floor (DESIGN.md + // R15), so fainter on a light page too, never darkened to black. + if (st.dim) fg = fadeToward(fg, bg, 1, @min(pardes.colors.contrast(fg, bg), pardes.colors.Chrome.dim_floor)); } if (reverse) std.mem.swap([3]u8, &fg, &bg); @@ -4345,13 +4347,14 @@ fn gripButton(g: *const Gui, chrome: *const pardes.Chrome, col: u16, row: u16, l fn gripFill(chrome: *const pardes.Chrome, focus: bool, dirty: bool, reading: bool) [3]u8 { if (dirty) return chrome.grip_dirty; if (focus) return chrome.grip_focus_ring; - // The ring's inside is the tag's ground: a reading pane's tint. + // The ring's inside is the tag's ground. return if (reading) chrome.tag_reading_bg else chrome.tag_bg; } -fn inkOn(bg: [3]u8) [3]u8 { - const lum = (@as(u16, bg[0]) * 3 + @as(u16, bg[1]) * 6 + @as(u16, bg[2])) / 10; - return if (lum > 140) .{ 0x00, 0x00, 0x00 } else .{ 0xff, 0xff, 0xff }; +/// The ink on a pane's button (DESIGN.md R6): the chrome's grip ink on a +/// fill, the tag's own on its ground. +fn gripInk(chrome: *const pardes.Chrome, focus: bool, dirty: bool) [3]u8 { + return if (focus or dirty) chrome.grip_ink else chrome.tag_fg; } /// Cuts an instance's quad to a pixel rectangle (left, top, right, bottom), @@ -4463,8 +4466,8 @@ fn emitSurfaceCell( // or dirty (UX D4). const ink = if (mark) switch (glyph.style.fg) { .rgb => |rgb| pardes.colors.pushAway(rgb, &.{fill}, pardes.colors.Roles.ink_floor), - else => inkOn(fill), - } else if (here.pane_grip) inkOn(fill) else resolved.fg; + else => gripInk(chrome, here.focus, here.dirty), + } else if (here.pane_grip) gripInk(chrome, here.focus, here.dirty) else resolved.fg; instances[next.*].fr = @as(f32, @floatFromInt(ink[0])) / 255; instances[next.*].fg = @as(f32, @floatFromInt(ink[1])) / 255; instances[next.*].fb = @as(f32, @floatFromInt(ink[2])) / 255; @@ -5141,7 +5144,7 @@ fn laneStrip(g: *Gui, gpa: std.mem.Allocator, lane: pardes.Lane, row: i32, ride: /// coloured gutter with a thin track and its thumb, running down through the /// pixels past the last whole row. fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, tags: []const pardes.Layer, ticks: []const pardes.RailTick, heat: []const pardes.RailHeat, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void { - const page = chrome.page orelse bg_default; + const page = chrome.page orelse null_page; for (regions) |rail| { if (rail.kind != .rail or rail.rect.h == 0) continue; const tag = for (regions) |region| { @@ -5165,7 +5168,7 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ta if (!tag_bottom and head.rows > 0) tag_end = @max(tag_end, head.viewport.y + head.rows); if (!tag_bottom and band.rows > 0 and band.kind == .band and band.id == rail.owner) tag_end = @max(tag_end, band.viewport.y + band.rows); const rule_y = @as(f32, @floatFromInt(if (tag_bottom) tag.rect.y else tag_end)) * layout.h; - try addDecor(g, gpa, x0, if (tag_bottom) rule_y else rule_y - dp(1), rule_x1, if (tag_bottom) rule_y + dp(1) else rule_y, chrome.tag_rule orelse mixRgb(chrome.tag_bg, page), 1, win_w, win_h); + try addDecor(g, gpa, x0, if (tag_bottom) rule_y else rule_y - dp(1), rule_x1, if (tag_bottom) rule_y + dp(1) else rule_y, chrome.tag_rule, 1, win_w, win_h); // Stacked panes are ruled apart as columns are, where one pane's // body meets the next one's tag (acme's Border). { @@ -5238,9 +5241,6 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ta } } -/// Halfway between two colours. -const mixRgb = pardes.colors.mix; - /// A rule's width: the theme's own, or one pixel. fn rulePx(chrome: *const pardes.Chrome) f32 { return dp(@floatFromInt(@max(1, chrome.rule_px))); @@ -5270,17 +5270,15 @@ fn updateDisplayScale(window: *c.SDL_Window) void { /// InactiveDim: the unfocused panes' text faded toward its ground by the /// setting's percent, never below the pair's own contrast or 4.5, whichever -/// is lower. The window's alone, from the regions' focus: renderFrame -/// begins it each frame. ponytail: one window per process, as display_scale. +/// is lower (`fadeToward`: worked out, no search, so nothing is kept). The +/// window's alone, from the regions' focus: renderFrame begins it each +/// frame. ponytail: one window per process, as display_scale. var dim: Dim = .{}; const Dim = struct { amount: f32 = 0, /// The pane with the keyboard, from its regions. focused: u16 = pardes.Region.none, - /// The few ink and paper pairs a frame has, each faded once. - keys: [32]?[6]u8 = @splat(null), - values: [32][3]u8 = undefined, fn begin(d: *Dim, percent: u8, regions: []const pardes.Region) void { d.* = .{ .amount = @as(f32, @floatFromInt(@min(percent, 100))) / 100 }; @@ -5297,35 +5295,15 @@ const Dim = struct { } /// A cell instance's ink faded toward its ground. - fn fade(d: *Dim, instance: *CellInstance) void { - const ink = d.faded(byteRgb(.{ instance.fr, instance.fg, instance.fb }), byteRgb(.{ instance.br, instance.bg, instance.bb })); + fn fade(d: *const Dim, instance: *CellInstance) void { + const from = byteRgb(.{ instance.fr, instance.fg, instance.fb }); + const paper = byteRgb(.{ instance.br, instance.bg, instance.bb }); + const ink = fadeToward(from, paper, d.amount, @min(pardes.colors.contrast(from, paper), 4.5)); instance.fr = @as(f32, @floatFromInt(ink[0])) / 255.0; instance.fg = @as(f32, @floatFromInt(ink[1])) / 255.0; instance.fb = @as(f32, @floatFromInt(ink[2])) / 255.0; } - fn faded(d: *Dim, ink: [3]u8, paper: [3]u8) [3]u8 { - const key = ink ++ paper; - const slot = (@as(usize, ink[0]) *% 31 +% @as(usize, ink[1]) *% 7 +% ink[2] +% @as(usize, paper[0]) *% 13 +% @as(usize, paper[1]) *% 3 +% paper[2]) % d.keys.len; - if (d.keys[slot]) |held| if (std.mem.eql(u8, &held, &key)) return d.values[slot]; - // Contrast falls as the ink nears its paper: the most of `amount` - // that keeps the pair at its own contrast or 4.5, whichever is lower. - const floor = @min(pardes.colors.contrast(ink, paper), 4.5); - var t = d.amount; - if (pardes.colors.contrast(blendLinear(ink, paper, t), paper) < floor) { - var lo: f32 = 0; - var hi: f32 = t; - for (0..8) |_| { - const mid = (lo + hi) / 2; - if (pardes.colors.contrast(blendLinear(ink, paper, mid), paper) >= floor) lo = mid else hi = mid; - } - t = lo; - } - d.keys[slot] = key; - d.values[slot] = blendLinear(ink, paper, t); - return d.values[slot]; - } - fn byteRgb(rgb: [3]f32) [3]u8 { var out: [3]u8 = undefined; for (&out, rgb) |*o, v| o.* = @intFromFloat(@round(std.math.clamp(v, 0, 1) * 255)); @@ -5333,6 +5311,19 @@ const Dim = struct { } }; +/// `ink` toward `paper` in linear light, `most` of the way at most and +/// never under `floor`:1 on it. Luminance runs straight in linear light, so +/// the most that keeps the floor is worked out, never searched (a hair +/// inside it, for the bytes' rounding). +fn fadeToward(ink: [3]u8, paper: [3]u8, most: f32, floor: f32) [3]u8 { + const yi = pardes.colors.relativeLuminance(ink); + const yp = pardes.colors.relativeLuminance(paper); + if (@abs(yi - yp) < 1e-6) return ink; + const f = floor * 1.02; + const stop = if (yi > yp) f * (yp + 0.05) - 0.05 else (yp + 0.05) / f - 0.05; + return blendLinear(ink, paper, std.math.clamp((yi - stop) / (yi - yp), 0, most)); +} + /// `t` of the way from one colour to the other in linear light, so a /// coloured ink does not muddy on its way to the paper. fn blendLinear(from: [3]u8, to: [3]u8, t: f32) [3]u8 { @@ -5378,10 +5369,12 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce 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 - // pixel of band inside its ring, so the four states differ in shape - // whatever a theme's colours (a focused dirty one is acme's - // modbutton, filled up to its ring). + // the focused one's in its own fill, a reading pane's in the mode's + // ink (DESIGN.md G1'). An unfocused dirty one and a reading one keep + // a pixel of band inside the ring, so the fill never touches the + // mode's ring and the four states differ in shape whatever a theme's + // colours (a focused dirty held one is acme's modbutton, filled up to + // its ring). { // The rules drawn over the row (paneDecor, after this) cut into // it: the ring runs inside them, from rule to rule. @@ -5401,14 +5394,14 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce const x1 = button[2]; const y0 = button[1] + top_rule; const y1 = button[3] - bottom_rule; - const ring = if (grip.active) chrome.grip_focus_ring else chrome.grip_border; + const ring = if (grip.reading) chrome.grip_mode else if (grip.active) chrome.grip_focus_ring else chrome.grip_border; // acme's ButtonBorder: two logical pixels. const b = dp(2); try addDecor(g, gpa, x0, y0, x1, y0 + b, ring, 1, win_w, win_h); try addDecor(g, gpa, x0, y1 - b, x1, y1, ring, 1, win_w, win_h); try addDecor(g, gpa, x0, y0 + b, x0 + b, y1 - b, ring, 1, win_w, win_h); try addDecor(g, gpa, x1 - b, y0 + b, x1, y1 - b, ring, 1, win_w, win_h); - if (grip.dirty and !grip.active) { + if (grip.reading or (grip.dirty and !grip.active)) { const gap = b + dp(1); try addDecor(g, gpa, x0 + b, y0 + b, x1 - b, y0 + gap, band, 1, win_w, win_h); try addDecor(g, gpa, x0 + b, y1 - gap, x1 - b, y1 - b, band, 1, win_w, win_h); @@ -5424,7 +5417,7 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce if (x >= cols) continue; const cell = &cells[@as(usize, y) * cols + x]; if (cell.default or cell.printableAscii() != ' ' or boxMark(cells[@as(usize, y) * cols ..][0..cols], x)) continue; - const rgb = inkOn(gripFill(chrome, grip.active, grip.dirty, grip.reading)); + const rgb = gripInk(chrome, grip.active, grip.dirty); const center_x = @floor((button[0] + button[2]) / 2); const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, win_h, g.cell_h, g.tagline_height))) + @as(f32, @floatFromInt(g.tagline_height)) / 2; const half_w = @max(dp(1), @min(dp(3), @floor((button[2] - button[0] - 2 * dp(3)) / 2))); @@ -5757,7 +5750,7 @@ fn appendJumpTrail(g: *Gui, on: bool, surface: *const pardes.Surface, now_ns: u6 if (region.kind == .body and cursor.x >= region.rect.x and cursor.x < @as(u32, region.rect.x) + region.rect.w and cursor.y >= region.rect.y and cursor.y < @as(u32, region.rect.y) + region.rect.h) break region.rect; } else return; - const page = surface.chrome.page orelse bg_default; + const page = surface.chrome.page orelse null_page; const w: f32 = @floatFromInt(g.cell_w); const h: f32 = @floatFromInt(g.cell_h); for (lit) |cell| { @@ -5769,7 +5762,7 @@ fn appendJumpTrail(g: *Gui, on: bool, surface: *const pardes.Surface, now_ns: u6 else => page, }; if (!std.mem.eql(u8, &ground, &page)) continue; - var color = overlayRgb(surface.chrome.fg orelse fg_default); + var color = overlayRgb(surface.chrome.fg orelse null_text); color.a = cell.strength; const x0 = @as(f32, @floatFromInt(cell.x)) * w; const y0 = @as(f32, @floatFromInt(cell.y)) * h; @@ -5855,7 +5848,7 @@ fn appendCursorGlide(g: *Gui, surface: *const pardes.Surface, now_ns: u64, build } // Its colour: the cursor the cells would draw nearest the quad. var boxes: [max_cursors]CursorBox = undefined; - var rgb: [3]u8 = chrome.fg orelse fg_default; + var rgb: [3]u8 = chrome.fg orelse null_text; var nearest: f32 = std.math.inf(f32); for (boxes[0..cursorBoxes(g, surface, layout, builder.win_h, &boxes)]) |box| { const dx = (box.x0 + box.x1) / 2 - centre[0]; @@ -6030,7 +6023,7 @@ fn cursorColor(chrome: *const pardes.Chrome, cell: *const pardes.Cell, role: par return if (role == .tagline) switch (cell.style.fg) { .rgb => |rgb| rgb, else => chrome.tag_fg, - } else chrome.fg orelse fg_default; + } else chrome.fg orelse null_text; } test "FreeType and HarfBuzz allocate from the gui allocator and give it all back" { @@ -7170,7 +7163,7 @@ test "a touchpad's fraction over a body whose context rows went (scrolled out of for (&s.body_layers) |*layer| layer.cells = blank[0..layer.cells.len]; @memset(wr.g.scroll_edge, .{}); const held = if (s.facts.pane(id)) |shown| shown.context_rows else 0; - const n = emitScrollRows(&wr.g, instances.ptr, 0, &s, fixedCellLayout(&wr.g), 800, 480, bg_default, held); + const n = emitScrollRows(&wr.g, instances.ptr, 0, &s, fixedCellLayout(&wr.g), 800, 480, null_page, held); // The body's moving rows under the held ones, the layer's // rows past the grid's while there is a layer, and the row // that left. @@ -7197,24 +7190,24 @@ test "a scroll's body taller than its body layer (the pane shrunk under a glide) g.scroll_body_h = 19; var instances: [3 * 40 * 20]CellInstance = undefined; const layout = fixedCellLayout(&g); - try std.testing.expectEqual(@as(u32, 0), emitScrollRows(&g, &instances, 0, &surface, layout, 400, 400, bg_default, 2)); + try std.testing.expectEqual(@as(u32, 0), emitScrollRows(&g, &instances, 0, &surface, layout, 400, 400, null_page, 2)); // As tall as the body, its cells short of its rows: the same. surface.body_layers[0].rows = 21; - try std.testing.expectEqual(@as(u32, 0), emitScrollRows(&g, &instances, 0, &surface, layout, 400, 400, bg_default, 2)); + try std.testing.expectEqual(@as(u32, 0), emitScrollRows(&g, &instances, 0, &surface, layout, 400, 400, null_page, 2)); // Its cells all there: the body's moving rows under the two held, and // the layer's two past the grid's. var whole: [38 * 21]pardes.Cell = @splat(.{}); surface.body_layers[0].cells = &whole; - try std.testing.expectEqual(@as(u32, (19 - 2 + 2) * 38), emitScrollRows(&g, &instances, 0, &surface, layout, 400, 400, bg_default, 2)); + try std.testing.expectEqual(@as(u32, (19 - 2 + 2) * 38), emitScrollRows(&g, &instances, 0, &surface, layout, 400, 400, null_page, 2)); } test "concealed terminal text emits no ink on its ground" { var g = testGui(10, 20, 6, 12); var cell: pardes.Cell = .{ .default = false, .style = .{ .invisible = true, .ul = .single } }; cell.text[0] = 'X'; - const resolved = resolveCell(&g, (&cell)[0..1], 0, null, .body, false, bg_default); + const resolved = resolveCell(&g, (&cell)[0..1], 0, null, .body, false, null_page); try std.testing.expectEqualDeep(g.atlas.space_slot, resolved.slot); - try std.testing.expectEqual(bg_default, resolved.bg); + try std.testing.expectEqual(null_page, resolved.bg); } test "a block cursor's cell is drawn reversed: the cell's ink its ground, its ground its ink" { @@ -7226,8 +7219,8 @@ test "a block cursor's cell is drawn reversed: the cell's ink its ground, its gr .default = false, .style = .{ .fg = .{ .rgb = .{ 10, 20, 30 } }, .bg = .{ .rgb = .{ 200, 210, 220 } } }, }; - const plain = resolveCell(&g, (&cell)[0..1], 0, null, .body, false, bg_default); - const cursor = resolveCell(&g, (&cell)[0..1], 0, 0, .body, true, bg_default); + const plain = resolveCell(&g, (&cell)[0..1], 0, null, .body, false, null_page); + const cursor = resolveCell(&g, (&cell)[0..1], 0, 0, .body, true, null_page); try std.testing.expectEqual([3]u8{ 10, 20, 30 }, plain.fg); try std.testing.expectEqual(plain.fg, cursor.bg); try std.testing.expectEqual(plain.bg, cursor.fg); @@ -7354,7 +7347,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits const row: u16 = grip.rect.y + @as(u16, @intCast(line)); const at = @as(usize, row) * s.cols; var next: u32 = 0; - emitSurfaceCell(&g, &s.chrome, &instances, &next, col, row, layout, win_w, win_h, s.cells[at..][0..s.cols], cover[at..][0..s.cols], col, null, false, bg_default); + emitSurfaceCell(&g, &s.chrome, &instances, &next, col, row, layout, win_w, win_h, s.cells[at..][0..s.cols], cover[at..][0..s.cols], col, null, false, null_page); for (instances[0..next]) |i| paint.quad(pixels, i.x0, i.y0, i.x1, i.y1, .{ i.br, i.bg, i.bb }, win_w, win_h, x_px, y_px, w_px, h_px); }; for (g.decor.items) |i| if (i.fr >= 1 and i.clip_x1 < i.clip_x0) paint.quad(pixels, i.x0, i.y0, i.x1, i.y1, .{ i.br, i.bg, i.bb }, win_w, win_h, x_px, y_px, w_px, h_px); @@ -7370,8 +7363,8 @@ test "every pixel of a grip column is band, button or ring, and the button sits const band = if (pardes.Trail.reading(core, core.panes[0].?)) chrome.tag_reading_bg else if (focus == 0) chrome.tag_focus_bg else chrome.tag_bg; // Band, fills, rings, the rules between stacked panes and under the // tag, and the mode marks' ink (the grip's first cell's). - const ink = inkOn(gripFill(chrome, grip.active, grip.dirty, grip.reading)); - const allowed = [_][3]f32{ rgb(band), rgb(core.chromeTheme().box), rgb(pardes.draw.boxDirty(core)), rgb(chrome.grip_border), rgb(chrome.grip_focus_ring), rgb(chrome.border), rgb(ink), rgb(chrome.tag_rule orelse mixRgb(chrome.tag_bg, chrome.page orelse bg_default)) }; + const ink = gripInk(chrome, grip.active, grip.dirty); + const allowed = [_][3]f32{ rgb(band), rgb(chrome.grip_focus_ring), rgb(chrome.grip_dirty), rgb(chrome.grip_border), rgb(chrome.grip_mode), rgb(chrome.border), rgb(ink), rgb(chrome.tag_rule) }; for (pixels, 0..) |pixel, n| { const got = pixel orelse return error.TestUnpaintedGripPixel; const known = for (allowed) |a| { @@ -7385,7 +7378,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits } // The rule under the tag runs unbroken across the grip column. for (pixels[(h_px - 1) * w_px ..][0..w_px]) |pixel| - try std.testing.expectEqual(rgb(chrome.tag_rule orelse mixRgb(chrome.tag_bg, chrome.page orelse bg_default)), pixel.?); + try std.testing.expectEqual(rgb(chrome.tag_rule), pixel.?); // The button's edges are the scrollbar's. const button = gripButton(&g, chrome, grip.rect.x, grip.rect.y, layout); const column = scrollColumn(&g, chrome, s.region(.rail, 0).?.rect.x, layout); @@ -7403,7 +7396,7 @@ test "small tagline fonts leave no background gutters between adjacent tags" { var next: u32 = 0; for (0..3) |row| { // Column 1: past the anchor's inset edge at the column's left. - emitSurfaceCell(&g, &chrome, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{}}, 0, null, false, bg_default); + emitSurfaceCell(&g, &chrome, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{}}, 0, null, false, null_page); const base = instances[row * 2]; const ink = instances[row * 2 + 1]; try std.testing.expectApproxEqAbs(@as(f32, 20.0 / 480.0 * 2), base.y0 - base.y1, 0.0001); @@ -7416,7 +7409,7 @@ test "small tagline fonts leave no background gutters between adjacent tags" { // Column 0 is an anchor's edge: its ink is inset by the band's margin // (2 px here) and its underlay still covers the whole cell. next = 0; - emitSurfaceCell(&g, &chrome, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{ .anchor = true }}, 0, null, false, bg_default); + emitSurfaceCell(&g, &chrome, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{ .anchor = true }}, 0, null, false, null_page); try std.testing.expectApproxEqAbs(@as(f32, 10.0 / 800.0 * 2), instances[0].x1 - instances[0].x0, 0.0001); try std.testing.expectApproxEqAbs(@as(f32, 8.0 / 800.0 * 2), instances[1].x1 - instances[1].x0, 0.0001); try std.testing.expectApproxEqAbs(@as(f32, 8) / atlas_w, instances[1].u1 - instances[1].u0, 0.0001); @@ -7427,7 +7420,7 @@ test "block cursor alone overrides transparent cell background" { const cell: pardes.Cell = .{}; var instances: [2]CellInstance = undefined; for ([_]bool{ false, true }, 0..) |cursor, i| { - emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, .body, (&cell)[0..1], 0, null, cursor, bg_default); + emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, .body, (&cell)[0..1], 0, null, cursor, null_page); try std.testing.expectEqual(cursor, instances[i].effect & opaque_bg_bit != 0); } } @@ -7596,7 +7589,7 @@ test "pane indicator halves are safe on an exhausted atlas" { var instances: [4]CellInstance = undefined; var next: u32 = 0; for (0..2) |col| { - emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, cells[0..6], cover[0..6], col, null, false, bg_default); + emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, cells[0..6], cover[0..6], col, null, false, null_page); try std.testing.expectEqual(@as(f32, 0), instances[col * 2 + 1].u0); } try std.testing.expectEqual(@as(u32, 4), next); @@ -8037,7 +8030,7 @@ test "compact body layer rendering fills recovered rows and clips the final glyp layer.setContextLines(&.{ 0, 4, 5, 6 }); var instances: [32]CellInstance = undefined; var next: u32 = 0; - emitBodyLayer(&g, &instances, &next, &layer, 200, 200, bg_default, false, .{ 80, 90, 100 }); + emitBodyLayer(&g, &instances, &next, &layer, 200, 200, null_page, false, .{ 80, 90, 100 }); // Four compact header rows (48px), then three body rows: two complete // and a third clipped to the remaining12px of the100px viewport. try std.testing.expectEqual(@as(u32, 20), next); @@ -8052,7 +8045,7 @@ test "compact body layer rendering fills recovered rows and clips the final glyp // A drag preview reserves the last physical column without changing cells. layer.viewport.w = 1; next = 0; - emitBodyLayer(&g, &instances, &next, &layer, 200, 200, bg_default, false, .{ 80, 90, 100 }); + emitBodyLayer(&g, &instances, &next, &layer, 200, 200, null_page, false, .{ 80, 90, 100 }); for (instances[0..next]) |instance| try std.testing.expect(instance.x1 <= -0.6 + 0.0001); } @@ -8062,14 +8055,14 @@ test "compact tag layers fill available width and clip at their physical edge" { const layer: pardes.Layer = .{ .kind = .pane, .id = 0, .serial = 7, .viewport = .{ .x = 2, .y = 3, .w = 3, .h = 1 }, .cols = 6, .rows = 1, .cells = &cells, .bg = .{ 20, 30, 40 } }; var instances: [8]CellInstance = undefined; var next: u32 = 0; - emitTagLayer(&g, &instances, &next, &layer, 100, 100, bg_default, false); + emitTagLayer(&g, &instances, &next, &layer, 100, 100, null_page, false); // Five six-pixel cells fit in the three body-column viewport. try std.testing.expectEqual(@as(u32, 6), next); try std.testing.expectApproxEqAbs(@as(f32, -0.6), instances[1].x0, 0.0001); try std.testing.expectApproxEqAbs(@as(f32, 0), instances[5].x1, 0.0001); g.tagline_width = 8; next = 0; - emitTagLayer(&g, &instances, &next, &layer, 100, 100, bg_default, false); + emitTagLayer(&g, &instances, &next, &layer, 100, 100, null_page, false); try std.testing.expectEqual(@as(u32, 5), next); try std.testing.expectApproxEqAbs(@as(f32, 0), instances[4].x1, 0.0001); try std.testing.expectApproxEqAbs(@as(f32, 6) / atlas_w, instances[4].u1 - instances[4].u0, 0.0001); @@ -8334,7 +8327,7 @@ test "a `│` in a tag layer runs its row's whole height at a tagline smaller th var instances: [8]CellInstance = undefined; var next: u32 = 0; const win_h: f32 = 200; - emitTagLayer(&g, &instances, &next, &layer, 200, win_h, bg_default, false); + emitTagLayer(&g, &instances, &next, &layer, 200, win_h, null_page, false); try std.testing.expectEqual(@as(u32, 3), next); const bh: f32 = @floatFromInt(g.cell_h); // [0] the row's ground, [1] `a` at the tagline's height, [2] `│` the @@ -8402,7 +8395,7 @@ test "a pane's mark is its button's glyph where the mode draws none, in its kind defer g.decor.deinit(gpa); var instances: [4]CellInstance = undefined; var next: u32 = 0; - for (0..2) |col| emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, cells[0..6], cover[0..6], col, null, false, bg_default); + for (0..2) |col| emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, cells[0..6], cover[0..6], col, null, false, null_page); try std.testing.expectEqual(@as(u32, 4), next); // Each of the box's two cells draws its slice of the mark's glyph, in // the err ink pushed off the focused button's fill. |
