Blender  V3.3
tree_element_id.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "DNA_ID.h"
8 #include "DNA_space_types.h"
9 
10 #include "BLI_listbase_wrapper.hh"
11 #include "BLI_utildefines.h"
12 
13 #include "BKE_lib_override.h"
14 
15 #include "BLT_translation.h"
16 
17 #include "RNA_access.h"
18 
19 #include "../outliner_intern.hh"
20 #include "common.hh"
22 #include "tree_element_id_scene.hh"
23 
24 #include "tree_element_id.hh"
25 
26 namespace blender::ed::outliner {
27 
28 std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_te, ID &id)
29 {
30  if (ID_TYPE_IS_DEPRECATED(GS(id.name))) {
31  BLI_assert_msg(0, "Outliner trying to build tree-element for deprecated ID type");
32  return nullptr;
33  }
34 
35  switch (ID_Type type = GS(id.name); type) {
36  case ID_LI:
37  return std::make_unique<TreeElementIDLibrary>(legacy_te, (Library &)id);
38  case ID_SCE:
39  return std::make_unique<TreeElementIDScene>(legacy_te, (Scene &)id);
40  case ID_OB:
41  case ID_ME:
42  case ID_CU_LEGACY:
43  case ID_MB:
44  case ID_MA:
45  case ID_TE:
46  case ID_LT:
47  case ID_LA:
48  case ID_CA:
49  case ID_KE:
50  case ID_SCR:
51  case ID_WO:
52  case ID_SPK:
53  case ID_GR:
54  case ID_NT:
55  case ID_BR:
56  case ID_PA:
57  case ID_MC:
58  case ID_MSK:
59  case ID_LS:
60  case ID_LP:
61  case ID_GD:
62  case ID_WS:
63  case ID_CV:
64  case ID_PT:
65  case ID_VO:
66  case ID_SIM:
67  case ID_WM:
68  case ID_IM:
69  case ID_VF:
70  case ID_TXT:
71  case ID_SO:
72  case ID_AR:
73  case ID_AC:
74  case ID_PAL:
75  case ID_PC:
76  case ID_CF:
77  return std::make_unique<TreeElementID>(legacy_te, id);
78  case ID_IP:
80  break;
81  }
82 
83  return nullptr;
84 }
85 
86 /* -------------------------------------------------------------------- */
87 /* ID Tree-Element Base Class (common/default logic) */
88 
90  : AbstractTreeElement(legacy_te), id_(id)
91 {
94 
95  /* Default, some specific types override this. */
96  legacy_te_.name = id.name + 2;
97  legacy_te_.idcode = GS(id.name);
98 }
99 
100 bool TreeElementID::expandPoll(const SpaceOutliner &space_outliner) const
101 {
102  const TreeStoreElem *tsepar = legacy_te_.parent ? TREESTORE(legacy_te_.parent) : nullptr;
103  return (tsepar == nullptr || tsepar->type != TSE_ID_BASE || space_outliner.filter_id_type);
104 }
105 
107  const AnimData *anim_data) const
108 {
109  if (outliner_animdata_test(anim_data)) {
111  &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_ANIM_DATA, 0);
112  }
113 }
114 
115 } // namespace blender::ed::outliner
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
ID and Library types, which are fundamental for sdna.
#define ID_TYPE_IS_DEPRECATED(id_type)
Definition: DNA_ID.h:608
ID_Type
Definition: DNA_ID_enums.h:44
@ ID_WM
Definition: DNA_ID_enums.h:72
@ ID_CA
Definition: DNA_ID_enums.h:56
@ ID_AR
Definition: DNA_ID_enums.h:66
@ ID_MC
Definition: DNA_ID_enums.h:73
@ ID_CF
Definition: DNA_ID_enums.h:78
@ ID_LI
Definition: DNA_ID_enums.h:46
@ ID_TE
Definition: DNA_ID_enums.h:52
@ ID_IM
Definition: DNA_ID_enums.h:53
@ ID_VO
Definition: DNA_ID_enums.h:83
@ ID_WS
Definition: DNA_ID_enums.h:79
@ ID_NT
Definition: DNA_ID_enums.h:68
@ ID_LA
Definition: DNA_ID_enums.h:55
@ ID_KE
Definition: DNA_ID_enums.h:58
@ ID_TXT
Definition: DNA_ID_enums.h:62
@ ID_SO
Definition: DNA_ID_enums.h:64
@ ID_SCE
Definition: DNA_ID_enums.h:45
@ ID_LS
Definition: DNA_ID_enums.h:75
@ ID_MSK
Definition: DNA_ID_enums.h:74
@ ID_GD
Definition: DNA_ID_enums.h:71
@ ID_CV
Definition: DNA_ID_enums.h:81
@ ID_PAL
Definition: DNA_ID_enums.h:76
@ ID_BR
Definition: DNA_ID_enums.h:69
@ ID_LP
Definition: DNA_ID_enums.h:80
@ ID_WO
Definition: DNA_ID_enums.h:59
@ ID_SIM
Definition: DNA_ID_enums.h:84
@ ID_MA
Definition: DNA_ID_enums.h:51
@ ID_AC
Definition: DNA_ID_enums.h:67
@ ID_SCR
Definition: DNA_ID_enums.h:60
@ ID_CU_LEGACY
Definition: DNA_ID_enums.h:49
@ ID_VF
Definition: DNA_ID_enums.h:61
@ ID_ME
Definition: DNA_ID_enums.h:48
@ ID_IP
Definition: DNA_ID_enums.h:57
@ ID_GR
Definition: DNA_ID_enums.h:65
@ ID_SPK
Definition: DNA_ID_enums.h:63
@ ID_MB
Definition: DNA_ID_enums.h:50
@ ID_LT
Definition: DNA_ID_enums.h:54
@ ID_OB
Definition: DNA_ID_enums.h:47
@ ID_PA
Definition: DNA_ID_enums.h:70
@ ID_PT
Definition: DNA_ID_enums.h:82
@ ID_PC
Definition: DNA_ID_enums.h:77
#define TSE_IS_REAL_ID(_tse)
@ TSE_ANIM_DATA
@ TSE_ID_BASE
@ TSE_SOME_ID
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
TreeElementID(TreeElement &legacy_te, ID &id)
bool expandPoll(const SpaceOutliner &) const override
void expand_animation_data(SpaceOutliner &, const AnimData *) const
static std::unique_ptr< TreeElementID > createFromID(TreeElement &legacy_te, ID &id)
bool outliner_animdata_test(const AnimData *adt)
Definition: common.cc:59
#define GS(x)
Definition: iris.c:225
TreeElement * outliner_add_element(SpaceOutliner *space_outliner, ListBase *lb, void *idv, TreeElement *parent, short type, short index, const bool expand)
#define TREESTORE(a)
Definition: DNA_ID.h:368
struct TreeElement * parent
ListBase subtree
TreeStoreElem * store_elem
const char * name