diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-03-24 03:34:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-03-24 05:41:18 +0300 |
commit | c46dcdf8871e7404516a234087cfc4bf4e2794d0 (patch) | |
tree | ca5f6d549a3294441a452ae04507e46360324bad /release | |
parent | 94b8166a8b0519aef76e8cb8d0c9a6035fe04baf (diff) |
UI: add menu search functionality to operator search menu
This has some advantages over operator search:
- Some operators need options set to be usefully accessed.
- Shows key bindings to access menus
(for actions that don't have key bindings themselves).
- Non operator actions such as check-boxes are also shown.
- Menu items can control execution context, using invoke or execute
where appropriate so we can control how the operator runs.
Part of the design task T74157.
This can be tested using the 'Experimental' preferences section
or selected in the key-map editor.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_ui/space_topbar.py | 3 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 68 |
2 files changed, 38 insertions, 33 deletions
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 1f52323f540..7ffb61fef5a 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -207,7 +207,8 @@ class TOPBAR_MT_editor_menus(Menu): def draw(self, context): layout = self.layout - if context.area.show_menus: + # Allow calling this menu directly (this might not be a header area). + if getattr(context.area, "show_menus"): layout.menu("TOPBAR_MT_app", text="", icon='BLENDER') else: layout.menu("TOPBAR_MT_app", text="Blender") diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index e6ee779d89b..165761254d0 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -2134,6 +2134,21 @@ class ExperimentalPanel: url_prefix = "https://developer.blender.org/" + def _draw_items(self, context, items): + prefs = context.preferences + experimental = prefs.experimental + + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + for prop_keywords, task in items: + split = layout.split(factor=0.66) + col = split.split() + col.prop(experimental, **prop_keywords) + col = split.split() + col.operator("wm.url_open", text=task, icon='URL').url = self.url_prefix + task + """ # Example panel, leave it here so we always have a template to follow even # after the features are gone from the experimental panel. @@ -2142,46 +2157,34 @@ class USERPREF_PT_experimental_virtual_reality(ExperimentalPanel, Panel): bl_label = "Virtual Reality" def draw(self, context): - prefs = context.preferences - experimental = prefs.experimental + self._draw_items( + context, ( + ({"property": "use_virtual_reality_scene_inspection"}, "T71347"), + ({"property": "use_virtual_reality_immersive_drawing"}, "T71348"), + ) + ) +""" - layout = self.layout - layout.use_property_split = True - layout.use_property_decorate = False +class USERPREF_PT_experimental_ui(ExperimentalPanel, Panel): + bl_label = "UI" - task = "T71347" - split = layout.split(factor=0.66) - col = split.split() - col.prop(experimental, "use_virtual_reality_scene_inspection", text="Scene Inspection") - col = split.split() - col.operator("wm.url_open", text=task, icon='URL').url = self.url_prefix + task - - task = "T71348" - split = layout.split(factor=0.66) - col = split.column() - col.prop(experimental, "use_virtual_reality_immersive_drawing", text="Continuous Immersive Drawing") - col = split.column() - col.operator("wm.url_open", text=task, icon='URL').url = self.url_prefix + task -""" + def draw(self, context): + self._draw_items( + context, ( + ({"property": "use_menu_search"}, "T74157"), + ), + ) class USERPREF_PT_experimental_system(ExperimentalPanel, Panel): bl_label = "System" def draw(self, context): - prefs = context.preferences - experimental = prefs.experimental - - layout = self.layout - layout.use_property_split = True - layout.use_property_decorate = False - - task = "T60695" - split = layout.split(factor=0.66) - col = split.split() - col.prop(experimental, "use_undo_speedup") - col = split.split() - col.operator("wm.url_open", text=task, icon='URL').url = self.url_prefix + task + self._draw_items( + context, ( + ({"property": "use_undo_speedup"}, "T60695"), + ), + ) # ----------------------------------------------------------------------------- @@ -2274,6 +2277,7 @@ classes = ( # Popovers. USERPREF_PT_ndof_settings, + USERPREF_PT_experimental_ui, USERPREF_PT_experimental_system, # Add dynamically generated editor theme panels last, |