Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoep Peters <Joep>2019-09-13 13:33:08 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-09-13 14:06:06 +0300
commit95ef6dfa9e4d4c617e2f931cc0b5dba2df793648 (patch)
tree340a3efa4b63594e96174671696cf9bcffba782c /source/blender/editors/interface/interface_handlers.c
parentf7ee2348c00d7263c33b1e05173942349e9bb312 (diff)
UI: use pageup/down and home/end to scroll to start/end of menus
Differential Revision: https://developer.blender.org/D5582
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 65655c74ee9..cc13c4004a4 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -153,6 +153,13 @@ typedef enum uiHandleButtonState {
BUTTON_STATE_EXIT,
} uiHandleButtonState;
+typedef enum uiMenuScrollType {
+ MENU_SCROLL_UP,
+ MENU_SCROLL_DOWN,
+ MENU_SCROLL_TOP,
+ MENU_SCROLL_BOTTOM,
+} uiMenuScrollType;
+
#ifdef USE_ALLSELECT
/* Unfortunately there's no good way handle more generally:
@@ -9122,6 +9129,10 @@ static int ui_handle_menu_event(bContext *C,
}
case UPARROWKEY:
case DOWNARROWKEY:
+ case PAGEUPKEY:
+ case PAGEDOWNKEY:
+ case HOMEKEY:
+ case ENDKEY:
case MOUSEPAN:
/* arrowkeys: only handle for block_loop blocks */
if (IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) {
@@ -9137,8 +9148,22 @@ static int ui_handle_menu_event(bContext *C,
}
if (val == KM_PRESS) {
- const bool is_next = (ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE) ==
- ((block->flag & UI_BLOCK_IS_FLIP) != 0));
+ /* Determine scroll operation. */
+ uiMenuScrollType scrolltype;
+ bool ui_block_flipped = (block->flag & UI_BLOCK_IS_FLIP) != 0;
+
+ if (ELEM(type, PAGEUPKEY, HOMEKEY)) {
+ scrolltype = ui_block_flipped ? MENU_SCROLL_TOP : MENU_SCROLL_BOTTOM;
+ }
+ else if (ELEM(type, PAGEDOWNKEY, ENDKEY)) {
+ scrolltype = ui_block_flipped ? MENU_SCROLL_BOTTOM : MENU_SCROLL_TOP;
+ }
+ else if (ELEM(type, UPARROWKEY, WHEELUPMOUSE)) {
+ scrolltype = ui_block_flipped ? MENU_SCROLL_UP : MENU_SCROLL_DOWN;
+ }
+ else {
+ scrolltype = ui_block_flipped ? MENU_SCROLL_DOWN : MENU_SCROLL_UP;
+ }
if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) {
break;
@@ -9150,16 +9175,24 @@ static int ui_handle_menu_event(bContext *C,
but = ui_region_find_active_but(ar);
if (but) {
- /* next button */
- but = is_next ? ui_but_next(but) : ui_but_prev(but);
- }
-
- if (!but) {
- /* wrap button */
- uiBut *but_wrap;
- but_wrap = is_next ? ui_but_first(block) : ui_but_last(block);
- if (but_wrap) {
- but = but_wrap;
+ /* Apply scroll operation. */
+ if (scrolltype == MENU_SCROLL_DOWN) {
+ but = ui_but_next(but);
+ if (but == NULL) {
+ but = ui_but_first(block);
+ }
+ }
+ else if (scrolltype == MENU_SCROLL_UP) {
+ but = ui_but_prev(but);
+ if (but == NULL) {
+ but = ui_but_last(block);
+ }
+ }
+ else if (scrolltype == MENU_SCROLL_TOP) {
+ but = ui_but_first(block);
+ }
+ else if (scrolltype == MENU_SCROLL_BOTTOM) {
+ but = ui_but_last(block);
}
}