mod(container): integrate minSize call when fit_resize is calculated
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:
@@ -685,7 +685,7 @@ pub fn Container(Model: type, Event: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Resize all fit sized `Containers` to the necessary size required by its child elements.
|
/// Resize all fit sized `Containers` to the necessary size required by its child elements.
|
||||||
fn fit_resize(this: *@This()) Point {
|
fn fit_resize(this: *@This(), model: *const Model) Point {
|
||||||
// NOTE this is supposed to be a simple and easy to understand algorithm, there are currently no optimizations done
|
// NOTE this is supposed to be a simple and easy to understand algorithm, there are currently no optimizations done
|
||||||
const layout = this.properties.layout;
|
const layout = this.properties.layout;
|
||||||
var size: Point = switch (layout.direction) {
|
var size: Point = switch (layout.direction) {
|
||||||
@@ -710,7 +710,7 @@ pub fn Container(Model: type, Event: type) type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (this.elements.items) |*child| {
|
for (this.elements.items) |*child| {
|
||||||
const child_size = child.fit_resize();
|
const child_size = child.fit_resize(model);
|
||||||
switch (layout.direction) {
|
switch (layout.direction) {
|
||||||
.horizontal => {
|
.horizontal => {
|
||||||
size.x += child_size.x;
|
size.x += child_size.x;
|
||||||
@@ -723,7 +723,7 @@ pub fn Container(Model: type, Event: type) type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size = this.minSize(&.{}, size);
|
size = this.minSize(model, 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),
|
||||||
@@ -890,7 +890,7 @@ 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 = this.fit_resize();
|
const fit_size = this.fit_resize(model);
|
||||||
this.size = switch (this.properties.size.grow) {
|
this.size = switch (this.properties.size.grow) {
|
||||||
.both => .max(size, fit_size),
|
.both => .max(size, fit_size),
|
||||||
.fixed => fit_size,
|
.fixed => fit_size,
|
||||||
|
|||||||
Reference in New Issue
Block a user