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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include <memory>
#include "BLI_string_ref.hh"
struct ListBase;
struct SpaceOutliner;
struct TreeElement;
namespace blender::ed::outliner {
/* -------------------------------------------------------------------- */
/* Tree-Display Interface */
class AbstractTreeElement {
protected:
/**
* Reference back to the owning legacy TreeElement.
* Most concrete types need access to this, so storing here. Eventually the type should be
* replaced by AbstractTreeElement and derived types.
*/
TreeElement &legacy_te_;
public:
virtual ~AbstractTreeElement() = default;
static std::unique_ptr<AbstractTreeElement> createFromType(int type,
TreeElement &legacy_te,
void *idv);
/**
* Check if the type is expandable in current context.
*/
virtual bool expandPoll(const SpaceOutliner &) const
{
return true;
}
/**
* Just while transitioning to the new tree-element design: Some types are only partially ported,
* and the expanding isn't done yet.
*/
virtual bool isExpandValid() const
{
return true;
}
TreeElement &getLegacyElement()
{
return legacy_te_;
}
/**
* By letting this return a warning message, the tree element will display a warning icon with
* the message in the tooltip.
*/
virtual StringRefNull getWarning() const;
/**
* Expand this tree element if it is displayed for the first time (as identified by its
* tree-store element).
*
* Static for now to allow doing this from the legacy tree element.
*/
static void uncollapse_by_default(TreeElement *legacy_te);
friend void tree_element_expand(const AbstractTreeElement &tree_element,
SpaceOutliner &space_outliner);
protected:
/* Pseudo-abstract: Only allow creation through derived types. */
AbstractTreeElement(TreeElement &legacy_te) : legacy_te_(legacy_te)
{
}
/**
* Let the type add its own children.
*/
virtual void expand(SpaceOutliner &) const
{
}
};
/**
* TODO: this function needs to be split up! It's getting a bit too large...
*
* \note "ID" is not always a real ID.
* \note If child items are only added to the tree if the item is open,
* the `TSE_` type _must_ be added to #outliner_element_needs_rebuild_on_open_change().
*
* \param expand: If true, the element may add its own sub-tree. E.g. objects will list their
* animation data, object data, constraints, modifiers, ... This often adds visual
* noise, and can be expensive to add in big scenes. So prefer setting this to
* false.
*/
struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
ListBase *lb,
void *idv,
struct TreeElement *parent,
short type,
short index,
const bool expand = true);
void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner);
} // namespace blender::ed::outliner
|