abstract input into platform layer
This commit is contained in:
@@ -14,11 +14,9 @@ void ui_widgets_init() {
|
||||
g_wstate = {};
|
||||
}
|
||||
|
||||
void ui_widgets_begin_frame(PlatformInputEvents input, B32 mouse_down, B32 was_mouse_down) {
|
||||
void ui_widgets_begin_frame(PlatformInput input) {
|
||||
g_wstate.input = input;
|
||||
g_wstate.was_mouse_down = g_wstate.mouse_down;
|
||||
g_wstate.mouse_down = mouse_down;
|
||||
g_wstate.mouse_clicked = (mouse_down && !g_wstate.was_mouse_down);
|
||||
g_wstate.mouse_clicked = (input.mouse_down && !input.was_mouse_down);
|
||||
g_wstate.cursor_blink += 1.0f / 60.0f;
|
||||
g_wstate.text_input_count = 0;
|
||||
g_wstate.tab_pressed = 0;
|
||||
|
||||
@@ -33,12 +33,10 @@ struct UI_WidgetState {
|
||||
// Dropdown
|
||||
uint32_t open_dropdown_id; // Clay element ID hash of the open dropdown (0 = none)
|
||||
|
||||
// Input events for this frame
|
||||
PlatformInputEvents input;
|
||||
// Input for this frame
|
||||
PlatformInput input;
|
||||
|
||||
// Click detection
|
||||
B32 mouse_down;
|
||||
B32 was_mouse_down;
|
||||
B32 mouse_clicked; // true on the frame mouse transitions from up->down
|
||||
};
|
||||
|
||||
@@ -47,8 +45,8 @@ extern UI_WidgetState g_wstate;
|
||||
// Call once at startup
|
||||
void ui_widgets_init();
|
||||
|
||||
// Call each frame before building widgets. Pass in the frame's input events.
|
||||
void ui_widgets_begin_frame(PlatformInputEvents input, B32 mouse_down, B32 was_mouse_down);
|
||||
// Call each frame before building widgets. Pass in the frame's input.
|
||||
void ui_widgets_begin_frame(PlatformInput input);
|
||||
|
||||
// Reset per-frame text input display buffer allocator (called by begin_frame, but
|
||||
// can also be called manually if needed)
|
||||
|
||||
Reference in New Issue
Block a user