Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tree_iterator.cc « tree « space_outliner « editors « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d2b0b2143311291e5b49eb5ed67e6b9087a28ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* SPDX-License-Identifier: GPL-2.0-or-later */

/** \file
 * \ingroup spoutliner
 */

#include "DNA_space_types.h"

#include "BLI_listbase.h"

#include "../outliner_intern.hh"

#include "tree_iterator.hh"

namespace blender::ed::outliner::tree_iterator {

void all(const SpaceOutliner &space_outliner, const VisitorFn visitor)
{
  all_open(space_outliner, space_outliner.tree, visitor);
}

void all(const ListBase &subtree, const VisitorFn visitor)
{
  LISTBASE_FOREACH_MUTABLE (TreeElement *, element, &subtree) {
    /* Get needed data out in case element gets freed. */
    const ListBase subtree = element->subtree;

    visitor(element);
    /* Don't access element from now on, it may be freed. */

    all(subtree, visitor);
  }
}

void all_open(const SpaceOutliner &space_outliner, const VisitorFn visitor)
{
  all_open(space_outliner, space_outliner.tree, visitor);
}

void all_open(const SpaceOutliner &space_outliner,
              const ListBase &subtree,
              const VisitorFn visitor)
{
  LISTBASE_FOREACH_MUTABLE (TreeElement *, element, &subtree) {
    /* Get needed data out in case element gets freed. */
    const TreeStoreElem *tselem = TREESTORE(element);
    const ListBase subtree = element->subtree;

    visitor(element);
    /* Don't access element from now on, it may be freed. Note that the open/collapsed state may
     * also have been changed in the visitor callback. */

    if (TSELEM_OPEN(tselem, &space_outliner)) {
      all_open(space_outliner, subtree, visitor);
    }
  }
}

}  // namespace blender::ed::outliner::tree_iterator