[Bf-blender-cvs] [863ea6a32c6] property-search-ui-v2: Property Search: Quick start and clear operators

Hans Goudey noreply at git.blender.org
Wed Sep 9 21:03:18 CEST 2020


Commit: 863ea6a32c64846b62b7cf07cd1adf93a279bd94
Author: Hans Goudey
Date:   Wed Sep 9 13:13:49 2020 -0500
Branches: property-search-ui-v2
https://developer.blender.org/rB863ea6a32c64846b62b7cf07cd1adf93a279bd94

Property Search: Quick start and clear operators

This patch adds quick start and quick clear operators.

`ctrl-F` is obviously necessary, but the clear operator, `alt-F` requires
a bit of explanation. First, it maps nicely to the paradigm of "key to set,
alt-key to clear," which makes it pretty unobtrusive. Second, it can be
a quicker way to clear the search than moving the mouse to the top.
Finally, a future improvement I would like to make to property search
is adding the ability to reset the panels to their expansion before the
search started. Either escaping out of the button while text editing or
pressing `alt-F` would be the way to do that.

Differential Revision: https://developer.blender.org/D8857

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/editors/space_buttons/buttons_intern.h
M	source/blender/editors/space_buttons/buttons_ops.c
M	source/blender/editors/space_buttons/space_buttons.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 53b45ed6c90..8a09f4bd83a 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -736,6 +736,8 @@ def km_property_editor(_params):
          {"properties": [("direction", 'PREV'), ], },),
         ("screen.space_context_cycle", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True},
          {"properties": [("direction", 'NEXT'), ], },),
+        ("buttons.start_filter", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+        ("buttons.clear_filter", {"type": 'F', "value": 'PRESS', "alt": True}, None),
         # Modifier panels
         ("object.modifier_remove", {"type": 'X', "value": 'PRESS'}, {"properties": [("report", True)]}),
         ("object.modifier_remove", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("report", True)]}),
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 76a4d72057f..a5419fea5ca 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -89,6 +89,8 @@ extern const char *buttons_context_dir[]; /* doc access */
 void buttons_texture_context_compute(const struct bContext *C, struct SpaceProperties *sbuts);
 
 /* buttons_ops.c */
+void BUTTONS_OT_start_filter(struct wmOperatorType *ot);
+void BUTTONS_OT_clear_filter(struct wmOperatorType *ot);
 void BUTTONS_OT_toggle_pin(struct wmOperatorType *ot);
 void BUTTONS_OT_file_browse(struct wmOperatorType *ot);
 void BUTTONS_OT_directory_browse(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 2e6ad82ef08..1a084efecc7 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -38,6 +38,7 @@
 #include "BKE_context.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
+#include "BKE_screen.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -52,6 +53,65 @@
 
 #include "buttons_intern.h" /* own include */
 
+/* -------------------------------------------------------------------- */
+/** \name Start / Clear Seach Filter Operators
+ *
+ *  \note Almost a duplicate of the file browser operator #FILE_OT_start_filter.
+ * \{ */
+
+static int buttons_start_filter_exec(bContext *C, wmOperator *UNUSED(op))
+{
+  SpaceProperties *space = CTX_wm_space_properties(C);
+  ScrArea *area = CTX_wm_area(C);
+  ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
+
+  ARegion *region_ctx = CTX_wm_region(C);
+  CTX_wm_region_set(C, region);
+  UI_textbutton_activate_rna(C, region, space, "search_filter");
+  CTX_wm_region_set(C, region_ctx);
+
+  return OPERATOR_FINISHED;
+}
+
+void BUTTONS_OT_start_filter(struct wmOperatorType *ot)
+{
+  /* Identifiers. */
+  ot->name = "Filter";
+  ot->description = "Start entering filter text";
+  ot->idname = "BUTTONS_OT_start_filter";
+
+  /* Callbacks. */
+  ot->exec = buttons_start_filter_exec;
+  ot->poll = ED_operator_buttons_active;
+}
+
+static int buttons_clear_filter_exec(bContext *C, wmOperator *UNUSED(op))
+{
+  ScrArea *area = CTX_wm_area(C);
+  SpaceProperties *space = CTX_wm_space_properties(C);
+
+  strcpy(space->search_string, "");
+
+  ED_region_search_filter_update(C, CTX_wm_region(C));
+  ED_area_tag_redraw(area);
+
+  return OPERATOR_FINISHED;
+}
+
+void BUTTONS_OT_clear_filter(struct wmOperatorType *ot)
+{
+  /* Identifiers. */
+  ot->name = "Clear Filter";
+  ot->description = "Clear the search filter";
+  ot->idname = "BUTTONS_OT_clear_filter";
+
+  /* Callbacks. */
+  ot->exec = buttons_clear_filter_exec;
+  ot->poll = ED_operator_buttons_active;
+}
+
+/** \} */
+
 /* -------------------------------------------------------------------- */
 /** \name Pin ID Operator
  * \{ */
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 609d53ccc55..4b439c16f3c 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -329,6 +329,8 @@ static void buttons_main_region_listener(wmWindow *UNUSED(win),
 
 static void buttons_operatortypes(void)
 {
+  WM_operatortype_append(BUTTONS_OT_start_filter);
+  WM_operatortype_append(BUTTONS_OT_clear_filter);
   WM_operatortype_append(BUTTONS_OT_toggle_pin);
   WM_operatortype_append(BUTTONS_OT_context_menu);
   WM_operatortype_append(BUTTONS_OT_file_browse);



More information about the Bf-blender-cvs mailing list