mod(container): provide minSize function for Element implementation to refer for nested structures
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 1m6s
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 1m6s
This commit is contained in:
@@ -906,6 +906,24 @@ pub fn Container(Model: type, Event: type) type {
|
||||
this.grow_resize(model, this.size);
|
||||
}
|
||||
|
||||
pub fn minSize(this: *const @This(), model: *const Model, size: Point) Point {
|
||||
var min_size = this.element.minSize(model, size);
|
||||
for (this.elements.items) |child| {
|
||||
const child_size = child.minSize(model, child.properties.size.dim);
|
||||
min_size = switch (this.properties.layout.direction) {
|
||||
.horizontal => .{
|
||||
.x = child_size.x + min_size.x,
|
||||
.y = @max(child_size.y, min_size.y),
|
||||
},
|
||||
.vertical => .{
|
||||
.x = @max(child_size.x, min_size.x),
|
||||
.y = child_size.y + min_size.y,
|
||||
},
|
||||
};
|
||||
}
|
||||
return min_size;
|
||||
}
|
||||
|
||||
pub fn handle(this: *const @This(), model: *Model, event: Event) !void {
|
||||
switch (event) {
|
||||
.mouse => |mouse| if (mouse.in(this.origin, this.size)) {
|
||||
|
||||
Reference in New Issue
Block a user