[Bf-blender-cvs] [1b391f14fcd] property-search-ui: Property Search: Fixes for other-tab searching

Hans Goudey noreply at git.blender.org
Tue Jul 28 18:11:40 CEST 2020


Commit: 1b391f14fcd3956eab8d71cdde347ef45fc6e03f
Author: Hans Goudey
Date:   Tue Jul 28 12:11:48 2020 -0400
Branches: property-search-ui
https://developer.blender.org/rB1b391f14fcd3956eab8d71cdde347ef45fc6e03f

Property Search: Fixes for other-tab searching

The main change here is not running the search twice for the active tab.
We also check for the panel being active rather than just not filtered.

There are still errors when the tool tab is active, those will be solved
in a future commit.

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/space_buttons/space_buttons.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index f6405d1a1ae..1d56cbb782d 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1691,6 +1691,7 @@ void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
 int UI_panel_size_y(const struct Panel *panel);
 bool UI_panel_is_dragging(const struct Panel *panel);
 bool UI_panel_is_search_filtered(const struct Panel *panel);
+bool UI_panel_is_active(const struct Panel *panel);
 
 bool UI_panel_category_is_visible(const struct ARegion *region);
 void UI_panel_category_add(struct ARegion *region, const char *name);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 8fe89a225a7..bbe3668e756 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -904,6 +904,14 @@ bool UI_panel_is_search_filtered(const Panel *panel)
   return is_search_filtered;
 }
 
+/**
+ * Returns whether a panel is currently active (displayed).
+ */
+bool UI_panel_is_active(const Panel *panel)
+{
+  return panel->runtime_flag & PNL_ACTIVE;
+}
+
 /**************************** drawing *******************************/
 
 /* triangle 'icon' for panel header */
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 6a173d2dea7..1fcd98246bf 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -145,6 +145,7 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *region)
  *
  * \return The total number of items in the array returned.
  */
+/* HANS-TODO: Use short for this. */
 int ED_buttons_tabs_list(SpaceProperties *sbuts, int *context_tabs_array)
 {
   int length = 0;
@@ -299,15 +300,26 @@ static void buttons_main_region_layout_properties(const bContext *C,
       C, region, &region->type->paneltypes, contexts, sbuts->mainb, vertical, NULL);
 }
 
-static void property_search_other_tabs(const bContext *C,
-                                       SpaceProperties *sbuts,
-                                       ARegion *main_region)
+static void main_region_layout(const bContext *C, SpaceProperties *sbuts, ARegion *region)
+{
+  if (sbuts->mainb == BCONTEXT_TOOL) {
+    ED_view3d_buttons_region_layout_ex(C, region, "Tool");
+  }
+  else {
+    buttons_main_region_layout_properties(C, sbuts, region);
+  }
+}
+
+static void property_search_all_tabs(const bContext *C,
+                                     SpaceProperties *sbuts,
+                                     ARegion *main_region)
 {
   sbuts->context_search_filter_active = 0;
 
   /* Duplicate space and region so we don't change any data for this space. */
   ScrArea *area_copy = MEM_dupallocN(CTX_wm_area(C));
   ARegion *region_copy = BKE_area_region_copy(CTX_wm_area(C)->type, main_region);
+  BKE_area_region_panels_free(&region_copy->panels);
   bContext *C_copy = CTX_copy(C);
   CTX_wm_area_set(C_copy, area_copy);
   CTX_wm_region_set(C_copy, region_copy);
@@ -324,12 +336,21 @@ static void property_search_other_tabs(const bContext *C,
 
     /* Run the layout with this tab set active. */
     sbuts_copy->mainb = sbuts->mainbo = sbuts_copy->mainbuser = context_tabs_array[i];
-    buttons_main_region_layout_properties(C_copy, sbuts_copy, region_copy);
+
+    /* Run the layout for the actual region if the tab matches to avoid doing it again later on. */
+    const bool use_actual_region = sbuts->mainb == sbuts_copy->mainb;
+    if (use_actual_region) {
+      main_region_layout(C, sbuts, main_region);
+    }
+    else {
+      main_region_layout(C_copy, sbuts_copy, region_copy);
+    }
 
     /* Store whether this tab has any unfiltered panels left. */
     bool has_unfiltered_panel = false;
-    LISTBASE_FOREACH (Panel *, panel, &region_copy->panels) {
-      has_unfiltered_panel |= !UI_panel_is_search_filtered(panel);
+    LISTBASE_FOREACH (
+        Panel *, panel, use_actual_region ? &main_region->panels : &region_copy->panels) {
+      has_unfiltered_panel |= !UI_panel_is_search_filtered(panel) && UI_panel_is_active(panel);
     }
     if (has_unfiltered_panel) {
       sbuts->context_search_filter_active |= (1 << i);
@@ -354,14 +375,10 @@ static void buttons_main_region_layout(const bContext *C, ARegion *region)
   SpaceProperties *sbuts = CTX_wm_space_properties(C);
 
   if (sbuts->search_string != NULL && sbuts->search_string[0] != '\0') {
-    property_search_other_tabs(C, sbuts, region);
-  }
-
-  if (sbuts->mainb == BCONTEXT_TOOL) {
-    ED_view3d_buttons_region_layout_ex(C, region, "Tool");
+    property_search_all_tabs(C, sbuts, region);
   }
   else {
-    buttons_main_region_layout_properties(C, sbuts, region);
+    main_region_layout(C, sbuts, region);
   }
 
   sbuts->mainbo = sbuts->mainb;



More information about the Bf-blender-cvs mailing list