diff options
author | Julian Eisel <julian@blender.org> | 2022-05-25 23:51:52 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-05-26 00:20:05 +0300 |
commit | a4a7af47326f6ca2ba881c3a2a25a0bdeed17c66 (patch) | |
tree | e504b2f95d11c7021b75bdf100e136ab6aa86798 /source/blender/editors/space_outliner/CMakeLists.txt | |
parent | f3c03982e5f5ff16029e21f565267d5353799d54 (diff) |
Outliner: New C++ based functional tree iterators
(Not meant to cause user visible changes.)
Adds some first new iterators to traverse over tree elements with a
functional syntax. Functional because it meant to be used with C++
lambdas.
For example, this common pattern:
```lang=cpp
void some_recursive_function(SpaceOutliner *space_outliner, ListBase *tree, ...)
{
LISTBASE_FOREACH (TreeElement *, te, tree) {
/* ... do something with the element ... */
/* Recurse into open children. */
if (TSELEM_OPEN(TREESTORE(te), space_outliner) {
some_recursive_function(&te->subtree, ...);
}
}
}
```
Gets simplified to this:
```lang=cpp
void some_function(SpaceOutliner &space_outliner, ...)
{
tree_iterator::all_open(space_outliner, [&](TreeElement *te) {
/* ... do something with the element ... */
});
}
```
We can add more iterators, e.g. some that support early exiting or
skipping children, returning a custom type, only act on selected
elements, etc.
The following commit will convert a bunch of code to use these. Some
further benefits will become visible there. Not all cases are straight
forward to convert, but hopefully more and more code can be refactored
to work with this. This deduplicates and centralizes the iteration
logic, which will later make it much easier to refactor how the tree
storage is done (e.g. move it to `SpaceOutliner_Runtime` and use a
better container than `ListBase`).
Diffstat (limited to 'source/blender/editors/space_outliner/CMakeLists.txt')
-rw-r--r-- | source/blender/editors/space_outliner/CMakeLists.txt | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 1c09ad2d98f..97d2957eed2 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -58,6 +58,7 @@ set(SRC tree/tree_element_scene_objects.cc tree/tree_element_seq.cc tree/tree_element_view_layer.cc + tree/tree_iterator.cc outliner_intern.hh tree/common.hh @@ -76,6 +77,7 @@ set(SRC tree/tree_element_scene_objects.hh tree/tree_element_seq.hh tree/tree_element_view_layer.hh + tree/tree_iterator.hh ) set(LIB |