Finished initial window implementation
This commit is contained in:
@ -228,9 +228,9 @@ ui_graph_build_end :: proc( ui : ^UI_State )
|
||||
render_queue := array_to_slice(ui.render_queue)
|
||||
for current := root.first; current != nil; current = ui_box_tranverse_next_depth_first( current )
|
||||
{
|
||||
// if ! current.computed.fresh {
|
||||
if ! current.computed.fresh {
|
||||
ui_box_compute_layout( current )
|
||||
// }
|
||||
}
|
||||
|
||||
when UI_Render_Method == .Layers
|
||||
{
|
||||
|
@ -204,7 +204,6 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
}
|
||||
computed.fresh = true && !dont_mark_fresh
|
||||
|
||||
content_size := size_range2(computed.bounds)
|
||||
if .Order_Children_Left_To_Right in layout.flags {
|
||||
ui_layout_children_horizontally( box, .Left_To_Right )
|
||||
}
|
||||
@ -236,7 +235,8 @@ 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_traverse_next_breadth_first( current, )
|
||||
// for current := box.first; current != nil && current.prev != box; current = ui_box_traverse_next_breadth_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
|
||||
|
@ -5,6 +5,8 @@ import lalg "core:math/linalg"
|
||||
|
||||
/*
|
||||
Widget Layout Ops
|
||||
|
||||
TODO(Ed): Review this file, these are can now be done with ui_box_compute_layout
|
||||
*/
|
||||
|
||||
ui_layout_children_horizontally :: proc( container : ^UI_Box, direction : UI_LayoutDirection_X, width_ref : ^f32 = nil )
|
||||
|
@ -288,12 +288,12 @@ test_whitespace_ast :: proc( default_layout : ^UI_Layout, frame_style_default :
|
||||
if len(line_hbox.text.str) > 0 {
|
||||
array_append( widgets_ptr, line_hbox )
|
||||
text_layout.pos.x = text_layout.pos.x
|
||||
text_layout.pos.y += size_range2(line_hbox.computed.bounds).y
|
||||
text_layout.pos.y -= size_range2(line_hbox.computed.bounds).y
|
||||
}
|
||||
else {
|
||||
widget := & widgets.data[ widgets.num - 1 ]
|
||||
if widget.box != nil {
|
||||
text_layout.pos.y += size_range2( widget.computed.bounds ).y
|
||||
text_layout.pos.y -= size_range2( widget.computed.bounds ).y
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ ui_drop_down :: proc( drop_down : ^UI_DropDown, label : string, title_text : Str
|
||||
direction := UI_LayoutDirection_Y.Top_To_Bottom,
|
||||
btn_flags := UI_BoxFlags{},
|
||||
vb_flags := UI_BoxFlags{},
|
||||
vb_compute_layout := true,
|
||||
vb_compute_layout := false,
|
||||
btn_theme : ^UI_Theme = nil,
|
||||
title_theme : ^UI_Theme = nil,
|
||||
vb_parent : ^UI_Box = nil,
|
||||
@ -125,6 +125,8 @@ fixed size or "scale by ratio" flags are not used for the width.
|
||||
The hbox will use the anchor's (range2) ratio.x value to determine the "stretch ratio".
|
||||
|
||||
Keep in mind the stretch ratio is only respected if no size.min.x value is violated for each of the widgets.
|
||||
|
||||
TODO(Ed): We may no longer need to manually handle early compute_layout or direct calls to ui_layout_children_horizontally
|
||||
*/
|
||||
|
||||
UI_HBox :: struct {
|
||||
@ -151,7 +153,7 @@ ui_hbox_begin :: proc( direction : UI_LayoutDirection_X, label : string, flags :
|
||||
ui_hbox_end :: proc( hbox : UI_HBox, width_ref : ^f32 = nil, compute_layout := false )
|
||||
{
|
||||
// profile(#procedure)
|
||||
// if compute_layout do ui_box_compute_layout(hbox.box, dont_mark_fresh = true)
|
||||
if compute_layout do ui_box_compute_layout(hbox.box, dont_mark_fresh = true)
|
||||
// ui_layout_children_horizontally( hbox.box, hbox.direction, width_ref )
|
||||
}
|
||||
|
||||
@ -757,6 +759,8 @@ fixed size or "scale by ratio" flags are not used for the width.
|
||||
The hbox will use the anchor's (range2) ratio.y value to determine the "stretch ratio".
|
||||
|
||||
Keep in mind the stretch ratio is only respected if no size.min.y value is violated for each of the widgets.
|
||||
|
||||
TODO(Ed): We may no longer need to manually handle early compute_layout or direct calls to ui_layout_children_horizontally
|
||||
*/
|
||||
|
||||
UI_VBox :: struct {
|
||||
@ -769,7 +773,7 @@ ui_vbox_begin :: proc( direction : UI_LayoutDirection_Y, label : string, flags :
|
||||
vbox.direction = direction
|
||||
vbox.box = ui_box_make( flags, label )
|
||||
vbox.signal = ui_signal_from_box( vbox.box )
|
||||
// if compute_layout do ui_box_compute_layout(vbox, dont_mark_fresh = true)
|
||||
if compute_layout do ui_box_compute_layout(vbox, dont_mark_fresh = true)
|
||||
switch direction {
|
||||
case .Top_To_Bottom:
|
||||
vbox.layout.flags |= { .Order_Children_Top_To_Bottom }
|
||||
@ -782,7 +786,7 @@ ui_vbox_begin :: proc( direction : UI_LayoutDirection_Y, label : string, flags :
|
||||
// Auto-layout children
|
||||
ui_vbox_end :: proc( vbox : UI_VBox, height_ref : ^f32 = nil, compute_layout := false ) {
|
||||
// profile(#procedure)
|
||||
// if compute_layout do ui_box_compute_layout(vbox, dont_mark_fresh = true)
|
||||
if compute_layout do ui_box_compute_layout(vbox, dont_mark_fresh = true)
|
||||
// ui_layout_children_vertically( vbox.box, vbox.direction, height_ref )
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,9 @@ package sectr
|
||||
UI_Window :: struct
|
||||
{
|
||||
frame : UI_Widget,
|
||||
vb : UI_VBox,
|
||||
bar : UI_HBox,
|
||||
children_box : struct #raw_union {
|
||||
box : UI_Widget,
|
||||
hbox : UI_HBox,
|
||||
vbox : UI_VBox,
|
||||
},
|
||||
children_box : UI_Widget,
|
||||
tile_text : UI_Widget,
|
||||
maximize_btn : UI_Widget,
|
||||
close_btn : UI_Widget,
|
||||
@ -58,47 +55,52 @@ ui_window_begin :: proc( window : ^UI_Window, label : string,
|
||||
if size.x < min_size.x do size.x = min_size.x
|
||||
if size.y < min_size.y do size.y = min_size.y
|
||||
|
||||
scope(theme_window_panel)
|
||||
frame = ui_widget(label, {})
|
||||
using frame
|
||||
ui_parent(frame)
|
||||
|
||||
if ! is_maximized
|
||||
{
|
||||
layout.flags = {
|
||||
.Fixed_Width, .Fixed_Height,
|
||||
frame.layout.flags = {
|
||||
.Fixed_Width, .Fixed_Height,
|
||||
.Fixed_Position_X, .Fixed_Position_Y,
|
||||
.Origin_At_Anchor_Center
|
||||
.Origin_At_Anchor_Center,
|
||||
// .Order_Children_Top_To_Bottom,
|
||||
}
|
||||
layout.pos = position
|
||||
layout.size = range2( size, {})
|
||||
frame.layout.pos = position
|
||||
frame.layout.size = range2( size, {})
|
||||
}
|
||||
else
|
||||
{
|
||||
layout.flags = {.Origin_At_Anchor_Center }
|
||||
layout.pos = {}
|
||||
frame.layout.flags = {.Origin_At_Anchor_Center }
|
||||
frame.layout.pos = {}
|
||||
}
|
||||
|
||||
if resizable {
|
||||
resized = ui_resizable_handles( & frame, & position, & size)
|
||||
}
|
||||
|
||||
scope(theme_transparent)
|
||||
vb = ui_vbox(.Top_To_Bottom, str_fmt_tmp("%s.vb", label))
|
||||
|
||||
if len(title.str) > 0 || closable || maximizable || draggable {
|
||||
dragged, maximized, closed = ui_window_bar(window, title, closable, maximizable, draggable)
|
||||
}
|
||||
|
||||
// child_bounds = bar.computed.bounds =
|
||||
// child_position
|
||||
|
||||
children_box = ui_widget(str_fmt_tmp("%v.children_box", label), {})
|
||||
switch child_layout
|
||||
{
|
||||
case .None:
|
||||
|
||||
|
||||
case .Left_To_Right:
|
||||
children_box.layout.flags |= {.Order_Children_Left_To_Right}
|
||||
case .Right_to_Left:
|
||||
children_box.layout.flags |= {.Order_Children_Right_To_Left}
|
||||
case .Top_To_Bottom:
|
||||
children_box.layout.flags |= {.Order_Children_Top_To_Bottom}
|
||||
case .Bottom_To_Top:
|
||||
children_box.layout.flags |= {.Order_Children_Bottom_To_Top}
|
||||
case .None:
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -130,13 +132,13 @@ ui_window_bar :: proc( window : ^UI_Window,
|
||||
draggable_flag : UI_BoxFlags = draggable ? {.Mouse_Clickable} : {}
|
||||
|
||||
scope(theme_window_bar)
|
||||
bar = ui_hbox(.Left_To_Right, str_intern_fmt("%v.bar", frame.label). str, draggable_flag);
|
||||
bar = ui_hbox(.Left_To_Right, str_fmt_tmp("%s.bar", frame.label.str), draggable_flag);
|
||||
ui_parent(bar)
|
||||
|
||||
if len(title.str) > 0
|
||||
{
|
||||
scope(theme_text)
|
||||
tile_text = ui_text( str_intern_fmt("%v.title_text", bar.label).str, title, {.Disabled}); {
|
||||
tile_text = ui_text( str_fmt_tmp("%s.title_text", bar.label.str), title, {.Disabled}); {
|
||||
using tile_text
|
||||
layout.anchor.ratio.x = 1.0
|
||||
layout.margins = { 0, 0, 15, 0}
|
||||
@ -147,7 +149,7 @@ ui_window_bar :: proc( window : ^UI_Window,
|
||||
scope(theme_window_bar_btn)
|
||||
if maximizable
|
||||
{
|
||||
maximize_btn = ui_button( str_intern_fmt("%v.maximize_btn", bar.label).str ); {
|
||||
maximize_btn = ui_button( str_fmt_tmp("%v.maximize_btn", bar.label.str) ); {
|
||||
using maximize_btn
|
||||
if maximize_btn.pressed {
|
||||
is_maximized = ~is_maximized
|
||||
@ -159,7 +161,7 @@ ui_window_bar :: proc( window : ^UI_Window,
|
||||
}
|
||||
if closable
|
||||
{
|
||||
close_btn = ui_button( str_intern_fmt("%v.close_btn", bar.label).str ); {
|
||||
close_btn = ui_button( str_fmt_tmp("%v.close_btn", bar.label) ); {
|
||||
using close_btn
|
||||
text = str_intern("close")
|
||||
if close_btn.hot do style.bg_color = app_color_theme().window_btn_close_bg_hot
|
||||
|
Reference in New Issue
Block a user