Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_handlers.c
| Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
| return retval; | return retval; | ||||
| } | } | ||||
| static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *region, uiBut *listbox) | static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *region, uiBut *listbox) | ||||
| { | { | ||||
| int retval = WM_UI_HANDLER_CONTINUE; | int retval = WM_UI_HANDLER_CONTINUE; | ||||
| int type = event->type, val = event->val; | int type = event->type, val = event->val; | ||||
| int scroll_dir = 1; | |||||
| bool redraw = false; | bool redraw = false; | ||||
| uiList *ui_list = listbox->custom_data; | uiList *ui_list = listbox->custom_data; | ||||
| if (!ui_list || !ui_list->dyn_data) { | if (!ui_list || !ui_list->dyn_data) { | ||||
| return retval; | return retval; | ||||
| } | } | ||||
| uiListDyn *dyn_data = ui_list->dyn_data; | uiListDyn *dyn_data = ui_list->dyn_data; | ||||
| int mx = event->x; | int mx = event->x; | ||||
| int my = event->y; | int my = event->y; | ||||
| ui_window_to_block(region, listbox->block, &mx, &my); | ui_window_to_block(region, listbox->block, &mx, &my); | ||||
| /* Convert pan to scroll-wheel. */ | /* Convert pan to scroll-wheel. */ | ||||
| if (type == MOUSEPAN) { | if (type == MOUSEPAN) { | ||||
| ui_pan_to_scroll(event, &type, &val); | ui_pan_to_scroll(event, &type, &val); | ||||
| /* 'ui_pan_to_scroll' gives the absolute direction. */ | |||||
| if (event->is_direction_inverted) { | |||||
| scroll_dir = -1; | |||||
| } | |||||
| /* If type still is mouse-pan, we call it handled, since delta-y accumulate. */ | /* If type still is mouse-pan, we call it handled, since delta-y accumulate. */ | ||||
| /* also see wm_event_system.c do_wheel_ui hack */ | /* also see wm_event_system.c do_wheel_ui hack */ | ||||
| if (type == MOUSEPAN) { | if (type == MOUSEPAN) { | ||||
| retval = WM_UI_HANDLER_BREAK; | retval = WM_UI_HANDLER_BREAK; | ||||
| } | } | ||||
| } | } | ||||
| if (val == KM_PRESS) { | if (val == KM_PRESS) { | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
| ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; | ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; | ||||
| redraw = true; | redraw = true; | ||||
| retval = WM_UI_HANDLER_BREAK; | retval = WM_UI_HANDLER_BREAK; | ||||
| } | } | ||||
| else if (ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { | else if (ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { | ||||
| if (dyn_data->height > dyn_data->visual_height) { | if (dyn_data->height > dyn_data->visual_height) { | ||||
| /* list template will clamp */ | /* list template will clamp */ | ||||
| ui_list->list_scroll += (type == WHEELUPMOUSE) ? -1 : 1; | ui_list->list_scroll += scroll_dir * ((type == WHEELUPMOUSE) ? -1 : 1); | ||||
| redraw = true; | redraw = true; | ||||
| retval = WM_UI_HANDLER_BREAK; | retval = WM_UI_HANDLER_BREAK; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (redraw) { | if (redraw) { | ||||
| ▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines | |||||