diff options
Diffstat (limited to 'dev/gui/gui.zig')
| -rw-r--r-- | dev/gui/gui.zig | 33 |
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); +} |
