diff options
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 63 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 13 |
3 files changed, 33 insertions, 48 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a8a1f283ccb..a64ec7fca2b 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3270,6 +3270,9 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu if (free) { MEM_freeN(item_array); } + + BLI_assert((block->flag & UI_BLOCK_IS_FLIP) == 0); + block->flag |= UI_BLOCK_IS_FLIP; } /** @@ -3888,6 +3891,8 @@ void UI_block_order_flip(uiBlock *block) but->rect.ymax = centy - (but->rect.ymax - centy); SWAP(float, but->rect.ymin, but->rect.ymax); } + + block->flag ^= UI_BLOCK_IS_FLIP; } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 90df2d7ad5b..c841370a8fd 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8045,7 +8045,7 @@ static int ui_handle_menu_event( { ARegion *ar; uiBlock *block; - uiBut *but, *bt; + uiBut *but; int mx, my, retval; bool inside; bool inside_title; /* check for title dragging */ @@ -8173,7 +8173,9 @@ static int ui_handle_menu_event( ui_pan_to_scroll(event, &type, &val); if (val == KM_PRESS) { - const eButType type_flip = UI_BTYPE_BUT | UI_BTYPE_ROW; + const bool is_next = + (ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE) == + ((block->flag & UI_BLOCK_IS_FLIP) != 0)); if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) break; @@ -8184,57 +8186,22 @@ static int ui_handle_menu_event( but = ui_but_find_active_in_region(ar); if (but) { - /* is there a situation where UI_DIR_LEFT or UI_DIR_RIGHT would also change navigation direction? */ - if (((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DIR_DOWN)) || - ((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DIR_RIGHT)) || - ((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DIR_UP))) - { - /* the following is just a hack - uiBut->type set to - * UI_BTYPE_BUT and UI_BTYPE_BUT_MENU have there menus built opposite ways - - * this should be changed so that all popup-menus use the same uiBlock->direction */ - if (but->type & type_flip) - but = ui_but_next(but); - else - but = ui_but_prev(but); - } - else { - if (but->type & type_flip) - but = ui_but_prev(but); - else - but = ui_but_next(but); - } - - if (but) { - ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); - ui_menu_scroll(ar, block, my, but); - } + /* next button */ + but = is_next ? ui_but_next(but) : ui_but_prev(but); } if (!but) { - if (((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DIR_DOWN)) || - ((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DIR_RIGHT)) || - ((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DIR_UP))) - { - if ((bt = ui_but_first(block)) && (bt->type & type_flip)) { - bt = ui_but_last(block); - } - else { - /* keep ui_but_first() */ - } - } - else { - if ((bt = ui_but_first(block)) && (bt->type & type_flip)) { - /* keep ui_but_first() */ - } - else { - bt = ui_but_last(block); - } + /* wrap button */ + uiBut *but_wrap; + but_wrap = is_next ? ui_but_first(block) : ui_but_last(block); + if (but_wrap) { + but = but_wrap; } + } - if (bt) { - ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE); - ui_menu_scroll(ar, block, my, bt); - } + if (but) { + ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); + ui_menu_scroll(ar, block, my, but); } } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index e8e9475c338..47b9c85fb0b 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -977,6 +977,11 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname if (free) { MEM_freeN(item_array); } + + if ((block->flag & UI_BLOCK_NO_FLIP) == 0) { + BLI_assert((block->flag & UI_BLOCK_IS_FLIP) == 0); + block->flag |= UI_BLOCK_IS_FLIP; + } } else if (prop && RNA_property_type(prop) != PROP_ENUM) { RNA_warning("%s.%s, not an enum type", RNA_struct_identifier(ptr.type), propname); @@ -1431,6 +1436,11 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname MEM_freeN(item); } } + + if ((block->flag & UI_BLOCK_NO_FLIP) == 0) { + BLI_assert((block->flag & UI_BLOCK_IS_FLIP) == 0); + block->flag |= UI_BLOCK_IS_FLIP; + } } /* Pointer RNA button with search */ @@ -1663,6 +1673,9 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt) if (layout->context) CTX_store_set(C, NULL); + + /* menus are created flipped (from event handling pov) */ + layout->root->block->flag ^= UI_BLOCK_IS_FLIP; } static uiBut *ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN, |