fix(container): growth resize for size all size options and starting sizes (i.e. the smallest being a non grow-able one)
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m14s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m14s
This commit is contained in:
@@ -697,13 +697,11 @@ pub fn Container(comptime Event: type) type {
|
|||||||
.y = @max(size.y, this.properties.size.dim.y),
|
.y = @max(size.y, this.properties.size.dim.y),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
log.debug("fit_size returning: {any}", .{this.size});
|
|
||||||
return this.size;
|
return this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// growable implicitly requires the root `Container` to have a set a size property to the size of the available terminal screen
|
/// growable implicitly requires the root `Container` to have a set a size property to the size of the available terminal screen
|
||||||
fn grow_resize(this: *@This(), max_size: Point) void {
|
fn grow_resize(this: *@This(), max_size: Point) void {
|
||||||
log.debug("grow_size: {any}", .{this.size});
|
|
||||||
const layout = this.properties.layout;
|
const layout = this.properties.layout;
|
||||||
var remainder = switch (layout.direction) {
|
var remainder = switch (layout.direction) {
|
||||||
.horizontal => max_size.x -| (layout.padding.left + layout.padding.right),
|
.horizontal => max_size.x -| (layout.padding.left + layout.padding.right),
|
||||||
@@ -787,6 +785,10 @@ pub fn Container(comptime Event: type) type {
|
|||||||
|
|
||||||
for (this.elements.items) |child| {
|
for (this.elements.items) |child| {
|
||||||
if (child.properties.size.grow == .fixed) continue;
|
if (child.properties.size.grow == .fixed) continue;
|
||||||
|
switch (layout.direction) {
|
||||||
|
.horizontal => if (child.properties.size.grow == .vertical) continue,
|
||||||
|
.vertical => if (child.properties.size.grow == .horizontal) continue,
|
||||||
|
}
|
||||||
|
|
||||||
const size = switch (layout.direction) {
|
const size = switch (layout.direction) {
|
||||||
.horizontal => child.size.x,
|
.horizontal => child.size.x,
|
||||||
@@ -817,9 +819,11 @@ pub fn Container(comptime Event: type) type {
|
|||||||
switch (layout.direction) {
|
switch (layout.direction) {
|
||||||
.horizontal => if (child.properties.size.grow != .vertical) {
|
.horizontal => if (child.properties.size.grow != .vertical) {
|
||||||
child.size.x += size_to_correct;
|
child.size.x += size_to_correct;
|
||||||
|
remainder -|= size_to_correct;
|
||||||
},
|
},
|
||||||
.vertical => if (child.properties.size.grow != .horizontal) {
|
.vertical => if (child.properties.size.grow != .horizontal) {
|
||||||
child.size.y += size_to_correct;
|
child.size.y += size_to_correct;
|
||||||
|
remainder -|= size_to_correct;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if (overflow > 0) {
|
if (overflow > 0) {
|
||||||
@@ -836,7 +840,6 @@ pub fn Container(comptime Event: type) type {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remainder -|= size_to_correct;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user