diff --git a/src/main.c3 b/src/main.c3 index 7c7228d..d2be50b 100644 --- a/src/main.c3 +++ b/src/main.c3 @@ -152,7 +152,6 @@ fn int main(String[] args) if (ui.check_key_combo(ugui::KMOD_CTRL, "q")) break; - // main div, fill the whole window ui.div_begin("main", ugui::Rect{.w=-100})!!; {| ui.layout_set_column()!!; @@ -186,6 +185,17 @@ fn int main(String[] args) ui.layout_next_row()!!; static bool check; ui.checkbox("check1", "", ugui::Point{}, &check)!!; + +/* + ui.layout_set_column()!!; + ui.button_label(" A ")!!; + ui.button_label(" B ")!!; + ui.layout_next_column()!!; + ui.button_label(" C ")!!; + ui.button_label(" D ")!!; + ui.layout_next_row()!!; + ui.button_label(" E ")!!; +*/ |}; ui.draw_sprite("sprite1", "tux")!!; ui.div_end()!!; diff --git a/src/ugui_div.c3 b/src/ugui_div.c3 index 3f32e73..da175cf 100644 --- a/src/ugui_div.c3 +++ b/src/ugui_div.c3 @@ -55,7 +55,7 @@ fn void! Ctx.div_begin(&ctx, String label, Rect size, bool scroll_x = false, boo .h = size.h < 0 ? max(elem.div.pcb.h, (short)-size.h) : size.h, }; elem.bounds = ctx.position_element(parent, wanted_size); - elem.div.children_bounds = elem.bounds; + elem.div.children_bounds = Rect{}; // update the ctx scissor ctx.div_scissor = elem.bounds; @@ -89,7 +89,7 @@ fn void! Ctx.div_end(&ctx) // FIXME: this causes all elements inside the div to loose focus since the mouse press happens // both inside the element and inside the div bounds //elem.events = ctx.get_elem_events(elem); - + Rect cb = elem.div.pcb; // children bounds bottom-right corner Point cbc = { diff --git a/src/ugui_layout.c3 b/src/ugui_layout.c3 index 01c03bc..3a2ac9a 100644 --- a/src/ugui_layout.c3 +++ b/src/ugui_layout.c3 @@ -52,13 +52,12 @@ fn void! Ctx.layout_next_row(&ctx) Elem *parent = ctx.cache.search(parent_id)!; if (parent.type != ETYPE_DIV) { - // what? return UgError.UNEXPECTED_ELEMENT?; } parent.div.origin_r = Point{ .x = parent.bounds.x, - .y = parent.div.origin_c.y, + .y = parent.div.children_bounds.bottom_right().y, }; parent.div.origin_c = parent.div.origin_r; } @@ -69,12 +68,11 @@ fn void! Ctx.layout_next_column(&ctx) Elem *parent = ctx.cache.search(parent_id)!; if (parent.type != ETYPE_DIV) { - // what? return UgError.UNEXPECTED_ELEMENT?; } parent.div.origin_c = Point{ - .x = parent.div.origin_r.x, + .x = parent.div.children_bounds.bottom_right().x, .y = parent.bounds.y, }; parent.div.origin_r = parent.div.origin_c; @@ -158,7 +156,7 @@ fn Rect Ctx.position_element(&ctx, Elem *parent, Rect rect, bool style = false) // margin, offsets the placement and grows the occupied area child_placement = child_placement.off(margin.position()); child_occupied = child_occupied.grow(margin.position().add(margin.size())); - + // oh yeah also adjust the rect if i was to grow if (adapt_x) rect.w -= padding.x+padding.w + border.x+border.w + margin.x+margin.w; if (adapt_y) rect.h -= padding.y+padding.h + border.y+border.h + margin.y+margin.h; @@ -183,7 +181,7 @@ fn Rect Ctx.position_element(&ctx, Elem *parent, Rect rect, bool style = false) 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; } - // left overflow + // 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; }