diff options
Diffstat (limited to 'dev/gui')
| -rw-r--r-- | dev/gui/gui.zig | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 46895123..6db354db 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -5002,7 +5002,7 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g else => {}, } else false; if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, win_w, win_h); - try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], surface.heat.items, chrome, layout, surface.cols, surface.rows, win_w, win_h); + try paneDecor(g, gpa, regions, &surface.tag_layers[pardes.BAND_LAYER], surface.rail_ticks[0..surface.nrail_ticks], surface.heat.items, chrome, layout, surface.cols, surface.rows, win_w, win_h); try laneDecor(g, gpa, surface, layout, win_w, win_h); // A single spine runs down each column, through every tag and body. for (regions) |column| { @@ -5107,7 +5107,7 @@ fn laneStrip(g: *Gui, gpa: std.mem.Allocator, lane: pardes.Lane, row: i32, ride: /// Each pane's rule between its tag and body, and its scroll rail: a page /// 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, 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 { +fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, band: *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; for (regions) |rail| { if (rail.kind != .rail or rail.rect.h == 0) continue; @@ -5123,7 +5123,12 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti // top, over one below its body. const rule_x1 = if (win_w - x1 < layout.w) @max(x1, win_w) else x1; const tag_bottom = tag.rect.y > rail.rect.y; - const rule_y = @as(f32, @floatFromInt(if (tag_bottom) tag.rect.y else tag.rect.y + tag.rect.h)) * layout.h; + // A band drawn over the body (a terminal's, a kind's: Band.over) + // is the tag grown downward too: the rule under its last row (UX + // D5, E3). + const over = band.rows > 0 and band.kind == .band and band.id == rail.owner and !tag_bottom; + const tag_end = if (over) @max(tag.rect.y + tag.rect.h, band.viewport.y + band.rows) else tag.rect.y + tag.rect.h; + 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); // Stacked panes are ruled apart as columns are, where one pane's // body meets the next one's tag (acme's Border). @@ -8218,3 +8223,40 @@ test "a `│` in a tag layer runs its row's whole height at a tagline smaller th 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); } + +test "a band over a terminal's body has the tag rule under its last row, as a band under a text pane's tag has (UX E3)" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell + const gpa = std.testing.allocator; + const core = try pardes.Pardes.init(gpa, .{ .file = "mise.toml", .cols = 100, .rows = 30 }); + defer core.deinit(); + _ = pardes.exec.spawnTty(core, 0); + const shell = core.view().active; + core.panes[shell].?.body.mode = .normal; + try std.testing.expect(core.executeBuiltinLine(shell, "Theme acme")); + core.sync(); + while (core.nextEffect()) |_| {} + core.update(.{ .key = .{ .cp = ' ' } }); + core.update(.{ .key = .{ .cp = pardes.Key.down } }); + core.sync(); + const s = try core.render(core.scratch.allocator()); + const band = &s.tag_layers[pardes.BAND_LAYER]; + try std.testing.expect(band.kind == .band and band.rows > 0 and band.id == shell); + const tag = s.region(.tag, shell).?; + try std.testing.expect(band.viewport.y >= tag.rect.y + tag.rect.h); + var g = testGui(16, 32, 12, 24); + defer g.decor.deinit(gpa); + var groups: Groups = .{}; + try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1600, 960, true); + const under_band: f32 = @floatFromInt(@as(u32, band.viewport.y + band.rows) * 32); + const under_tag: f32 = @floatFromInt(@as(u32, tag.rect.y + tag.rect.h) * 32); + var found = false; + for (g.decor.items) |item| { + const rgb: [3]u8 = .{ @intFromFloat(@round(item.br * 255)), @intFromFloat(@round(item.bg * 255)), @intFromFloat(@round(item.bb * 255)) }; + const wide = (item.x1 - item.x0) / 2 * 1600 > 200 and (item.y0 - item.y1) / 2 * 960 < 4; + if (!std.mem.eql(u8, &rgb, &.{ 0x88, 0x88, 0xcc }) or !wide) continue; + const bottom = (1 - item.y1) / 2 * 960; + if (@abs(bottom - under_band) < 0.5) found = true; + try std.testing.expect(@abs(bottom - under_tag) >= 0.5); + } + try std.testing.expect(found); +} |
