diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 11:26:05 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 15:12:36 -0300 |
| commit | 7ec1181244c039db72986eec46f21a9d5ac2e171 (patch) | |
| tree | cd1b71ecefd5331cb0cff096c4db5a65b279f6e2 | |
| parent | 65b838b9b441a7ce1810f979216ff9246d63df72 (diff) | |
| download | pardes-7ec1181244c039db72986eec46f21a9d5ac2e171.tar.gz pardes-7ec1181244c039db72986eec46f21a9d5ac2e171.zip | |
effects out, the window's glows: SelectionGlow, HoverGlow and Occlusion go with their decor (glowBlocks, occlusion, the glow trackers that kept frames coming), their tests, words and settings, and Chrome.accent, which only the hover glow read; Chrome.fx keeps Parallax's bit until the lapis ornament goes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | docs/typ/builtins-gui.json | 3 | ||||
| -rw-r--r-- | docs/typ/reference.typ | 3 | ||||
| -rw-r--r-- | src/config.zig | 19 | ||||
| -rw-r--r-- | src/draw.zig | 3 | ||||
| -rw-r--r-- | src/gui/gui.zig | 322 | ||||
| -rw-r--r-- | src/surface.zig | 8 | ||||
| -rw-r--r-- | test/process/window.zig | 2 | ||||
| -rw-r--r-- | test/record_casts.py | 3 |
8 files changed, 10 insertions, 353 deletions
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index 006b6c12..16fd9f2b 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -45,7 +45,6 @@ {"name": "GripWidth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The grip and scrollbar width, as a percent of the theme's rail."}, {"name": "Help", "leader": "SPC ?", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the help: every key and every builtin."}, {"name": "Hover", "leader": "SPC l k", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Ask the language server about the symbol under the cursor."}, - {"name": "HoverGlow", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A soft underline of light under the word a look-hover would open, on or off."}, {"name": "InactiveDim", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off."}, {"name": "Incl", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "acme's Incl, for the session: `Incl dir ...` adds directories a look at a name found nowhere else is tried in (`stdio.h`, `<foo.h>`), bare lists them, `Incl -` empties the list."}, {"name": "Index", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Run the file's language indexer at its project root, writing the index.scip the language words ask first."}, @@ -77,7 +76,6 @@ {"name": "New", "leader": "SPC f n", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Open an empty scratch pane, <dir>/+New, in this pane's directory."}, {"name": "Newcol", "leader": "SPC c n", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "An empty column right of the keyboard's, its tag taking the keyboard."}, {"name": "NextColor", "leader": "SPC t n", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Switch to the next bundled theme."}, - {"name": "Occlusion", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Pane bodies darken faintly toward their edges, on or off."}, {"name": "Pager", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "pardes, off", "doc": "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it."}, {"name": "PagerColor", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A +Pager keeps its program's colours, on or off; for the next text paged."}, {"name": "Palette", "leader": "SPC t l", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "the C64 palette or the terminal's own 16"}, @@ -113,7 +111,6 @@ {"name": "SearchPlace", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "attached, column", "doc": "Where a query pane goes: attached, under the pane that asked, out of its rows alone, or column, in the finder column."}, {"name": "SearchRows", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The rows a query pane is born with under its line 1, 1 through 100; default 8. It never resizes itself."}, {"name": "SelectRefs", "leader": "SPC l h", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Select every reference to the symbol under the cursor."}, - {"name": "SelectionGlow", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A soft halo of the selection's colour round it in the body, on or off."}, {"name": "Shell", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The shell new terminals run; bare, $SHELL if it is executable, else /bin/sh."}, {"name": "Subtypes", "leader": "SPC l T", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the subtypes of the type under the cursor."}, {"name": "Supertypes", "leader": "SPC l t", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the supertypes of the type under the cursor."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 00d71e9c..22d68c99 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -468,8 +468,7 @@ turning it off: #word("PanelSlide"), #word("PanelZoom"), start off, and the web shell has none. The focused pane can stand off the page: #word("Lift") `shadow|rim|auto|off`, #word("InactiveDim") `<percent>`, #word("Motion") `off|crisp|smooth|bouncy|playful` (default -`smooth`), #word("SelectionGlow"), #word("HoverGlow"), #word("Occlusion"), -#word("Parallax"), #word("CursorBlink"), #word("GripWidth") `<50-300>`. Most are +`smooth`), #word("Parallax"), #word("CursorBlink"), #word("GripWidth") `<50-300>`. Most are the GUI's; #word("InactiveDim") works everywhere. No effect may lower the contrast of text, the selection or a focus indicator. diff --git a/src/config.zig b/src/config.zig index 3c8e25de..e2d81c6d 100644 --- a/src/config.zig +++ b/src/config.zig @@ -167,9 +167,6 @@ pub const leader_path = paths: { if (builtins.capabilities.window_blur) table.set(.WindowBlur, null); if (builtins.capabilities.ligatures) table.set(.Ligatures, null); if (builtins.capabilities.lift) table.set(.CursorBlink, null); - if (builtins.capabilities.lift) table.set(.SelectionGlow, null); - if (builtins.capabilities.lift) table.set(.HoverGlow, null); - if (builtins.capabilities.lift) table.set(.Occlusion, null); if (builtins.capabilities.lift) table.set(.Parallax, null); table.set(.ProgramEsc, null); if (builtins.capabilities.lift) table.set(.Lift, null); @@ -750,15 +747,6 @@ pub const Runtime = struct { /// solid while typing and for half a second after, eased at each edge, /// solid again after ten idle seconds. cursor_blink: bool = true, - /// G9: a soft halo round the selection in the body, fading in over - /// 100 ms, a pixel shell's (docs/effects.md). - selection_glow: bool = false, - /// G11: a soft glow under the word a look-hover would open, fading in - /// over 80 ms, a pixel shell's. - hover_glow: bool = false, - /// G12: pane bodies darken faintly toward their edges (ambient - /// occlusion, at most 2%), a pixel shell's. - occlusion: bool = false, /// G13: a theme's page pattern under the bodies (lapis's dots) moves /// with the text at a quarter of its speed, a pixel shell's. parallax: bool = false, @@ -918,7 +906,7 @@ pub const Runtime = struct { /// The message timings a setting word sets, each in milliseconds. pub const MessageTime = enum { linger, fall, dissolve }; - pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, selection_glow, hover_glow, occlusion, parallax, program_esc }; + pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, parallax, program_esc }; pub const Action = union(enum) { toggle: Toggle, @@ -970,7 +958,7 @@ pub const Runtime = struct { .lift, .grip_width => .lift, .toggle => |field| switch (field) { .ligatures => .ligatures, - .cursor_blink, .selection_glow, .hover_glow, .occlusion, .parallax => .lift, + .cursor_blink, .parallax => .lift, else => null, }, else => null, @@ -990,9 +978,6 @@ pub const Runtime = struct { .{ .word = "MessageAnimation", .action = .{ .toggle = .message_animation }, .doc = "A message falls into its row and dissolves out of it, on or off." }, .{ .word = "Ligatures", .action = .{ .toggle = .ligatures }, .doc = "A font's programming ligatures draw across their cells, on or off." }, .{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .doc = "The cursor blinks, solid while typing, on or off." }, - .{ .word = "SelectionGlow", .action = .{ .toggle = .selection_glow }, .doc = "A soft halo of the selection's colour round it in the body, on or off." }, - .{ .word = "HoverGlow", .action = .{ .toggle = .hover_glow }, .doc = "A soft underline of light under the word a look-hover would open, on or off." }, - .{ .word = "Occlusion", .action = .{ .toggle = .occlusion }, .doc = "Pane bodies darken faintly toward their edges, on or off." }, .{ .word = "Parallax", .action = .{ .toggle = .parallax }, .doc = "A theme's page pattern moves with the text at a quarter of its speed, on or off." }, .{ .word = "ProgramEsc", .action = .{ .toggle = .program_esc }, .doc = "In a raw terminal, Esc goes to the program and Shift-Esc backs out, on; off (the default) swaps them." }, .{ .word = "Lift", .action = .lift, .doc = "How the focused pane stands off the page: off, shadow, rim or auto." }, diff --git a/src/draw.zig b/src/draw.zig index a7498cab..68e1fb41 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -546,7 +546,6 @@ 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, - .accent = chrome.box, .sel_fg = p.theme().sel_fg, .sel_bg = p.theme().sel_bg, .lift_style = @backingInt(liftStyle(p)), @@ -558,7 +557,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { .rail_px = @intCast(@min(255, @as(u32, p.theme().rail_px orelse 12) * p.settings.grip_width / 100)), .name_ink = chrome.tag_name_fg, .active_name_ink = if (p.settings.focus_tint) chrome.tag_active_name_fg else chrome.tag_name_fg, - .fx = @as(u8, @intFromBool(p.settings.selection_glow)) | @as(u8, @intFromBool(p.settings.hover_glow)) << 1 | @as(u8, @intFromBool(p.settings.occlusion)) << 2 | @as(u8, @intFromBool(p.settings.parallax)) << 3, + .fx = @as(u8, @intFromBool(p.settings.parallax)) << 3, }; if (p.theme().decor) |decor| { s.chrome.decor_dots = decor.page_dots; diff --git a/src/gui/gui.zig b/src/gui/gui.zig index ee565aeb..ca3c7724 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1166,10 +1166,6 @@ const Gui = struct { /// whether this loop's wait read an input (drawn at once, not paced). pace_ns: u64 = 0, input_seen: bool = false, - /// G9 and G11: the selection's and the hovered word's glow blocks as - /// last drawn, for their fade-in. - sel_glow: SelGlow = .{}, - hover_glow: SelGlow = .{}, /// G14: the cells last drawn and when each last changed. /// The cursor's blink (blinkNow): when the frame drawn last arrived, /// a redraw owed for an edge, and this frame's cursor mode and alpha. @@ -1235,7 +1231,7 @@ const window_fields = [_][:0]const u8{ "window_w", "window_h", "scroll_pane", "scroll_rect", "scroll_body_y", "scroll_body_h", "scroll_held_px", "scroll_col", "scroll_row", "scroll_delta", "scroll_lag", "scroll_edge", "scroll_edge_len", "scroll_notch", "program_wheel", - "glide", "pace_ns", "sel_glow", "hover_glow", "frame_arrival_ns", + "glide", "pace_ns", "frame_arrival_ns", "blink_due", "cursor_quad_alpha", "pointer_present", "pointer_shape", "pointer_cell", "presented_images", "prepared_images", "touch", "live_ctrl", "live_alt", "applied_window_opacity", "capture_tex", "capture_tex_w", @@ -4817,7 +4813,7 @@ fn stepGlide(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void { const glide = &g.glide; // The glide runs on the core's continuous path: frames every loop, and // a virtual clock carried on. - defer core.shell_continuous = glide.moving() or g.sel_glow.fading or g.hover_glow.fading; + defer core.shell_continuous = glide.moving(); const notch = g.scroll_notch; g.scroll_notch = 0; var wheeled: ?usize = null; @@ -5812,11 +5808,6 @@ fn renderFrame( // G6: what the scroll just done moved the pane's rows by, measured on // this frame against the last (the glide follows it from there). if (g.glide.pending) g.glide.measure(gpa, surface); - g.sel_glow.now_ns = core.now_ns; - // Off, or while panes move, no glow and nothing fading. - if (surface.chrome.fx & 1 == 0 or surface.panelTracks().len != 0) g.sel_glow = .{ .now_ns = g.sel_glow.now_ns }; - g.hover_glow.now_ns = g.sel_glow.now_ns; - if (surface.chrome.fx & 2 == 0 or surface.panelTracks().len != 0) g.hover_glow = .{ .now_ns = g.sel_glow.now_ns }; if (g.glide.moving()) g.glide.advance(g.glide.now_ns, g.glide.motion); cell_decor = CellDecor.of(chrome); plaque_through_len = 0; @@ -8645,13 +8636,6 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g const bodies = body_buf[0..nbodies]; const ticks: []const pardes.RailTick = if (closing) &.{} else surface.rail_ticks[0..surface.nrail_ticks]; try paneDecor(g, gpa, placed, ticks, groups, index, chrome, layout, surface.cols, surface.rows, win_w, win_h, track); - // G9, while nothing moves: a halo round the body's selection. - if (index == 0 and groups.tracks == 0 and chrome.fx & 1 != 0) try glowBlocks(g, gpa, surface, .selection, layout, win_w, win_h); - // G11: a glow under the word a look-hover would open. - if (index == 0 and groups.tracks == 0 and chrome.fx & 2 != 0) try glowBlocks(g, gpa, surface, .hover, layout, win_w, win_h); - // G14: what changed glows, while nothing moves. - // G12: the bodies' edges shaded, a pane's in its own group. - if (chrome.fx & 4 != 0) try occlusion(g, gpa, placed, groups, index, surface, ceilings, layout, win_w, win_h, track); // A single spine runs down each column, through every tag and body. if (index == 0) for (regions) |column| { if (column.kind != .column) continue; @@ -8935,187 +8919,6 @@ fn dp(logical: f32) f32 { return @max(1, @round(logical * display_scale)); } -/// G9's state: the selection's blocks last drawn and when each appeared. -const SelGlow = struct { - const Block = struct { box: [4]u16, start_ns: u64 }; - blocks: [32]Block = undefined, - len: usize = 0, - now_ns: u64 = 0, - /// A block is still fading in: the core keeps frames coming. - fading: bool = false, -}; - -/// How long a glow takes to come up (§8.1's micro-feedback: 80 to 120 ms). -const sel_glow_ns: u64 = 100 * std.time.ns_per_ms; - -/// A glow's kind: G9's halo round the selection, G11's under a hovered word. -const GlowKind = enum { selection, hover }; - -/// G9: a soft halo of the selection's own colour round each block of it in -/// a pane body (rows of selected cells that touch), fading in over 100 ms -/// with an ease-out. The selection itself is the halo's caster, never -/// touched; so is a cursor beside it; the halo stays on bodies (never a -/// tag or a grip) and at most 22%, less where the text round it would drop -/// below min(its contrast, 4.5). -/// G11: under the word a look-hover would open (its cells in the -/// affordance's tint), a soft line of the theme's accent along its foot, -/// fading in over 80 ms, as strong at most, never under a cursor. -fn glowBlocks(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, kind: GlowKind, layout: CellLayout, win_w: f32, win_h: f32) !void { - const chrome = &surface.chrome; - const page = chrome.page orelse bg_default; - const fg = chrome.fg orelse fg_default; - // The selection's halo is its own colour; a hovered word's underline is - // the theme's accent (its focused grip), like a link's. - const glow = if (kind == .selection) chrome.sel_bg else chrome.accent; - // The cells a block is made of: the selection's, or the hover - // affordance's tint (draw.zig: halfway to a quarter of the selection). - const sel = if (kind == .selection) chrome.sel_bg else mixRgb(page, mixRgb(page, chrome.sel_bg)); - const tracker = if (kind == .selection) &g.sel_glow else &g.hover_glow; - const rise_ns: u64 = if (kind == .selection) sel_glow_ns else 80 * std.time.ns_per_ms; - const cap = @min(0.22, lightenCeiling(fg, page, glow)); - var blocks: [32][4]u16 = undefined; - var nblocks: usize = 0; - var bodies: [pardes.MAX_PANES][4]f32 = undefined; - var nbodies: usize = 0; - for (surface.regionList()) |body| { - if (body.kind != .body or body.rect.w == 0) continue; - if (nbodies < bodies.len) { - bodies[nbodies] = bodyPixels(body, layout); - nbodies += 1; - } - var open: ?[4]u16 = null; // x0, y0, x1, y1 of the block being grown - var row = body.rect.y; - while (row < body.rect.y + body.rect.h and row < surface.rows) : (row += 1) { - var x0: ?u16 = null; - var x1: u16 = 0; - var col = body.rect.x; - while (col < body.rect.x + body.rect.w and col < surface.cols) : (col += 1) { - const cell = &surface.cells[@as(usize, row) * surface.cols + col]; - const selected = !cell.default and switch (cell.style.bg) { - .rgb => |rgb| std.mem.eql(u8, &rgb, &sel), - else => false, - }; - if (!selected) continue; - if (x0 == null) x0 = col; - x1 = col + 1; - } - if (x0) |start| { - if (open) |*block| { - block.* = .{ @min(block[0], start), block[1], @max(block[2], x1), row + 1 }; - } else open = .{ start, row, x1, row + 1 }; - } else if (open) |block| { - if (nblocks < blocks.len) blocks[nblocks] = block; - nblocks += 1; - open = null; - } - } - if (open) |block| if (nblocks < blocks.len) { - blocks[nblocks] = block; - nblocks += 1; - }; - } - nblocks = @min(nblocks, blocks.len); - // Each block keeps the start of the one it overlaps from the last frame. - var next: SelGlow = .{ .now_ns = tracker.now_ns }; - for (blocks[0..nblocks]) |block| { - const start = for (tracker.blocks[0..tracker.len]) |old| { - if (old.box[0] < block[2] and block[0] < old.box[2] and old.box[1] < block[3] and block[1] < old.box[3]) break old.start_ns; - } else tracker.now_ns; - next.blocks[next.len] = .{ .box = block, .start_ns = start }; - next.len += 1; - const t = @as(f32, @floatFromInt(tracker.now_ns -| start)) / @as(f32, @floatFromInt(rise_ns)); - if (t < 1) next.fading = true; - const u = std.math.clamp(t, 0, 1); - const fade = 1 - (1 - u) * (1 - u) * (1 - u); - var caster: [4]f32 = .{ @as(f32, @floatFromInt(block[0])) * layout.w, @as(f32, @floatFromInt(block[1])) * layout.h, @as(f32, @floatFromInt(block[2])) * layout.w, @as(f32, @floatFromInt(block[3])) * layout.h }; - const cursor_box: ?[4]f32 = if (surface.cursor) |cu| .{ @as(f32, @floatFromInt(cu.x)) * layout.w, @as(f32, @floatFromInt(cu.y)) * layout.h, @as(f32, @floatFromInt(cu.x + 1)) * layout.w, @as(f32, @floatFromInt(cu.y + 1)) * layout.h } else null; - const first = g.decor.items.len; - switch (kind) { - .selection => { - // A cursor beside the selection is not glowed over: it - // joins the caster. - if (surface.cursor) |cu| if (cu.x + 1 >= block[0] and cu.x <= block[2] and cu.y + 1 >= block[1] and cu.y <= block[3]) { - const cb = cursor_box.?; - caster = .{ @min(caster[0], cb[0]), @min(caster[1], cb[1]), @max(caster[2], cb[2]), @max(caster[3], cb[3]) }; - }; - try addSoft(g, gpa, caster, 0.3 * layout.h, 0, 0, cap * fade, glow, null, win_w, win_h); - try clipToBodies(g, gpa, first, bodies[0..nbodies]); - }, - .hover => { - // A strip three logical pixels tall along the word's foot, - // its edges blurred by one: an underline of light. It is - // cast from a row away (addSoft leaves its caster's own - // rectangle out), so all of it shows. - const foot = caster[3] - dp(1); - const away = layout.h; - try addSoft(g, gpa, .{ caster[0] + dp(1), foot - dp(3) - away, caster[2] - dp(1), foot - away }, dp(1), 0, away, cap * fade, glow, null, win_w, win_h); - // Kept to the bodies, and off a cursor: the parts either - // side of it. - var parts: [4 * pardes.MAX_PANES][4]f32 = undefined; - var nparts: usize = 0; - for (bodies[0..nbodies]) |b| { - const cb = cursor_box orelse { - parts[nparts] = b; - nparts += 1; - continue; - }; - if (cb[0] >= b[2] or cb[2] <= b[0] or cb[1] >= b[3] or cb[3] <= b[1]) { - parts[nparts] = b; - nparts += 1; - continue; - } - // Left and right of it, and above and below it. - parts[nparts] = .{ b[0], b[1], cb[0], b[3] }; - parts[nparts + 1] = .{ cb[2], b[1], b[2], b[3] }; - parts[nparts + 2] = .{ cb[0], b[1], cb[2], cb[1] }; - parts[nparts + 3] = .{ cb[0], cb[3], cb[2], b[3] }; - nparts += 4; - } - try clipToBodies(g, gpa, first, parts[0..nparts]); - }, - } - } - tracker.* = next; -} - -/// G12: ambient occlusion, a pane body darkening faintly toward its edges -/// (§9.1: an inner shadow of 1 to 2%): four soft strips cast from just -/// outside the body inward, clipped to it and round a cursor, black in -/// linear light, under the same contrast ceiling as a lift. -fn occlusion(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, groups: *const Groups, index: usize, surface: *const pardes.Surface, ceilings: LiftCeilings, layout: CellLayout, win_w: f32, win_h: f32, track: ?pardes.animation.Track) !void { - const strength = @min(0.02, ceilings.shadow); - if (strength <= 0.002) return; - const reach = 0.5 * layout.h; - for (regions) |body| { - if (body.kind != .body or body.rect.w == 0 or body.rect.h == 0 or groupOf(groups, body.serial) != index) continue; - const b = bodyPixels(body, layout); - // The body, less a cursor's cell in it: left, right, above, below. - var parts: [4][4]f32 = undefined; - var nparts: usize = 0; - const cursor: ?[4]f32 = if (surface.cursor) |cu| .{ @as(f32, @floatFromInt(cu.x)) * layout.w, @as(f32, @floatFromInt(cu.y)) * layout.h, @as(f32, @floatFromInt(cu.x + 1)) * layout.w, @as(f32, @floatFromInt(cu.y + 1)) * layout.h } else null; - if (cursor) |cb| if (!(cb[0] >= b[2] or cb[2] <= b[0] or cb[1] >= b[3] or cb[3] <= b[1])) { - parts = .{ .{ b[0], b[1], cb[0], b[3] }, .{ cb[2], b[1], b[2], b[3] }, .{ cb[0], b[1], cb[2], cb[1] }, .{ cb[0], cb[3], cb[2], b[3] } }; - nparts = 4; - }; - if (nparts == 0) { - parts[0] = b; - nparts = 1; - } - const t = reach / 3; - const strips = [_][4]f32{ - .{ b[0], b[1] - t, b[2], b[1] }, - .{ b[0], b[3], b[2], b[3] + t }, - .{ b[0] - t, b[1], b[0], b[3] }, - .{ b[2], b[1], b[2] + t, b[3] }, - }; - for (strips) |strip| { - const first = g.decor.items.len; - try addSoft(g, gpa, strip, reach / 3, 0, 0, strength, .{ 0, 0, 0 }, track, win_w, win_h); - try clipToBodies(g, gpa, first, parts[0..nparts]); - } - } -} - /// A theme's tag plaques (Chrome.decor_box_*), drawn under the cells of /// group `index`: each pane tag, and with the still panes the column and /// workspace tags, becomes a framed box inside its own band with a hard @@ -9651,127 +9454,6 @@ test "a pane on the move casts a shadow on the other panes' bodies alone, most a try std.testing.expectEqual(@as(f32, 0), strengths[2]); } -test "the selection glows round its block, on the body only, fading in over 100 ms" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.setTestFile(std.mem.asBytes(&@as([30][20]u8, @splat("some text on a line\n".*)))); - core.settings.selection_glow = true; - core.sync(); - const s = try core.render(core.scratch.allocator()); - try std.testing.expectEqual(@as(u8, 1), s.chrome.fx); - // Two rows of a selection in the body, as the core paints one. - const body = for (s.regionList()) |region| { - if (region.kind == .body) break region; - } else return error.NoBody; - for (0..2) |dy| for (5..12) |x| { - const cell = &s.cells[(@as(usize, body.rect.y) + 3 + dy) * s.cols + body.rect.x + x]; - cell.default = false; - cell.style.bg = .{ .rgb = s.chrome.sel_bg }; - }; - s.cursor = null; - var g = testGui(10, 20, 6, 12); - defer g.decor.deinit(gpa); - g.sel_glow = .{ .now_ns = std.time.ns_per_s }; - var strengths: [2]f32 = .{ 0, 0 }; - for ([_]u64{ 0, 150 * std.time.ns_per_ms }, 0..) |later, i| { - g.decor.clearRetainingCapacity(); - g.sel_glow.now_ns = std.time.ns_per_s + later; - var groups = makeGroups(&.{}, false); - try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true); - for (g.decor.items) |item| { - if (item.effect & soft_shadow_bit == 0) continue; - const rgb: [3]u8 = .{ @intFromFloat(@round(item.br * 255)), @intFromFloat(@round(item.bg * 255)), @intFromFloat(@round(item.bb * 255)) }; - if (!std.mem.eql(u8, &rgb, &s.chrome.sel_bg)) continue; - strengths[i] = @max(strengths[i], item.fr); - // On the body alone. - const r = bodyPixels(body, fixedCellLayout(&g)); - try std.testing.expect(item.clip_x0 >= r[0] - 0.01 and item.clip_x1 <= r[2] + 0.01 and item.clip_y0 >= r[1] - 0.01 and item.clip_y1 <= r[3] + 0.01); - } - try std.testing.expectEqual(@as(usize, 1), g.sel_glow.len); - } - // Just appeared: nothing yet, and still fading; later, up to its cap. - try std.testing.expectEqual(@as(f32, 0), strengths[0]); - try std.testing.expect(strengths[1] > 0.05 and strengths[1] <= 0.22 + 1e-4); - try std.testing.expect(!g.sel_glow.fading); -} - -test "a hovered word glows along its foot, never over the cursor, fading in over 80 ms" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.setTestFile(std.mem.asBytes(&@as([30][20]u8, @splat("some text on a line\n".*)))); - core.settings.hover_glow = true; - core.sync(); - const s = try core.render(core.scratch.allocator()); - try std.testing.expectEqual(@as(u8, 2), s.chrome.fx); - const body = for (s.regionList()) |region| { - if (region.kind == .body) break region; - } else return error.NoBody; - const page = s.chrome.page orelse bg_default; - const tint = mixRgb(page, mixRgb(page, s.chrome.sel_bg)); - const row = body.rect.y + 4; - for (5..12) |x| { - const cell = &s.cells[@as(usize, row) * s.cols + body.rect.x + x]; - cell.default = false; - cell.style.bg = .{ .rgb = tint }; - } - s.cursor = .{ .x = body.rect.x + 8, .y = row }; - var g = testGui(10, 20, 6, 12); - defer g.decor.deinit(gpa); - g.hover_glow = .{ .now_ns = std.time.ns_per_s }; - var strongest: f32 = 0; - for ([_]u64{ 0, 90 * std.time.ns_per_ms }) |later| { - g.decor.clearRetainingCapacity(); - g.hover_glow.now_ns = std.time.ns_per_s + later; - var groups = makeGroups(&.{}, false); - try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true); - for (g.decor.items) |item| { - if (item.effect & soft_shadow_bit == 0) continue; - if (later == 0) try std.testing.expect(false); - strongest = @max(strongest, item.fr); - // Never over the cursor's cell. - const cx0: f32 = @floatFromInt(@as(u32, s.cursor.?.x) * 10); - const cy0: f32 = @floatFromInt(@as(u32, s.cursor.?.y) * 20); - try std.testing.expect(item.clip_x1 <= cx0 + 0.01 or item.clip_x0 >= cx0 + 10 - 0.01 or item.clip_y1 <= cy0 + 0.01 or item.clip_y0 >= cy0 + 20 - 0.01); - } - } - try std.testing.expect(strongest > 0.05); - try std.testing.expect(!g.hover_glow.fading); -} - -test "occlusion shades each body's edges, inside it, never a tag, a grip or the cursor" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.setTestFile(std.mem.asBytes(&@as([30][20]u8, @splat("some text on a line\n".*)))); - core.settings.occlusion = true; - core.sync(); - const s = try core.render(core.scratch.allocator()); - try std.testing.expectEqual(@as(u8, 4), s.chrome.fx); - const body = for (s.regionList()) |region| { - if (region.kind == .body) break region; - } else return error.NoBody; - // The cursor on the body's top-left cell, where the shade is. - s.cursor = .{ .x = body.rect.x, .y = body.rect.y }; - var g = testGui(10, 20, 6, 12); - defer g.decor.deinit(gpa); - var groups = makeGroups(&.{}, false); - try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true); - const r = bodyPixels(body, fixedCellLayout(&g)); - var shades: usize = 0; - for (g.decor.items) |item| { - if (item.effect & soft_shadow_bit == 0) continue; - shades += 1; - try std.testing.expect(item.fr <= 0.02 + 1e-6); - try std.testing.expect(item.clip_x0 >= r[0] - 0.01 and item.clip_x1 <= r[2] + 0.01 and item.clip_y0 >= r[1] - 0.01 and item.clip_y1 <= r[3] + 0.01); - const cx: f32 = @floatFromInt(@as(u32, s.cursor.?.x) * 10); - const cy: f32 = @floatFromInt(@as(u32, s.cursor.?.y) * 20); - try std.testing.expect(item.clip_x1 <= cx + 0.01 or item.clip_x0 >= cx + 10 - 0.01 or item.clip_y1 <= cy + 0.01 or item.clip_y0 >= cy + 20 - 0.01); - } - try std.testing.expect(shades >= 4); -} - test "a body tells its first line, and lapis's dots under it move a quarter as far" { const gpa = std.testing.allocator; const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); diff --git a/src/surface.zig b/src/surface.zig index 3b99f517..3b05d5f9 100644 --- a/src/surface.zig +++ b/src/surface.zig @@ -420,8 +420,6 @@ pub const Chrome = struct { /// A pane's places' ticks on its rail, and its current one's. match_tick: [3]u8 = .{ 0, 0, 0 }, match_current: [3]u8 = .{ 0, 0, 0 }, - /// The theme's accent (a glow's tint). - accent: [3]u8 = .{ 0, 0, 0 }, /// A selection's text and ground: a lift keeps their contrast too. sel_fg: [3]u8 = .{ 0, 0, 0 }, sel_bg: [3]u8 = .{ 0, 0, 0 }, @@ -470,10 +468,8 @@ pub const Chrome = struct { decor_title_px: u8 = 2, name_ink: [3]u8 = .{ 0, 0, 0 }, active_name_ink: [3]u8 = .{ 0, 0, 0 }, - /// A pixel shell's small effects: bit 0 a glow round the body's - /// selection (G9, SelectionGlow), bit 1 one under the word a look-hover - /// would open (G11, HoverGlow), bit 2 the bodies' edge shade (G12, - /// Occlusion), bit 3 the page pattern's parallax (G13, Parallax). + /// A pixel shell's small effects: bit 3 the page pattern's parallax + /// (G13, Parallax). fx: u8 = 0, }; diff --git a/test/process/window.zig b/test/process/window.zig index 40d2e6a6..ca91d110 100644 --- a/test/process/window.zig +++ b/test/process/window.zig @@ -57,7 +57,7 @@ fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, lift var arena = std.heap.ArenaAllocator.init(gpa); defer arena.deinit(); const a = arena.allocator(); - const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nLift {s}\nPanelSlide\nSelectionGlow on\nHoverGlow on\n", .{ motion, lift }); + const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nLift {s}\nPanelSlide\n", .{ motion, lift }); var d = try process.Detached.start(gpa, exe, "monkey", .{ .init = init, .grid = .{ 80, 28 }, .env = &.{ .{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_PAD", "0" }, } }); diff --git a/test/record_casts.py b/test/record_casts.py index 703f1459..bcb106d9 100644 --- a/test/record_casts.py +++ b/test/record_casts.py @@ -858,8 +858,7 @@ def make_home(work): # No animation or blink: a frame drawn on a timer would land in the cast # wherever the wall clock put it. (home / 'config/pardes/init').write_text( - 'Theme orchard\nShell /bin/sh\nMessageLinger 0\nMessageAnimation off\nCursorBlink off\n' - 'SelectionGlow off\nHoverGlow off\n') + 'Theme orchard\nShell /bin/sh\nMessageLinger 0\nMessageAnimation off\nCursorBlink off\n') (home / '.gitconfig').write_text('[log]\n\tabbrevCommit = true\n[color]\n\tui = always\n') return home |
