[Bf-blender-cvs] [dcc32116504] property-search-ui-v2: Property Search: Add search filter active flag to region

Hans Goudey noreply at git.blender.org
Fri Aug 14 22:13:04 CEST 2020


Commit: dcc32116504405589a21cb87886f2473f32acb2b
Author: Hans Goudey
Date:   Fri Aug 14 15:52:30 2020 -0400
Branches: property-search-ui-v2
https://developer.blender.org/rBdcc32116504405589a21cb87886f2473f32acb2b

Property Search: Add search filter active flag to region

This seems like a good way to quickly check whether or not to gray out
panel header text (in addition to whether they have a match).  It might
be nice to have this information quickly accessible in the future as well.

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

M	release/scripts/startup/bl_ui/space_properties.py
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_buttons/buttons_ops.c
M	source/blender/makesdna/DNA_screen_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py
index ead39c7b6fa..cf41808f2aa 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -30,7 +30,7 @@ class PROPERTIES_HT_header(Header):
         layout.template_header()
 
         layout.separator_spacer()
-        layout.prop(view, "filter_text", icon='VIEWZOOM', text="")
+        layout.prop(view, "search_filter", icon='VIEWZOOM', text="")
         layout.separator_spacer()
         
         row = layout.row()
@@ -51,7 +51,7 @@ class PROPERTIES_PT_navigation_bar(Panel):
 
         layout.scale_x = 1.4
         layout.scale_y = 1.4
-        if view.filter_text:
+        if view.search_filter:
             layout.prop_tabs_enum(view, "context", data_highlight=view, 
                 property_highlight="context_search_filter_active", icon_only=True)
         else:
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 29fe766b2d0..be9c271a9e2 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -80,6 +80,9 @@ void ED_region_tag_redraw_no_rebuild(struct ARegion *region);
 void ED_region_tag_refresh_ui(struct ARegion *region);
 void ED_region_tag_redraw_editor_overlays(struct ARegion *region);
 
+void ED_region_search_filter_update(const struct bContext *C, struct ARegion *region);
+char *ED_area_search_filter_get(const struct bContext *C);
+
 void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *region);
 void ED_region_panels_ex(const struct bContext *C,
                          struct ARegion *region,
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 9a58eb0b098..3e4b5d13363 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -753,6 +753,26 @@ void ED_area_tag_refresh(ScrArea *area)
 
 /* *************************************************************** */
 
+/**
+ * Returns the search string if the space type supports property search.
+ */
+char *ED_area_search_filter_get(const bContext *C)
+{
+  SpaceProperties *sbuts = CTX_wm_space_properties(C);
+  if (sbuts != NULL) {
+    return sbuts->search_string;
+  }
+  return NULL;
+}
+
+void ED_region_search_filter_update(const bContext *C, ARegion *region)
+{
+  const char *search_filter = ED_area_search_filter_get(C);
+  SET_FLAG_FROM_TEST(region->flag, search_filter[0] != '\0', RGN_FLAG_SEARCH_FILTER_ACTIVE);
+}
+
+/* *************************************************************** */
+
 /* use NULL to disable it */
 void ED_area_status_text(ScrArea *area, const char *str)
 {
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index f5efeabf2bf..42c8452f764 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -92,6 +92,7 @@ static int buttons_clear_filter_exec(bContext *C, wmOperator *UNUSED(op))
 
   strcpy(space->search_string, "");
 
+  ED_region_search_filter_update(C, CTX_wm_region(C));
   ED_area_tag_redraw(area);
 
   return OPERATOR_FINISHED;
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index d5b828c898d..9c7bf509c17 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -682,6 +682,8 @@ enum {
   /** When the user sets the region is hidden,
    * needed for floating regions that may be hidden for other reasons. */
   RGN_FLAG_HIDDEN_BY_USER = (1 << 7),
+  /** Property search filter is active. */
+  RGN_FLAG_SEARCH_FILTER_ACTIVE = (1 << 8),
 };
 
 /** #ARegion.do_draw */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index ef666694240..d224d28d221 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1817,6 +1817,14 @@ static void rna_SpaceProperties_context_update(Main *UNUSED(bmain),
   }
 }
 
+static void rna_SpaceProperties_search_filter_update(struct bContext *C,
+                                                     struct PointerRNA *UNUSED(ptr))
+{
+  ARegion *region = CTX_wm_region(C);
+
+  ED_region_search_filter_update(C, region);
+}
+
 /* Space Console */
 static void rna_ConsoleLine_body_get(PointerRNA *ptr, char *value)
 {
@@ -4480,11 +4488,13 @@ static void rna_def_space_properties(BlenderRNA *brna)
   RNA_def_property_update(
       prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_context_update");
 
-  prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE);
+  prop = RNA_def_property(srna, "search_filter", PROP_STRING, PROP_NONE);
   RNA_def_property_string_sdna(prop, NULL, "search_string");
   RNA_def_property_ui_text(prop, "Display Filter", "Live search filtering string");
   RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
-  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL);
+  RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+  RNA_def_property_update(
+      prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_search_filter_update");
 }
 
 static void rna_def_space_image(BlenderRNA *brna)



More information about the Bf-blender-cvs mailing list