fix: FlowBox always lays out children

This commit is contained in:
LordMZTE 2023-01-14 14:13:33 +01:00
parent c7f98cf115
commit 98f3837c81
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6

View file

@ -49,6 +49,7 @@ pub fn deinit(self: *Self) void {
} }
fn layout(self: *Self, ctx: *LayoutCtx, cons: Constraints, final_pass: bool) anyerror!void { fn layout(self: *Self, ctx: *LayoutCtx, cons: Constraints, final_pass: bool) anyerror!void {
_ = final_pass;
switch (self.direction) { switch (self.direction) {
.vertical => { .vertical => {
// the maximum width of the children // the maximum width of the children
@ -111,12 +112,9 @@ fn layout(self: *Self, ctx: *LayoutCtx, cons: Constraints, final_pass: bool) any
.height = child_height, .height = child_height,
}); });
// TODO: really only layout children on the final pass? try child.layout(ctx, child_cons, true);
if (final_pass) { if (!child.data.overflow)
try child.layout(ctx, child_cons, true); try child_cons.assertFits(child.data.size);
if (!child.data.overflow)
try child_cons.assertFits(child.data.size);
}
} }
self.child_offsets[i] = cur_pos; self.child_offsets[i] = cur_pos;
@ -192,12 +190,9 @@ fn layout(self: *Self, ctx: *LayoutCtx, cons: Constraints, final_pass: bool) any
.height = child.data.size.height, .height = child.data.size.height,
}); });
// TODO: really only layout children on the final pass? try child.layout(ctx, child_cons, true);
if (final_pass) { if (!child.data.overflow)
try child.layout(ctx, child_cons, true); try child_cons.assertFits(child.data.size);
if (!child.data.overflow)
try child_cons.assertFits(child.data.size);
}
} }
self.child_offsets[i] = cur_pos; self.child_offsets[i] = cur_pos;