Fix #126006: UI: Few id operators appears in nested context menus
lib override and add asset operation appears in nested context menu. They are incorrectly exposed when right clicked on an operator in context menu. So don't expose then when opening nested context menu on operator. Pull Request: https://projects.blender.org/blender/blender/pulls/126927
This commit is contained in:
committed by
Harley Acheson
parent
e1a44ad129
commit
ccb1865925
@@ -1097,32 +1097,37 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
||||
}
|
||||
}
|
||||
|
||||
/* If the button represents an id, it can set the "id" context pointer. */
|
||||
if (asset::can_mark_single_from_context(C)) {
|
||||
const ID *id = static_cast<const ID *>(CTX_data_pointer_get_type(C, "id", &RNA_ID).data);
|
||||
/* Expose id specific operators in context menu when button has no operator associated. Otherwise
|
||||
* they would appear in nested context menus, see: #126006. */
|
||||
if ((but->optype == nullptr) && (but->apply_func == nullptr)) {
|
||||
/* If the button represents an id, it can set the "id" context pointer. */
|
||||
if (asset::can_mark_single_from_context(C)) {
|
||||
const ID *id = static_cast<const ID *>(CTX_data_pointer_get_type(C, "id", &RNA_ID).data);
|
||||
|
||||
/* Gray out items depending on if data-block is an asset. Preferably this could be done via
|
||||
* operator poll, but that doesn't work since the operator also works with "selected_ids",
|
||||
* which isn't cheap to check. */
|
||||
uiLayout *sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetEnabled(sub, !id->asset_data);
|
||||
uiItemO(sub,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Mark as Asset"),
|
||||
ICON_ASSET_MANAGER,
|
||||
"ASSET_OT_mark_single");
|
||||
sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetEnabled(sub, id->asset_data);
|
||||
uiItemO(sub,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Asset"),
|
||||
ICON_NONE,
|
||||
"ASSET_OT_clear_single");
|
||||
uiItemS(layout);
|
||||
}
|
||||
/* Gray out items depending on if data-block is an asset. Preferably this could be done via
|
||||
* operator poll, but that doesn't work since the operator also works with "selected_ids",
|
||||
* which isn't cheap to check. */
|
||||
uiLayout *sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetEnabled(sub, !id->asset_data);
|
||||
uiItemO(sub,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Mark as Asset"),
|
||||
ICON_ASSET_MANAGER,
|
||||
"ASSET_OT_mark_single");
|
||||
sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetEnabled(sub, id->asset_data);
|
||||
uiItemO(sub,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Asset"),
|
||||
ICON_NONE,
|
||||
"ASSET_OT_clear_single");
|
||||
uiItemS(layout);
|
||||
}
|
||||
|
||||
MenuType *mt_idtemplate_liboverride = WM_menutype_find("UI_MT_idtemplate_liboverride", true);
|
||||
if (mt_idtemplate_liboverride && mt_idtemplate_liboverride->poll(C, mt_idtemplate_liboverride)) {
|
||||
uiItemM_ptr(layout, mt_idtemplate_liboverride, IFACE_("Library Override"), ICON_NONE);
|
||||
uiItemS(layout);
|
||||
MenuType *mt_idtemplate_liboverride = WM_menutype_find("UI_MT_idtemplate_liboverride", true);
|
||||
if (mt_idtemplate_liboverride && mt_idtemplate_liboverride->poll(C, mt_idtemplate_liboverride))
|
||||
{
|
||||
uiItemM_ptr(layout, mt_idtemplate_liboverride, IFACE_("Library Override"), ICON_NONE);
|
||||
uiItemS(layout);
|
||||
}
|
||||
}
|
||||
|
||||
/* Pointer properties and string properties with
|
||||
|
||||
Reference in New Issue
Block a user