summaryrefslogtreecommitdiff
path: root/src/pdf_view.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 00:30:46 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit232bfbbc4371a1fe9df210874118b4450dce7f9d (patch)
tree6af9cfcc6e741082b15a270a6d80d3d182301ce5 /src/pdf_view.zig
parent42748f92b77367db415c8b4d0f2e537a9e1ddde7 (diff)
downloadpardes-232bfbbc4371a1fe9df210874118b4450dce7f9d.tar.gz
pardes-232bfbbc4371a1fe9df210874118b4450dce7f9d.zip
Let a pane's tag take a row for each line it holds
A tag that is a text can hold a newline, and the tagline, the body under it and the pointer all assumed one row. The pane's tag now takes a row per line (up to eight, and never the body's last row); the body starts below it, the rows a pointer counts start the body after the tag's lines, a click on any line puts the tag's cursor there, and a pixel shell gets a tag layer per line. A tag of one line draws exactly as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pdf_view.zig')
-rw-r--r--src/pdf_view.zig23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/pdf_view.zig b/src/pdf_view.zig
index 92a05618..b2fd5866 100644
--- a/src/pdf_view.zig
+++ b/src/pdf_view.zig
@@ -2170,7 +2170,7 @@ pub fn paneViewport(core: *const pardes.Pardes, pane: *const pardes.Pane) ?Viewp
if (slot == pane) break core.rects[id];
} else return null;
const cols = rect.w -| config.GUTTER;
- const rows = rect.h -| pardes.BOX_H;
+ const rows = rect.h -| pane.tag_rows;
if (cols == 0 or rows == 0) return null;
return .{
.pixel_w = @as(u32, cols) * @as(u32, core.cell_pixels.w),
@@ -2208,8 +2208,8 @@ pub fn pageAtGridRow(core: *const pardes.Pardes, pane: *const pardes.Pane, row:
const rect = for (core.panes, 0..) |slot, id| {
if (slot == pane) break core.rects[id];
} else return null;
- const body_y = core.bodyTop(rect);
- if (row < body_y or row >= body_y + (rect.h -| pardes.BOX_H)) return null;
+ const body_y = core.bodyTop(pane, rect);
+ if (row < body_y or row >= body_y + (rect.h -| pane.tag_rows)) return null;
const local_y = @as(f64, @floatFromInt(
@as(u32, row - body_y) * core.cell_pixels.h + core.cell_pixels.h / 2,
));
@@ -2265,7 +2265,7 @@ pub fn panePointAtPage(
if (slot == pane) break core.rects[id];
} else return null;
const body_x = @as(i64, rect.x + config.GUTTER);
- const body_y = @as(i64, core.bodyTop(rect));
+ const body_y = @as(i64, core.bodyTop(pane, rect));
const px = (@as(i64, col) - body_x) * core.cell_pixels.w + core.cell_pixels.w / 2;
const py = (@as(i64, row) - body_y) * core.cell_pixels.h + core.cell_pixels.h / 2;
return pointAtPage(state, view, page, px, py, clamp_to_page);
@@ -2549,7 +2549,7 @@ pub fn draw(
text_width: u16,
) bool {
if (comptime !enabled) return false;
- if (!core.native_images or rect.h <= pardes.BOX_H) return false;
+ if (!core.native_images or rect.h <= pane.tag_rows) return false;
const state = &(pane.pdf orelse return false);
const view = paneViewport(core, pane) orelse return false;
const key = TintKey{ .mode = state.tint, .colors = tintColors(core) };
@@ -2598,9 +2598,9 @@ pub fn draw(
.x = text_x,
// Below the notice chips, like an image: a placed page is
// drawn after the cells and would paint a chip out.
- .y = core.bodyTop(rect) + pane.notices.span(),
+ .y = core.bodyTop(pane, rect) + pane.notices.span(),
.w = text_width,
- .h = (rect.h -| pardes.BOX_H) -| pane.notices.span(),
+ .h = (rect.h -| pane.tag_rows) -| pane.notices.span(),
.rgba = placed.rgba,
.iw = placed.width,
// The texture contains the retained band, not the full page.
@@ -2616,15 +2616,14 @@ pub fn draw(
// This frame has spent the motion used to choose its raster band.
state.scroll_travel = 0;
- const body_y = core.bodyTop(rect);
- const body_h = rect.h -| pardes.BOX_H;
+ 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.
- const rail_y = if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
- core.surface.fill(rect.x, rail_y, 1, rect.h -| pardes.BOX_H, .{ .bg = .{ .rgb = chrome.scroll_track } });
- core.surface.fill(rect.x + 1, rail_y, 1, rect.h -| pardes.BOX_H, .{ .bg = pane_bg });
+ core.surface.fill(rect.x, body_y, 1, body_h, .{ .bg = .{ .rgb = chrome.scroll_track } });
+ core.surface.fill(rect.x + 1, body_y, 1, body_h, .{ .bg = pane_bg });
const track_h: usize = body_h;
const total = @max(@as(u64, 1), state.document_height);