[Bf-blender-cvs] [6513d556365] soc-2019-outliner: Outliner: Use existing function to get unique index for element type

Nathan Craddock noreply at git.blender.org
Fri Jul 19 21:57:01 CEST 2019


Commit: 6513d556365267287f4496ed80b255d861dd8d83
Author: Nathan Craddock
Date:   Fri Jul 19 10:31:43 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB6513d556365267287f4496ed80b255d861dd8d83

Outliner: Use existing function to get unique index for element type

Just code cleanup for merged element search menu

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

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

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index f6dd6f0a84e..e874db5616d 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2782,7 +2782,7 @@ static void outliner_draw_iconrow_doit(uiBlock *block,
  * We use a continuum of indices until we get to the object data-blocks
  * and we then make room for the object types.
  */
-static int tree_element_id_type_to_index(TreeElement *te)
+int tree_element_id_type_to_index(TreeElement *te)
 {
   TreeStoreElem *tselem = TREESTORE(te);
 
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index b0a17dfc0b7..c1575360ff2 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -232,6 +232,8 @@ void outliner_collection_isolate_flag(struct Scene *scene,
                                       const char *propname,
                                       const bool value);
 
+int tree_element_id_type_to_index(TreeElement *te);
+
 /* outliner_select.c -------------------------------------------- */
 eOLDrawState tree_element_type_active(struct bContext *C,
                                       struct Scene *scene,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 1268bba7cb2..53a926dd6e4 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1375,22 +1375,6 @@ void outliner_item_do_activate_from_tree_element(
       C, scene, view_layer, soops, te, tselem, extend, recursive);
 }
 
-static int get_element_type(TreeElement *te)
-{
-  TreeStoreElem *tselem = TREESTORE(te);
-  const int id_index = tselem->type == 0 ? BKE_idcode_to_index(te->idcode) : INDEX_ID_GR;
-  if (id_index < INDEX_ID_OB) {
-    return id_index;
-  }
-  else if (id_index == INDEX_ID_OB) {
-    const Object *ob = (Object *)tselem->id;
-    return INDEX_ID_OB + ob->type;
-  }
-  else {
-    return 0;
-  }
-}
-
 static void merged_element_search_cb_recursive(const ListBase *tree,
                                                short type,
                                                const char *str,
@@ -1399,7 +1383,7 @@ static void merged_element_search_cb_recursive(const ListBase *tree,
   char name[64];
 
   for (TreeElement *te = tree->first; te; te = te->next) {
-    if (get_element_type(te) == type) {
+    if (tree_element_id_type_to_index(te) == type) {
       if (BLI_strcasestr(te->name, str)) {
         BLI_strncpy(name, te->name, 64);
 
@@ -1419,7 +1403,7 @@ static void merged_element_search_cb(const bContext *C,
                                      uiSearchItems *items)
 {
   TreeElement *te = (TreeElement *)element;
-  const short type = get_element_type(te);
+  const short type = tree_element_id_type_to_index(te);
 
   merged_element_search_cb_recursive(&te->parent->subtree, type, str, items);
 }
@@ -1428,7 +1412,6 @@ static void merged_element_search_call_cb(struct bContext *C, void *arg1, void *
 {
   char search = (char *)arg1;
   search = "";
-  puts("HI");
 
   TreeElement *te = (TreeElement *)arg2;



More information about the Bf-blender-cvs mailing list