[ui] Fix ui scrolling

This commit is contained in:
martinfouilleul 2023-05-17 15:48:25 +02:00
parent 9f7cfd985c
commit 2a01cba026
2 changed files with 2819 additions and 2815 deletions

View File

@ -449,6 +449,8 @@ ui_box* ui_box_make_str8(str8 string, ui_flags flags)
//NOTE: set scroll //NOTE: set scroll
if(ui_box_hovering(box, ui_mouse_position()))
{
vec2 wheel = ui_mouse_wheel(); vec2 wheel = ui_mouse_wheel();
if(box->flags & UI_FLAG_SCROLL_WHEEL_X) if(box->flags & UI_FLAG_SCROLL_WHEEL_X)
{ {
@ -458,7 +460,7 @@ ui_box* ui_box_make_str8(str8 string, ui_flags flags)
{ {
box->scroll.y += wheel.y; box->scroll.y += wheel.y;
} }
}
return(box); return(box);
} }
@ -1813,7 +1815,9 @@ void ui_panel_begin(const char* str, ui_flags flags)
| UI_FLAG_CLIP | UI_FLAG_CLIP
| UI_FLAG_BLOCK_MOUSE | UI_FLAG_BLOCK_MOUSE
| UI_FLAG_ALLOW_OVERFLOW_X | UI_FLAG_ALLOW_OVERFLOW_X
| UI_FLAG_ALLOW_OVERFLOW_Y; | UI_FLAG_ALLOW_OVERFLOW_Y
| UI_FLAG_SCROLL_WHEEL_X
| UI_FLAG_SCROLL_WHEEL_Y;
ui_box_begin(str, flags); ui_box_begin(str, flags);
} }

View File

@ -234,7 +234,7 @@ static void process_wheel_event(mp_window_data* window, f32 x, f32 y)
event.window = mp_window_handle_from_ptr(window); event.window = mp_window_handle_from_ptr(window);
event.type = MP_EVENT_MOUSE_WHEEL; event.type = MP_EVENT_MOUSE_WHEEL;
event.move.deltaX = x/30.0f; event.move.deltaX = x/30.0f;
event.move.deltaY = y/30.0f; event.move.deltaY = -y/30.0f;
event.move.mods = mp_get_mod_keys(); event.move.mods = mp_get_mod_keys();
mp_queue_event(&event); mp_queue_event(&event);