summaryrefslogtreecommitdiff
path: root/core/layout.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/layout.zig')
-rw-r--r--core/layout.zig26
1 files changed, 25 insertions, 1 deletions
diff --git a/core/layout.zig b/core/layout.zig
index 5550ef4a..2a5d2cf3 100644
--- a/core/layout.zig
+++ b/core/layout.zig
@@ -600,6 +600,22 @@ pub fn wantedTagRows(p: *Pardes, id: usize) u16 {
return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS)));
}
+/// The rows pane `id`'s tag's text takes now: out of rest its head
+/// (TagState) after what of its prefix stays (UX D1), wrapped at its width
+/// as Pardes.sync wraps it; at rest what wantedTagRows says.
+fn headRows(p: *Pardes, id: usize) u16 {
+ const pane = p.panes[id] orelse return BOX_H;
+ if (pane.collapsed or !pane.tag_expanded) return BOX_H;
+ var wrap_room: [Pane.prefix_room]u8 = undefined;
+ var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room);
+ const wa = wrap_fba.allocator();
+ const prefix = tagline.prefixIn(p, wa, pane) catch return pane.tag_rows;
+ const tail = tagline.shownTail(p, wa, pane) catch return pane.tag_rows;
+ const whole = std.mem.concat(wa, u8, &.{ prefix, tail }) catch return pane.tag_rows;
+ const shown = tagline.wrapTag(p.settings.tab, wa, whole, tagline.tagWidth(p, id)) catch return pane.tag_rows;
+ return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS)));
+}
+
/// The rows a placement, and a `size`, leave a pane: its tag at its width
/// and `min_body_rows`. The one minimum both ask.
pub fn minRows(p: *Pardes, id: usize) u16 {
@@ -1436,6 +1452,9 @@ pub fn compute(p: *Pardes) void {
var vsum: f32 = 0;
for (0..p.view().cols[c].n) |k| {
if (p.panes[v.cols[c].panes[k]]) |pane| vsum += pane.vweight;
+ // Its width before its height: a band's floor wraps its tag at
+ // it (floorRows).
+ v.rects[v.cols[c].panes[k]] = .{ .x = x, .w = cw };
}
if (vsum <= 0) vsum = 1;
@@ -1478,7 +1497,12 @@ fn floorRows(p: *Pardes, id: usize) u16 {
const pane = p.panes[id] orelse return 0;
const band = if (pardes.Band.over(pane)) 0 else pardes.Band.takes(p, id);
if (band > 0) {
- const above = @max(1, pane.tag_rows -| pane.band_rows) + band;
+ // Over its body as Pardes.sync lays it out (UX E3): the head's rows
+ // and the band under them, or the rows the tag keeps from rest
+ // where those are more; worked out from the state, never the last
+ // sync's rows (the first layout after a head changed read the
+ // rows of the one before, and the next moved the body).
+ const above = @max(wantedTagRows(p, id), headRows(p, id) + band);
// A body of 60 % is one and a half times what is above it.
return above + @max(pardes.Band.body_rows, (3 * above + 1) / 2);
}