From 6a4f7ac6de0b984deef1361da42010d9450f01ae Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 11 May 2024 01:30:54 -0400 Subject: [PATCH] minor changes, prepping for next tasks --- code/api.odin | 4 ++-- code/input_actions.odin | 1 + code/input_event.odin | 1 + code/tick_render.odin | 4 ++-- code/ui.odin | 10 ++++++---- code/ui_layout.odin | 4 ++++ code/ui_screen.odin | 12 ++++++------ code/ui_signal.odin | 2 ++ code/ui_widgets.odin | 7 +++++-- scripts/build.ps1 | 16 ++++++++-------- 10 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 code/input_actions.odin create mode 100644 code/input_event.odin diff --git a/code/api.odin b/code/api.odin index 9005a80..5b7abc4 100644 --- a/code/api.odin +++ b/code/api.odin @@ -190,7 +190,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem log( "Default font loaded" ) } - // Setup the app ui state + // Setup the screen ui state { ui_startup( & screen_ui.base, cache_allocator = persistent_slab_allocator() ) @@ -348,7 +348,7 @@ tick :: proc( host_delta_time : f64, host_delta_ns : Duration ) -> b32 { // profile("Client tick timing processing") config.engine_refresh_hz = uint(monitor_refresh_hz) - // config.engine_refresh_hz = 30 + // config.engine_refresh_hz = 10 frametime_target_ms = 1.0 / f64(config.engine_refresh_hz) * S_To_MS sub_ms_granularity_required := frametime_target_ms <= Frametime_High_Perf_Threshold_MS diff --git a/code/input_actions.odin b/code/input_actions.odin new file mode 100644 index 0000000..3876406 --- /dev/null +++ b/code/input_actions.odin @@ -0,0 +1 @@ +package sectr \ No newline at end of file diff --git a/code/input_event.odin b/code/input_event.odin new file mode 100644 index 0000000..3876406 --- /dev/null +++ b/code/input_event.odin @@ -0,0 +1 @@ +package sectr \ No newline at end of file diff --git a/code/tick_render.odin b/code/tick_render.odin index 4e642e2..b95af9f 100644 --- a/code/tick_render.odin +++ b/code/tick_render.odin @@ -221,7 +221,7 @@ render_mode_screenspace :: proc () cam := & project.workspace.cam win_extent := state.app_window.extent - render_app_ui() + render_screen_ui() fps_msg := str_fmt_tmp( "FPS: %f", fps_avg) fps_msg_width := measure_text_size( fps_msg, default_font, 16.0, 0.0 ).x @@ -314,7 +314,7 @@ render_mode_screenspace :: proc () // A non-zoomable static-view for ui // Only a scalar factor may be applied to the size of widgets & fonts // 'Window tiled' panels reside here -render_app_ui :: proc() +render_screen_ui :: proc() { profile(#procedure) diff --git a/code/ui.odin b/code/ui.odin index 68956e8..4700828 100644 --- a/code/ui.odin +++ b/code/ui.odin @@ -79,6 +79,7 @@ UI_BoxFlag_Scroll :: UI_BoxFlags { .Scroll_X, .Scroll_Y } // The UI_Box's actual positioning and sizing // There is an excess of rectangles here for debug puproses. UI_Computed :: struct { + fresh : b32, // If the auto-layout has been computed for the current frame anchors : Range2, // Bounds for anchors within parent margins : Range2, // Bounds for margins within parent bounds : Range2, // Bounds for box itself @@ -268,10 +269,11 @@ ui_box_make :: proc( flags : UI_BoxFlags, label : string ) -> (^ UI_Box) curr_box.flags = flags - // Clear old links - curr_box.parent = nil - curr_box.links = {} - curr_box.num_children = 0 + // Clear non-persistent data + curr_box.computed.fresh = false + curr_box.parent = nil + curr_box.links = {} + curr_box.num_children = 0 // If there is a parent, setup the relevant references parent := stack_peek( & parent_stack ) diff --git a/code/ui_layout.odin b/code/ui_layout.odin index 73a6dec..39ba006 100644 --- a/code/ui_layout.odin +++ b/code/ui_layout.odin @@ -23,6 +23,9 @@ ui_compute_layout :: proc( ui : ^UI_State ) current := root.first for ; current != nil; { + // if current.computed.fresh do return + + // TODO(Ed): Lift this to ui_box_compute_layout // profile("Layout Box") style := current.style @@ -174,6 +177,7 @@ ui_compute_layout :: proc( ui : ^UI_State ) computed.text_size = text_size computed.text_pos = { text_pos.x, text_pos.y } } + computed.fresh = true current = ui_box_tranverse_next( current ) } diff --git a/code/ui_screen.odin b/code/ui_screen.odin index 0b55758..e76ed04 100644 --- a/code/ui_screen.odin +++ b/code/ui_screen.odin @@ -27,11 +27,11 @@ ui_screen_tick :: proc() { ui_graph_build( & screen_ui ) ui := ui_context - ui_app_menu_bar() - ui_app_settings_menu() + ui_screen_menu_bar() + ui_screen_settings_menu() } -ui_app_menu_bar :: proc() +ui_screen_menu_bar :: proc() { profile("App Menu Bar") fmt :: str_fmt_alloc @@ -104,7 +104,7 @@ ui_app_menu_bar :: proc() } } -ui_app_settings_menu :: proc() +ui_screen_settings_menu :: proc() { profile("Settings Menu") using state := get_state() @@ -171,13 +171,13 @@ ui_app_settings_menu :: proc() } } - ui_hbox_end(frame_bar, & size.x) + ui_hbox_end(frame_bar)//, & size.x) } spacer := ui_spacer("Settings Menu: Spacer") spacer.style.anchor.ratio.y = 1.0 - ui_vbox_end(container, & size.y) + ui_vbox_end(container)//, & size.y) } ui_resizable_handles( & container, & pos, & size ) diff --git a/code/ui_signal.odin b/code/ui_signal.odin index e16220f..f2ddf1a 100644 --- a/code/ui_signal.odin +++ b/code/ui_signal.odin @@ -72,6 +72,8 @@ ui_signal_from_box :: proc ( box : ^ UI_Box, update_style := true, update_deltas if mouse_clickable && signal.cursor_over && left_pressed && was_hot { + //TODO(Ed): We need to add the reorder of top-level widgets based on this interaction + // runtime.debug_trap() // ui.hot = box.key ui.active = box.key diff --git a/code/ui_widgets.odin b/code/ui_widgets.odin index 81f25fa..9d08252 100644 --- a/code/ui_widgets.odin +++ b/code/ui_widgets.odin @@ -122,8 +122,9 @@ ui_hbox_end :: proc( hbox : UI_HBox, width_ref : ^f32 = nil ) { // Auto-layout children and pop parent from parent stack ui_hbox_end_pop_parent :: proc( hbox : UI_HBox ) { - ui_hbox_end(hbox) + // ui_box_compute_layout(hox.widget) ui_parent_pop() + ui_hbox_end(hbox) } @(deferred_out = ui_hbox_end_pop_parent) @@ -135,6 +136,7 @@ ui_hbox :: #force_inline proc( direction : UI_LayoutDirectionX, label : string, //endregion Horizontal Box // Adds resizable handles to a widget +// TODO(Ed): Add centered resize support (use center alignment on shift-click) ui_resizable_handles :: proc( parent : ^UI_Widget, pos, size : ^Vec2, handle_width : f32 = 15, @@ -429,8 +431,9 @@ ui_vbox_end :: proc( vbox : UI_VBox, height_ref : ^f32 = nil ) { // Auto-layout children and pop parent from parent stack ui_vbox_end_pop_parent :: proc( vbox : UI_VBox ) { - ui_vbox_end(vbox) + // ui_box_compute_layout(vbox) ui_parent_pop() + ui_vbox_end(vbox) } @(deferred_out = ui_vbox_end_pop_parent) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 262c569..7954386 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -167,10 +167,10 @@ push-location $path_root $build_args += $flag_output_path + $module_dll $build_args += ($flag_collection + $pkg_collection_thirdparty) # $build_args += $flag_micro_architecture_native - # $build_args += $flag_use_separate_modules - # $build_args += $flag_thread_count + $CoreCount_Physical - # $build_args += $flag_optimize_none - $build_args += $flag_optimize_minimal + $build_args += $flag_use_separate_modules + $build_args += $flag_thread_count + $CoreCount_Physical + $build_args += $flag_optimize_none + # $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed # $build_args += $falg_optimize_aggressive $build_args += $flag_debug @@ -249,10 +249,10 @@ push-location $path_root $build_args += $flag_output_path + $executable $build_args += ($flag_collection + $pkg_collection_thirdparty) # $build_args += $flag_micro_architecture_native - # $build_args += $flag_use_separate_modules - # $build_args += $flag_thread_count + $CoreCount_Physical - # $build_args += $flag_optimize_none - $build_args += $flag_optimize_minimal + $build_args += $flag_use_separate_modules + $build_args += $flag_thread_count + $CoreCount_Physical + $build_args += $flag_optimize_none + # $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed # $build_args += $falg_optimize_aggressive $build_args += $flag_debug