Blender  V2.93
tree_element_overrides.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 "BKE_collection.h"
22 #include "BKE_lib_override.h"
23 
24 #include "BLI_utildefines.h"
25 
26 #include "BLI_listbase_wrapper.hh"
27 
28 #include "BLT_translation.h"
29 
30 #include "RNA_access.h"
31 
32 #include "../outliner_intern.h"
33 #include "tree_display.h"
34 
36 
37 namespace blender::ed::outliner {
38 
40  : AbstractTreeElement(legacy_te), id_(id)
41 {
43  if (legacy_te.parent != nullptr &&
45 
46  {
47  legacy_te.name = IFACE_("Library Overrides");
48  }
49  else {
50  legacy_te.name = id.name + 2;
51  }
52 }
53 
55 {
56  BLI_assert(id_.override_library != nullptr);
57 
58  const bool show_system_overrides = (SUPPORT_FILTER_OUTLINER(&space_outliner) &&
59  (space_outliner.filter & SO_FILTER_SHOW_SYSTEM_OVERRIDES) !=
60  0);
61  PointerRNA idpoin;
62  RNA_id_pointer_create(&id_, &idpoin);
63 
64  PointerRNA override_rna_ptr;
65  PropertyRNA *override_rna_prop;
66  short index = 0;
67 
68  for (auto *override_prop :
70  const bool is_rna_path_valid = BKE_lib_override_rna_property_find(
71  &idpoin, override_prop, &override_rna_ptr, &override_rna_prop);
72  if (is_rna_path_valid && !show_system_overrides &&
73  ELEM(override_prop->rna_prop_type, PROP_POINTER, PROP_COLLECTION) &&
74  RNA_struct_is_ID(RNA_property_pointer_type(&override_rna_ptr, override_rna_prop))) {
75  bool do_continue = true;
76  for (auto *override_prop_op :
77  ListBaseWrapper<IDOverrideLibraryPropertyOperation>(override_prop->operations)) {
78  if ((override_prop_op->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) {
79  do_continue = false;
80  break;
81  }
82  }
83 
84  if (do_continue) {
85  continue;
86  }
87  }
88 
89  TreeElementOverridesData data = {id_, *override_prop, is_rna_path_valid};
91  &space_outliner, &legacy_te_.subtree, &data, &legacy_te_, TSE_LIBRARY_OVERRIDE, index++);
92  }
93 }
94 
96  TreeElementOverridesData &override_data)
97  : AbstractTreeElement(legacy_te),
98  id_(override_data.id),
99  override_prop_(override_data.override_property)
100 {
102 
103  legacy_te.name = override_prop_.rna_path;
104  /* Abusing this for now, better way to do it is also pending current refactor of the whole tree
105  * code to use C++. */
106  legacy_te.directdata = POINTER_FROM_UINT(override_data.is_rna_path_valid);
107 }
108 
109 } // namespace blender::ed::outliner
bool BKE_lib_override_rna_property_find(struct PointerRNA *idpoin, const struct IDOverrideLibraryProperty *library_prop, struct PointerRNA *r_override_poin, struct PropertyRNA **r_override_prop)
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define ELEM(...)
#define POINTER_FROM_UINT(i)
#define IFACE_(msgid)
@ IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE
Definition: DNA_ID.h:200
@ TSE_LIBRARY_OVERRIDE
@ TSE_LIBRARY_OVERRIDE_BASE
@ TSE_LAYER_COLLECTION
@ TSE_SOME_ID
@ SO_FILTER_SHOW_SYSTEM_OVERRIDES
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
TreeElementOverridesBase(TreeElement &legacy_te, ID &id)
TreeElementOverridesProperty(TreeElement &legacy_te, TreeElementOverridesData &override_data)
#define SUPPORT_FILTER_OUTLINER(space_outliner_)
TreeElement * outliner_add_element(SpaceOutliner *space_outliner, ListBase *lb, void *idv, TreeElement *parent, short type, short index)
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
bool RNA_struct_is_ID(const StructRNA *type)
Definition: rna_access.c:797
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1567
ListBase properties
Definition: DNA_ID.h:252
Definition: DNA_ID.h:273
IDOverrideLibrary * override_library
Definition: DNA_ID.h:317
struct TreeElement * parent
ListBase subtree
TreeStoreElem * store_elem
void * directdata
const char * name