Hopefully last design change to auto-layout algorithim
I'm sticking with not supporting the top-left alignment for default and instead going with bottom left. This allows for 0,0 alignment to the "bottom left pivot" for a box and 1,1 to the "top-right pivot" of a box. These naturally coincide with where the actual min-max points that define the box are for the coodrindate convention I decided to go with. I'll write docs to migitate confusion. Now I just need to fix the layout presets I have for the currently existing constructions...
This commit is contained in:
parent
e5be246d30
commit
17859a5eb9
24253
Sectr.sublime-workspace
24253
Sectr.sublime-workspace
File diff suppressed because one or more lines are too long
@ -98,11 +98,11 @@ App_Thm_Dark :: AppColorTheme {
|
||||
|
||||
translucent_panel = Color { 30, 30, 30, 50},
|
||||
|
||||
window_bar_border = Color{74, 74, 74, 255}, // border_default
|
||||
window_bar_border = Color{74, 74, 74, 255},
|
||||
window_bar_bg = Color{32, 32, 32, 255},
|
||||
window_btn_close_bg_hot = Color{65, 45, 45, 255},
|
||||
|
||||
window_panel_bg = Color{ 20, 20, 20, 50}, // translucent_panel
|
||||
window_panel_bg = Color{ 20, 20, 20, 50},
|
||||
window_panel_border = Color{ 84, 84, 84, 255},
|
||||
}
|
||||
|
||||
|
@ -338,9 +338,9 @@ tick :: proc( host_delta_time : f64, host_delta_ns : Duration ) -> b32
|
||||
debug.draw_UI_padding_bounds = false
|
||||
debug.draw_ui_content_bounds = false
|
||||
|
||||
// config.color_theme = App_Thm_Light
|
||||
config.color_theme = App_Thm_Light
|
||||
// config.color_theme = App_Thm_Dusk
|
||||
config.color_theme = App_Thm_Dark
|
||||
// config.color_theme = App_Thm_Dark
|
||||
should_close = update( host_delta_time )
|
||||
render()
|
||||
|
||||
|
@ -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
|
||||
|
@ -4,4 +4,7 @@ Eventually want to generalize this core UI as its own library.
|
||||
This will keep track of here whats needed for it to work wihtout the rest of this codebase.
|
||||
|
||||
* Provide UI input state or "events" in its own data stucture at the beginning of `ui_build_graph`:
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
TODO(Ed): I'm not sure what to make the default coordinate space for this widget
|
@ -88,7 +88,7 @@ UI_LayoutFlag :: enum u32 {
|
||||
Scale_Height_By_Width_Ratio,
|
||||
|
||||
// Sets the (0, 0) position of the child box to the parents anchor's center (post-margins bounds)
|
||||
// By Default, the origin is at the top left of the anchor's bounds
|
||||
// By Default, the origin is at the top left of the anchor's bounds (traditional)
|
||||
Origin_At_Anchor_Center,
|
||||
|
||||
// TODO(Ed): Implement this!
|
||||
|
@ -106,11 +106,11 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
|
||||
// 5. Determine relative position
|
||||
|
||||
origin_center := margined_bounds_origin
|
||||
origin_top_left := Vec2 { margined_bounds.min.x, margined_bounds.max.y }
|
||||
|
||||
origin := .Origin_At_Anchor_Center in layout.flags ? origin_center : origin_top_left
|
||||
origin_center := margined_bounds_origin
|
||||
origin_top_left := Vec2 { margined_bounds.min.x, margined_bounds.max.y }
|
||||
origin_bottom_left := Vec2 { margined_bounds.min.x, margined_bounds.min.y }
|
||||
|
||||
origin := .Origin_At_Anchor_Center in layout.flags ? origin_center : origin_bottom_left
|
||||
rel_pos := origin + layout.pos
|
||||
|
||||
if .Fixed_Position_X in layout.flags {
|
||||
@ -127,11 +127,10 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
alignment := layout.alignment
|
||||
bounds : Range2
|
||||
if ! (.Origin_At_Anchor_Center in layout.flags) {
|
||||
// The convention offset adjust the box so that the top-left point is at the top left of the anchor's bounds
|
||||
tl_convention_offset := adjusted_size * {0, -1}
|
||||
// alignment *= -1 // Inversing so that it goes toward top-right.
|
||||
bounds = range2(
|
||||
rel_pos - adjusted_size * alignment + tl_convention_offset,
|
||||
rel_pos + adjusted_size * (vec2_one - alignment) + tl_convention_offset,
|
||||
rel_pos - adjusted_size * alignment ,
|
||||
rel_pos + adjusted_size * (vec2_one - alignment),
|
||||
)
|
||||
}
|
||||
else {
|
||||
@ -184,4 +183,3 @@ ui_box_compute_layout_children :: proc( box : ^UI_Box )
|
||||
ui_box_compute_layout( current )
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ test_parenting :: proc( default_layout : ^UI_Layout, frame_style_default : ^UI_S
|
||||
parent_layout.size = range2( { 300, 300 }, {} )
|
||||
parent_layout.alignment = { 0.0, 0.0 }
|
||||
// parent_layout.margins = { 100, 100, 100, 100 }
|
||||
parent_layout.padding = { 5, 10, 5, 5 }
|
||||
// parent_layout.padding = { 5, 10, 5, 5 }
|
||||
parent_layout.pos = { 0, 0 }
|
||||
parent_layout.flags = {
|
||||
.Fixed_Position_X, .Fixed_Position_Y,
|
||||
@ -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, 0.0 }
|
||||
child_layout.alignment = { 1.0, 1.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 })
|
||||
|
Loading…
Reference in New Issue
Block a user