diff --git a/TODO b/TODO index 22f1803..24cfa94 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/lib/ugui.c3l/src/ugui_layout.c3 b/lib/ugui.c3l/src/ugui_layout.c3 index 805b2c9..a81eb22 100644 --- a/lib/ugui.c3l/src/ugui_layout.c3 +++ b/lib/ugui.c3l/src/ugui_layout.c3 @@ -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)) {