diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 80c8d3c0ea4..7ddf85707fe 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -94,6 +94,13 @@ static void ui_free_but(const bContext *C, uiBut *but); +bool ui_block_is_menu(const uiBlock *block) +{ + return (((block->flag & UI_BLOCK_LOOP) != 0) && + /* non-menu popups use keep-open, so check this is off */ + ((block->flag & UI_BLOCK_KEEP_OPEN) == 0)); +} + /* ************* window matrix ************** */ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index dcad65c3f48..055cceeb4ea 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5338,7 +5338,9 @@ static bool ui_but_menu(bContext *C, uiBut *but) } /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */ - uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); + if (ui_block_is_menu(but->block) == false) { + uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); + } uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 874928ae749..9b5c2d9522d 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -370,6 +370,7 @@ extern void ui_delete_linkline(uiLinkLine *line, uiBut *but); void ui_fontscale(short *points, float aspect); +extern bool ui_block_is_menu(const uiBlock *block); extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y); extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y); extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, const rctf *graph, rcti *winr); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index d8a49fa86d9..03d831035b2 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2323,7 +2323,8 @@ struct uiPopupMenu { uiLayout *layout; uiBut *but; - int mx, my, popup, slideout; + int mx, my; + bool popup, slideout; int startx, starty, maxrow; uiMenuCreateFunc menu_func; @@ -2440,11 +2441,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->block->flag |= UI_BLOCK_NUMSELECT; /* default menus to numselect */ pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); - pup->slideout = (but && - /* check this is a menu */ - ((but->block->flag & UI_BLOCK_LOOP) != 0) && - /* non-menu popups use keep-open, so check this is off */ - ((but->block->flag & UI_BLOCK_KEEP_OPEN) == 0)); + pup->slideout = but ? ui_block_is_menu(but->block) : false; pup->but = but; uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN); @@ -2452,7 +2449,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut /* no button to start from, means we are a popup */ pup->mx = window->eventstate->x; pup->my = window->eventstate->y; - pup->popup = 1; + pup->popup = true; pup->block->flag |= UI_BLOCK_NO_FLIP; } /* some enums reversing is strange, currently we have no good way to