From d1cc6d5e33107396d1e34fdf0ec4fdbed3814199 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 7 Nov 2026 20:31:57 -0300 Subject: gui: a body scrolling under held rows (TreeContext's sticky context) glides without trash: the glide measured and kept its rows from the body's top, so the gap showed a held row or none, its rows that left were drawn above the held band where the scissor hid them (the layer's first row showed through twice, 0.9 rows apart), and a body layer's rows past the grid (what the compact context rows save at TaglineSize < 100) were left behind at the bottom; the glide now takes each body's held rows (Glide.held), the gap rows go under them, the touch path's edge row too, and the layer's extra rows move with the rest; a glide test pins the kept row under held rows Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/gui/gui.zig | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 3538481a..80fdb39b 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -4971,7 +4971,8 @@ fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void { const bw = r.w - config.GUTTER; const bh = g.scroll_body_h; const k: u16 = @intCast(@min(@abs(st.rows), @as(i32, bh))); - const srow = body_y + (if (st.rows > 0) k - 1 else bh - k); + const held = @min(pane.context_rows, bh - k); + const srow = body_y + (if (st.rows > 0) held + k - 1 else bh - k); if (srow < s.rows) { if (g.scroll_edge.len < bw) { gpa.free(g.scroll_edge); @@ -5030,10 +5031,24 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons n += 1; } } + // A body layer's held rows are compact, so it has rows past the grid's + // (lifted into the body by what they save): the moving rows go on with + // them, or the band under the grid's last row shows the layer's, still. + if (pane < surface.body_layers.len and surface.body_layers[pane].context_rows != 0) { + const layer = &surface.body_layers[pane]; + if (layer.cols == bw) for (bh..layer.rows) |k| { + const line = layer.cells[k * layer.cols ..][0..layer.cols]; + for (0..bw) |c_i| { + emitInstance(g, instances, base + n, x0 + @as(u16, @intCast(c_i)), y0 + @as(u16, @intCast(k)), shifted, win_w, win_h, cellFontRole(&line[c_i]), line, c_i, null, false, page); + n += 1; + } + }; + } if (!gliding) { - // A touchpad's fraction opens one row, the one that left. + // A touchpad's fraction opens one row, the one that left: under the + // held rows, where the moving rows start. if (g.scroll_edge_len >= bw) { - const erow: u16 = if (lag > 0) y0 + bh else y0 - 1; + const erow: u16 = if (lag > 0) y0 + bh else y0 + kept.rows - 1; var i: u16 = 0; while (i < bw) : (i += 1) { emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, cellFontRole(&g.scroll_edge[i]), g.scroll_edge[0..bw], i, null, false, page); @@ -5049,8 +5064,9 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons const rows = if (lag < 0) glide.above else glide.below; for (0..@min(gap, nkept)) |i| { const cells = rows[i * bw ..][0..bw]; - // Row -1 - i above the body, or bh + i below it, in grid rows. - const at_row: i32 = if (lag < 0) @as(i32, y0) - 1 - @as(i32, @intCast(i)) else @as(i32, y0) + bh + @as(i32, @intCast(i)); + // Row -1 - i above the moving rows (under the held ones), or bh + i + // below the body, in grid rows. + const at_row: i32 = if (lag < 0) @as(i32, y0 + kept.rows) - 1 - @as(i32, @intCast(i)) else @as(i32, y0) + bh + @as(i32, @intCast(i)); var at = shifted; // emitInstance takes an unsigned row: move the layout instead. at.y_off += @as(f32, @floatFromInt(at_row - @as(i32, y0))) * layout.h; @@ -5413,6 +5429,7 @@ fn renderFrame( const chrome = &surface.chrome; // 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). + for (core.panes, &g.glide.held) |slot, *held| held.* = if (slot) |pane| pane.context_rows else 0; glideFrame(g, gpa, surface); var groups: Groups = .{}; const now = g.now_ns; @@ -5498,8 +5515,9 @@ fn renderFrame( } const decor_len: u32 = @intCast(g.decor.items.len); if (cell_total != 0 or decor_len != 0) { - // The shifted rows of a scroll: its body, and a glide's rows past it. - const capacity = std.math.add(u32, cell_total, 2 * cells + decor_len) catch return error.GpuCapacity; + // The shifted rows of a scroll: its body, a glide's rows past it, and + // a body layer's rows past the grid's. + const capacity = std.math.add(u32, cell_total, 3 * cells + decor_len) catch return error.GpuCapacity; try growInstances(g, &g.vbuf, &g.vxfer, &g.vbuf_cells, capacity, @sizeOf(CellInstance)); const vptr: [*]u8 = @ptrCast(c.SDL_MapGPUTransferBuffer(g.device, g.vxfer.?, false) orelse { -- cgit v1.3