diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 00:13:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:40:08 -0300 |
| commit | b1d2c6ae01bf08370e18913ac6a7e8f0074c9113 (patch) | |
| tree | 37612ae2f85e931ba62c6d91674a758896133802 /src/gui | |
| parent | 3ece644731e94584beb17bc75e3628ecde8cd7d2 (diff) | |
| download | pardes-b1d2c6ae01bf08370e18913ac6a7e8f0074c9113.tar.gz pardes-b1d2c6ae01bf08370e18913ac6a7e8f0074c9113.zip | |
gui: gripDecor draws a grip's mode bars from its first row without a loop over the rows it skipped, Post's vignette ceiling is shadowCeiling's (the same sum), ShaderBuild drops expand and a Wake struct whose ctx was never set, and ShaderBuild's and Post's headers say an attached window runs the bundled passes alone (no SPIR-V travels the wire)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/gui')
| -rw-r--r-- | src/gui/Post.zig | 10 | ||||
| -rw-r--r-- | src/gui/gui.zig | 38 |
2 files changed, 22 insertions, 26 deletions
diff --git a/src/gui/Post.zig b/src/gui/Post.zig index 64a431b9..19b10c52 100644 --- a/src/gui/Post.zig +++ b/src/gui/Post.zig @@ -2,8 +2,8 @@ //! finished frame, each reading the one before it (the frame first) and the //! last one writing the window. A pass is the bundled Crt (shaders/post/, //! compiled with the build) or a user's file (Shader <path>), whose SPIR-V -//! comes from ShaderBuild.zig: compiled by the process that holds the core, -//! this one or the detached session this GUI is attached to. A file whose +//! comes from ShaderBuild.zig, compiled by this process (a window attached +//! to a session elsewhere runs the bundled passes alone). A file whose //! compile fails keeps its last good pipeline. //! //! The uniforms are ghostty's (Uniforms), so a shader written for ghostty runs @@ -289,7 +289,6 @@ fn unit(rgb: [3]u8) [3]f32 { pub fn capsOf(frame: Frame) std.EnumArray(Scene, f32) { const pairs = [_][2][3]f32{ .{ unit(frame.foreground), unit(frame.background) }, .{ unit(frame.selection_foreground), unit(frame.selection_background) } }; var bloom: f32 = 1; - var shade: f32 = 1; for (pairs) |pair| { const a = luminance(pair[0]); const b = luminance(pair[1]); @@ -298,10 +297,9 @@ pub fn capsOf(frame: Frame) std.EnumArray(Scene, f32) { const target = @min(contrastOf(a, b), 4.5); // (light + e + .05) / (dark + e + .05) >= target bloom = @min(bloom, @max(0, (light + 0.05 - target * (dark + 0.05)) / @max(target - 1, 1e-3))); - // (k light + .05) / (k dark + .05) >= target, darkened by 1 - k - const room = light - target * dark; - shade = @min(shade, if (room <= 0) 0 else std.math.clamp(1 - 0.05 * (target - 1) / room, 0, 1)); } + // A vignette darkens both of a pair as a lift's shadow does. + const shade = @min(gui.shadowCeiling(frame.foreground, frame.background), gui.shadowCeiling(frame.selection_foreground, frame.selection_background)); // Grain: the largest step off the page, up and down, that keeps the text // on it at its contrast or 4.5 (searched in 1/1020 steps up to 8/255). const ink = luminance(unit(frame.foreground)); diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 3ed97f10..c7b52fc4 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -4484,7 +4484,7 @@ fn pollFrame(ctx: ?*anyopaque) void { const geom = windowCells(g); if (updateCoreResize(core, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) resetScroll(g); stepScroll(g, core, s.gpa); - _ = s.shaders.sync(s.gpa, s.io, core, s.inotify_fd, s.watches, .{ .call = sdlWake }); + _ = s.shaders.sync(s.gpa, s.io, core, s.inotify_fd, s.watches, sdlWake); { var passes: [Post.max]ShaderBuild.Pass = undefined; g.post.sync(s.gpa, g.device, g.swapchain_format, s.shaders.view(&core.settings.post, &passes), s.shaders.revision, core); @@ -8959,7 +8959,7 @@ const luminance = pardes.colors.relativeLuminance; /// How dark a shadow may make the page and its text, both together, before /// the pair drops below its own contrast or 4.5, whichever is lower (ยง8.2): /// darkening in linear light by k leaves (k L1 + .05) / (k L2 + .05). -fn shadowCeiling(fg: [3]u8, bg: [3]u8) f32 { +pub fn shadowCeiling(fg: [3]u8, bg: [3]u8) f32 { const a = luminance(fg); const b = luminance(bg); const light = @max(a, b); @@ -9839,25 +9839,23 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce try addDecor(g, gpa, x1 - gap, y0 + gap, x1 - b, y1 - gap, band, 1, track, win_w, win_h); } } + // The marks are the first row's alone, where its cell is blank (no + // mode glyph), centered in the button, in its ink from the region's + // state. const x = grip.rect.x; - for (0..grip.rect.h) |line| { - const y = grip.rect.y + @as(u16, @intCast(line)); - if (x >= cols or y >= rows) continue; - const cell = &cells[@as(usize, y) * cols + x]; - if (cell.default or cell.printableAscii() != ' ') continue; - // The marks are in the button's ink, from the region's state. - const rgb = inkOn(gripFill(chrome, grip.active, grip.dirty)); - // The marks are the first row's alone, centered in the button. - if (line != 0) continue; - 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))); - // The mode's two bars: a logical pixel thick, a pixel either - // side of the middle. - const bar = dp(1); - try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, track, win_w, win_h); - try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, track, win_w, win_h); - } + const y = grip.rect.y; + 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 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))); + // The mode's two bars: a logical pixel thick, a pixel either side of + // the middle. + const bar = dp(1); + try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, track, win_w, win_h); + try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, track, win_w, win_h); } } |
