[Bf-blender-cvs] [95fabb12cbc] property-search-ui-v2: Property Search: Highlight panel headers with a search match

Hans Goudey noreply at git.blender.org
Thu Jul 30 23:44:15 CEST 2020


Commit: 95fabb12cbcc4b027c53993f00bad0278efe133f
Author: Hans Goudey
Date:   Thu Jul 30 17:44:22 2020 -0400
Branches: property-search-ui-v2
https://developer.blender.org/rB95fabb12cbcc4b027c53993f00bad0278efe133f

Property Search: Highlight panel headers with a search match

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

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/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b8ad3c11a58..b885ac76851 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -5224,11 +5224,11 @@ static bool block_search_filter_tag_buttons(uiBlock *block)
   return has_result;
 }
 
-static void block_search(uiBlock *block)
+static bool block_search(uiBlock *block)
 {
   /* Only continue if the block has the search filter set. */
   if (!(block->search_filter && block->search_filter[0])) {
-    return;
+    return false;
   }
 
   /* Also search based on panel labels. */
@@ -5269,8 +5269,10 @@ static void block_search(uiBlock *block)
   }
 
   if (block->panel != NULL) {
-    ui_panel_set_search_filter_match(block->panel, !has_result);
+    ui_panel_set_search_filter_match(block->panel, has_result);
   }
+
+  return panel_label_matches;
 }
 
 static void block_search_deactive_buttons(uiBlock *block)
@@ -5281,7 +5283,7 @@ static void block_search_deactive_buttons(uiBlock *block)
   }
 
   LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
-    if ((but->flag & UI_SEARCH_FILTER_MATCHES)) {
+    if (!(but->flag & UI_SEARCH_FILTER_MATCHES)) {
       but->flag |= UI_BUT_INACTIVE;
     }
   }
@@ -5702,7 +5704,7 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
 
   block->curlayout = NULL;
 
-  block_search(block);
+  const bool search_disabled = block_search(block);
 
   for (root = block->layouts.first; root; root = root->next) {
     ui_layout_add_padding_button(root);
@@ -5712,7 +5714,9 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
     ui_layout_free(root->layout);
   }
 
-  block_search_deactive_buttons(block);
+  if (!search_disabled) {
+    block_search_deactive_buttons(block);
+  }
 
   BLI_freelistN(&block->layouts);
 
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 96e9713ccc2..1c483ea8d2d 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -867,10 +867,10 @@ void ui_panel_set_search_filter_match(struct Panel *panel, const bool value)
 
 static void panel_matches_search_filter_recursive(const Panel *panel, bool *filter_matches)
 {
-  *filter_matches = *filter_matches && (panel->runtime_flag & PNL_SEARCH_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 (*filter_matches) {
+  if (!*filter_matches) {
     LISTBASE_FOREACH (const Panel *, child_panel, &panel->children) {
       panel_matches_search_filter_recursive(child_panel, filter_matches);
     }
@@ -1053,7 +1053,8 @@ void ui_draw_aligned_panel(uiStyle *style,
     GPU_blend(true);
 
     /* draw with background color */
-    immUniformThemeColor(TH_PANEL_HEADER);
+    immUniformThemeColor(UI_panel_matches_search_filter(panel) ? TH_SEARCH_MATCH :
+                                                                 TH_PANEL_HEADER);
     immRectf(pos, minx, headrect.ymin, maxx, y);
 
     immBegin(GPU_PRIM_LINES, 4);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index a789f382f76..02814c0e6a8 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -347,12 +347,12 @@ static void property_search_all_tabs(const bContext *C,
     }
 
     /* Store whether this tab has any unfiltered panels left. */
-    bool has_unfiltered_panel = false;
+    bool tab_has_search_match = false;
     LISTBASE_FOREACH (
         Panel *, panel, use_actual_region ? &main_region->panels : &region_copy->panels) {
-      has_unfiltered_panel |= UI_panel_matches_search_filter(panel) && UI_panel_is_active(panel);
+      tab_has_search_match |= UI_panel_matches_search_filter(panel) && UI_panel_is_active(panel);
     }
-    if (has_unfiltered_panel) {
+    if (tab_has_search_match) {
       sbuts->context_search_filter_active |= (1 << i);
     }



More information about the Bf-blender-cvs mailing list