MAYBE correct layout with next_row and next_column
This commit is contained in:
parent
92614e4d8b
commit
c53b9eed5e
12
src/main.c3
12
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()!!;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user