summaryrefslogtreecommitdiff
path: root/dev/gui/gui.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 11:01:54 -0300
committerGabriel Schneider <[email protected]>2026-11-25 11:01:54 -0300
commit47518368121ab7edadc13d4746bd617edd144dd6 (patch)
treee0b47eb6503dd750b68241bf6109beab98eaa600 /dev/gui/gui.zig
parent1479c4ef253a0a05b1a64e368334ce07f9922244 (diff)
downloadpardes-47518368121ab7edadc13d4746bd617edd144dd6.tar.gz
pardes-47518368121ab7edadc13d4746bd617edd144dd6.zip
gui: a `│` in a tag layer (the walk UI's spines, the rules between a band's steps) runs its row's whole height, so the lines meet from row to row at a tagline smaller than the row (UX D5 as E3 amends it, DESIGN.md E5.9: "gapped spines at 16 px", P1 05/08; P1's not-done "gap-free window spines at tag 80 %"); TEST FIRST: gui.zig "a `│` in a tag layer runs its row's whole height at a tagline smaller than the row: the spines and the rules between steps meet from row to row (UX D5)" (the embedded face at 16 px, its tagline at 82 %: on the base the `│`'s quad was the tagline's height, `actual 0.56, not within 0.0001 of expected 0.58` for the quad's top); THE CHANGE: emitTagLayer stretches a U+2502 cell's quad to its grid row (y from the row's top to its bottom), where emitInstance placed it at the tagline's height and band offset; the glyph (Atlas's ruleArms, drawn by hand) is a line from its slot's top to its bottom, so stretched it is the same line, the row's height; only `│` (no other box-drawing glyph is drawn in a tag), in every tag layer (a pane's tag, whose head's continuation rows carry the spines, and the band); the terminal draws a row's cell whole and needed nothing; gui unit-test filtered: 14/14 (the step's one failure the known perf BaselineHarnessMismatch); the whole gui unit-test on the stack's tip (E5.11)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'dev/gui/gui.zig')
-rw-r--r--dev/gui/gui.zig33
1 files changed, 33 insertions, 0 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index 9f6e4876..46895123 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -4222,6 +4222,15 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
for (0..tagLayerCellCount(g, layer)) |col| {
const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == index else false;
emitInstance(g, instances, next.*, @intCast(col), y, .{ .w = tw, .h = bh, .x_off = left, .y_off = 0 }, win_w, win_h, .tagline, cells, col, line_cursor, cursor, page);
+ // A `│` (the walk UI's spines and the rules between its steps,
+ // UX D5) runs its row's whole height: a tagline glyph is shorter
+ // than the row, and the rule drawn at its height left a gap
+ // between every two rows. Its glyph is a line top to bottom:
+ // stretched, it stays one.
+ if (cellCodepoint(&cells[col]) == 0x2502) {
+ instances[next.*].y0 = 1.0 - (@as(f32, @floatFromInt(y)) * bh / win_h) * 2.0;
+ instances[next.*].y1 = 1.0 - ((@as(f32, @floatFromInt(y)) + 1) * bh / win_h) * 2.0;
+ }
clipInstance(&instances[next.*], .{ -1e9, -1e9, right, 1e9 }, win_w, win_h);
if (faded and !cursor) dim.fade(&instances[next.*]);
next.* += 1;
@@ -8185,3 +8194,27 @@ test "the atlas's bytes: a fixed key list at 27 px and at 54 px (2x) rasterizes
if (!std.meta.eql(want, got)) std.debug.print("atlas hashes: .{{ .{{ 0x{x}, 0x{x} }}, .{{ 0x{x}, 0x{x} }} }}\n", .{ got[0][0], got[0][1], got[1][0], got[1][1] });
try std.testing.expectEqual(want, got);
}
+
+test "a `│` in a tag layer runs its row's whole height at a tagline smaller than the row: the spines and the rules between steps meet from row to row (UX D5)" {
+ var g = try textTestGui(font_ttf, 16);
+ defer font_allocator = std.heap.smp_allocator;
+ defer g.atlas.deinit(std.testing.allocator);
+ defer g.words.deinit(std.testing.allocator);
+ try std.testing.expect(g.tagline_height < g.cell_h);
+ var cells: [2]pardes.Cell = @splat(.{ .default = false });
+ cells[0].text[0] = 'a';
+ @memcpy(cells[1].text[0.."│".len], "│");
+ cells[1].len = "│".len;
+ const layer: pardes.Layer = .{ .kind = .band, .id = 0, .serial = 7, .viewport = .{ .x = 0, .y = 2, .w = 2, .h = 1 }, .cols = 2, .rows = 1, .cells = &cells, .bg = .{ 20, 30, 40 } };
+ 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);
+ 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
+ // row's own: rows 2 to 3.
+ try std.testing.expectApproxEqAbs(1.0 - 2 * bh / win_h * 2, instances[2].y0, 0.0001);
+ try std.testing.expectApproxEqAbs(1.0 - 3 * bh / win_h * 2, instances[2].y1, 0.0001);
+ try std.testing.expect(instances[1].y0 - instances[1].y1 < instances[2].y0 - instances[2].y1);
+}