Commit: 92113e2da742e6b647578633a97ed6d16476fb97
Author: Campbell Barton
Date:   Wed Apr 15 12:42:01 2020 +1000
Branches: master
https://developer.blender.org/rB92113e2da742e6b647578633a97ed6d16476fb97

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.

===================================================================

M       release/scripts/presets/keyconfig/keymap_data/blender_default.py
M       
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M       release/scripts/startup/bl_ui/space_outliner.py
M       source/blender/editors/space_outliner/outliner_tools.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 7a48516cfa7..22afe9fd7ce 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -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),
diff --git 
a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py 
b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index bfe47ff4bac..0005e7dd3d2 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -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),
diff --git a/release/scripts/startup/bl_ui/space_outliner.py 
b/release/scripts/startup/bl_ui/space_outliner.py
index 413659735b6..a74d9cc9547 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -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.
+    @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
 
-        layout.operator("outliner.collection_new", text="New 
Collection").nested = False
-        layout.operator("outliner.id_paste", text="Paste Data-Blocks", 
icon='PASTEDOWN')
+        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,
 )
 
diff --git a/source/blender/editors/space_outliner/outliner_tools.c 
b/source/blender/editors/space_outliner/outliner_tools.c
index fe62272614f..d7b673c1b9e 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -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 */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to