[Bf-blender-cvs] [fd917935d14] soc-2019-outliner: Outliner: Utils made outliner_find_active more general

Nathan Craddock noreply at git.blender.org
Wed Jul 10 22:30:46 CEST 2019


Commit: fd917935d14d07bb2343c35963d93605370990e0
Author: Nathan Craddock
Date:   Wed Jul 10 11:50:07 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBfd917935d14d07bb2343c35963d93605370990e0

Outliner: Utils made outliner_find_active more general

Rather than only searching for active, now search for element with
matching flag.

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

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_utils.c

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

diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 424f96d9bd3..a9e9185e7f6 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -465,7 +465,7 @@ bool outliner_tree_traverse(const SpaceOutliner *soops,
                             TreeTraversalFunc func,
                             void *customdata);
 float outliner_restrict_columns_width(const struct SpaceOutliner *soops);
-TreeElement *outliner_find_active_element(const ListBase *lb);
+TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag);
 bool outliner_is_element_visible(const TreeElement *te);
 
 /* outliner_sync.c ---------------------------------------------- */
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index e85cff3a72b..9419bebfe46 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1123,7 +1123,7 @@ static void do_outliner_item_activate_tree_element(bContext *C,
                                                    const bool extend,
                                                    const bool recursive)
 {
-  TreeElement *te_active = outliner_find_active_element(&soops->tree);
+  TreeElement *te_active = outliner_find_element_with_flag(&soops->tree, TSE_ACTIVE);
   Object *obact = OBACT(view_layer);
 
   if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
@@ -1284,7 +1284,7 @@ static void do_outliner_range_select_recursive(ListBase *lb,
 /* Select a range of items between cursor and active element */
 static void do_outliner_range_select(SpaceOutliner *soops, TreeElement *cursor)
 {
-  TreeElement *active = outliner_find_active_element(&soops->tree);
+  TreeElement *active = outliner_find_element_with_flag(&soops->tree, TSE_ACTIVE);
 
   if (!active) {
     TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE;
@@ -1702,7 +1702,7 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
   const int direction = RNA_enum_get(op->ptr, "direction");
   const bool extend = RNA_boolean_get(op->ptr, "extend");
 
-  TreeElement *active = outliner_find_active_element(&soops->tree);
+  TreeElement *active = outliner_find_element_with_flag(&soops->tree, TSE_ACTIVE);
 
   Object *obact = OBACT(view_layer);
   Base *base = BKE_view_layer_base_find(view_layer, obact);
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index afa1c989959..50b1ef08cc9 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -301,14 +301,14 @@ float outliner_restrict_columns_width(const SpaceOutliner *soops)
   return (num_columns * UI_UNIT_X + V2D_SCROLL_WIDTH);
 }
 
-/* Find active element in tree */
-TreeElement *outliner_find_active_element(const ListBase *lb)
+/* Find first tree element in tree with matching treestore flag */
+TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag)
 {
   for (TreeElement *te = lb->first; te; te = te->next) {
-    if (TREESTORE(te)->flag & TSE_ACTIVE) {
+    if ((TREESTORE(te)->flag & flag) == flag) {
       return te;
     }
-    TreeElement *active_element = outliner_find_active_element(&te->subtree);
+    TreeElement *active_element = outliner_find_element_with_flag(&te->subtree, flag);
     if (active_element) {
       return active_element;
     }



More information about the Bf-blender-cvs mailing list