mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-17 14:51:26 -07:00
os_gfx -> report mouse move events; still allow passive mouse interaction if window is unfocused, but have recently received mousemove events
This commit is contained in:
+9
-1
@@ -2881,8 +2881,16 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
|
||||
icon_info.icon_kind_text_map[UI_IconKind_CheckFilled] = df_g_icon_kind_text_table[DF_IconKind_CheckFilled];
|
||||
}
|
||||
|
||||
// rjf: form mouse position used for passive UI mouse interaction
|
||||
Vec2F32 mouse_ui = os_mouse_from_window(ws->os);
|
||||
if(!os_window_is_focused(ws->os) &&
|
||||
df_gfx_state->last_time_mousemoved_us+500000 <= os_now_microseconds())
|
||||
{
|
||||
mouse_ui = v2f32(-100, -100);
|
||||
}
|
||||
|
||||
// rjf: begin & push initial stack values
|
||||
ui_begin_build(events, ws->os, &nav_actions, &icon_info, df_dt(), df_dt());
|
||||
ui_begin_build(events, mouse_ui, ws->os, &nav_actions, &icon_info, df_dt(), df_dt());
|
||||
ui_push_font(main_font);
|
||||
ui_push_font_size(main_font_size);
|
||||
ui_push_pref_width(ui_em(20.f, 1));
|
||||
|
||||
@@ -689,6 +689,7 @@ struct DF_GfxState
|
||||
|
||||
// rjf: frame request state
|
||||
U64 num_frames_requested;
|
||||
U64 last_time_mousemoved_us;
|
||||
|
||||
// rjf: history cache
|
||||
DF_StateDeltaHistory *hist;
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef enum OS_EventKind
|
||||
OS_EventKind_Null,
|
||||
OS_EventKind_Press,
|
||||
OS_EventKind_Release,
|
||||
OS_EventKind_MouseMove,
|
||||
OS_EventKind_Text,
|
||||
OS_EventKind_Scroll,
|
||||
OS_EventKind_WindowLoseFocus,
|
||||
|
||||
@@ -429,6 +429,13 @@ w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
OS_Event *event = w32_push_event(OS_EventKind_MouseMove, window);
|
||||
event->pos.x = (F32)LOWORD(lParam);
|
||||
event->pos.y = (F32)HIWORD(lParam);
|
||||
}break;
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
{
|
||||
S16 wheel_delta = HIWORD(wParam);
|
||||
|
||||
@@ -69,6 +69,14 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
|
||||
OS_EventList new_events = os_get_events(scratch.arena, df_gfx_state->num_frames_requested == 0);
|
||||
os_event_list_concat_in_place(&events, &leftover_events_copy);
|
||||
os_event_list_concat_in_place(&events, &new_events);
|
||||
for(OS_Event *e = events.first; e != 0; e = e->next)
|
||||
{
|
||||
if(e->kind == OS_EventKind_MouseMove)
|
||||
{
|
||||
df_gfx_state->last_time_mousemoved_us = os_now_microseconds();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: enable txti change detection
|
||||
|
||||
+2
-3
@@ -631,7 +631,7 @@ ui_box_from_key(UI_Key key)
|
||||
//~ rjf: Top-Level Building API
|
||||
|
||||
internal void
|
||||
ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_actions, UI_IconInfo *icon_info, F32 real_dt, F32 animation_dt)
|
||||
ui_begin_build(OS_EventList *events, Vec2F32 mouse, OS_Handle window, UI_NavActionList *nav_actions, UI_IconInfo *icon_info, F32 real_dt, F32 animation_dt)
|
||||
{
|
||||
//- rjf: reset per-build ui state
|
||||
{
|
||||
@@ -651,7 +651,7 @@ ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_act
|
||||
ui_state->events = events;
|
||||
ui_state->window = window;
|
||||
ui_state->nav_actions = nav_actions;
|
||||
ui_state->mouse = os_window_is_focused(window) ? os_mouse_from_window(window) : v2f32(-100, -100);
|
||||
ui_state->mouse = mouse;
|
||||
ui_state->animation_dt = animation_dt;
|
||||
MemoryZeroStruct(&ui_state->icon_info);
|
||||
ui_state->icon_info.icon_font = icon_info->icon_font;
|
||||
@@ -922,7 +922,6 @@ ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_act
|
||||
}
|
||||
|
||||
//- rjf: setup parent box for tooltip
|
||||
Vec2F32 mouse = ui_state->mouse;
|
||||
UI_FixedX(mouse.x+15.f) UI_FixedY(mouse.y) UI_PrefWidth(ui_children_sum(1.f)) UI_PrefHeight(ui_children_sum(1.f))
|
||||
{
|
||||
ui_set_next_child_layout_axis(Axis2_Y);
|
||||
|
||||
+1
-1
@@ -560,7 +560,7 @@ internal UI_Box * ui_box_from_key(UI_Key key);
|
||||
////////////////////////////////
|
||||
//~ rjf: Top-Level Building API
|
||||
|
||||
internal void ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_actions, UI_IconInfo *icon_info, F32 real_dt, F32 animation_dt);
|
||||
internal void ui_begin_build(OS_EventList *events, Vec2F32 mouse, OS_Handle window, UI_NavActionList *nav_actions, UI_IconInfo *icon_info, F32 real_dt, F32 animation_dt);
|
||||
internal void ui_end_build(void);
|
||||
internal void ui_calc_sizes_standalone__in_place_rec(UI_Box *root, Axis2 axis);
|
||||
internal void ui_calc_sizes_upwards_dependent__in_place_rec(UI_Box *root, Axis2 axis);
|
||||
|
||||
Reference in New Issue
Block a user