Fixed the layout boxes & resize handles anchors & alignemnts
This commit is contained in:
parent
17859a5eb9
commit
31bc207c75
@ -1,23 +0,0 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "code_virtual_view"
|
||||
},
|
||||
{
|
||||
"path": "scripts"
|
||||
},
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"autoHide.autoHidePanel": false,
|
||||
"autoHide.autoHideSideBar": false,
|
||||
"files.associations": {
|
||||
"*.rmd": "markdown",
|
||||
"type_traits": "cpp",
|
||||
"utf8proc.c": "cpp",
|
||||
"xtr1common": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
@ -244,7 +244,7 @@ update :: proc( delta_time : f64 ) -> b32
|
||||
// test_hover_n_click()
|
||||
// test_draggable()
|
||||
// test_text_box()
|
||||
test_parenting( & default_layout, & frame_style_default )
|
||||
// test_parenting( & default_layout, & frame_style_default )
|
||||
// test_whitespace_ast( & default_layout, & frame_style_default )
|
||||
}
|
||||
//endregion Workspace Imgui Tick
|
||||
|
@ -139,24 +139,27 @@ ui_layout_children_vertically :: proc( container : ^UI_Box, direction : UI_Layou
|
||||
return
|
||||
}
|
||||
|
||||
space_used : f32 = 0.0
|
||||
switch direction
|
||||
{
|
||||
case .Bottom_To_Top:
|
||||
for child := container.last; child != nil; child = child.prev {
|
||||
using child.layout
|
||||
child_height := allocate_space(child, total_stretch_ratio, avail_flex_space, container_width)
|
||||
anchor = range2({0,0}, {0, 0})
|
||||
pos.y = -space_used
|
||||
space_used += child_height + child.layout.margins.top + child.layout.margins.bottom
|
||||
}
|
||||
case .Top_To_Bottom:
|
||||
space_used : f32 = 0
|
||||
for child := container.first; child != nil; child = child.next {
|
||||
using child.layout
|
||||
child_height := allocate_space(child, total_stretch_ratio, avail_flex_space, container_width)
|
||||
anchor = range2({0, 0}, {0, 0})
|
||||
pos.y = -space_used
|
||||
space_used += child_height + child.layout.margins.top + child.layout.margins.bottom
|
||||
anchor = range2({0, 1}, {0, 0})
|
||||
alignment = {0, 1}
|
||||
pos.y = space_used
|
||||
space_used -= child_height - child.layout.margins.top - child.layout.margins.bottom
|
||||
}
|
||||
case .Bottom_To_Top:
|
||||
space_used : f32 = 0
|
||||
for child := container.first; child != nil; child = child.next {
|
||||
using child.layout
|
||||
child_height := allocate_space(child, total_stretch_ratio, avail_flex_space, container_width)
|
||||
anchor = range2({0,0}, {0, 0})
|
||||
alignment = {0, 0}
|
||||
pos.y = space_used
|
||||
space_used += child_height - child.layout.margins.top - child.layout.margins.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ test_parenting :: proc( default_layout : ^UI_Layout, frame_style_default : ^UI_S
|
||||
|
||||
child_layout := default_layout ^
|
||||
child_layout.size = range2({ 100, 100 }, { 0, 0 })
|
||||
child_layout.alignment = { 1.0, 1.0 }
|
||||
child_layout.alignment = { 0.0, 0.0 }
|
||||
// child_layout.margins = { 20, 20, 20, 20 }
|
||||
child_layout.padding = { 5, 5, 5, 5 }
|
||||
// child_layout.anchor = range2({ 0.2, 0.1 }, { 0.1, 0.15 })
|
||||
|
@ -329,7 +329,7 @@ ui_resizable_handles :: proc( parent : ^UI_Widget, pos : ^Vec2, size : ^Vec2,
|
||||
handle_left = ui_widget(name("resize_handle_left"), flags )
|
||||
handle_left.layout.anchor.left = 0
|
||||
handle_left.layout.anchor.right = 1
|
||||
handle_left.layout.alignment = {1, 0}
|
||||
handle_left.layout.alignment = { 1, 0 }
|
||||
}
|
||||
if right {
|
||||
handle_right = ui_widget(name("resize_handle_right"), flags )
|
||||
@ -339,32 +339,33 @@ ui_resizable_handles :: proc( parent : ^UI_Widget, pos : ^Vec2, size : ^Vec2,
|
||||
if top {
|
||||
handle_top = ui_widget(name("resize_handle_top"), flags )
|
||||
handle_top.layout.anchor.bottom = 1
|
||||
handle_top.layout.alignment = {0, -1}
|
||||
handle_top.layout.alignment = { 0, 0 }
|
||||
}
|
||||
if bottom {
|
||||
handle_bottom = ui_widget("resize_handle_bottom", flags)
|
||||
handle_bottom.layout.anchor.top = 1
|
||||
handle_bottom.layout.alignment = { 0, 0 }
|
||||
handle_bottom.layout.alignment = { 0, 1 }
|
||||
}
|
||||
theme_handle( theme, {0,0}, {handle_width, handle_width}, {.Fixed_Width, .Fixed_Height} )
|
||||
if corner_tl {
|
||||
handle_corner_tl = ui_widget(name("corner_top_left"), flags)
|
||||
handle_corner_tl.layout.alignment = {1, -1}
|
||||
handle_corner_tl.layout.anchor.bottom = 1
|
||||
handle_corner_tl.layout.alignment = { 1, 0 }
|
||||
}
|
||||
if corner_tr {
|
||||
handle_corner_tr = ui_widget(name("corner_top_right"), flags)
|
||||
handle_corner_tr.layout.anchor = range2({1, 0}, {})
|
||||
handle_corner_tr.layout.alignment = {0, -1}
|
||||
handle_corner_tr.layout.anchor = range2({1, 1}, {})
|
||||
handle_corner_tr.layout.alignment = { 0, 0 }
|
||||
}
|
||||
if corner_bl {
|
||||
handle_corner_bl = ui_widget("corner_bottom_left", flags)
|
||||
handle_corner_bl.layout.anchor = range2({}, {0, 1})
|
||||
handle_corner_bl.layout.alignment = { 1, 0 }
|
||||
handle_corner_bl.layout.alignment = { 1, 1 }
|
||||
}
|
||||
if corner_br {
|
||||
handle_corner_br = ui_widget("corner_bottom_right", flags)
|
||||
handle_corner_br.layout.anchor = range2({1, 0}, {0, 1})
|
||||
handle_corner_br.layout.alignment = {0, 0}
|
||||
handle_corner_br.layout.alignment = { 0, 1 }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user