fix/workaround for v3d object mode selector flipping direction
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Feb 2014 23:29:15 +0000 (10:29 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Feb 2014 23:29:15 +0000 (10:29 +1100)
Allow menu functions to define their own direction, this way
menu_item_enum_opname_menu can keep menu flipping from 2.69.

source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_regions.c

index 1dbef0ba0149bfe88ffa534edf3f8fdb8c0e2a29..d235441d53e5b347aafab4c5b6d10eaa3c7f9a8b 100644 (file)
@@ -418,7 +418,7 @@ void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int max
 
 int     uiBlocksGetYMin(struct ListBase *lb);
 
-void    uiBlockSetDirection(uiBlock *block, int direction);
+void    uiBlockSetDirection(uiBlock *block, char direction);
 void    uiBlockFlipOrder(uiBlock *block);
 void    uiBlockSetFlag(uiBlock *block, int flag);
 void    uiBlockClearFlag(uiBlock *block, int flag);
index 2e6cb35faaae2e60fbcfb8ab43c6805b3aeff526..aa3be71aa5d8a8360969b5158fa184cfcd1c33a5 100644 (file)
@@ -3684,7 +3684,7 @@ int uiBlocksGetYMin(ListBase *lb)
        return min;
 }
 
-void uiBlockSetDirection(uiBlock *block, int direction)
+void uiBlockSetDirection(uiBlock *block, char direction)
 {
        block->direction = direction;
 }
index e27177be4b4b27e4f271e79d01bc870ea14aebb3..57e7ebfd800e519208737ac931654f84a6345b2a 100644 (file)
@@ -1793,6 +1793,9 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo
 
        uiLayoutSetOperatorContext(layout, lvl->opcontext);
        uiItemsEnumO(layout, lvl->opname, lvl->propname);
+
+       /* override default, needed since this was assumed pre 2.70 */
+       uiBlockSetDirection(layout->root->block, UI_DOWN);
 }
 
 void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name, int icon)
index 9bb8ed0d1e07602147c8715e033704638ef7b300..e413808f1ddb641b2ae491c8d91968404de0639d 100644 (file)
@@ -2102,7 +2102,9 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
        uiBlock *block;
        uiBut *bt;
        uiPopupMenu *pup = arg_pup;
-       int offset[2], direction, minwidth, width, height, flip;
+       int offset[2], minwidth, width, height;
+       char direction;
+       bool flip;
 
        if (pup->menu_func) {
                pup->block->handle = handle;
@@ -2116,21 +2118,26 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
 
                /* settings (typically rna-enum-popups) show above the button,
                 * menu's like file-menu, show below */
-               if (pup->but->type == PULLDOWN || (uiButGetMenuType(pup->but) != NULL)) {
+               if (pup->block->direction != 0) {
+                       /* allow overriding the direction from menu_func */
+                       direction = pup->block->direction;
+               }
+               else if ((pup->but->type == PULLDOWN) ||
+                   (uiButGetMenuType(pup->but) != NULL))
+               {
                        direction = UI_DOWN;
-                       flip = 1;
                }
                else {
                        direction = UI_TOP;
-                       flip = 0;
                }
        }
        else {
                minwidth = 50;
                direction = UI_DOWN;
-               flip = 1;
        }
 
+       flip = (direction == UI_DOWN);
+
        block = pup->block;
        
        /* in some cases we create the block before the region,