From 67bfd90a2ce5bbb4dabda4009c6bdca4205c4e21 Mon Sep 17 00:00:00 2001 From: Yves Biener Date: Fri, 28 Nov 2025 15:25:10 +0100 Subject: [PATCH] WIP(container): `fit_size` call `minSize` for determining the minimal required size of a given `Container` --- src/container.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/container.zig b/src/container.zig index eb37f26..638ef64 100644 --- a/src/container.zig +++ b/src/container.zig @@ -723,6 +723,7 @@ pub fn Container(Model: type, Event: type) type { } } + size = this.minSize(&.{}, size); // assign currently calculated size this.size = switch (this.properties.size.grow) { .both => .max(size, this.properties.size.dim), @@ -889,20 +890,19 @@ pub fn Container(Model: type, Event: type) type { pub fn resize(this: *@This(), model: *const Model, size: Point) void { // NOTE assume that this function is only called for the root `Container` this.size = size; - const fit_size: Point = .max(this.minSize(model, size), this.fit_resize()); - // if (fit_size.y > size.y or fit_size.x > size.x) @panic("error: cannot render in available space"); - switch (this.properties.size.grow) { - .both => this.size = .max(size, fit_size), - .fixed => {}, - .horizontal => this.size = .{ + const fit_size = this.fit_resize(); + this.size = switch (this.properties.size.grow) { + .both => .max(size, fit_size), + .fixed => fit_size, + .horizontal => .{ .x = @max(size.x, fit_size.x), .y = size.y, }, - .vertical => this.size = .{ + .vertical => .{ .x = size.x, .y = @max(size.y, fit_size.y), }, - } + }; this.grow_resize(model, this.size); }