Began to setup a UI_Window (generalized window widget)

This commit is contained in:
2024-12-30 15:01:37 -05:00
parent 841260849e
commit 495e14194e
7 changed files with 147 additions and 24 deletions

View File

@ -2,11 +2,23 @@ package sectr
UI_LoggerScope :: struct
{
using window : UI_Window,
}
ui_logger_scope :: proc( captures : rawptr = nil ) -> ( should_raise : b32 = false )
ui_logger_scope_builder :: proc( captures : rawptr = nil ) -> ( should_raise : b32 = false )
{
profile("Logger Scope")
logger_scope := cast(^UI_LoggerScope) captures
using logger_scope
scope(theme_window_panel)
dragged, resized, maximized := ui_window_begin( & window, "Logger Scope: Window")
should_raise |= dragged | resized | maximized
return
}
ui_logger_scope_open :: #force_inline proc "contextless" () {
get_state().screen_ui.logger_scope.is_open = true
}

View File

@ -1,12 +1,10 @@
package sectr
UI_ScreenMenuBar :: struct {
pos, size : Vec2,
container : UI_HBox,
settings_btn : struct
{
using widget : UI_Widget,
}
pos, size : Vec2,
container : UI_HBox,
logger_scope_btn : UI_Widget,
settings_btn : UI_Widget
}
UI_ScreenState :: struct
@ -19,6 +17,7 @@ UI_ScreenState :: struct
// docked : UI_Docking,
menu_bar : UI_ScreenMenuBar,
logger_scope : UI_LoggerScope,
settings_menu : UI_SettingsMenu
}
@ -37,6 +36,7 @@ ui_screen_tick :: proc( screen_ui : ^UI_ScreenState ) {
ui_graph_build( screen_ui )
ui_floating_manager( & screen_ui.floating )
ui_floating("Menu Bar", & screen_ui.menu_bar, ui_screen_menu_bar_builder)
ui_floating("Logger Scope", & screen_ui.logger_scope, ui_logger_scope_builder)
ui_floating("Settings Menu", & screen_ui.settings_menu, ui_settings_menu_builder)
}
@ -98,7 +98,12 @@ ui_screen_menu_bar_builder :: proc( captures : rawptr = nil ) -> (should_raise :
scope(theme_app_menu_bar)
container = ui_hbox( .Left_To_Right, "Menu Bar" ); {
using container
layout.flags = {.Fixed_Position_X, .Fixed_Position_Y, .Fixed_Width, .Fixed_Height, .Origin_At_Anchor_Center}
layout.flags = {
.Fixed_Position_X, .Fixed_Position_Y,
// .Min_Size_To_Content_X,
.Fixed_Width, .Fixed_Height,
.Origin_At_Anchor_Center
}
layout.pos = pos
layout.size = range2( size, {})
text = str_intern("menu_bar")
@ -120,10 +125,19 @@ ui_screen_menu_bar_builder :: proc( captures : rawptr = nil ) -> (should_raise :
spacer.layout.flags |= {.Fixed_Width}
spacer.layout.size.min.x = 30
scope(theme_button)
Build_Logger_Scope_Btn: {
using logger_scope_btn
logger_scope_btn = ui_button("Menu Bar: Logger Scope Btn")
text = str_intern("Log Scope")
layout.flags = { .Scale_Width_By_Height_Ratio }
layout.size.ratio.x = 2.0
if pressed do ui_logger_scope_open()
}
Build_Settings_Btn: {
scope(theme_button)
using settings_btn
widget = ui_button("Menu Bar: Settings Btn")
settings_btn = ui_button("Menu Bar: Settings Btn")
text = str_intern("Settings")
layout.flags = { .Scale_Width_By_Height_Ratio }
layout.size.ratio.x = 2.0

View File

@ -23,8 +23,8 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
{
profile("Settings Menu")
settings_menu := cast(^UI_SettingsMenu) captures
if ! settings_menu.is_open do return
app_color := app_color_theme()
using settings_menu
@ -32,7 +32,7 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
if size.y < min_size.y do size.y = min_size.y
scope(theme_window_panel)
container = ui_widget("Settings Menu", {});
container = ui_widget("Settings Menu: Window", {});
setup_container:
{
using container
@ -57,6 +57,7 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
dragged := ui_resizable_handles( & container, & pos, & size)
should_raise |= dragged
// TODO(Ed): This demonstrated a minimum viable-size window to content, however we still need to support a scroll box and switch this window to that.
old_vbox := ui_box_from_key(get_ui_context_mut().prev_cache, ui_key_from_string("Settings Menu: VBox"))
if old_vbox != nil
{
@ -77,7 +78,7 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
vbox := ui_vbox_begin( .Top_To_Bottom, "Settings Menu: VBox", {.Mouse_Clickable}, compute_layout = true )
{
// should_raise |= b32(vbox.active)
should_raise |= b32(vbox.active)
ui_parent(vbox)
Frame_Bar:
@ -124,6 +125,7 @@ ui_settings_menu_builder :: proc( captures : rawptr = nil ) -> ( should_raise :
app_config_closed:
{
dd_app_config.title.layout.font_size = 12
should_raise |= cast(b32) dd_app_config.btn.active
if ! dd_app_config.is_open do break app_config_closed
ui_settings_entry_inputbox :: proc( input_box : ^UI_TextInputBox, is_even : bool, label : string, setting_title : StrRunesPair, input_policy : UI_TextInput_Policy )

View File

@ -285,10 +285,7 @@ get_frametime :: #force_inline proc "contextless" () -> FrameTime { retur
get_default_font :: #force_inline proc "contextless" () -> FontID { return get_state().default_font }
get_input_state :: #force_inline proc "contextless" () -> InputState { return (get_state().input ^) }
get_ui_context_mut :: #force_inline proc "contextless" () -> ^UI_State { return get_state().ui_context }
set_ui_context :: #force_inline proc "contextless" ( ui : ^UI_State ) {
get_state().ui_context = ui
}
get_ui_context_mut :: #force_inline proc "contextless" () -> ^UI_State { return get_state().ui_context }
set_ui_context :: #force_inline proc "contextless" ( ui : ^UI_State ) { get_state().ui_context = ui }
#endregion("State")