Even width and height comparisons

This commit is contained in:
2025-11-01 13:01:44 +01:00
parent f41a4936f9
commit 5cb6d341af
2 changed files with 12 additions and 0 deletions
+1
View File
@@ -49,6 +49,7 @@ impl Element for Div {
let mut scope = crate::render_scope::RenderScope::new();
scope.set_parent_transform(transform.clone());
transform.width = 0;
transform.height = 0;
let mut renderer = DivRenderer(&mut transform);
for widget in &self.children {
+11
View File
@@ -176,6 +176,9 @@ impl RawTransform {
let child_bottom = self.y + self.height;
let parent_bottom = parent.y + parent.height;
let child_right = self.x + self.width;
let parent_right = parent.x + parent.width;
if child_bottom > parent_bottom {
if parent_bottom > self.y {
self.height = parent_bottom - self.y;
@@ -183,6 +186,14 @@ impl RawTransform {
self.height = 0;
}
}
if child_right > parent_right {
if parent_right > self.x {
self.width = parent_right - self.x;
} else {
self.width = 0;
}
}
}
}