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
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include <memory>
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;
}
virtual void postExpand(SpaceOutliner &) const
{
}
/**
* 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;
}
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().
*/
struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
ListBase *lb,
void *idv,
struct TreeElement *parent,
short type,
short index);
void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner);
/**
* Get actual warning data of a tree element, if any.
*
* \param r_icon: The icon to display as warning.
* \param r_message: The message to display as warning.
* \return true if there is a warning, false otherwise.
*/
bool tree_element_warnings_get(struct TreeElement *te, int *r_icon, const char **r_message);
} // namespace blender::ed::outliner
|