[Bf-blender-cvs] [1836a979586] property-search-ui-v2: Property Search: Continued refactoring / cleanup

Hans Goudey noreply at git.blender.org
Thu Jul 30 21:23:12 CEST 2020


Commit: 1836a979586b18c29e855aa5cab611fbda030084
Author: Hans Goudey
Date:   Thu Jul 30 15:23:18 2020 -0400
Branches: property-search-ui-v2
https://developer.blender.org/rB1836a979586b18c29e855aa5cab611fbda030084

Property Search: Continued refactoring / cleanup

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_layout.c
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 65f770887fe..20bbc22dbfc 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1692,7 +1692,7 @@ void UI_panels_scale(struct ARegion *region, float new_width);
 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_matches_search_filter(const struct Panel *panel);
 bool UI_panel_is_active(const struct Panel *panel);
 
 bool UI_panel_category_is_visible(const struct ARegion *region);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index d533035798a..fb01f265994 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -750,7 +750,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style,
                                   const rcti *rect,
                                   const bool show_pin,
                                   const bool show_background);
-void ui_panel_set_search_filtered(struct Panel *panel, const bool value);
+void ui_panel_set_search_filter_match(struct Panel *panel, const bool value);
 
 /* interface_draw.c */
 extern void ui_draw_dropshadow(
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 23dcdefdf75..b8ad3c11a58 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -5153,8 +5153,6 @@ void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only)
 // #define PROPERTY_SEARCH_USE_TOOLTIPS
 #define PROPERTY_SEARCH_USE_PANEL_LABELS
 
-static void ui_layout_free(uiLayout *layout);
-
 static void layout_free_and_hide_buttons(uiLayout *layout)
 {
   LISTBASE_FOREACH_MUTABLE (uiItem *, item, &layout->items) {
@@ -5248,6 +5246,9 @@ static void block_search(uiBlock *block)
   if (!panel_label_matches) {
     has_result = block_search_filter_tag_buttons(block);
   }
+  else {
+    has_result = true;
+  }
 
   /* Remove search only layout roots before the next step. */
   LISTBASE_FOREACH_MUTABLE (uiLayoutRoot *, root, &block->layouts) {
@@ -5268,7 +5269,21 @@ static void block_search(uiBlock *block)
   }
 
   if (block->panel != NULL) {
-    ui_panel_set_search_filtered(block->panel, !has_result);
+    ui_panel_set_search_filter_match(block->panel, !has_result);
+  }
+}
+
+static void block_search_deactive_buttons(uiBlock *block)
+{
+  /* Only continue if the block has the search filter set. */
+  if (!(block->search_filter && block->search_filter[0])) {
+    return;
+  }
+
+  LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
+    if ((but->flag & UI_SEARCH_FILTER_MATCHES)) {
+      but->flag |= UI_BUT_INACTIVE;
+    }
   }
 }
 
@@ -5485,13 +5500,10 @@ static void ui_item_layout(uiItem *item)
     }
   }
   else {
-    uiButtonItem *bitem = (uiButtonItem *)item;
     if (item->flag & UI_ITEM_BOX_ITEM) {
+      uiButtonItem *bitem = (uiButtonItem *)item;
       bitem->but->drawflag |= UI_BUT_BOX_ITEM;
     }
-    if (!(bitem->but->flag & UI_SEARCH_FILTER_MATCHES)) {
-      bitem->but->flag |= UI_BUT_INACTIVE;
-    }
   }
 }
 
@@ -5700,6 +5712,8 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
     ui_layout_free(root->layout);
   }
 
+  block_search_deactive_buttons(block);
+
   BLI_freelistN(&block->layouts);
 
   /* XXX silly trick, interface_templates.c doesn't get linked
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 82331f68242..96e9713ccc2 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -75,8 +75,7 @@
 #define PNL_ANIM_ALIGN (1 << 3)
 #define PNL_NEW_ADDED (1 << 4)
 #define PNL_FIRST (1 << 5)
-#define PNL_SEARCH_FILTERED (1 << 6)
-#define PNL_WAS_SEARCH_FILTERED (1 << 7)
+#define PNL_SEARCH_FILTER_MATCHES (1 << 6)
 
 /* only show pin header button for pinned panels */
 #define USE_PIN_HIDDEN
@@ -861,35 +860,31 @@ static void ui_offset_panel_block(uiBlock *block)
   block->rect.xmin = block->rect.ymin = 0.0;
 }
 
-void ui_panel_set_search_filtered(struct Panel *panel, const bool value)
+void ui_panel_set_search_filter_match(struct Panel *panel, const bool value)
 {
-  SET_FLAG_FROM_TEST(panel->runtime_flag, value, PNL_SEARCH_FILTERED);
+  SET_FLAG_FROM_TEST(panel->runtime_flag, value, PNL_SEARCH_FILTER_MATCHES);
 }
 
-static void panel_is_search_filtered_recursive(const Panel *panel, bool *is_search_filtered)
+static void panel_matches_search_filter_recursive(const Panel *panel, bool *filter_matches)
 {
-  *is_search_filtered = *is_search_filtered && (panel->runtime_flag & PNL_SEARCH_FILTERED);
+  *filter_matches = *filter_matches && (panel->runtime_flag & PNL_SEARCH_FILTER_MATCHES);
 
   /* If the panel is filtered (removed) we need to check that its children are too. */
-  if (*is_search_filtered) {
+  if (*filter_matches) {
     LISTBASE_FOREACH (const Panel *, child_panel, &panel->children) {
-      panel_is_search_filtered_recursive(child_panel, is_search_filtered);
+      panel_matches_search_filter_recursive(child_panel, filter_matches);
     }
   }
 }
 
 /**
- * Find whether a panel and all of its subpanels have been filtered by property search.
- *
- * \note We maintain a separate flag for active and search filtered. This prevents the
- * search filtering from being too invasive to other code and makes animation of search
- * filtered panels possible.
+ * Find whether a panel or any of its subpanels contain a property that matches the search filter.
  */
-bool UI_panel_is_search_filtered(const Panel *panel)
+bool UI_panel_matches_search_filter(const Panel *panel)
 {
-  bool is_search_filtered = true;
-  panel_is_search_filtered_recursive(panel, &is_search_filtered);
-  return is_search_filtered;
+  bool search_filter_matches = false;
+  panel_matches_search_filter_recursive(panel, &search_filter_matches);
+  return search_filter_matches;
 }
 
 /**
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 1fcd98246bf..a789f382f76 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -350,7 +350,7 @@ static void property_search_all_tabs(const bContext *C,
     bool has_unfiltered_panel = false;
     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);
+      has_unfiltered_panel |= UI_panel_matches_search_filter(panel) && UI_panel_is_active(panel);
     }
     if (has_unfiltered_panel) {
       sbuts->context_search_filter_active |= (1 << i);



More information about the Bf-blender-cvs mailing list