[Bf-blender-cvs] [debd8aab4a8] master: UI: default to searching menus instead of operators

Campbell Barton noreply at git.blender.org
Wed Apr 15 16:37:22 CEST 2020


Commit: debd8aab4a82d221b9b2207a2fd7a25bb34a1c16
Author: Campbell Barton
Date:   Thu Apr 16 00:32:30 2020 +1000
Branches: master
https://developer.blender.org/rBdebd8aab4a82d221b9b2207a2fd7a25bb34a1c16

UI: default to searching menus instead of operators

Menus from the top-bar, space-header and key bindings are used
to gather menus to populate the search popup.

Giving better context and default options for operators.

Part of T74157

Enabling "Developer Extras" exposes operator search in the Edit menu,
as this can be useful for developers to run operators
without first exposing them in the interface.

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

M	release/scripts/startup/bl_ui/space_topbar.py
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 1e6f03c2b0c..7a23eb9282c 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -580,6 +580,8 @@ class TOPBAR_MT_edit(Menu):
     def draw(self, context):
         layout = self.layout
 
+        show_developer = context.preferences.view.show_developer_ui
+
         layout.operator("ed.undo")
         layout.operator("ed.redo")
 
@@ -598,8 +600,9 @@ class TOPBAR_MT_edit(Menu):
 
         layout.separator()
 
-        layout.operator("wm.search_menu",
-                        text="Operator Search...", icon='VIEWZOOM')
+        layout.operator("wm.search_menu", text="Menu Search...", icon='VIEWZOOM')
+        if show_developer:
+            layout.operator("wm.search_operator", text="Operator Search...", icon='VIEWZOOM')
 
         layout.separator()
 
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 76e80fdb414..5ff463c4700 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2158,16 +2158,6 @@ class USERPREF_PT_experimental_virtual_reality(ExperimentalPanel, Panel):
         )
 """
 
-class USERPREF_PT_experimental_ui(ExperimentalPanel, Panel):
-    bl_label = "UI"
-
-    def draw(self, context):
-        self._draw_items(
-            context, (
-                ({"property": "use_menu_search"}, "T74157"),
-            ),
-        )
-
 
 class USERPREF_PT_experimental_system(ExperimentalPanel, Panel):
     bl_label = "System"
@@ -2270,7 +2260,6 @@ classes = (
     # Popovers.
     USERPREF_PT_ndof_settings,
 
-    USERPREF_PT_experimental_ui,
     USERPREF_PT_experimental_system,
 
     # Add dynamically generated editor theme panels last,
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index e8f4cae573a..2c938ab036f 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -619,9 +619,8 @@ typedef struct UserDef_FileSpaceData {
 
 typedef struct UserDef_Experimental {
   char use_undo_speedup;
-  char use_menu_search;
   /** `makesdna` does not allow empty structs. */
-  char _pad0[6];
+  char _pad0[7];
 } UserDef_Experimental;
 
 #define USER_EXPERIMENTAL_TEST(userdef, member) \
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 514d7428ff8..2df2a481091 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6063,10 +6063,6 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
       prop,
       "Undo Speedup",
       "Use new undo speedup (WARNING: can lead to crashes and serious .blend file corruption)");
-
-  prop = RNA_def_property(srna, "use_menu_search", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "use_menu_search", 1);
-  RNA_def_property_ui_text(prop, "Menu Search", "Search actions by menus instead of operators");
 }
 
 static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index a7578291a21..abbb6d3b994 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1794,13 +1794,12 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *eve
     }
   }
 
-  PropertyRNA *prop = op->type->prop;
   int search_type;
-  if (RNA_property_is_set(op->ptr, prop)) {
-    search_type = RNA_property_enum_get(op->ptr, prop);
+  if (STREQ(op->type->idname, "WM_OT_search_menu")) {
+    search_type = SEARCH_TYPE_MENU;
   }
   else {
-    search_type = U.experimental.use_menu_search ? SEARCH_TYPE_MENU : SEARCH_TYPE_OPERATOR;
+    search_type = SEARCH_TYPE_OPERATOR;
   }
 
   static struct SearchPopupInit_Data data;
@@ -1818,20 +1817,22 @@ static void WM_OT_search_menu(wmOperatorType *ot)
 {
   ot->name = "Search Menu";
   ot->idname = "WM_OT_search_menu";
-  ot->description = "Pop-up a search menu over all available operators in current context";
+  ot->description = "Pop-up a search over all menus in the current context";
 
   ot->invoke = wm_search_menu_invoke;
   ot->exec = wm_search_menu_exec;
   ot->poll = WM_operator_winactive;
+}
 
-  static const EnumPropertyItem search_type_items[] = {
-      {SEARCH_TYPE_OPERATOR, "OPERATOR", 0, "Operator", "Search all operators"},
-      {SEARCH_TYPE_MENU, "MENU", 0, "Menu", "Search active menu items"},
-      {0, NULL, 0, NULL, NULL},
-  };
+static void WM_OT_search_operator(wmOperatorType *ot)
+{
+  ot->name = "Search Operator";
+  ot->idname = "WM_OT_search_operator";
+  ot->description = "Pop-up a search over all available operators in current context";
 
-  /* properties */
-  ot->prop = RNA_def_enum(ot->srna, "type", search_type_items, SEARCH_TYPE_OPERATOR, "Type", "");
+  ot->invoke = wm_search_menu_invoke;
+  ot->exec = wm_search_menu_exec;
+  ot->poll = WM_operator_winactive;
 }
 
 static int wm_call_menu_exec(bContext *C, wmOperator *op)
@@ -3806,6 +3807,7 @@ void wm_operatortypes_register(void)
   WM_operatortype_append(WM_OT_operator_defaults);
   WM_operatortype_append(WM_OT_splash);
   WM_operatortype_append(WM_OT_search_menu);
+  WM_operatortype_append(WM_OT_search_operator);
   WM_operatortype_append(WM_OT_call_menu);
   WM_operatortype_append(WM_OT_call_menu_pie);
   WM_operatortype_append(WM_OT_call_panel);



More information about the Bf-blender-cvs mailing list