diff options
Diffstat (limited to 'core/draw.zig')
| -rw-r--r-- | core/draw.zig | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/core/draw.zig b/core/draw.zig index c156352f..42396aa1 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -336,11 +336,14 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { s.placements.clearRetainingCapacity(); @memset(&s.gpu_frames, null); const chrome = p.chromeTheme(); + // The window's rules and grips from the chrome (the themes programme's + // L2e; DESIGN.md R6, R11, G1'). + const resolved = p.chrome(); s.chrome = .{ .page = p.theme().bg, .fg = p.theme().fg, - .border = chrome.border, - .topbar_rule = config.gui_topbar_pane_border_rgb orelse chrome.border, + .border = resolved.rule, + .topbar_rule = config.gui_topbar_pane_border_rgb orelse resolved.rule, .tag_bg = chrome.tag_bg, .tagline_bg = chrome.tagline_bg, .tag_focus_bg = chrome.tag_active_bg, @@ -350,12 +353,14 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { .scroll_thumb = chrome.scroll_thumb, .match_tick = chrome.search_bg, .match_current = p.theme().fg orelse chrome.tag_fg, - .rule_px = p.theme().rule_px orelse 2, - .grip_border = boxBorder(p), - .grip_focus_ring = chrome.box, - .grip_dirty = boxDirty(p), - .tag_rule = p.theme().tag_rule, - .rail_px = @intCast(@min(255, @as(u32, p.theme().rail_px orelse 12) * p.settings.grip_width / 100)), + .rule_px = resolved.rule_px, + .grip_border = resolved.grip.ring, + .grip_focus_ring = resolved.grip.focus, + .grip_dirty = resolved.grip.dirty, + .grip_mode = resolved.grip.mode, + .grip_ink = resolved.grip.ink, + .tag_rule = resolved.tag_rule, + .rail_px = @intCast(@min(255, @as(u32, resolved.rail_px) * p.settings.grip_width / 100)), }; place(p, s); // Separators have their own role; a scrollbar need not frame the page. @@ -539,7 +544,14 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: // painted out. Text gets the overlay; a kind's pane gives up the rows. const shown = pane.notices.span(); const body_h = (r.h -| pane.tag_rows) -| shown; - pardes.Kind.draw(p, s, arena, pane, id, tx, body_y + shown, tw, body_h); + // A picker's preview through a kind (Pick.showKind): its file named + // until its kind has drawn it. + if (!pardes.Kind.draw(p, s, arena, pane, id, tx, body_y + shown, tw, body_h) and body_h > 0 and pardes.Pick.previewing(p, id)) { + const k = pane.addon.?; + if (pardes.Pick.nameLine(arena, k.path, k.nameOf(), k.size, "")) |line| { + _ = s.print(tx, body_y + shown, tw, line, .{ .fg = if (th.fg) |c| .{ .rgb = c } else .default, .bg = pane_bg }); + } else |_| {} + } // The same one column as the real scrollbar below, running past // the notice bands so the gutter has no notch in it; its thumb // where this frame's paint said its window is in its whole (a @@ -849,8 +861,8 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v var col = panes.File.rawDisplayCol(p.settings.tab, shown, @max(swept.lo, start) - start) -| scroll; const stop = panes.File.rawDisplayCol(p.settings.tab, shown, @min(swept.hi, end) - start) -| scroll; while (col < stop and col < columns) : (col += 1) { - surface.at(@intCast(col), 0).style.bg = .{ .rgb = body_layer.buttonTints(p.theme())[button] }; - surface.at(@intCast(col), 0).style.fg = .{ .rgb = body_layer.buttonInks(p.theme())[button] }; + surface.at(@intCast(col), 0).style.bg = .{ .rgb = p.chrome().sweeps[button].ground }; + surface.at(@intCast(col), 0).style.fg = .{ .rgb = p.chrome().sweeps[button].text }; } } } else |_| {}; @@ -933,6 +945,9 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R const ground = groundOf(p, pane, active); const inks = chrome.roles.on(ground); const selected = chrome.roles.selectedOn(ground); + // A symbol's kind mark (colors.Chrome.Inks.kind): held on this tag's + // ground and on its cursor row's selection. + const kind = p.chrome().on(if (active) .focus else .plain).kind; const bg = inks.ground; const fg = inks.text; const storage = try arena.alloc(Cell, @as(usize, columns) * rows); @@ -977,6 +992,7 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R if (b < part.row.chord) style.fg = .{ .rgb = chrome.roles.key }; if (b < part.row.pre) style.fg = .{ .rgb = if (active) chrome.tag_active_name_fg else chrome.tag_name_fg }; if (part.row.dim or (b >= part.row.pre and b < part.row.pre + part.row.faint) or (b >= part.row.quiet[0] and b < part.row.quiet[1])) style.fg = .{ .rgb = on.dim }; + if (b < part.row.kind) style.fg = .{ .rgb = kind }; for (part.row.keys) |k| if (k == b) { style.fg = .{ .rgb = chrome.roles.key }; style.bold = true; @@ -1134,11 +1150,11 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, if (pane.file != null and pane.trail.n > 0 and !pardes.Trail.outOfRest(p, pane)) { const kept = tagline.folded(p, pane).whole; const t = &pane.trail; - const first: usize = @intFromBool(t.steps[0] == .owner); - if (t.isFolded(first, kept)) { - const fold = t.spanOf(first, kept); + // Each run of folded places' `+N` (UX L'1: words never fold). + for (0..t.backs()) |i| if (t.isFolded(i, kept) and !(i > 0 and t.isFolded(i - 1, kept))) { + const fold = t.spanOf(i, kept); inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, fold[0], @min(fold[1], first_line.len), inks.dim, false); - } + }; if (t.walked()) |i| if (!t.isFolded(i, kept)) { const word = t.spanOf(i, kept); inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, word[0], @min(word[1], first_line.len), chrome.roles.key, true); @@ -1228,12 +1244,11 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, body_layer.paintPointerSelection(p, s, pane, r, sel, 0, preview_bg, null); }; } - const sel_btn = body_layer.buttonTints(th); - const sel_ink = body_layer.buttonInks(th); + const sweeps = &p.chrome().sweeps; for (pane.sel, 0..) |selection, button| { if (selection.state == .none or (selection.state == .done and button != 0)) continue; if (button == pardes.sel_slot or @min(selection.r0, selection.r1) >= rows) continue; - body_layer.paintPointerSelection(p, s, pane, r, selection, 0, sel_btn[button], sel_ink[button]); + body_layer.paintPointerSelection(p, s, pane, r, selection, 0, sweeps[button].ground, sweeps[button].text); } } |
