summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index d871e55e..c26629ab 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -1788,6 +1788,7 @@ const Gui = struct {
scroll_pane: ?usize = null,
scroll_rect: pardes.Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 },
scroll_body_y: u16 = 0, // that rect's first BODY row (Tagbottom moves it)
+ scroll_body_h: u16 = 0, // and how many rows it has, notice bands taken off
scroll_col: u16 = 0, // where the wheel turned: crossed rows are delivered
scroll_row: u16 = 0, // THERE, not wherever the pointer has drifted to since
scroll_delta: f32 = 0, // finite raw distance waiting for the render batch
@@ -4292,14 +4293,15 @@ fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void {
}
g.scroll_lag = st.lag;
g.scroll_rect = r;
- const body_y = if (core.settings.tag_bottom) r.y else r.y + pardes.BOX_H;
+ const body_y = core.bodyTop(pane, r);
g.scroll_body_y = body_y;
+ g.scroll_body_h = (r.h -| pardes.BOX_H) -| pane.body_offset;
if (st.rows != 0) {
const s = &core.surface;
g.scroll_edge_len = 0;
- if (r.w > config.GUTTER and r.h > pardes.BOX_H and r.x + r.w <= s.cols) {
+ if (r.w > config.GUTTER and r.h > pardes.BOX_H + pane.body_offset and r.x + r.w <= s.cols) {
const bw = r.w - config.GUTTER;
- const bh = r.h - pardes.BOX_H;
+ const bh = (r.h - pardes.BOX_H) - pane.body_offset;
const k: u16 = @intCast(@min(@abs(st.rows), @as(i32, bh)));
const srow = body_y + (if (st.rows > 0) k - 1 else bh - k);
if (srow < s.rows) {
@@ -4327,7 +4329,11 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *pard
const x0 = r.x + config.GUTTER;
const y0 = g.scroll_body_y;
const bw = r.w - config.GUTTER;
- const bh = r.h - pardes.BOX_H;
+ // The body the editor actually painted: measuring it from the rect while
+ // the origin comes from bodyTop reads past the pane by the band rows, and
+ // for the bottom-most pane past the surface, which drops the animation.
+ const bh = g.scroll_body_h;
+ if (bh == 0) return 0;
if (x0 + bw > surface.cols or y0 + bh > surface.rows) return 0; // resized under us
var shifted = layout;
shifted.y_off -= g.scroll_lag * layout.h;
@@ -4359,7 +4365,7 @@ fn scrollScissor(g: *const Gui, layout: CellLayout, sw: u32, sh: u32) c.SDL_Rect
const px = layout.x_off + @as(f32, @floatFromInt(r.x + config.GUTTER)) * layout.w;
const py = layout.y_off + @as(f32, @floatFromInt(g.scroll_body_y)) * layout.h;
const pw = @as(f32, @floatFromInt(r.w - config.GUTTER)) * layout.w;
- const ph = @as(f32, @floatFromInt(r.h - pardes.BOX_H)) * layout.h;
+ const ph = @as(f32, @floatFromInt(g.scroll_body_h)) * layout.h;
const x0 = std.math.clamp(@as(i32, @intFromFloat(@floor(px))), 0, @as(i32, @intCast(sw)));
const y0 = std.math.clamp(@as(i32, @intFromFloat(@floor(py))), 0, @as(i32, @intCast(sh)));
const x1 = std.math.clamp(@as(i32, @intFromFloat(@ceil(px + pw))), x0, @as(i32, @intCast(sw)));
@@ -6685,11 +6691,14 @@ fn appendPaneChrome(
const chrome = core.chromeTheme();
const page = overlayRgb(core.theme().bg orelse bg_default);
for (core.panes, core.rects) |slot, r| {
- if (slot == null or r.w <= config.GUTTER or r.h <= pardes.BOX_H) continue;
+ const pane = slot orelse continue;
+ if (r.w <= config.GUTTER or r.h <= pardes.BOX_H) continue;
if (@as(u32, r.x) + r.w > surface.cols or @as(u32, r.y) + r.h > surface.rows) continue;
const tag_y = if (core.settings.tag_bottom) r.y + r.h - pardes.BOX_H else r.y;
- const body_y = if (core.settings.tag_bottom) r.y else r.y + pardes.BOX_H;
- const body_end = body_y + r.h - pardes.BOX_H;
+ // The rail the editor painted, notice bands included -- overlaying the
+ // rows above it would tint the bands instead of the scrollbar.
+ const body_y = core.bodyTop(pane, r);
+ const body_end = body_y + ((r.h -| pardes.BOX_H) -| pane.body_offset);
const x0 = @as(f32, @floatFromInt(r.x)) * layout.w;
const x1 = x0 + @as(f32, @floatFromInt(r.w)) * layout.w;
const tag_cells = surface.cells[@as(usize, tag_y) * surface.cols + r.x + pardes.TAG_TEXT_INSET ..][0 .. r.w - pardes.TAG_TEXT_INSET];