fix/workaround for v3d object mode selector flipping direction
Allow menu functions to define their own direction, this way menu_item_enum_opname_menu can keep menu flipping from 2.69.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user