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); }