use containing_rect() in position_element()

This commit is contained in:
Alessandro Mauri 2025-07-14 13:10:14 +02:00
parent 78fc1c1e87
commit 278e4988e9
2 changed files with 2 additions and 11 deletions

2
TODO
View File

@ -59,7 +59,7 @@ to maintain focus until mouse release (fix scroll bars)
[ ] Find a way to concile pixel measurements to the mm ones used in css, for example in min/max sizing
of elements
[ ] Center elements to div (center children_bounds to the center of the div bounds and shift the origin accordingly)
[ ] Use containing_rect() in position_element() to skip some computing and semplify the function
[x] Use containing_rect() in position_element() to skip some computing and semplify the function
[ ] Rename position_element() to layout_element()
[ ] Make functions to mark rows/columns as full, to fix the calculator demo

View File

@ -146,16 +146,7 @@ fn Rect Ctx.position_element(&ctx, Elem *parent, Rect rect, Style* style)
};
// 5. Update the parent's children bounds
if (!child_occupied.bottom_right().in_rect(div.children_bounds)) {
// right overflow
if (child_occupied.bottom_right().x > div.children_bounds.bottom_right().x) {
div.children_bounds.w += child_occupied.bottom_right().x - div.children_bounds.bottom_right().x;
}
// bottom overflow
if (child_occupied.bottom_right().y > div.children_bounds.bottom_right().y) {
div.children_bounds.h += child_occupied.bottom_right().y - div.children_bounds.bottom_right().y;
}
}
div.children_bounds = containing_rect(div.children_bounds, child_occupied);
// 99. return the placement
if (child_placement.collides(parent_view)) {