WIP(container): propagate individual child sizes correctly
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 57s
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 57s
This commit is contained in:
@@ -725,7 +725,7 @@ pub fn Container(Model: type, Event: type) type {
|
|||||||
|
|
||||||
// assign currently calculated size
|
// assign currently calculated size
|
||||||
this.size = switch (this.properties.size.grow) {
|
this.size = switch (this.properties.size.grow) {
|
||||||
.both => Point.max(size, this.properties.size.dim),
|
.both => .max(size, this.properties.size.dim),
|
||||||
.fixed => this.properties.size.dim,
|
.fixed => this.properties.size.dim,
|
||||||
.horizontal => .{
|
.horizontal => .{
|
||||||
.x = @max(size.x, this.properties.size.dim.x),
|
.x = @max(size.x, this.properties.size.dim.x),
|
||||||
@@ -908,8 +908,10 @@ pub fn Container(Model: type, Event: type) type {
|
|||||||
|
|
||||||
pub fn minSize(this: *const @This(), model: *const Model, size: Point) Point {
|
pub fn minSize(this: *const @This(), model: *const Model, size: Point) Point {
|
||||||
var min_size: Point = .{};
|
var min_size: Point = .{};
|
||||||
for (this.elements.items) |child| {
|
for (this.elements.items) |*child| {
|
||||||
const child_size = child.minSize(model, child.properties.size.dim);
|
const child_size = child.minSize(model, child.properties.size.dim);
|
||||||
|
child.properties.size.dim = child_size;
|
||||||
|
child.properties.size.grow = .fixed;
|
||||||
min_size = switch (this.properties.layout.direction) {
|
min_size = switch (this.properties.layout.direction) {
|
||||||
.horizontal => .{
|
.horizontal => .{
|
||||||
.x = child_size.x + min_size.x,
|
.x = child_size.x + min_size.x,
|
||||||
@@ -922,10 +924,7 @@ pub fn Container(Model: type, Event: type) type {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
const element_size = this.element.minSize(model, size);
|
const element_size = this.element.minSize(model, size);
|
||||||
return .{
|
return .max(element_size, min_size);
|
||||||
.x = @max(element_size.x, min_size.x),
|
|
||||||
.y = @max(element_size.y, min_size.y),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle(this: *const @This(), model: *Model, event: Event) !void {
|
pub fn handle(this: *const @This(), model: *Model, event: Event) !void {
|
||||||
|
|||||||
Reference in New Issue
Block a user