diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 13:42:03 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 29e734cf91ffe5f4cca8b40a54aad91fff464a82 (patch) | |
| tree | 384056b816943fcff95a45d42cd1fd4be1fe6f1d /src/pdf_view.zig | |
| parent | e11048c20a50b67841e648a4d5ddd7490bc9c9b7 (diff) | |
| download | pardes-29e734cf91ffe5f4cca8b40a54aad91fff464a82.tar.gz pardes-29e734cf91ffe5f4cca8b40a54aad91fff464a82.zip | |
Place every part of the frame once, before painting it
draw.place builds the Surface's region list at the head of render: the
page; each pane's grip, tag rows, body, rail with its thumb, and notice
chips; each column's grip and tag; the workspace tag. The painters read
their geometry from it instead of working it out again: the grid's notice
chips and the notice layers share one chip rectangle, the rails (file,
terminal, image, PDF page) paint the placed thumb (a native PDF measures
its own into the region as it places its pages), and the body, tag, notice
and column layers take their viewports from their regions. A collapsed pane
places only its grip and tag. The column-move rail's one-cell clip of the
layers under it is now a region field set in place, not a mutation of the
built layers. No behaviour change; a test checks every region against the
old geometry, the painted rail and the layer viewports across tag bottom,
column tags, notices, a collapsed pane and a multi-line tag.
Diffstat (limited to 'src/pdf_view.zig')
| -rw-r--r-- | src/pdf_view.zig | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/pdf_view.zig b/src/pdf_view.zig index 78d3de27..13c02231 100644 --- a/src/pdf_view.zig +++ b/src/pdf_view.zig @@ -2548,6 +2548,7 @@ pub fn draw( pane_id: usize, text_x: u16, text_width: u16, + rail: *pardes.Region, ) bool { if (comptime !enabled) return false; if (!core.native_images or rect.h <= pane.tag_rows) return false; @@ -2617,16 +2618,12 @@ pub fn draw( // This frame has spent the motion used to choose its raster band. state.scroll_travel = 0; - const body_y = core.bodyTop(pane, rect); - const body_h = rect.h -| pane.tag_rows; const chrome = core.chromeTheme(); const theme = core.theme(); const pane_bg: pardes.Color = if (theme.bg) |color| .{ .rgb = color } else .default; - // The rail runs past the notice bands; only the thumb tracks the text. - s.fill(rect.x, body_y, 1, body_h, .{ .bg = .{ .rgb = chrome.scroll_track } }); - s.fill(rect.x + 1, body_y, 1, body_h, .{ .bg = pane_bg }); - - const track_h: usize = body_h; + // The rail runs past the notice bands; only the thumb tracks the text, + // and it is measured here, in document pixels, for `place`'s region. + const track_h: usize = rail.rect.h; const total = @max(@as(u64, 1), state.document_height); const len = @max( @as(usize, 1), @@ -2640,15 +2637,11 @@ pub fn draw( @as(u64, track_h -| 1), @as(u64, track_h) * offset / total, )); - var y = pos; - while (y < track_h and y < pos + len) : (y += 1) - s.fill( - rect.x, - body_y + @as(u16, @intCast(y)), - 1, - 1, - .{ .bg = .{ .rgb = chrome.scroll_thumb } }, - ); + rail.thumb_y = @intCast(pos); + rail.thumb_h = @intCast(@min(len, track_h -| pos)); + s.fill(rail.rect.x, rail.rect.y, 1, rail.rect.h, .{ .bg = .{ .rgb = chrome.scroll_track } }); + s.fill(rail.rect.x + 1, rail.rect.y, 1, rail.rect.h, .{ .bg = pane_bg }); + s.fill(rail.rect.x, rail.rect.y + rail.thumb_y, 1, rail.thumb_h, .{ .bg = .{ .rgb = chrome.scroll_thumb } }); return true; } |
