Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_handlers.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 9,224 Lines • ▼ Show 20 Lines | else { | ||||
| RNA_property_int_set(&listbox->rnapoin, listbox->rnaprop, index); | RNA_property_int_set(&listbox->rnapoin, listbox->rnaprop, index); | ||||
| RNA_property_update(C, &listbox->rnapoin, listbox->rnaprop); | RNA_property_update(C, &listbox->rnapoin, listbox->rnaprop); | ||||
| ui_apply_but_undo(listbox); | ui_apply_but_undo(listbox); | ||||
| } | } | ||||
| ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; | ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; | ||||
| } | } | ||||
| static int ui_list_get_increment(const uiList *ui_list, const int type, const int columns) | |||||
| { | |||||
| int increment = 0; | |||||
| /* Handle column offsets for grid layouts. */ | |||||
| if (ELEM(type, EVT_UPARROWKEY, EVT_DOWNARROWKEY) && | |||||
| ELEM(ui_list->layout_type, UILST_LAYOUT_GRID, UILST_LAYOUT_BIG_PREVIEW_GRID)) { | |||||
| increment = (type == EVT_UPARROWKEY) ? -columns : columns; | |||||
| } | |||||
| else { | |||||
| /* Left or right in grid layouts or any direction in single column layouts increments by 1. */ | |||||
| increment = ELEM(type, EVT_UPARROWKEY, EVT_LEFTARROWKEY, WHEELUPMOUSE) ? -1 : 1; | |||||
| } | |||||
| if ((ui_list->filter_sort_flag & UILST_FLT_SORT_REVERSE) != 0) { | |||||
| increment *= -1; | |||||
| } | |||||
| return increment; | |||||
| } | |||||
| 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; | int scroll_dir = 1; | ||||
| bool redraw = false; | bool redraw = false; | ||||
| uiList *ui_list = listbox->custom_data; | uiList *ui_list = listbox->custom_data; | ||||
| Show All 21 Lines | if (type == MOUSEPAN) { | ||||
| retval = WM_UI_HANDLER_BREAK; | retval = WM_UI_HANDLER_BREAK; | ||||
| } | } | ||||
| } | } | ||||
| if (ELEM(event->type, LEFTMOUSE, EVT_TWEAK_L)) { | if (ELEM(event->type, LEFTMOUSE, EVT_TWEAK_L)) { | ||||
| retval = ui_list_handle_click_drag(C, ui_list, region, event); | retval = ui_list_handle_click_drag(C, ui_list, region, event); | ||||
| } | } | ||||
| else if (val == KM_PRESS) { | else if (val == KM_PRESS) { | ||||
| if ((ELEM(type, EVT_UPARROWKEY, EVT_DOWNARROWKEY) && | if ((ELEM(type, EVT_UPARROWKEY, EVT_DOWNARROWKEY, EVT_LEFTARROWKEY, EVT_RIGHTARROWKEY) && | ||||
| !IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) || | !IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) || | ||||
| ((ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->ctrl && | ((ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->ctrl && | ||||
| !IS_EVENT_MOD(event, shift, alt, oskey)))) { | !IS_EVENT_MOD(event, shift, alt, oskey)))) { | ||||
| const int value_orig = RNA_property_int_get(&listbox->rnapoin, listbox->rnaprop); | const int value_orig = RNA_property_int_get(&listbox->rnapoin, listbox->rnaprop); | ||||
| int value, min, max, inc; | int value, min, max; | ||||
| /* activate up/down the list */ | |||||
| value = value_orig; | value = value_orig; | ||||
| if ((ui_list->filter_sort_flag & UILST_FLT_SORT_REVERSE) != 0) { | const int inc = ui_list_get_increment(ui_list, type, dyn_data->columns); | ||||
| inc = ELEM(type, EVT_UPARROWKEY, WHEELUPMOUSE) ? 1 : -1; | |||||
| } | |||||
| else { | |||||
| inc = ELEM(type, EVT_UPARROWKEY, WHEELUPMOUSE) ? -1 : 1; | |||||
| } | |||||
| if (dyn_data->items_filter_neworder || dyn_data->items_filter_flags) { | if (dyn_data->items_filter_neworder || dyn_data->items_filter_flags) { | ||||
| /* If we have a display order different from | /* If we have a display order different from | ||||
| * collection order, we have some work! */ | * collection order, we have some work! */ | ||||
| int *org_order = MEM_mallocN(dyn_data->items_shown * sizeof(int), __func__); | int *org_order = MEM_mallocN(dyn_data->items_shown * sizeof(int), __func__); | ||||
| const int *new_order = dyn_data->items_filter_neworder; | const int *new_order = dyn_data->items_filter_neworder; | ||||
| int org_idx = -1, len = dyn_data->items_len; | int org_idx = -1, len = dyn_data->items_len; | ||||
| int current_idx = -1; | int current_idx = -1; | ||||
| ▲ Show 20 Lines • Show All 2,066 Lines • Show Last 20 Lines | |||||