Cleanup and setup of drop down widget

Got an initial variant of the drop down widget, not completely set on it..
I put some more time to figuring out how I'm going to be ideomatically constructing the widgets. screen.odin I think its getting pretty close to what it will be like.
I'm ready to start lifting the input box. I'll be adding the constraints when I lift it.

Added the option to toggle the debug text in screenspace
Added the fixes from the ui_layout_children_horizontally for margins to ui_layout_children_vertically

Known issue:
There is a bug with test_whitespace that forced me todo a null check on a box. Not sure why.
It needs to be redone anyway.. (compose it with the h/vboxes instead)

There is some sublime files added in, started to use it.
This commit is contained in:
2024-05-20 22:05:52 -04:00
parent cdfc3d65bb
commit e5be246d30
23 changed files with 23871 additions and 411 deletions

View File

@ -124,7 +124,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
cam_zoom_sensitivity_digital = 0.2
cam_zoom_sensitivity_smooth = 4.0
engine_refresh_hz = 30
engine_refresh_hz = 0
timing_fps_moving_avg_alpha = 0.9
@ -162,7 +162,10 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
// Determining current monitor and setting the target frametime based on it..
monitor_id = rl.GetCurrentMonitor()
monitor_refresh_hz = rl.GetMonitorRefreshRate( monitor_id )
log( str_fmt_tmp( "Set target FPS to: %v", monitor_refresh_hz ) )
if config.engine_refresh_hz == 0 {
config.engine_refresh_hz = uint(monitor_refresh_hz)
}
}
// Basic Font Setup
@ -188,7 +191,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
using screen_ui
menu_bar.pos = { -60, 0 }
// menu_bar.pos = Vec2(app_window.extent) * { -1, 1 }
menu_bar.size = {200, 40}
menu_bar.size = {140, 40}
settings_menu.min_size = {250, 200}
}
@ -335,8 +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
should_close = update( host_delta_time )
render()

View File

@ -117,6 +117,10 @@ logger_interface :: proc(
str_to_file_ln( logger.file, to_string(builder) )
}
// TODO(Ed): Use a fixed size block allocation for message formatting used by core_log
// This will prevent stack overflows with the virtual arena debug logs at worst case and not need to do
// some inline arena allocation on-site such as with the memory tracker
log :: proc( msg : string, level := LogLevel.Info, loc := #caller_location ) {
core_log.log( level, msg, location = loc )
}

View File

