[Bf-blender-cvs] [b22c84d7800] soc-2019-outliner: Outliner: Fix merge search menu not showing all children

Nathan Craddock noreply at git.blender.org
Sun Jul 21 01:23:46 CEST 2019


Commit: b22c84d7800a18e333ddcbd2472d74b475d32ec4
Author: Nathan Craddock
Date:   Sat Jul 20 17:22:24 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBb22c84d7800a18e333ddcbd2472d74b475d32ec4

Outliner: Fix merge search menu not showing all children

The menu was not searching over the entire subtree of the
collapsed element, but it also needed information of the
parent element and type, so a struct and memory allocation were
required to pass all of the data into the popup menu.

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

M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_tools.c

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

diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 5e4ac823f51..e4306cde834 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -88,6 +88,11 @@ typedef struct TreeElementIcon {
   int icon;
 } TreeElementIcon;
 
+typedef struct MergedSearchData {
+  TreeElement *parent_element;
+  int element_type;
+} MergedSearchData;
+
 #define TREESTORE_ID_TYPE(_id) \
   (ELEM(GS((_id)->name), \
         ID_SCE, \
@@ -395,6 +400,7 @@ void OUTLINER_OT_orphans_purge(struct wmOperatorType *ot);
 /* outliner_tools.c ---------------------------------------------- */
 
 struct uiBlock *merged_element_search_menu(struct bContext *C, struct ARegion *ar, void *element);
+void merged_element_search_free_cb();
 
 void OUTLINER_OT_operation(struct wmOperatorType *ot);
 void OUTLINER_OT_scene_operation(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 821a6320558..a8f287becf7 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1423,7 +1423,12 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
 
     /* If the selected icon was an aggregate of multiple elements, run the search popup */
     if (merged_elements) {
-      UI_popup_block_invoke(C, merged_element_search_menu, activate_te, NULL);
+      MergedSearchData *select_data = MEM_callocN(sizeof(MergedSearchData), "merge_search_data");
+      select_data->parent_element = te;
+      select_data->element_type = tree_element_id_type_to_index(activate_te);
+
+      UI_popup_block_invoke(
+          C, merged_element_search_menu, select_data, merged_element_search_free_cb);
       return OPERATOR_CANCELLED;
     }
 
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 3666ec40058..baec8495a40 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -478,6 +478,11 @@ void OUTLINER_OT_scene_operation(wmOperatorType *ot)
 }
 /* ******************************************** */
 
+void merged_element_search_free_cb(void *arg)
+{
+  MEM_freeN(arg);
+}
+
 static void merged_element_search_cb_recursive(const ListBase *tree,
                                                short type,
                                                const char *str,
@@ -505,14 +510,15 @@ static void merged_element_search_cb_recursive(const ListBase *tree,
 
 /* Get a list of elements that match the search string */
 static void merged_element_search_cb(const bContext *UNUSED(C),
-                                     void *element,
+                                     void *data,
                                      const char *str,
                                      uiSearchItems *items)
 {
-  TreeElement *te = (TreeElement *)element;
-  const short type = tree_element_id_type_to_index(te);
+  MergedSearchData *search_data = (MergedSearchData *)data;
+  TreeElement *parent = search_data->parent_element;
+  int type = search_data->element_type;
 
-  merged_element_search_cb_recursive(&te->parent->subtree, type, str, items);
+  merged_element_search_cb_recursive(&parent->subtree, type, str, items);
 }
 
 /* Activate an element from the merged element search menu */
@@ -526,7 +532,7 @@ static void merged_element_search_call_cb(struct bContext *C, void *UNUSED(arg1)
 /** Merged element search menu
  * Created on activation of a merged or aggregated iconrow icon.
  */
-uiBlock *merged_element_search_menu(bContext *C, ARegion *ar, void *element)
+uiBlock *merged_element_search_menu(bContext *C, ARegion *ar, void *data)
 {
   static char search[64] = "";
   uiBlock *block;
@@ -539,13 +545,11 @@ uiBlock *merged_element_search_menu(bContext *C, ARegion *ar, void *element)
   UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
   UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
 
-  TreeElement *te = (TreeElement *)element;
-
   short menu_width = 10 * UI_UNIT_X;
   but = uiDefSearchBut(
       block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, menu_width, UI_UNIT_Y, 0, 0, "");
   UI_but_func_search_set(
-      but, NULL, merged_element_search_cb, te, false, merged_element_search_call_cb, NULL);
+      but, NULL, merged_element_search_cb, data, false, merged_element_search_call_cb, NULL);
   UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
 
   /* Fake button to hold space for search items */



More information about the Bf-blender-cvs mailing list