[ui] Fix ui scrolling
This commit is contained in:
parent
9f7cfd985c
commit
2a01cba026
22
src/ui.c
22
src/ui.c
|
@ -449,16 +449,18 @@ ui_box* ui_box_make_str8(str8 string, ui_flags flags)
|
|||
|
||||
|
||||
//NOTE: set scroll
|
||||
vec2 wheel = ui_mouse_wheel();
|
||||
if(box->flags & UI_FLAG_SCROLL_WHEEL_X)
|
||||
if(ui_box_hovering(box, ui_mouse_position()))
|
||||
{
|
||||
box->scroll.x += wheel.x;
|
||||
vec2 wheel = ui_mouse_wheel();
|
||||
if(box->flags & UI_FLAG_SCROLL_WHEEL_X)
|
||||
{
|
||||
box->scroll.x += wheel.x;
|
||||
}
|
||||
if(box->flags & UI_FLAG_SCROLL_WHEEL_Y)
|
||||
{
|
||||
box->scroll.y += wheel.y;
|
||||
}
|
||||
}
|
||||
if(box->flags & UI_FLAG_SCROLL_WHEEL_Y)
|
||||
{
|
||||
box->scroll.y += wheel.y;
|
||||
}
|
||||
|
||||
return(box);
|
||||
}
|
||||
|
||||
|
@ -1813,7 +1815,9 @@ void ui_panel_begin(const char* str, ui_flags flags)
|
|||
| UI_FLAG_CLIP
|
||||
| UI_FLAG_BLOCK_MOUSE
|
||||
| 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);
|
||||
}
|
||||
|
|
|
@ -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.type = MP_EVENT_MOUSE_WHEEL;
|
||||
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();
|
||||
|
||||
mp_queue_event(&event);
|
||||
|
|
Loading…
Reference in New Issue