WIP(container): fit_size call minSize for determining the minimal required size of a given Container
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 57s

This commit is contained in:
2025-11-28 15:25:10 +01:00
parent 40fa080af6
commit 67bfd90a2c

View File

@@ -723,6 +723,7 @@ pub fn Container(Model: type, Event: type) type {
} }
} }
size = this.minSize(&.{}, size);
// assign currently calculated size // assign currently calculated size
this.size = switch (this.properties.size.grow) { this.size = switch (this.properties.size.grow) {
.both => .max(size, this.properties.size.dim), .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 { pub fn resize(this: *@This(), model: *const Model, size: Point) void {
// NOTE assume that this function is only called for the root `Container` // NOTE assume that this function is only called for the root `Container`
this.size = size; this.size = size;
const fit_size: Point = .max(this.minSize(model, size), this.fit_resize()); const fit_size = this.fit_resize();
// if (fit_size.y > size.y or fit_size.x > size.x) @panic("error: cannot render in available space"); this.size = switch (this.properties.size.grow) {
switch (this.properties.size.grow) { .both => .max(size, fit_size),
.both => this.size = .max(size, fit_size), .fixed => fit_size,
.fixed => {}, .horizontal => .{
.horizontal => this.size = .{
.x = @max(size.x, fit_size.x), .x = @max(size.x, fit_size.x),
.y = size.y, .y = size.y,
}, },
.vertical => this.size = .{ .vertical => .{
.x = size.x, .x = size.x,
.y = @max(size.y, fit_size.y), .y = @max(size.y, fit_size.y),
}, },
} };
this.grow_resize(model, this.size); this.grow_resize(model, this.size);
} }