Auto layout bug fix
This commit is contained in:
parent
ca0a8e6e59
commit
1e00b977d4
1 changed files with 32 additions and 8 deletions
38
ui.odin
38
ui.odin
|
|
@ -117,11 +117,21 @@ container_end :: proc() {
|
||||||
container_index := pop(&ctx.containers)
|
container_index := pop(&ctx.containers)
|
||||||
container := &ctx.elements[container_index]
|
container := &ctx.elements[container_index]
|
||||||
pop(&ctx.container_last_element)
|
pop(&ctx.container_last_element)
|
||||||
if _, width_is_auto := container.dimensions.width.(Size_Auto); width_is_auto {
|
|
||||||
container.area.width = rect_get_br(get_element_outer_area(_element_previous()^)).x - container.area.x
|
_, width_is_auto := container.dimensions.width.(Size_Auto)
|
||||||
|
_, height_is_auto := container.dimensions.height.(Size_Auto)
|
||||||
|
if width_is_auto || height_is_auto {
|
||||||
|
br := v2{min(f32), min(f32)}
|
||||||
|
for element in ctx.elements[container_index:] {
|
||||||
|
element_br := rect_get_br(get_element_outer_area(element))
|
||||||
|
br = {max(br.x, element_br.x), max(br.y, element_br.y)}
|
||||||
|
}
|
||||||
|
if width_is_auto {
|
||||||
|
container.area.width = br.x - container.area.x
|
||||||
|
}
|
||||||
|
if height_is_auto {
|
||||||
|
container.area.height = br.y - container.area.y
|
||||||
}
|
}
|
||||||
if _, height_is_auto := container.dimensions.height.(Size_Auto); height_is_auto {
|
|
||||||
container.area.height = rect_get_br(get_element_outer_area(_element_previous()^)).y - container.area.y
|
|
||||||
}
|
}
|
||||||
ctx.same_line = false
|
ctx.same_line = false
|
||||||
}
|
}
|
||||||
|
|
@ -141,19 +151,33 @@ assert_no_dimensions_percentage_in_auto_container :: proc(dimensions: Dimensions
|
||||||
button :: proc(dimensions: Dimensions, config: ElementConfiguration) -> ^Element {
|
button :: proc(dimensions: Dimensions, config: ElementConfiguration) -> ^Element {
|
||||||
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
||||||
area := _resolve_element_area(dimensions, config.margin)
|
area := _resolve_element_area(dimensions, config.margin)
|
||||||
return _append_element({area = area, config = config, type = .Button, dimensions = dimensions})
|
return _append_element({
|
||||||
|
area = area,
|
||||||
|
config = config,
|
||||||
|
type = .Button,
|
||||||
|
dimensions = dimensions})
|
||||||
}
|
}
|
||||||
|
|
||||||
slider :: proc(dimensions: Dimensions, config: ElementConfiguration, data: ElementData_FloatInput) -> ^Element {
|
slider :: proc(dimensions: Dimensions, config: ElementConfiguration, data: ElementData_FloatInput) -> ^Element {
|
||||||
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
||||||
area := _resolve_element_area(dimensions, config.margin)
|
area := _resolve_element_area(dimensions, config.margin)
|
||||||
return _append_element({area = area, config = config, type = .Slider, data = {float_input_data = data}, dimensions = dimensions})
|
return _append_element({
|
||||||
|
area = area,
|
||||||
|
config = config,
|
||||||
|
type = .Slider,
|
||||||
|
data = {float_input_data = data},
|
||||||
|
dimensions = dimensions})
|
||||||
}
|
}
|
||||||
|
|
||||||
input_float :: proc(dimensions: Dimensions, config: ElementConfiguration, data: ElementData_FloatInput) -> ^Element {
|
input_float :: proc(dimensions: Dimensions, config: ElementConfiguration, data: ElementData_FloatInput) -> ^Element {
|
||||||
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
||||||
area := _resolve_element_area(dimensions, config.margin)
|
area := _resolve_element_area(dimensions, config.margin)
|
||||||
return _append_element({area = area, config = config, type = .InputFloat, data = {float_input_data = data}, dimensions = dimensions})
|
return _append_element({
|
||||||
|
area = area,
|
||||||
|
config = config,
|
||||||
|
type = .InputFloat,
|
||||||
|
data = {float_input_data = data},
|
||||||
|
dimensions = dimensions})
|
||||||
}
|
}
|
||||||
|
|
||||||
get_element_outer_area :: proc(element: Element) -> rect2 {
|
get_element_outer_area :: proc(element: Element) -> rect2 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue