summaryrefslogtreecommitdiff
path: root/src/layout.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout.zig')
-rw-r--r--src/layout.zig18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/layout.zig b/src/layout.zig
index f0689b10..dac0aa7e 100644
--- a/src/layout.zig
+++ b/src/layout.zig
@@ -1016,21 +1016,31 @@ pub fn keepGroups(p: *Pardes) void {
/// False, `id` in no column, when the owner has not the rows for its tag
/// and the attachment's minimum.
pub fn attach(p: *Pardes, owner: usize, id: usize, rows: u16) bool {
+ return attachFrom(p, owner, id, rows, owner);
+}
+
+/// attach, the rows given by `giver`: the owner itself or a pane of its
+/// group (a +Preview added under a query pane later takes the text's rows,
+/// so the query pane, typed into, keeps its own).
+pub fn attachFrom(p: *Pardes, owner: usize, id: usize, rows: u16, giver: usize) bool {
const o = p.panes[owner] orelse return false;
+ const g = p.panes[giver] orelse return false;
const nw = p.panes[id] orelse return false;
if (o.collapsed) toggleCollapse(p, owner);
+ if (g.collapsed) toggleCollapse(p, giver);
compute(p);
const f = findPane(p, owner) orelse return false;
+ if (giver != owner and groupRoot(p, owner) != groupRoot(p, giver)) return false;
// Its tag wraps at the column's width: measured there.
p.rects[id].w = p.col_w[f.col];
- const oh = p.rects[owner].h;
+ const oh = p.rects[giver].h;
const least = minRows(p, id);
if (oh < least + BOX_H) return false;
- const owner_keeps = if (oh >= least + minRows(p, owner)) minRows(p, owner) else BOX_H;
- const give = std.math.clamp(rows, least, oh - owner_keeps);
+ const giver_keeps = if (oh >= least + minRows(p, giver)) minRows(p, giver) else BOX_H;
+ const give = std.math.clamp(rows, least, oh - giver_keeps);
snapColWeights(p, f.col);
insert(p, f.col, groupEnd(p, f.col, f.idx), id);
- o.vweight = @floatFromInt(oh - give);
+ g.vweight = @floatFromInt(oh - give);
nw.vweight = @floatFromInt(give);
nw.attached_to = o.serial;
compute(p);