fix(container/layout): padding calculation for anchor corrections

This commit is contained in:
2025-02-14 21:59:10 +01:00
parent 8998afd9d6
commit c2a03e95c1
2 changed files with 14 additions and 9 deletions

View File

@@ -417,10 +417,15 @@ pub fn Container(comptime Event: type) type {
.cols = cols,
.rows = size.rows,
};
// border
if (sides.top) element_size.rows -= 1;
if (sides.bottom) element_size.rows -= 1;
offset += cols;
// padding
element_size.anchor.row += padding.top;
element_size.rows -= padding.top + padding.bottom;
// gap
offset += gap;
offset += cols;
},
.vertical => {
var rows = element_rows;
@@ -436,10 +441,15 @@ pub fn Container(comptime Event: type) type {
.cols = size.cols,
.rows = rows,
};
// border
if (sides.left) element_size.cols -= 1;
if (sides.right) element_size.cols -= 1;
offset += rows;
// padding
element_size.anchor.col += padding.left;
element_size.cols -= padding.left + padding.right;
// gap
offset += gap;
offset += rows;
},
}
@@ -452,10 +462,6 @@ pub fn Container(comptime Event: type) type {
}
// padding resizing
element_size.anchor.row += padding.top;
element_size.anchor.col += padding.left;
element_size.rows -= padding.top + padding.bottom;
element_size.cols -= padding.left + padding.right;
try element.handle(.{ .resize = element_size });
}