Blender
V4.5
source
blender
editors
space_outliner
tree
tree_element_id_action.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2025 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
9
#include "
DNA_action_types.h
"
10
#include "
DNA_outliner_types.h
"
11
#include "
DNA_space_types.h
"
12
13
#include "
../outliner_intern.hh
"
14
15
#include "
tree_element_anim_data.hh
"
16
#include "
tree_element_id_action.hh
"
17
18
#include "
ANIM_action.hh
"
19
20
namespace
blender::ed::outliner
{
21
22
TreeElementIDAction::TreeElementIDAction
(
TreeElement
&legacy_te,
bAction
&action)
23
:
TreeElementID
(legacy_te, action.id), action_(action)
24
{
25
/* If the outliner is showing the Action because it's in some hierarchical data mode, only show
26
* the slot that is used by the parent ID tree element. Showing all slots will create quadratic
27
* complexity, as each user of the Action has a child tree element for the Action. This means the
28
* complexity is O(U x S), where U = the number of users of the Action, and S = the number of
29
* slots. Typically U = S.
30
*
31
* In `SO_LIBRARIES` mode, the outliner shows Actions as a flat list in the 'Actions' subtree,
32
* and also (just like `SO_SCENES` and `SO_VIEW_LAYER`) underneath each user. The former should
33
* show all slots, whereas the latter should only show the assigned one. The difference is
34
* detected by the type of the parent tree element.
35
*
36
* To simplify the code, the mode of the Outliner is ignored, and whether to show all slots or
37
* not is determined purely by the type of the parent tree element. See the constructor. */
38
39
/* Fetch the assigned slot handle from the parent node in the tree. This is done this way,
40
* because AbstractTreeElement::add_element() constructs the element and immediately calls its
41
* expand() function. That means that there is no time for the creator of this
42
* TreeElementIDAction to pass us the slot handle explicitly.
43
*
44
* Adding a constructor parameter for this is also not feasible, due to the generic nature of the
45
* code that constructs this TreeElement. */
46
const
TreeElement
*legacy_parent = legacy_te.
parent
;
47
if
(!legacy_parent) {
48
return
;
49
}
50
51
const
TreeElementAnimData
*parent_anim_te =
tree_element_cast<const TreeElementAnimData>
(
52
legacy_parent);
53
if
(!parent_anim_te) {
54
return
;
55
}
56
57
this->slot_handle_.emplace(parent_anim_te->
get_slot_handle
());
58
}
59
60
void
TreeElementIDAction::expand
(
SpaceOutliner
&
/*space_outliner*/
)
const
61
{
62
animrig::Action
&action = action_.wrap();
63
if
(!this->slot_handle_.has_value()) {
64
/* Show all slots of the Action. */
65
for
(
animrig::Slot
*slot : action.
slots
()) {
66
add_element
(&
legacy_te_
.
subtree
,
67
reinterpret_cast<
ID
*
>
(&action_),
68
slot,
69
&
legacy_te_
,
70
TSE_ACTION_SLOT
,
71
0);
72
}
73
return
;
74
}
75
76
/* Only show a single slot. Note that the slot handle value itself could be animrig::unassigned,
77
* in which case there will not be a slot to show. */
78
animrig::Slot
*slot = action.
slot_for_handle
(this->slot_handle_.value());
79
if
(!slot) {
80
return
;
81
}
82
add_element
(&
legacy_te_
.
subtree
,
83
reinterpret_cast<
ID
*
>
(&action_),
84
slot,
85
&
legacy_te_
,
86
TSE_ACTION_SLOT
,
87
0);
88
}
89
90
}
// namespace blender::ed::outliner
ANIM_action.hh
Functions and classes to work with Actions.
DNA_action_types.h
DNA_outliner_types.h
TSE_ACTION_SLOT
@ TSE_ACTION_SLOT
Definition
DNA_outliner_types.h:118
DNA_space_types.h
blender::animrig::Action
Definition
ANIM_action.hh:94
blender::animrig::Action::slots
blender::Span< const Slot * > slots() const
Definition
animrig/intern/action.cc:343
blender::animrig::Action::slot_for_handle
Slot * slot_for_handle(slot_handle_t handle)
Definition
animrig/intern/action.cc:360
blender::animrig::Slot
Definition
ANIM_action.hh:765
blender::ed::outliner::AbstractTreeElement::add_element
TreeElement * add_element(ListBase *lb, ID *owner_id, void *create_data, TreeElement *parent, short type, short index, const bool expand=true) const
Definition
tree_element.cc:243
blender::ed::outliner::AbstractTreeElement::legacy_te_
TreeElement & legacy_te_
Definition
tree_element.hh:36
blender::ed::outliner::TreeElementAnimData
Definition
tree_element_anim_data.hh:19
blender::ed::outliner::TreeElementAnimData::get_slot_handle
animrig::slot_handle_t get_slot_handle() const
Definition
tree_element_anim_data.cc:48
blender::ed::outliner::TreeElementIDAction::TreeElementIDAction
TreeElementIDAction(TreeElement &legacy_te, bAction &action)
Definition
tree_element_id_action.cc:22
blender::ed::outliner::TreeElementIDAction::expand
void expand(SpaceOutliner &space_outliner) const override
Definition
tree_element_id_action.cc:60
blender::ed::outliner::TreeElementID
Definition
tree_element_id.hh:20
blender::ed::outliner
Definition
outliner_collections.cc:44
blender::ed::outliner::tree_element_cast
TreeElementT * tree_element_cast(const TreeElement *te)
Definition
outliner_intern.hh:684
outliner_intern.hh
ID
Definition
DNA_ID.h:404
SpaceOutliner
Definition
DNA_space_types.h:187
bAction
Definition
DNA_action_types.h:769
blender::ed::outliner::TreeElement
Definition
outliner_intern.hh:86
blender::ed::outliner::TreeElement::subtree
ListBase subtree
Definition
outliner_intern.hh:97
blender::ed::outliner::TreeElement::parent
TreeElement * parent
Definition
outliner_intern.hh:87
tree_element_anim_data.hh
tree_element_id_action.hh
Generated on Fri Apr 3 2026 06:33:18 for Blender by
doxygen
1.11.0