diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-25 21:41:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-25 21:51:49 +0300 |
commit | 700012b66e87390a9eee33d4437a073cb8e42076 (patch) | |
tree | 033f62d67e3722f21b494aba9d2c8aa366b00117 | |
parent | 81f19b0c5f81e909001605137611120eb6ab0d77 (diff) |
UI: icon-only hold popup uses region alignment
Gives nicer tool popups for icon only buttons.
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3ea6ae08173..0163b19d57e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -902,7 +902,23 @@ static void ui_item_menu_hold(struct bContext *C, ARegion *butregion, uiBut *but block->flag |= UI_BLOCK_POPUP_HOLD; block->flag |= UI_BLOCK_IS_FLIP; - UI_block_direction_set(block, UI_DIR_DOWN); + + char direction = UI_DIR_DOWN; + if (!but->drawstr[0]) { + if (butregion->alignment == RGN_ALIGN_LEFT) { + direction = UI_DIR_RIGHT; + } + else if (butregion->alignment == RGN_ALIGN_RIGHT) { + direction = UI_DIR_LEFT; + } + else if (butregion->alignment == RGN_ALIGN_BOTTOM) { + direction = UI_DIR_UP; + } + else { + direction = UI_DIR_DOWN; + } + } + UI_block_direction_set(block, direction); const char *menu_id = but->hold_argN; MenuType *mt = WM_menutype_find(menu_id, true); |