Blender  V2.93
tree_element_id.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "DNA_ID.h"
22 
23 #include "BLI_listbase_wrapper.hh"
24 #include "BLI_utildefines.h"
25 
26 #include "BKE_lib_override.h"
27 
28 #include "BLT_translation.h"
29 
30 #include "RNA_access.h"
31 
32 #include "../outliner_intern.h"
33 #include "tree_display.h"
35 #include "tree_element_id_scene.hh"
36 
37 #include "tree_element_id.hh"
38 
39 namespace blender::ed::outliner {
40 
42 {
43  switch (ID_Type type = GS(id.name); type) {
44  case ID_LI:
45  return new TreeElementIDLibrary(legacy_te, (Library &)id);
46  case ID_SCE:
47  return new TreeElementIDScene(legacy_te, (Scene &)id);
48  case ID_OB:
49  case ID_ME:
50  case ID_CU:
51  case ID_MB:
52  case ID_MA:
53  case ID_TE:
54  case ID_LT:
55  case ID_LA:
56  case ID_CA:
57  case ID_KE:
58  case ID_SCR:
59  case ID_WO:
60  case ID_SPK:
61  case ID_GR:
62  case ID_NT:
63  case ID_BR:
64  case ID_PA:
65  case ID_MC:
66  case ID_MSK:
67  case ID_LS:
68  case ID_LP:
69  case ID_GD:
70  case ID_WS:
71  case ID_HA:
72  case ID_PT:
73  case ID_VO:
74  case ID_SIM:
75  case ID_WM:
76  case ID_IM:
77  case ID_VF:
78  case ID_TXT:
79  case ID_SO:
80  case ID_AR:
81  case ID_AC:
82  case ID_PAL:
83  case ID_PC:
84  case ID_CF:
85  return new TreeElementID(legacy_te, id);
86  /* Deprecated */
87  case ID_IP:
88  BLI_assert(!"Outliner trying to build tree-element for deprecated ID type");
89  return nullptr;
90  }
91 
92  return nullptr;
93 }
94 
95 /* -------------------------------------------------------------------- */
96 /* ID Tree-Element Base Class (common/default logic) */
97 
99  : AbstractTreeElement(legacy_te), id_(id)
100 {
103 
104  /* Default, some specific types override this. */
105  legacy_te_.name = id.name + 2;
106  legacy_te_.idcode = GS(id.name);
107 }
108 
109 void TreeElementID::postExpand(SpaceOutliner &space_outliner) const
110 {
111  const bool lib_overrides_visible = !SUPPORT_FILTER_OUTLINER(&space_outliner) ||
112  ((space_outliner.filter & SO_FILTER_NO_LIB_OVERRIDE) == 0);
113 
114  if (lib_overrides_visible && ID_IS_OVERRIDE_LIBRARY_REAL(&id_)) {
116  &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_LIBRARY_OVERRIDE_BASE, 0);
117  }
118 }
119 
120 bool TreeElementID::expandPoll(const SpaceOutliner &space_outliner) const
121 {
122  const TreeStoreElem *tsepar = legacy_te_.parent ? TREESTORE(legacy_te_.parent) : nullptr;
123  return (tsepar == nullptr || tsepar->type != TSE_ID_BASE || space_outliner.filter_id_type);
124 }
125 
127  const AnimData *anim_data) const
128 {
129  if (outliner_animdata_test(anim_data)) {
131  &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_ANIM_DATA, 0);
132  }
133 }
134 
135 } // namespace blender::ed::outliner
#define BLI_assert(a)
Definition: BLI_assert.h:58
ID and Library types, which are fundamental for sdna.
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition: DNA_ID.h:438
ID_Type
Definition: DNA_ID_enums.h:56
@ ID_WM
Definition: DNA_ID_enums.h:84
@ ID_CA
Definition: DNA_ID_enums.h:68
@ ID_AR
Definition: DNA_ID_enums.h:78
@ ID_MC
Definition: DNA_ID_enums.h:85
@ ID_CF
Definition: DNA_ID_enums.h:90
@ ID_LI
Definition: DNA_ID_enums.h:58
@ ID_TE
Definition: DNA_ID_enums.h:64
@ ID_IM
Definition: DNA_ID_enums.h:65
@ ID_VO
Definition: DNA_ID_enums.h:95
@ ID_WS
Definition: DNA_ID_enums.h:91
@ ID_NT
Definition: DNA_ID_enums.h:80
@ ID_LA
Definition: DNA_ID_enums.h:67
@ ID_KE
Definition: DNA_ID_enums.h:70
@ ID_TXT
Definition: DNA_ID_enums.h:74
@ ID_SO
Definition: DNA_ID_enums.h:76
@ ID_SCE
Definition: DNA_ID_enums.h:57
@ ID_LS
Definition: DNA_ID_enums.h:87
@ ID_MSK
Definition: DNA_ID_enums.h:86
@ ID_GD
Definition: DNA_ID_enums.h:83
@ ID_PAL
Definition: DNA_ID_enums.h:88
@ ID_BR
Definition: DNA_ID_enums.h:81
@ ID_LP
Definition: DNA_ID_enums.h:92
@ ID_HA
Definition: DNA_ID_enums.h:93
@ ID_WO
Definition: DNA_ID_enums.h:71
@ ID_SIM
Definition: DNA_ID_enums.h:96
@ ID_MA
Definition: DNA_ID_enums.h:63
@ ID_AC
Definition: DNA_ID_enums.h:79
@ ID_SCR
Definition: DNA_ID_enums.h:72
@ ID_VF
Definition: DNA_ID_enums.h:73
@ ID_ME
Definition: DNA_ID_enums.h:60
@ ID_IP
Definition: DNA_ID_enums.h:69
@ ID_GR
Definition: DNA_ID_enums.h:77
@ ID_SPK
Definition: DNA_ID_enums.h:75
@ ID_MB
Definition: DNA_ID_enums.h:62
@ ID_LT
Definition: DNA_ID_enums.h:66
@ ID_OB
Definition: DNA_ID_enums.h:59
@ ID_PA
Definition: DNA_ID_enums.h:82
@ ID_PT
Definition: DNA_ID_enums.h:94
@ ID_CU
Definition: DNA_ID_enums.h:61
@ ID_PC
Definition: DNA_ID_enums.h:89
#define TSE_IS_REAL_ID(_tse)
@ TSE_ANIM_DATA
@ TSE_LIBRARY_OVERRIDE_BASE
@ TSE_ID_BASE
@ TSE_SOME_ID
@ SO_FILTER_NO_LIB_OVERRIDE
_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 postExpand(SpaceOutliner &) const override
void expand_animation_data(SpaceOutliner &, const AnimData *) const
static TreeElementID * createFromID(TreeElement &legacy_te, ID &id)
#define GS(x)
Definition: iris.c:241
#define SUPPORT_FILTER_OUTLINER(space_outliner_)
#define TREESTORE(a)
bool outliner_animdata_test(const AnimData *adt)
TreeElement * outliner_add_element(SpaceOutliner *space_outliner, ListBase *lb, void *idv, TreeElement *parent, short type, short index)
Definition: DNA_ID.h:273
struct TreeElement * parent
ListBase subtree
TreeStoreElem * store_elem
const char * name