Got the first 'input box' to work. Did some changes to keyboard input

Renamed KeyboardKey to KeyCode, redid the encoding layout (preemtively getting ready for SDL later as well)

I got the input box working but it has no constraints and needs to be lifted. The scroll box construction does as well.
This commit is contained in:
2024-05-19 11:06:09 -04:00
parent b137bc542c
commit 275ffcf143
13 changed files with 782 additions and 500 deletions

View File

@ -3,5 +3,5 @@
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 in its own data stucture at the beginning of `ui_build_graph`:
* Provide UI input state or "events" in its own data stucture at the beginning of `ui_build_graph`:
*

View File

@ -128,6 +128,8 @@ ui_box_make :: proc( flags : UI_BoxFlags, label : string ) -> (^ UI_Box)
return curr_box
}
ui_prev_cached_box :: #force_inline proc( box : ^UI_Box ) -> ^UI_Box { return zpl_hmap_get( ui_context().prev_cache, cast(u64) box.key ) }
ui_box_tranverse_next :: proc "contextless" ( box : ^ UI_Box ) -> (^ UI_Box)
{
using state := get_state()

View File

@ -36,6 +36,8 @@ ui_signal_from_box :: proc ( box : ^ UI_Box, update_style := true, update_deltas
frame_delta := frametime_delta32()
prev_box := ui_prev_cached_box(box)
signal := UI_Signal {}
// Cursor Collision
@ -72,8 +74,8 @@ ui_signal_from_box :: proc ( box : ^ UI_Box, update_style := true, update_deltas
keyboard_clickable := UI_BoxFlag.Keyboard_Clickable in box.flags
is_focusable := .Focusable in box.flags
was_active := (ui.active == box.key) && (box.active_delta > 0)
was_hot := (box.hot_delta > 0)
was_active := box.active_delta > 0
was_hot := box.hot_delta > 0
was_disabled := box.disabled_delta > 0
is_focused_locked := is_focusable ? was_active : false

View File

@ -206,17 +206,6 @@ ui_graph_build_begin :: proc( ui : ^ UI_State, bounds : Vec2 = {} )
ui_parent_push(root)
}
ui_core_compute_layout :: proc( ui : ^UI_State )
{
profile(#procedure)
state := get_state()
}
ui_graph_build_end :: proc( ui : ^UI_State )
{
profile(#procedure)
@ -239,8 +228,6 @@ ui_graph_build_end :: proc( ui : ^UI_State )
}
for current := root.first; current != nil; current = ui_box_tranverse_next( current )
{
if ! current.computed.fresh {
ui_box_compute_layout( current )
}
@ -290,8 +277,6 @@ ui_parent_pop :: #force_inline proc() { stack_pop( & get_state(
@(deferred_none = ui_parent_pop)
ui_parent :: #force_inline proc( ui : ^UI_Box) { ui_parent_push( ui ) }
ui_prev_cached_box :: #force_inline proc( box : ^UI_Box ) -> ^UI_Box { return zpl_hmap_get( ui_context().prev_cache, cast(u64) box.key ) }
// Topmost ancestor that is not the root
ui_top_ancestor :: #force_inline proc "contextless" ( box : ^UI_Box ) -> (^UI_Box) {
using ui := get_state().ui_context