[Bf-blender-cvs] [fda3351c882] soc-2019-outliner: Outliner: Utils function to find active element

Nathan Craddock noreply at git.blender.org
Thu May 30 06:58:55 CEST 2019


Commit: fda3351c8827bfb6822747149c28228c775acb78
Author: Nathan Craddock
Date:   Wed May 29 07:54:52 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBfda3351c8827bfb6822747149c28228c775acb78

Outliner: Utils function to find active element

Searches tree and returns active TreeElement

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

M	source/blender/editors/space_outliner/outliner_intern.h
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 15489c61230..76c30fba5db 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -448,5 +448,6 @@ 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);
 
 #endif /* __OUTLINER_INTERN_H__ */
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index f57dce97b38..941b98a1591 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -300,3 +300,18 @@ 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)
+{
+  for (TreeElement *te = lb->first; te; te = te->next) {
+    if (TREESTORE(te)->flag & TSE_ACTIVE) {
+      return te;
+    }
+    TreeElement *active_element = outliner_find_active_element(&te->subtree);
+    if (active_element) {
+      return active_element;
+    }
+  }
+  return NULL;
+}



More information about the Bf-blender-cvs mailing list