summaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/gui/gui.zig47
1 files changed, 30 insertions, 17 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index 923db181..6cd97b69 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -689,7 +689,10 @@ 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,
- _: u3 = 0,
+ /// In a reading pane's grip or tag rows (Region.reading): their
+ /// underlay is the reading tint.
+ reading: bool = false,
+ _: u2 = 0,
};
/// Marks the grid cells a body or tag layer covers, which the layers paint
@@ -730,10 +733,14 @@ 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),
+ .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);
@@ -4300,9 +4307,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) [3]u8 {
+fn gripFill(chrome: *const pardes.Chrome, focus: bool, dirty: bool, reading: bool) [3]u8 {
if (dirty) return chrome.grip_dirty;
- return if (focus) chrome.grip_focus_ring else chrome.tag_bg;
+ if (focus) return chrome.grip_focus_ring;
+ // The ring's inside is the tag's ground: a reading pane's tint.
+ return if (reading) chrome.tag_reading_bg else chrome.tag_bg;
}
fn inkOn(bg: [3]u8) [3]u8 {
@@ -4367,9 +4376,9 @@ fn emitSurfaceCell(
if (role == .tagline) {
const here = line_cover[at];
// The workspace row's underlay is its own ground (a theme's status
- // bar), else the focused or plain tag's.
+ // bar), else a reading pane's tint, 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.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.reading) chrome.tag_reading_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
@@ -4410,7 +4419,7 @@ 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 ink = if (here.pane_grip) inkOn(gripFill(chrome, here.focus, here.dirty)) else resolved.fg;
+ const ink = if (here.pane_grip) inkOn(gripFill(chrome, here.focus, here.dirty, here.reading)) 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;
@@ -4427,7 +4436,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);
+ const fill = gripFill(chrome, here.focus, here.dirty, here.reading);
base.br = @as(f32, @floatFromInt(fill[0])) / 255;
base.bg = @as(f32, @floatFromInt(fill[1])) / 255;
base.bb = @as(f32, @floatFromInt(fill[2])) / 255;
@@ -5309,7 +5318,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.active) chrome.tag_focus_bg else chrome.tag_bg;
+ const band = if (grip.reading) chrome.tag_reading_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);
@@ -5362,7 +5371,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() != ' ') continue;
- const rgb = inkOn(gripFill(chrome, grip.active, grip.dirty));
+ const rgb = inkOn(gripFill(chrome, grip.active, grip.dirty, grip.reading));
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)));
@@ -7089,7 +7098,8 @@ test "a block cursor's cell is drawn reversed: the cell's ink its ground, its gr
test "the layer cover is the per-cell layer scan, over a core's layouts and random layers" {
// A gui-shaped core: its tagline is narrower and shorter than the body,
- // so tags and notices are layers.
+ // so tags and the notice row (the live messages' index at the window's
+ // foot, Messages.noticeRow) are layers.
const core = try pardes.Pardes.init(std.testing.allocator, .{ .cols = 97, .rows = 31 });
defer core.deinit();
core.update(.{ .resize = .{ .cols = 97, .rows = 31, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 7, .tagline_h = 13 } } });
@@ -7098,12 +7108,12 @@ test "the layer cover is the per-cell layer scan, over a core's layouts and rand
pardes.layout.insert(core, 1, 1, 2);
pardes.layout.insert(core, 0, 1, 3);
var cover: [97 * 31]Cover = undefined;
- var notices = false;
+ var notice_row = false;
for (0..32) |step| {
if (step & 3 == 0) try std.testing.expect(core.executeBuiltinLine(2, "Collapse"));
core.view().prefix = if (step & 4 != 0) .leader else .none;
if (step & 8 != 0) {
- try std.testing.expect(core.executeBuiltinLine(0, "Msg a message chip over the body"));
+ try std.testing.expect(core.executeBuiltinLine(0, "Msg a message on the notice row"));
try std.testing.expect(core.executeBuiltinLine(3, "Msg another"));
}
const s = try core.render(core.scratch.allocator());
@@ -7122,9 +7132,9 @@ test "the layer cover is the per-cell layer scan, over a core's layouts and rand
try std.testing.expectEqual(region.owner == core.view().active, cell.focus);
}
}
- for (s.tagLayers()) |layer| notices = notices or (layer.rows != 0 and layer.kind == .notice);
+ for (s.tagLayers()) |layer| notice_row = notice_row or (layer.rows != 0 and layer.kind == .notice_row);
}
- try std.testing.expect(notices);
+ try std.testing.expect(notice_row);
// Random layers: overlapping, empty, past the grid's right and bottom
// edges, and at the top of u16, where x + w overflows it.
@@ -7217,10 +7227,13 @@ test "every pixel of a grip column is band, button or ring, and the button sits
}
}.of;
const chrome = &s.chrome;
- const band = if (focus == 0) chrome.tag_focus_bg else chrome.tag_bg;
+ // 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;
// 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));
+ 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)) };
for (pixels, 0..) |pixel, n| {
const got = pixel orelse return error.TestUnpaintedGripPixel;