saving a mess of stuff with auto-layout before updating with new mess

This commit is contained in:
2024-03-14 00:00:22 -04:00
parent 159aedb592
commit 0627794e28
10 changed files with 284 additions and 106 deletions

View File

@ -207,9 +207,10 @@ update :: proc( delta_time : f64 ) -> b32
anchor = {},
alignment = { 0.0, 0.0 },
text_alignment = { 0.0, 0.0 },
corner_radii = { 0.2, 0.2, 0.2, 0.2 },
// corner_radii = { 0.2, 0.2, 0.2, 0.2 },
pos = { 0, 0 },
size = { 200, 200 },
size = range2( { 1000, 1000 }, {}),
// padding = { 20, 20, 20, 20 }
}
frame_style_default := UI_Style {
@ -230,8 +231,8 @@ update :: proc( delta_time : f64 ) -> b32
frame_style_default,
}}
frame_theme.disabled.bg_color = Color_Frame_Disabled
frame_theme.hot.bg_color = Color_Frame_Hover
frame_theme.active.bg_color = Color_Frame_Select
// frame_theme.hot.bg_color = Color_Frame_Hover
frame_theme.active.bg_color = Color_Frame_Select
ui_style_theme( frame_theme )
config.ui_resize_border_width = 2.5
@ -241,42 +242,72 @@ update :: proc( delta_time : f64 ) -> b32
// test_parenting()
if true
{
frame := ui_widget( "Frame", {} )
ui_parent(frame)
parent_layout := default_layout
parent_layout.size = { 300, 300 }
parent_layout.size = range2( { 300, 300 }, {} )
parent_layout.alignment = { 0.0, 0.0 }
parent_layout.padding = {}
parent_layout.pos = { 0, 0 }
parent_theme := frame_style_default
parent_theme.layout = parent_layout
parent_theme.flags = {
.Fixed_Width, .Fixed_Height,
}
ui_theme_via_style(parent_theme)
ui_style_theme_set_layout( parent_layout )
parent := ui_widget( "Parent", { .Mouse_Clickable })
parent := ui_widget( "Parent", { .Mouse_Clickable, .Mouse_Resizable })
ui_parent(parent)
{
if parent.first_frame {
debug.draggable_box_pos = parent.style.layout.pos + { 0, -100 }
debug.draggable_box_size = parent.style.layout.size
debug.draggable_box_pos = parent.style.layout.pos + { 0, 0 }
debug.draggable_box_size = parent.style.layout.size.min
}
if parent.dragging {
debug.draggable_box_pos += mouse_world_delta()
}
if parent.resizing
{
og_layout := ui_context.active_start_style.layout
center := debug.draggable_box_pos
original_distance := linalg.distance(ui.active_start_signal.cursor_pos, center)
cursor_distance := linalg.distance(parent.cursor_pos, center)
scale_factor := cursor_distance * (1 / original_distance)
debug.draggable_box_size = og_layout.size.min * scale_factor
}
if (ui.hot == parent.key) && (ui.hot_resizable || ui.active_start_signal.resizing) {
parent.style.bg_color = Color_Blue
}
parent.style.layout.pos = debug.draggable_box_pos
parent.style.layout.size.min = debug.draggable_box_size
}
child_layout := default_layout
child_layout.size = { 100, 100 }
child_layout.alignment = { 0.5, 0.5 }
child_layout.margins = { 20, 20, 20, 20 }
child_layout.anchor = range2( { 0.5, 0.5 }, { 0.5, 0.5 })
child_layout.size = range2({ 50, 50 }, { 200, 200 })
child_layout.alignment = { 0.0, 0.0 }
child_layout.margins = { 00, 00, 00, 00 }
child_layout.padding = {}
child_layout.anchor = range2({ 0.0, 0.0 }, { 0.0, 0.0 })
child_layout.pos = { 0, 0 }
child_theme := frame_style_default
// child_theme.flags = {}
child_theme.flags = {
// .Fixed_Width, .Fixed_Height,
}
child_theme.layout = child_layout
ui_theme_via_style(child_theme)
child := ui_widget( "Child", { .Mouse_Clickable })
}
// Whitespace AST test
if true
if false
{
profile("Whitespace AST test")
@ -292,10 +323,10 @@ update :: proc( delta_time : f64 ) -> b32
text_style,
text_style,
}}
text_theme.default.bg_color = Color_Transparent
text_theme.default.bg_color = Color_Transparent
text_theme.disabled.bg_color = Color_Frame_Disabled
text_theme.hot.bg_color = Color_Frame_Hover
text_theme.active.bg_color = Color_Frame_Select
text_theme.hot.bg_color = Color_Frame_Hover
text_theme.active.bg_color = Color_Frame_Select
layout_text := default_layout