diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/gui/gui.zig | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index ccf9387b..b0d5d3ec 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -679,7 +679,7 @@ const Cover = packed struct(u16) { /// glyph is the cell that far to the left. grip: bool = false, grip_offset: u4 = 0, - /// In the focused pane's or column's tag rows. + /// In the focused pane's tag rows. focus: bool = false, /// At a column's left edge, where a tag's anchor is inset. anchor: bool = false, @@ -691,10 +691,7 @@ const Cover = packed struct(u16) { grip_top: bool = false, /// In an unfocused pane's tag or body rows while InactiveDim fades them. dim: bool = false, - /// In a reading pane's grip or tag rows (Region.reading): their - /// underlay is the reading tint. - reading: bool = false, - _: u2 = 0, + _: u3 = 0, }; /// Marks the grid cells a body or tag layer covers, which the layers paint @@ -720,11 +717,6 @@ fn coverFrame(cover: []Cover, cols: u16, rows: u16, body_layers: []const pardes. for (tag_layers) |*layer| { if (layer.rows != 0) mark.rect(cover, cols, rows, .{ .x = layer.viewport.x, .y = layer.viewport.y, .w = layer.viewport.w, .h = layer.rows }, "layer", true); } - // The column bar's rows, which the focused column's tint spans. - var bar: ?pardes.Rect = null; - for (regions) |region| { - if (region.kind == .column_grip) bar = region.rect; - } // InactiveDim: an unfocused pane's tag and body rows (Dim.begin). if (dim.amount > 0) for (regions) |region| { if ((region.kind == .tag or region.kind == .body) and dim.of(region.owner)) mark.rect(cover, cols, rows, region.rect, "dim", true); @@ -735,18 +727,13 @@ fn coverFrame(cover: []Cover, cols: u16, rows: u16, body_layers: []const pardes. for (0..@min(region.rect.w, 16)) |offset| mark.rect(cover, cols, rows, .{ .x = region.rect.x +| @as(u16, @intCast(offset)), .y = region.rect.y, .w = 1, .h = region.rect.h }, "grip_offset", @as(u4, @intCast(offset))); if (region.kind == .grip and region.active) mark.rect(cover, cols, rows, region.rect, "focus", true); if (region.dirty) mark.rect(cover, cols, rows, region.rect, "dirty", true); - if (region.reading) mark.rect(cover, cols, rows, region.rect, "reading", true); if (region.kind == .grip) mark.rect(cover, cols, rows, region.rect, "pane_grip", true); mark.rect(cover, cols, rows, .{ .x = region.rect.x, .y = region.rect.y, .w = region.rect.w, .h = @min(1, region.rect.h) }, "grip_top", true); }, .tag => { if (region.active) mark.rect(cover, cols, rows, region.rect, "focus", true); - if (region.reading) mark.rect(cover, cols, rows, region.rect, "reading", true); - }, - .column => { - mark.rect(cover, cols, rows, .{ .x = region.rect.x, .y = 0, .w = 1, .h = rows }, "anchor", true); - if (region.active) if (bar) |b| mark.rect(cover, cols, rows, .{ .x = region.rect.x, .y = b.y, .w = region.rect.w, .h = b.h }, "focus", true); }, + .column => mark.rect(cover, cols, rows, .{ .x = region.rect.x, .y = 0, .w = 1, .h = rows }, "anchor", true), .debug => mark.rect(cover, cols, rows, region.rect, "floating", true), else => {}, }; @@ -4352,11 +4339,11 @@ fn gripButton(g: *const Gui, chrome: *const pardes.Chrome, col: u16, row: u16, l /// A pane's button fill, from its region's state, not the grid's cells /// (which are drawn for cell shells): dirty, focused, or the tag's ground. -fn gripFill(chrome: *const pardes.Chrome, focus: bool, dirty: bool, reading: bool) [3]u8 { +fn gripFill(chrome: *const pardes.Chrome, focus: bool, dirty: 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. - return if (reading) chrome.tag_reading_bg else chrome.tag_bg; + return chrome.tag_bg; } /// The ink on a pane's button (DESIGN.md R6): the chrome's grip ink on a @@ -4421,10 +4408,10 @@ fn emitSurfaceCell( const role = cellFontRole(&line[at]); if (role == .tagline) { const here = line_cover[at]; - // The workspace row's underlay is its own ground (a theme's status - // bar), else a reading pane's tint, the focused or the plain tag's. + // The window and column rows' underlay is their own ground (the + // page), else the focused or the plain tag's. const band_base: pardes.Cell = .{ - .style = .{ .bg = .{ .rgb = if (row < chrome.tagline_rows) chrome.tagline_bg else if (here.reading) chrome.tag_reading_bg else if (here.focus) chrome.tag_focus_bg else chrome.tag_bg }, .font_role = .tagline }, + .style = .{ .bg = .{ .rgb = if (row < chrome.tagline_rows) chrome.tagline_bg else if (here.focus) chrome.tag_focus_bg else chrome.tag_bg }, .font_role = .tagline }, .default = false, }; // The smaller font changes the ink, not the chrome's coverage. Painting @@ -4468,12 +4455,11 @@ fn emitSurfaceCell( const center = (b[0] + b[2]) / 2 - @as(f32, @floatFromInt(col - offset)) * body_layout.w; const shift: f32 = if (cached != null) @as(f32, @floatFromInt(@as(u32, offset) * g.cell_w)) + @as(f32, @floatFromInt(config.GUTTER * g.cell_w)) / 2 - center else 0; const resolved = resolveCell(g, glyph[0..1], 0, null, .tagline, false, page); - const fill = gripFill(chrome, here.focus, here.dirty, here.reading); - // A mark in its kind's ink (Messages.ink), held to its floor on - // the button's fill, which is not a tag's ground when focused - // or dirty (UX D4). + // A mark in its kind's ink, held on the button's fill and on + // the plain tag where the button is hollow (colors.Chrome.Marks, + // the grid's cell). const ink = if (mark) switch (glyph.style.fg) { - .rgb => |rgb| pardes.colors.pushAway(rgb, &.{fill}, pardes.colors.Roles.ink_floor), + .rgb => |rgb| rgb, 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; @@ -4492,7 +4478,7 @@ fn emitSurfaceCell( const base = &instances[next.* - 1]; const own: [3]f32 = .{ instances[next.*].br, instances[next.*].bg, instances[next.*].bb }; if (here.pane_grip) { - const fill = gripFill(chrome, here.focus, here.dirty, here.reading); + const fill = gripFill(chrome, here.focus, here.dirty); base.br = @as(f32, @floatFromInt(fill[0])) / 255; base.bg = @as(f32, @floatFromInt(fill[1])) / 255; base.bb = @as(f32, @floatFromInt(fill[2])) / 255; @@ -5370,7 +5356,7 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce const button = gripButton(g, chrome, grip.rect.x, grip.rect.y, layout); // Round the button, its first row is the tag's band: nothing of the // cells under it shows there. - const band = if (grip.reading) chrome.tag_reading_bg else if (grip.active) chrome.tag_focus_bg else chrome.tag_bg; + const band = if (grip.kind == .column_grip) chrome.tagline_bg else if (grip.active) chrome.tag_focus_bg else chrome.tag_bg; 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); @@ -7366,10 +7352,9 @@ test "every pixel of a grip column is band, button or ring, and the button sits } }.of; const chrome = &s.chrome; - // The tag's ground (draw.zig tagGround): a reading pane's tint where - // jumps walk (the pane's file never edited), else the focused tag's - // or the tag's; round the button and under it alike. - 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; + // The tag's ground, the focused tag's or the tag's, reading or not + // (DESIGN.md G1'); round the button and under it alike. + const band = 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 = gripInk(chrome, grip.active, grip.dirty); @@ -8383,7 +8368,7 @@ test "a band over a terminal's body has the tag rule under its last row, as a ba try std.testing.expect(found); } -test "a pane's mark is its button's glyph where the mode draws none, in its kind's ink held to 4.5:1 on the button's fill, and the mode's bars give way to it (S2 09a: the window drew the box, then the path)" { +test "a pane's mark is its button's glyph where the mode draws none, in its cell's ink (the core's, held on the button's fill: colors.Chrome.Marks), and the mode's bars give way to it (S2 09a: the window drew the box, then the path)" { const gpa = std.testing.allocator; var cells: [12]pardes.Cell = @splat(.{ .default = false, .style = .{ .font_role = .tagline } }); // draw.zig renderPane's box: the mode blank (normal), the mark beside it. @@ -8407,10 +8392,8 @@ test "a pane's mark is its button's glyph where the mode draws none, in its kind 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. - const fill = gripFill(&chrome, true, false, false); - const want = pardes.colors.pushAway(err, &.{fill}, pardes.colors.Roles.ink_floor); - try std.testing.expect(pardes.colors.contrast(want, fill) >= pardes.colors.Roles.ink_floor); + // the cell's ink as the core held it. + const want = err; const drawn = g.atlas.glyphForCodepoint(0x2717); try std.testing.expect(g.atlas.glyphs.get(.{ .face = drawn.face, .glyph = drawn.glyph, .role = .tagline, .decoration = .{ .bold = true }, .centered = true }) != null); for ([_]usize{ 1, 3 }) |i| { |
