Fix menu search omitting the outliner context menu

Use a regular context menu as a fallback for the outliner.

If there are no specific actions for the item under the cursor,
fall through to opening a regular menu.

This lets menu search find the context menu items which were previously
unavailable as menu search wont run operators.
This commit is contained in:
Campbell Barton
2020-04-15 12:42:01 +10:00
parent af91bbc221
commit 92113e2da7
4 changed files with 32 additions and 30 deletions

View File

@@ -763,7 +763,9 @@ def km_outliner(params):
{"properties": [("all", True)]}),
("outliner.item_openclose", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
{"properties": [("all", False)]}),
# Fall through to generic context menu if the item(s) selected have no type specific actions.
("outliner.operation", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None),
op_menu("OUTLINER_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True}, None),
("outliner.show_hierarchy", {"type": 'HOME', "value": 'PRESS'}, None),

View File

@@ -496,7 +496,9 @@ def km_outliner(params):
{"properties": [("all", True)]}),
("outliner.item_openclose", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
{"properties": [("all", False)]}),
# Fall through to generic context menu if the item(s) selected have no type specific actions.
("outliner.operation", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None),
op_menu("OUTLINER_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True}, None),
("outliner.show_hierarchy", {"type": 'A', "value": 'PRESS'}, None),

View File

@@ -104,20 +104,26 @@ class OUTLINER_MT_editor_menus(Menu):
layout.menu("OUTLINER_MT_edit_datablocks")
class OUTLINER_MT_context(Menu):
bl_label = "Outliner"
class OUTLINER_MT_context_menu(Menu):
bl_label = "Outliner Context Menu"
def draw(self, context):
space = context.space_data
def draw(self, _context):
layout = self.layout
layout.menu("OUTLINER_MT_context_view")
if space.display_mode == 'VIEW_LAYER':
OUTLINER_MT_collection_new.draw_without_context_menu(context, layout)
layout.separator()
layout.menu("OUTLINER_MT_context_menu_view")
layout.separator()
layout.menu("INFO_MT_area")
class OUTLINER_MT_context_view(Menu):
class OUTLINER_MT_context_menu_view(Menu):
bl_label = "View"
def draw(self, _context):
@@ -236,25 +242,25 @@ class OUTLINER_MT_collection(Menu):
layout.separator()
OUTLINER_MT_context.draw(self, context)
OUTLINER_MT_context_menu.draw(self, context)
class OUTLINER_MT_collection_new(Menu):
bl_label = "Collection"
def draw(self, context):
# Note: this menu is used in any context where collections exist,
# as a generic way to add data. The names here are expanded because
# this menu is often expended without it's title.
layout = self.layout
@staticmethod
def draw_without_context_menu(context, layout):
layout.operator("outliner.collection_new", text="New Collection").nested = False
layout.operator("outliner.id_paste", text="Paste Data-Blocks", icon='PASTEDOWN')
def draw(self, context):
layout = self.layout
self.draw_without_context_menu(context, layout)
layout.separator()
OUTLINER_MT_context.draw(self, context)
OUTLINER_MT_context_menu.draw(self, context)
class OUTLINER_MT_object(Menu):
@@ -303,7 +309,7 @@ class OUTLINER_MT_object(Menu):
layout.separator()
OUTLINER_MT_context.draw(self, context)
OUTLINER_MT_context_menu.draw(self, context)
class OUTLINER_PT_filter(Panel):
@@ -423,8 +429,8 @@ classes = (
OUTLINER_MT_collection_visibility,
OUTLINER_MT_collection_view_layer,
OUTLINER_MT_object,
OUTLINER_MT_context,
OUTLINER_MT_context_view,
OUTLINER_MT_context_menu,
OUTLINER_MT_context_menu_view,
OUTLINER_PT_filter,
)

View File

@@ -2332,11 +2332,9 @@ static int outliner_operator_menu(bContext *C, const char *opname)
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop));
MenuType *mt = WM_menutype_find("OUTLINER_MT_context", false);
if (mt) {
uiItemS(layout);
UI_menutype_draw(C, mt, layout);
}
uiItemS(layout);
uiItemMContents(layout, "OUTLINER_MT_context_menu");
UI_popup_menu_end(C, pup);
@@ -2471,14 +2469,8 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent
}
}
/* Menus for clicking in empty space. */
if (soops->outlinevis == SO_VIEW_LAYER) {
WM_menu_name_call(C, "OUTLINER_MT_collection_new", WM_OP_INVOKE_REGION_WIN);
return OPERATOR_FINISHED;
}
WM_menu_name_call(C, "OUTLINER_MT_context", WM_OP_INVOKE_REGION_WIN);
return OPERATOR_FINISHED;
/* Let this fall through to 'OUTLINER_MT_context_menu'. */
return OPERATOR_PASS_THROUGH;
}
/* Menu only! Calls other operators */