attempt to fix UI fill/childrensum behavior
parent
b52a2c38fe
commit
895a269bce
|
@ -10,6 +10,7 @@ function M.open_file_search_window()
|
|||
}
|
||||
|
||||
Editor.spawn_floating_window(input, function(ctx)
|
||||
UI.push_parent(ctx, UI.push_rect(ctx, "window", true, true, UI.Vertical, UI.Fill, UI.ChildrenSum))
|
||||
UI.label(ctx, "eventually this will be a window where you can search through a bunch of files 1")
|
||||
UI.label(ctx, "eventually this will be a window where you can search through a bunch of files 2")
|
||||
UI.label(ctx, "eventually this will be a window where you can search through a bunch of files 3")
|
||||
|
@ -17,6 +18,7 @@ function M.open_file_search_window()
|
|||
UI.label(ctx, "eventually this will be a window where you can search through a bunch of files 5")
|
||||
UI.label(ctx, "eventually this will be a window where you can search through a bunch of files 6")
|
||||
UI.label(ctx, "eventually this will be a window where you can search through a bunch of files 7")
|
||||
UI.pop_parent(ctx)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
|
@ -1363,12 +1363,12 @@ main :: proc() {
|
|||
{
|
||||
ui.spacer(&ui_context, "left spacer")
|
||||
|
||||
halfway, _ := ui.push_rect(&ui_context, "halfway centered", false, false, .Vertical, {ui.SemanticSize{kind = .ChildrenSum}, ui.SemanticSize{kind = .Fill}})
|
||||
halfway, _ := ui.push_rect(&ui_context, "halfway centered", false, true, .Vertical, {ui.SemanticSize{kind = .ChildrenSum}, ui.SemanticSize{kind = .Fill}})
|
||||
ui.push_parent(&ui_context, halfway)
|
||||
{
|
||||
ui.spacer(&ui_context, "top spacer")
|
||||
|
||||
centered_container, _ := ui.push_rect(&ui_context, "centered container", true, true, .Horizontal, {ui.SemanticSize{kind = .ChildrenSum, value=state.screen_width-32}, ui.SemanticSize{kind = .ChildrenSum, value = state.screen_height-32}})
|
||||
centered_container, _ := ui.push_rect(&ui_context, "centered container", false, false, .Horizontal, {ui.SemanticSize{kind = .Fill}, ui.SemanticSize{kind = .ChildrenSum}})
|
||||
ui.push_parent(&ui_context, centered_container)
|
||||
{
|
||||
lua.run_ui_function(&state, &ui_context, window.lua_draw_proc);
|
||||
|
|
|
@ -98,6 +98,7 @@ Box :: struct {
|
|||
axis: Axis,
|
||||
semantic_size: [2]SemanticSize,
|
||||
computed_size: [2]int,
|
||||
computed_child_size: [2]int,
|
||||
computed_pos: [2]int,
|
||||
|
||||
scroll_offset: int,
|
||||
|
@ -444,7 +445,7 @@ compute_layout :: proc(ctx: ^Context, canvas_size: [2]int, font_width: int, font
|
|||
}
|
||||
}
|
||||
|
||||
if compute_children {
|
||||
if true || compute_children {
|
||||
iter := BoxIter { box.first, 0 };
|
||||
child_size: [2]int = {0,0};
|
||||
|
||||
|
@ -456,6 +457,15 @@ compute_layout :: proc(ctx: ^Context, canvas_size: [2]int, font_width: int, font
|
|||
number_of_fills[box.axis] = 0;
|
||||
|
||||
our_size := box.computed_size;
|
||||
for axis in 0..<2 {
|
||||
if box.semantic_size[axis].kind == .ChildrenSum {
|
||||
if box.computed_size[axis] == 0 {
|
||||
our_size[axis] = ancestor_size(ctx, box, Axis(axis))
|
||||
} else {
|
||||
our_size[axis] = box.computed_child_size[axis]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for child in iterate_box(&iter) {
|
||||
if .Floating in child.flags { continue; }
|
||||
|
@ -482,8 +492,8 @@ compute_layout :: proc(ctx: ^Context, canvas_size: [2]int, font_width: int, font
|
|||
}
|
||||
}
|
||||
|
||||
if post_compute_size[Axis.Horizontal] {
|
||||
box.computed_size[Axis.Horizontal] = 0;
|
||||
{
|
||||
box.computed_child_size[Axis.Horizontal] = 0;
|
||||
|
||||
iter := BoxIter { box.first, 0 };
|
||||
for child in iterate_box(&iter) {
|
||||
|
@ -491,18 +501,22 @@ compute_layout :: proc(ctx: ^Context, canvas_size: [2]int, font_width: int, font
|
|||
|
||||
switch box.axis {
|
||||
case .Horizontal: {
|
||||
box.computed_size[Axis.Horizontal] += child.computed_size[Axis.Horizontal];
|
||||
box.computed_child_size[Axis.Horizontal] += child.computed_size[Axis.Horizontal];
|
||||
}
|
||||
case .Vertical: {
|
||||
if child.computed_size[Axis.Horizontal] > box.computed_size[Axis.Horizontal] {
|
||||
box.computed_size[Axis.Horizontal] = child.computed_size[Axis.Horizontal];
|
||||
if child.computed_size[Axis.Horizontal] > box.computed_child_size[Axis.Horizontal] {
|
||||
box.computed_child_size[Axis.Horizontal] = child.computed_size[Axis.Horizontal];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if post_compute_size[Axis.Vertical] {
|
||||
box.computed_size[Axis.Vertical] = 0;
|
||||
if post_compute_size[Axis.Horizontal] {
|
||||
box.computed_size[Axis.Horizontal] = box.computed_child_size[Axis.Horizontal];
|
||||
}
|
||||
|
||||
{
|
||||
box.computed_child_size[Axis.Vertical] = 0;
|
||||
|
||||
iter := BoxIter { box.first, 0 };
|
||||
for child in iterate_box(&iter) {
|
||||
|
@ -510,16 +524,19 @@ compute_layout :: proc(ctx: ^Context, canvas_size: [2]int, font_width: int, font
|
|||
|
||||
switch box.axis {
|
||||
case .Horizontal: {
|
||||
if child.computed_size[Axis.Vertical] > box.computed_size[Axis.Vertical] {
|
||||
box.computed_size[Axis.Vertical] = child.computed_size[Axis.Vertical];
|
||||
if child.computed_size[Axis.Vertical] > box.computed_child_size[Axis.Vertical] {
|
||||
box.computed_child_size[Axis.Vertical] = child.computed_size[Axis.Vertical];
|
||||
}
|
||||
}
|
||||
case .Vertical: {
|
||||
box.computed_size[Axis.Vertical] += child.computed_size[Axis.Vertical];
|
||||
box.computed_child_size[Axis.Vertical] += child.computed_size[Axis.Vertical];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if post_compute_size[Axis.Vertical] {
|
||||
box.computed_size[Axis.Vertical] = box.computed_child_size[Axis.Vertical];
|
||||
}
|
||||
}
|
||||
|
||||
push_clip :: proc(ctx: ^Context, pos: [2]int, size: [2]int, inside_parent: bool = true) {
|
||||
|
|
Loading…
Reference in New Issue