Fix to ui_box_tranverse_next_depth_first not taking into account a parent limit
For non-root traversal
This commit is contained in:
parent
495e14194e
commit
68b712acc6
@ -118,7 +118,8 @@ ui_prev_cached_box :: #force_inline proc( box : ^UI_Box ) -> ^UI_Box { return hm
|
||||
|
||||
// TODO(Ed): Rename to ui_box_tranverse_view_next
|
||||
// Traveral pritorizes immeidate children
|
||||
ui_box_tranverse_next_depth_first :: #force_inline proc "contextless" (box: ^UI_Box, bypass_intersection_test := false, ctx: ^UI_State = nil) -> ^UI_Box {
|
||||
ui_box_tranverse_next_depth_first :: #force_inline proc "contextless" (box : ^UI_Box, parent_limit : ^UI_Box = nil, bypass_intersection_test := false, ctx: ^UI_State = nil) -> ^UI_Box
|
||||
{
|
||||
state := get_state(); using state
|
||||
ctx := ctx if ctx != nil else ui_context
|
||||
|
||||
@ -136,11 +137,18 @@ ui_box_tranverse_next_depth_first :: #force_inline proc "contextless" (box: ^UI_
|
||||
|
||||
// No more siblings, traverse up the tree
|
||||
parent := box.parent
|
||||
for parent != nil {
|
||||
if parent.next != nil {
|
||||
return parent.next
|
||||
}
|
||||
parent = parent.parent
|
||||
for parent != nil
|
||||
{
|
||||
if parent_limit != nil && parent_limit == parent {
|
||||
// We've reached the end of the parent_limit's tree.
|
||||
return nil
|
||||
}
|
||||
|
||||
if parent.next != nil {
|
||||
return parent.next
|
||||
}
|
||||
|
||||
parent = parent.parent
|
||||
}
|
||||
|
||||
// We've reached the end of the tree
|
||||
|
@ -124,11 +124,11 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
}
|
||||
if .Min_Size_To_Content_Y in layout.flags {
|
||||
children_bounds := ui_compute_children_overall_bounds(box)
|
||||
resolved_bounds := range2(
|
||||
children_bounds.min - { layout.padding.left, layout.padding.bottom } - border_offset,
|
||||
children_bounds.max + { layout.padding.right, layout.padding.top } + border_offset,
|
||||
)
|
||||
adjusted_size.y = size_range2(resolved_bounds).y
|
||||
// resolved_bounds := range2(
|
||||
// children_bounds.min - { layout.padding.left, layout.padding.bottom } - border_offset,
|
||||
// children_bounds.max + { layout.padding.right, layout.padding.top } + border_offset,
|
||||
// )
|
||||
adjusted_size.y = size_range2(children_bounds).y
|
||||
}
|
||||
|
||||
// 5. Determine relative position
|
||||
@ -207,7 +207,7 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
|
||||
ui_compute_children_overall_bounds :: proc ( box : ^UI_Box ) -> ( children_bounds : Range2 )
|
||||
{
|
||||
for current := box.first; current != nil && current.prev != box; current = ui_box_tranverse_next_depth_first( current )
|
||||
for current := box.first; current != nil && current.prev != box; current = ui_box_tranverse_next_depth_first( current, parent_limit = box )
|
||||
{
|
||||
if current == box do return
|
||||
if ! current.computed.fresh do ui_box_compute_layout( current )
|
||||
@ -222,7 +222,7 @@ ui_compute_children_overall_bounds :: proc ( box : ^UI_Box ) -> ( children_bound
|
||||
|
||||
ui_box_compute_layout_children :: proc( box : ^UI_Box )
|
||||
{
|
||||
for current := box.first; current != nil && current.prev != box; current = ui_box_tranverse_next_depth_first( current )
|
||||
for current := box.first; current != nil && current.prev != box; current = ui_box_tranverse_next_depth_first( current, parent_limit = box )
|
||||
{
|
||||
if current == box do return
|
||||
if current.computed.fresh do continue
|
||||
|
Loading…
Reference in New Issue
Block a user