diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-04-15 05:42:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-04-15 06:04:13 +0300 |
commit | 92113e2da742e6b647578633a97ed6d16476fb97 (patch) | |
tree | 12d49c6cdd4914a70944acff91abd82213d7f625 /release/scripts/startup/bl_ui/space_outliner.py | |
parent | af91bbc221fe21f9238172a8e152fe49dcd67d4b (diff) |
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.
Diffstat (limited to 'release/scripts/startup/bl_ui/space_outliner.py')
-rw-r--r-- | release/scripts/startup/bl_ui/space_outliner.py | 38 |
1 files changed, 22 insertions, 16 deletions
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, ) |