@ -221,11 +221,6 @@ render_mode_screenspace :: proc ()
render_screen_ui()
fps_msg := str_fmt_tmp( "FPS: %f", fps_avg)
fps_msg_width := measure_text_size( fps_msg, default_font, 12.0, 0.0 ).x
fps_msg_pos := screen_get_corners().top_right - { fps_msg_width, 0 } - { 5, 5 }
debug_draw_text( fps_msg, fps_msg_pos, 12.0, color = rl.GREEN )
debug_text :: proc( format : string, args : ..any )
{
@static draw_text_scratch : [Kilobyte * 64]u8
@ -248,8 +243,13 @@ render_mode_screenspace :: proc ()
debug.draw_debug_text_y += 14
}
// Debug Text
if debug.debug_text_vis
{
fps_msg := str_fmt_tmp( "FPS: %f", fps_avg)
fps_msg_width := measure_text_size( fps_msg, default_font, 12.0, 0.0 ).x
fps_msg_pos := screen_get_corners().top_right - { fps_msg_width, 0 } - { 5, 5 }
debug_draw_text( fps_msg, fps_msg_pos, 12.0, color = rl.GREEN )
// debug_text( "Screen Width : %v", rl.GetScreenWidth () )
// debug_text( "Screen Height: %v", rl.GetScreenHeight() )
// debug_text( "frametime_target_ms : %f ms", frametime_target_ms )
@ -262,61 +262,52 @@ render_mode_screenspace :: proc ()
debug_text( "Replaying Input")
}
// debug_text("Zoom Target: %v", project.workspace.zoom_target)
}
if debug.mouse_vis {
debug_text("Mouse Vertical Wheel: %v", input.mouse.vertical_wheel )
debug_text("Mouse Delta : %v", input.mouse.delta )
debug_text("Mouse Position (Render) : %v", input.mouse.raw_pos )
debug_text("Mouse Position (Screen) : %v", input.mouse.pos )
debug_text("Mouse Position (Workspace View): %v", screen_to_ws_view_pos(input.mouse.pos) )
rl.DrawCircleV( input.mouse.raw_pos, 10, Color_White_A125 )
rl.DrawCircleV( screen_to_render_pos(input.mouse.pos), 2, Color_BG )
}
ui := & project.workspace.ui
if false
{
debug_text("Box Count (Workspace): %v", ui.built_box_count )
hot_box := ui_box_from_key( ui.curr_cache, ui.hot )
active_box := ui_box_from_key( ui.curr_cache, ui.active )
if hot_box != nil {
debug_text("Worksapce Hot Box : %v", hot_box.label.str )
debug_text("Workspace Hot Range2: %v", hot_box.computed.bounds.pts)
if debug.mouse_vis {
debug_text("Mouse Vertical Wheel: %v", input.mouse.vertical_wheel )
debug_text("Mouse Delta : %v", input.mouse.delta )
debug_text("Mouse Position (Render) : %v", input.mouse.raw_pos )
debug_text("Mouse Position (Screen) : %v", input.mouse.pos )
debug_text("Mouse Position (Workspace View): %v", screen_to_ws_view_pos(input.mouse.pos) )
rl.DrawCircleV( input.mouse.raw_pos, 10, Color_White_A125 )
rl.DrawCircleV( screen_to_render_pos(input.mouse.pos), 2, Color_BG )
}
if active_box != nil{
debug_text("Workspace Active Box: %v", active_box.label.str )
ui := & project.workspace.ui
if true
{
debug_text("Box Count (Workspace): %v", ui.built_box_count )
hot_box := ui_box_from_key( ui.curr_cache, ui.hot )
active_box := ui_box_from_key( ui.curr_cache, ui.active )
if hot_box != nil {
debug_text("Worksapce Hot Box : %v", hot_box.label.str )
debug_text("Workspace Hot Range2: %v", hot_box.computed.bounds.pts)
}
if active_box != nil{
debug_text("Workspace Active Box: %v", active_box.label.str )
}
}
}
ui = & screen_ui
ui = & screen_ui
if true
{
debug_text("Box Count: %v", ui.built_box_count )
if true
{
debug_text("Box Count: %v", ui.built_box_count )
hot_box := ui_box_from_key( ui.curr_cache, ui.hot )
active_box := ui_box_from_key( ui.curr_cache, ui.active )
if hot_box != nil {
debug_text("Hot Box : %v", hot_box.label.str )
debug_text("Hot Range2: %v", hot_box.computed.bounds.pts)
hot_box := ui_box_from_key( ui.curr_cache, ui.hot )
active_box := ui_box_from_key( ui.curr_cache, ui.active )
if hot_box != nil {
debug_text("Hot Box : %v", hot_box.label.str )
debug_text("Hot Range2: %v", hot_box.computed.bounds.pts)
}
if active_box != nil{
debug_text("Active Box: %v", active_box.label.str )
}
}
if active_box != nil{
debug_text("Active Box: %v", active_box.label.str )
}
}
view := view_get_bounds()
debug.draw_debug_text_y = 14
// Define the triangle vertices and colors
vertices := []f32{
// Positions // Colors (RGBA)
-0.5, -0.5, 0.0, 1.0, 0.0, 0.0, 1.0, // Vertex 1: Red
0.5, -0.5, 0.0, 0.0, 1.0, 0.0, 1.0, // Vertex 2: Green
0.0, 0.5, 0.0, 0.0, 0.0, 1.0, 1.0 // Vertex 3: Blue
debug.draw_debug_text_y = 14
}
}

View File

@ -17,7 +17,8 @@ DebugActions :: struct {
record_replay : b32,
play_replay : b32,
show_mouse_pos : b32,
show_debug_text : b32,
show_mouse_pos : b32,
mouse_select : b32,
@ -48,7 +49,8 @@ poll_debug_actions :: proc( actions : ^ DebugActions, input : ^ InputState )
record_replay = base_replay_bind && keyboard.right_shift.ended_down
play_replay = base_replay_bind && ! keyboard.right_shift.ended_down
show_mouse_pos = keyboard.right_alt.ended_down && pressed(keyboard.M)
show_debug_text = keyboard.right_alt.ended_down && pressed(keyboard.T)
show_mouse_pos = keyboard.right_alt.ended_down && pressed(keyboard.M)
mouse_select = pressed(mouse.left)
@ -146,6 +148,9 @@ update :: proc( delta_time : f64 ) -> b32
if debug_actions.show_mouse_pos {
debug.mouse_vis = !debug.mouse_vis
}
if debug_actions.show_debug_text {
debug.debug_text_vis = !debug.debug_text_vis
}
//region 2D Camera Manual Nav
// TODO(Ed): This should be per workspace view
@ -223,17 +228,17 @@ update :: proc( delta_time : f64 ) -> b32
// size = range2( { 1000, 1000 }, {}),
// padding = { 20, 20, 20, 20 }
}
ui_layout( default_layout )
scope( default_layout )
frame_style_default := UI_Style {
bg_color = Color_BG_TextBox,
font = default_font,
text_color = Color_White,
}
frame_theme := to_ui_style_combo(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
ui_style( frame_theme )
frame_style := to_ui_style_combo(frame_style_default)
frame_style.disabled.bg_color = Color_Frame_Disabled
frame_style.hot. bg_color = Color_Frame_Hover
frame_style.active. bg_color = Color_Frame_Select
scope( frame_style )
config.ui_resize_border_width = 2.5
// test_hover_n_click()