[Bf-blender-cvs] [612b19f4e79] property-search-ui-v2: Property Search: Correct the last commit

Hans Goudey noreply at git.blender.org
Thu Aug 20 20:54:35 CEST 2020


Commit: 612b19f4e794806e29a2cb32189b0d053e099699
Author: Hans Goudey
Date:   Thu Aug 20 14:54:00 2020 -0400
Branches: property-search-ui-v2
https://developer.blender.org/rB612b19f4e794806e29a2cb32189b0d053e099699

Property Search: Correct the last commit

Accidentally committed the wrong file...

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

M	source/blender/editors/space_buttons/space_buttons.c

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

diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 6bfcea0818e..8659853becf 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -310,6 +310,35 @@ static void main_region_layout_current_context(const bContext *C,
   }
 }
 
+static void property_search_move_to_next_tab_with_results(SpaceProperties *sbuts,
+                                                          const int *context_tabs_array,
+                                                          const int tabs_len)
+{
+  int current_tab_index = 0;
+  for (int i = 0; i < tabs_len; i++) {
+    if (sbuts->mainb == context_tabs_array[i]) {
+      current_tab_index = i;
+      break;
+    }
+  }
+
+  /* Try the tabs after the current tab. */
+  for (int i = current_tab_index; i < tabs_len; i++) {
+    if (sbuts->context_search_filter_active & (1 << i)) {
+      sbuts->mainbuser = context_tabs_array[i];
+      return;
+    }
+  }
+
+  /* Try the tabs before the current tab. */
+  for (int i = 0; i < current_tab_index; i++) {
+    if (sbuts->context_search_filter_active & (1 << i)) {
+      sbuts->mainbuser = context_tabs_array[i];
+      return;
+    }
+  }
+}
+
 static void property_search_all_tabs(const bContext *C,
                                      SpaceProperties *sbuts,
                                      ARegion *main_region)
@@ -328,6 +357,8 @@ static void property_search_all_tabs(const bContext *C,
   int context_tabs_array[32];
   int tabs_tot = ED_buttons_tabs_list(sbuts, context_tabs_array);
 
+  bool current_tab_has_search_match = false;
+
   /* Loop through the tabs added to the properties editor. */
   for (int i = 0; i < tabs_tot; i++) {
     if (context_tabs_array[i] == -1) {
@@ -354,6 +385,9 @@ static void property_search_all_tabs(const bContext *C,
     }
     if (tab_has_search_match) {
       sbuts->context_search_filter_active |= (1 << i);
+      if (use_actual_region) {
+        current_tab_has_search_match = tab_has_search_match;
+      }
     }
 
     /* Free data created during the layout process. */
@@ -362,6 +396,10 @@ static void property_search_all_tabs(const bContext *C,
     UI_blocklist_free(C_copy, &region_copy->uiblocks);
   }
 
+  if (!current_tab_has_search_match) {
+    property_search_move_to_next_tab_with_results(sbuts, context_tabs_array, tabs_tot);
+  }
+
   BKE_area_region_free(CTX_wm_area(C_copy)->type, region_copy);
   MEM_freeN(region_copy);
   MEM_freeN(sbuts_copy);



More information about the Bf-blender-cvs mailing list