Blender V5.3
rna_ID.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_ID.h"
12#include "DNA_material_types.h"
13
14#include "BKE_lib_id.hh"
15#include "BKE_library.hh"
16
17#include "BLT_translation.hh"
18
19#include "RNA_define.hh"
20#include "RNA_enum_types.hh"
21
22#include "UI_interface_c.hh"
23
24#include "WM_types.hh"
25
26#include "rna_internal.hh"
27
28namespace blender {
29
30/* enum of ID-block types
31 * NOTE: need to keep this in line with the other defines for these
32 */
34 {ID_AC, "ACTION", ICON_ACTION, "Action", ""},
35 {ID_AR, "ARMATURE", ICON_ARMATURE_DATA, "Armature", ""},
36 {ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brush", ""},
37 {ID_CF, "CACHEFILE", ICON_FILE, "Cache File", ""},
38 {ID_CA, "CAMERA", ICON_CAMERA_DATA, "Camera", ""},
39 {ID_GR, "COLLECTION", ICON_OUTLINER_COLLECTION, "Collection", ""},
40 {ID_CU_LEGACY, "CURVE", ICON_CURVE_DATA, "Curve", ""},
41 {ID_CV, "CURVES", ICON_CURVES_DATA, "Curves", ""},
42 {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""},
43 {ID_GD_LEGACY, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""},
44 {ID_GP, "GREASEPENCIL_V3", ICON_GREASEPENCIL, "Grease Pencil v3", ""},
45 {ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""},
46 {ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""},
47 {ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""},
48 {ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""},
49 {ID_LA, "LIGHT", ICON_LIGHT_DATA, "Light", ""},
50 {ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_SPHERE, "Light Probe", ""},
51 {ID_LS, "LINESTYLE", ICON_LINE_DATA, "Line Style", ""},
52 {ID_MSK, "MASK", ICON_MOD_MASK, "Mask", ""},
53 {ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""},
54 {ID_ME, "MESH", ICON_MESH_DATA, "Mesh", ""},
55 {ID_MB, "META", ICON_META_DATA, "Metaball", ""},
56 {ID_MC, "MOVIECLIP", ICON_TRACKER, "Movie Clip", ""},
57 {ID_NT, "NODETREE", ICON_NODETREE, "Node Tree", ""},
58 {ID_OB, "OBJECT", ICON_OBJECT_DATA, "Object", ""},
59 {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""},
60 {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""},
61 {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""},
62 {ID_PT, "POINTCLOUD", ICON_POINTCLOUD_DATA, "Point Cloud", ""},
63 {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
64 {ID_SCR, "SCREEN", ICON_WORKSPACE, "Screen", ""},
65 {ID_SO, "SOUND", ICON_SOUND, "Sound", ""},
66 {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""},
67 {ID_TXT, "TEXT", ICON_TEXT, "Text", ""},
68 {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""},
69 {ID_VO, "VOLUME", ICON_VOLUME_DATA, "Volume", ""},
70 {ID_WM, "WINDOWMANAGER", ICON_WINDOW, "Window Manager", ""},
71 {ID_WS, "WORKSPACE", ICON_WORKSPACE, "Workspace", ""},
72 {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""},
73 {0, nullptr, 0, nullptr, nullptr},
74};
75
78 "NOOP",
79 0,
80 "No-Op",
81 "Does nothing, prevents adding actual overrides (NOT USED)"},
83 "REPLACE",
84 0,
85 "Replace",
86 "Replace value of reference by overriding one"},
88 "DIFF_ADD",
89 0,
90 "Differential",
91 "Stores and apply difference between reference and local value (NOT USED)"},
93 "DIFF_SUB",
94 0,
95 "Differential",
96 "Stores and apply difference between reference and local value (NOT USED)"},
98 "FACT_MULTIPLY",
99 0,
100 "Factor",
101 "Stores and apply multiplication factor between reference and local value (NOT USED)"},
103 "INSERT_AFTER",
104 0,
105 "Insert After",
106 "Insert a new item into collection after the one referenced in "
107 "subitem_reference_name/_id or _index"},
109 "INSERT_BEFORE",
110 0,
111 "Insert Before",
112 "Insert a new item into collection before the one referenced in "
113 "subitem_reference_name/_id or _index (NOT USED)"},
115 "CUSTOM",
116 0,
117 "Custom",
118 "Custom operation, specific to a RNA property, and handled through dedicated callbacks (used "
119 "in specific cases, e.g. to handle data not actually exposed in RNA)"},
120 {0, nullptr, 0, nullptr, nullptr},
121};
122
127 /* Datablocks */
128 {FILTER_ID_AC, "filter_action", ICON_ACTION, "Actions", "Show Action data-blocks"},
130 "filter_armature",
131 ICON_ARMATURE_DATA,
132 "Armatures",
133 "Show Armature data-blocks"},
134 {FILTER_ID_BR, "filter_brush", ICON_BRUSH_DATA, "Brushes", "Show Brushes data-blocks"},
135 {FILTER_ID_CA, "filter_camera", ICON_CAMERA_DATA, "Cameras", "Show Camera data-blocks"},
136 {FILTER_ID_CF, "filter_cachefile", ICON_FILE, "Cache Files", "Show Cache File data-blocks"},
137 {FILTER_ID_CU_LEGACY, "filter_curve", ICON_CURVE_DATA, "Curves", "Show Curve data-blocks"},
139 "filter_annotations",
140 ICON_OUTLINER_DATA_GREASEPENCIL,
141 "Annotations",
142 "Show Annotation data-blocks"},
144 "filter_grease_pencil",
145 ICON_GREASEPENCIL,
146 "Grease Pencil",
147 "Show Grease Pencil data-blocks"},
148 {FILTER_ID_GR, "filter_group", ICON_GROUP, "Collections", "Show Collection data-blocks"},
150 "filter_curves",
151 ICON_CURVES_DATA,
152 "Hair Curves",
153 "Show/hide Curves data-blocks"},
154 {FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"},
155 {FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"},
157 "filter_light_probe",
158 ICON_OUTLINER_DATA_LIGHTPROBE,
159 "Light Probes",
160 "Show Light Probe data-blocks"},
162 "filter_linestyle",
163 ICON_LINE_DATA,
164 "Freestyle Linestyles",
165 "Show Freestyle's Line Style data-blocks"},
166 {FILTER_ID_LT, "filter_lattice", ICON_LATTICE_DATA, "Lattices", "Show Lattice data-blocks"},
168 "filter_material",
169 ICON_MATERIAL_DATA,
170 "Materials",
171 "Show Material data-blocks"},
172 {FILTER_ID_MB, "filter_metaball", ICON_META_DATA, "Metaballs", "Show Metaball data-blocks"},
174 "filter_movie_clip",
175 ICON_TRACKER,
176 "Movie Clips",
177 "Show Movie Clip data-blocks"},
178 {FILTER_ID_ME, "filter_mesh", ICON_MESH_DATA, "Meshes", "Show Mesh data-blocks"},
179 {FILTER_ID_MSK, "filter_mask", ICON_MOD_MASK, "Masks", "Show Mask data-blocks"},
180 {FILTER_ID_NT, "filter_node_tree", ICON_NODETREE, "Node Trees", "Show Node Tree data-blocks"},
181 {FILTER_ID_OB, "filter_object", ICON_OBJECT_DATA, "Objects", "Show Object data-blocks"},
183 "filter_particle_settings",
184 ICON_PARTICLE_DATA,
185 "Particles Settings",
186 "Show Particle Settings data-blocks"},
187 {FILTER_ID_PAL, "filter_palette", ICON_COLOR, "Palettes", "Show Palette data-blocks"},
189 "filter_paint_curve",
190 ICON_CURVE_BEZCURVE,
191 "Paint Curves",
192 "Show Paint Curve data-blocks"},
194 "filter_pointcloud",
195 ICON_POINTCLOUD_DATA,
196 "Point Clouds",
197 "Show/hide Point Cloud data-blocks"},
198 {FILTER_ID_SCE, "filter_scene", ICON_SCENE_DATA, "Scenes", "Show Scene data-blocks"},
199 {FILTER_ID_SPK, "filter_speaker", ICON_SPEAKER, "Speakers", "Show Speaker data-blocks"},
200 {FILTER_ID_SO, "filter_sound", ICON_SOUND, "Sounds", "Show Sound data-blocks"},
201 {FILTER_ID_TE, "filter_texture", ICON_TEXTURE_DATA, "Textures", "Show Texture data-blocks"},
202 {FILTER_ID_TXT, "filter_text", ICON_TEXT, "Texts", "Show Text data-blocks"},
203 {FILTER_ID_VF, "filter_font", ICON_FONT_DATA, "Fonts", "Show Font data-blocks"},
204 {FILTER_ID_VO, "filter_volume", ICON_VOLUME_DATA, "Volumes", "Show/hide Volume data-blocks"},
205 {FILTER_ID_WO, "filter_world", ICON_WORLD_DATA, "Worlds", "Show World data-blocks"},
207 "filter_work_space",
208 ICON_WORKSPACE,
209 "Workspaces",
210 "Show workspace data-blocks"},
211 {0, nullptr, 0, nullptr, nullptr},
212};
213
214} // namespace blender
215
216#ifdef RNA_RUNTIME
217
218# include "DNA_anim_types.h"
219
220# include "BLI_listbase.hh"
221# include "BLI_math_base_c.hh"
222# include "BLI_string.hh"
223
224# include "BLT_translation.hh"
225
226# include "BLO_readfile.hh"
227
228# include "BKE_anim_data.hh"
229# include "BKE_global.hh" /* XXX, remove me */
230# include "BKE_icons.hh"
231# include "BKE_idprop.hh"
232# include "BKE_idtype.hh"
233# include "BKE_lib_override.hh"
234# include "BKE_lib_query.hh"
235# include "BKE_lib_remap.hh"
236# include "BKE_library.hh"
237# include "BKE_main_invariants.hh"
238# include "BKE_material.hh"
239# include "BKE_preview_image.hh"
240# include "BKE_vfont.hh"
241
242# include "DEG_depsgraph.hh"
243# include "DEG_depsgraph_build.hh"
244# include "DEG_depsgraph_query.hh"
245
246# include "ED_asset.hh"
247
248# include "WM_api.hh"
249
250# ifdef WITH_PYTHON
251# include "BPY_extern.hh"
252# endif
253
254namespace blender {
255
256void rna_ID_override_library_property_operation_refname_get(PointerRNA *ptr, char *value)
257{
259 ptr->data);
260 strcpy(value, (opop->subitem_reference_name == nullptr) ? "" : opop->subitem_reference_name);
261}
262
263int rna_ID_override_library_property_operation_refname_length(PointerRNA *ptr)
264{
266 ptr->data);
267 return (opop->subitem_reference_name == nullptr) ? 0 : strlen(opop->subitem_reference_name);
268}
269
270void rna_ID_override_library_property_operation_locname_get(PointerRNA *ptr, char *value)
271{
273 ptr->data);
274 strcpy(value, (opop->subitem_local_name == nullptr) ? "" : opop->subitem_local_name);
275}
276
277int rna_ID_override_library_property_operation_locname_length(PointerRNA *ptr)
278{
280 ptr->data);
281 return (opop->subitem_local_name == nullptr) ? 0 : strlen(opop->subitem_local_name);
282}
283
284void rna_ID_override_library_property_operation_label_get(PointerRNA *ptr, char *value)
285{
287 ptr->data);
288 strcpy(value, (opop->label == nullptr) ? "" : opop->label);
289}
290
291int rna_ID_override_library_property_operation_label_length(PointerRNA *ptr)
292{
294 ptr->data);
295 return (opop->label == nullptr) ? 0 : strlen(opop->label);
296}
297
298void rna_ID_override_library_property_operation_tooltip_get(PointerRNA *ptr, char *value)
299{
301 ptr->data);
302 strcpy(value, (opop->tooltip == nullptr) ? "" : opop->tooltip);
303}
304
305int rna_ID_override_library_property_operation_tooltip_length(PointerRNA *ptr)
306{
308 ptr->data);
309 return (opop->tooltip == nullptr) ? 0 : strlen(opop->tooltip);
310}
311
312/* name functions that ignore the first two ID characters */
313void rna_ID_name_get(PointerRNA *ptr, char *value)
314{
315 ID *id = static_cast<ID *>(ptr->data);
316 strcpy(value, id->name + 2);
317}
318
320{
321 ID *id = static_cast<ID *>(ptr->data);
322 return strlen(id->name + 2);
323}
324
325static int rna_ID_rename(ID *self, Main *bmain, const char *new_name, const int mode)
326{
327 IDNewNameResult result = BKE_id_rename(*bmain, *self, new_name, IDNewNameMode(mode));
328 return int(result.action);
329}
330
331void rna_ID_name_set(PointerRNA *ptr, const char *value)
332{
333 ID *id = static_cast<ID *>(ptr->data);
334
335 rna_ID_rename(id, G_MAIN, value, int(IDNewNameMode::RenameExistingNever));
336}
337
338static int rna_ID_name_editable(const PointerRNA *ptr, const char **r_info)
339{
340 ID *id = static_cast<ID *>(ptr->data);
341
342 /* NOTE: For the time being, allow rename of local liboverrides from the RNA API.
343 * While this is not allowed from the UI, this should work with modern liboverride code,
344 * and could be useful in some cases. */
345 if (!ID_IS_EDITABLE(id)) {
346 if (r_info) {
347 if (ID_IS_PACKED(id)) {
348 *r_info = N_("Packed data-blocks cannot be renamed");
349 }
350 else {
351 *r_info = N_("Linked data-blocks cannot be renamed");
352 }
353 }
354 return 0;
355 }
356
357 if (GS(id->name) == ID_VF) {
358 VFont *vfont = reinterpret_cast<VFont *>(id);
359 if (BKE_vfont_is_builtin(vfont)) {
360 if (r_info) {
361 *r_info = N_("Built-in fonts cannot be renamed");
362 }
363 return 0;
364 }
365 }
366 else if (!BKE_id_is_in_global_main(id)) {
367 if (r_info) {
368 *r_info = N_("Data-blocks not in global Main data-base cannot be renamed");
369 }
370 return 0;
371 }
372
373 return PROP_EDITABLE;
374}
375
376void rna_ID_name_full_get(PointerRNA *ptr, char *value)
377{
378 ID *id = static_cast<ID *>(ptr->data);
379 BKE_id_full_name_get(value, id, 0);
380}
381
382int rna_ID_name_full_length(PointerRNA *ptr)
383{
384 ID *id = static_cast<ID *>(ptr->data);
385 char name[MAX_ID_FULL_NAME];
386 BKE_id_full_name_get(name, id, 0);
387 return strlen(name);
388}
389
390static int rna_ID_type_get(PointerRNA *ptr)
391{
392 ID *id = static_cast<ID *>(ptr->data);
393 return GS(id->name);
394}
395
396static bool rna_ID_is_evaluated_get(PointerRNA *ptr)
397{
398 ID *id = static_cast<ID *>(ptr->data);
399
400 return DEG_get_original(id) != id;
401}
402
403static PointerRNA rna_ID_original_get(PointerRNA *ptr)
404{
405 ID *id = static_cast<ID *>(ptr->data);
406
408}
409
410short RNA_type_to_ID_code(const StructRNA *type)
411{
412 const StructRNA *base_type = RNA_struct_base_child_of(type, RNA_ID);
413 if (base_type == nullptr) [[unlikely]] {
414 return 0;
415 }
416 if (base_type == RNA_Action) {
417 return ID_AC;
418 }
419 if (base_type == RNA_Armature) {
420 return ID_AR;
421 }
422 if (base_type == RNA_Brush) {
423 return ID_BR;
424 }
425 if (base_type == RNA_CacheFile) {
426 return ID_CF;
427 }
428 if (base_type == RNA_Camera) {
429 return ID_CA;
430 }
431 if (base_type == RNA_Curve) {
432 return ID_CU_LEGACY;
433 }
434 if (base_type == RNA_Annotation) {
435 return ID_GD_LEGACY;
436 }
437 if (base_type == RNA_GreasePencil) {
438 return ID_GP;
439 }
440 if (base_type == RNA_Collection) {
441 return ID_GR;
442 }
443 if (base_type == RNA_Image) {
444 return ID_IM;
445 }
446 if (base_type == RNA_Key) {
447 return ID_KE;
448 }
449 if (base_type == RNA_Light) {
450 return ID_LA;
451 }
452 if (base_type == RNA_Library) {
453 return ID_LI;
454 }
455 if (base_type == RNA_FreestyleLineStyle) {
456 return ID_LS;
457 }
458 if (base_type == RNA_Curves) {
459 return ID_CV;
460 }
461 if (base_type == RNA_Lattice) {
462 return ID_LT;
463 }
464 if (base_type == RNA_Material) {
465 return ID_MA;
466 }
467 if (base_type == RNA_MetaBall) {
468 return ID_MB;
469 }
470 if (base_type == RNA_MovieClip) {
471 return ID_MC;
472 }
473 if (base_type == RNA_Mesh) {
474 return ID_ME;
475 }
476 if (base_type == RNA_Mask) {
477 return ID_MSK;
478 }
479 if (base_type == RNA_NodeTree) {
480 return ID_NT;
481 }
482 if (base_type == RNA_Object) {
483 return ID_OB;
484 }
485 if (base_type == RNA_ParticleSettings) {
486 return ID_PA;
487 }
488 if (base_type == RNA_Palette) {
489 return ID_PAL;
490 }
491 if (base_type == RNA_PaintCurve) {
492 return ID_PC;
493 }
494 if (base_type == RNA_PointCloud) {
495 return ID_PT;
496 }
497 if (base_type == RNA_LightProbe) {
498 return ID_LP;
499 }
500 if (base_type == RNA_Scene) {
501 return ID_SCE;
502 }
503 if (base_type == RNA_Screen) {
504 return ID_SCR;
505 }
506 if (base_type == RNA_Sound) {
507 return ID_SO;
508 }
509 if (base_type == RNA_Speaker) {
510 return ID_SPK;
511 }
512 if (base_type == RNA_Texture) {
513 return ID_TE;
514 }
515 if (base_type == RNA_Text) {
516 return ID_TXT;
517 }
518 if (base_type == RNA_VectorFont) {
519 return ID_VF;
520 }
521 if (base_type == RNA_Volume) {
522 return ID_VO;
523 }
524 if (base_type == RNA_WorkSpace) {
525 return ID_WS;
526 }
527 if (base_type == RNA_World) {
528 return ID_WO;
529 }
530 if (base_type == RNA_WindowManager) {
531 return ID_WM;
532 }
533
534 return 0;
535}
536
537StructRNA *ID_code_to_RNA_type(short idcode)
538{
539 /* NOTE: this switch doesn't use a 'default',
540 * so adding new ID's causes a warning. */
541 switch (ID_Type(idcode)) {
542 case ID_AC:
543 return RNA_Action;
544 case ID_AR:
545 return RNA_Armature;
546 case ID_BR:
547 return RNA_Brush;
548 case ID_CA:
549 return RNA_Camera;
550 case ID_CF:
551 return RNA_CacheFile;
552 case ID_CU_LEGACY:
553 return RNA_Curve;
554 case ID_GD_LEGACY:
555 return RNA_Annotation;
556 case ID_GP:
557 return RNA_GreasePencil;
558 case ID_GR:
559 return RNA_Collection;
560 case ID_CV:
561 return RNA_Curves;
562 case ID_IM:
563 return RNA_Image;
564 case ID_KE:
565 return RNA_Key;
566 case ID_LA:
567 return RNA_Light;
568 case ID_LI:
569 return RNA_Library;
570 case ID_LS:
571 return RNA_FreestyleLineStyle;
572 case ID_LT:
573 return RNA_Lattice;
574 case ID_MA:
575 return RNA_Material;
576 case ID_MB:
577 return RNA_MetaBall;
578 case ID_MC:
579 return RNA_MovieClip;
580 case ID_ME:
581 return RNA_Mesh;
582 case ID_MSK:
583 return RNA_Mask;
584 case ID_NT:
585 return RNA_NodeTree;
586 case ID_OB:
587 return RNA_Object;
588 case ID_PA:
589 return RNA_ParticleSettings;
590 case ID_PAL:
591 return RNA_Palette;
592 case ID_PC:
593 return RNA_PaintCurve;
594 case ID_PT:
595 return RNA_PointCloud;
596 case ID_LP:
597 return RNA_LightProbe;
598 case ID_SCE:
599 return RNA_Scene;
600 case ID_SCR:
601 return RNA_Screen;
602 case ID_SO:
603 return RNA_Sound;
604 case ID_SPK:
605 return RNA_Speaker;
606 case ID_TE:
607 return RNA_Texture;
608 case ID_TXT:
609 return RNA_Text;
610 case ID_VF:
611 return RNA_VectorFont;
612 case ID_VO:
613 return RNA_Volume;
614 case ID_WM:
615 return RNA_WindowManager;
616 case ID_WO:
617 return RNA_World;
618 case ID_WS:
619 return RNA_WorkSpace;
620 }
621
622 return RNA_ID;
623}
624
626{
627 ID *id = static_cast<ID *>(ptr->data);
628
629 return ID_code_to_RNA_type(GS(id->name));
630}
631
633{
634 ID *id = static_cast<ID *>(ptr->data);
635 return &id->properties;
636}
637
639{
640 ID *id = static_cast<ID *>(ptr->data);
641 return &id->system_properties;
642}
643
644int rna_ID_is_runtime_editable(const PointerRNA *ptr, const char **r_info)
645{
646 ID *id = static_cast<ID *>(ptr->data);
647 /* TODO: This should be abstracted in a BKE function or define, somewhat related to #88555. */
649 *r_info = N_(
650 "Cannot edit 'runtime' status of non-blendfile data-blocks, as they are by definition "
651 "always runtime");
652 return 0;
653 }
654
655 return PROP_EDITABLE;
656}
657
658bool rna_ID_is_runtime_get(PointerRNA *ptr)
659{
660 ID *id = static_cast<ID *>(ptr->data);
661 /* TODO: This should be abstracted in a BKE function or define, somewhat related to #88555. */
663 return true;
664 }
665
666 return (id->tag & ID_TAG_RUNTIME) != 0;
667}
668
669bool rna_ID_is_editable_get(PointerRNA *ptr)
670{
671 ID *id = static_cast<ID *>(ptr->data);
672 return ID_IS_EDITABLE(id);
673}
674
675void rna_ID_fake_user_set(PointerRNA *ptr, bool value)
676{
677 ID *id = static_cast<ID *>(ptr->data);
678
679 if (value) {
681 }
682 else {
684 }
685}
686
687void rna_ID_extra_user_set(PointerRNA *ptr, bool value)
688{
689 ID *id = static_cast<ID *>(ptr->data);
690
691 if (value) {
693 }
694 else {
696 }
697}
698
700{
701 return reinterpret_cast<IDProperty **>(&ptr->data);
702}
703
705{
707# ifdef WITH_PYTHON
708 /* Ensure that a potential py object representing this RNA type is properly dereferenced. */
710# endif
711
713 return true;
714}
715
717 ReportList *reports,
718 void *data,
719 const char *identifier,
720 StructValidateFunc validate,
721 StructCallbackFunc /*call*/,
722 StructFreeFunc /*free*/)
723{
724 /* create dummy pointer */
725 PointerRNA dummy_ptr = RNA_pointer_create_discrete(nullptr, RNA_PropertyGroup, nullptr);
726
727 /* validate the python class */
728 if (validate(&dummy_ptr, data, nullptr) != 0) {
729 return nullptr;
730 }
731
732 /* NOTE: it looks like there is no length limit on the srna id since its
733 * just a char pointer, but take care here, also be careful that python
734 * owns the string pointer which it could potentially free while blender
735 * is running. */
736 if (BLI_strnlen(identifier, MAX_IDPROP_NAME) == MAX_IDPROP_NAME) {
737 BKE_reportf(reports,
738 RPT_ERROR,
739 "Registering id property class: '%s' is too long, maximum length is %d",
740 identifier,
742 return nullptr;
743 }
744
745 return RNA_def_struct_ptr(&RNA_blender_rna_get(), identifier, RNA_PropertyGroup); /* XXX */
746}
747
749{
750 return ptr->type;
751}
752
753static ID *rna_ID_evaluated_get(ID *id, Depsgraph *depsgraph)
754{
755 return DEG_get_evaluated(depsgraph, id);
756}
757
758static ID *rna_ID_copy(ID *id, Main *bmain)
759{
760 ID *newid = BKE_id_copy_for_use_in_bmain(bmain, id);
761
762 if (newid != nullptr) {
763 id_us_min(newid);
764 BKE_main_ensure_invariants(*bmain, *newid);
765 }
766
768
769 return newid;
770}
771
772static void rna_ID_asset_mark(ID *id)
773{
774 if (ed::asset::mark_id(id)) {
777 }
778}
779
780static void rna_ID_asset_generate_preview(ID *id, bContext *C)
781{
783
786}
787
788static void rna_ID_asset_clear(ID *id)
789{
790 if (ed::asset::clear_id(id)) {
793 }
794}
795
796static void rna_ID_asset_data_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
797{
798 ID *destination = static_cast<ID *>(ptr->data);
799
800 /* Avoid marking as asset by assigning. This should be done with `.asset_mark()`.
801 * This is just for clarity of the API, and to accommodate future changes. */
802 if (destination->asset_data == nullptr) {
803 BKE_report(reports,
804 RPT_ERROR,
805 "Asset data can only be assigned to assets. Use asset_mark() to mark as an asset.");
806 return;
807 }
808
809 const AssetMetaData *asset_data = static_cast<const AssetMetaData *>(value.data);
810 if (asset_data == nullptr) {
811 /* Avoid clearing the asset data on assets. Un-marking as asset should be done with
812 * `.asset_clear()`. This is just for clarity of the API, and to accommodate future changes. */
813 BKE_report(reports, RPT_ERROR, "Asset data cannot be None");
814 return;
815 }
816
817 const bool assigned_ok = ed::asset::copy_to_id(asset_data, destination);
818 if (!assigned_ok) {
820 reports, RPT_ERROR, "'%s' is of a type that cannot be an asset", destination->name + 2);
821 return;
822 }
823
826}
827
828static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages)
829{
830 if (!ID_IS_OVERRIDABLE_LIBRARY(id)) {
831 return nullptr;
832 }
833
834 if (remap_local_usages) {
835 BKE_main_id_tag_all(bmain, ID_TAG_DOIT, true);
836 }
837
838 ID *local_id = nullptr;
839# ifdef WITH_PYTHON
841# endif
842
843 local_id = BKE_lib_override_library_create_from_id(bmain, id, remap_local_usages);
844
845# ifdef WITH_PYTHON
847# endif
848
849 if (remap_local_usages) {
850 BKE_main_id_tag_all(bmain, ID_TAG_DOIT, false);
851 }
852
855
856 return local_id;
857}
858
859static ID *rna_ID_override_hierarchy_create(ID *id,
860 Main *bmain,
861 Scene *scene,
862 ViewLayer *view_layer,
863 ID *id_instance_hint,
864 bool do_fully_editable)
865{
866 if (!ID_IS_OVERRIDABLE_LIBRARY(id)) {
867 return nullptr;
868 }
869
870 BKE_main_id_tag_all(bmain, ID_TAG_DOIT, false);
871
872 ID *id_root_override = nullptr;
873
874# ifdef WITH_PYTHON
876# endif
877
879 scene,
880 view_layer,
881 nullptr,
882 id,
883 id,
884 id_instance_hint,
885 &id_root_override,
886 do_fully_editable);
887
888# ifdef WITH_PYTHON
890# endif
891
894
895 return id_root_override;
896}
897
898static void rna_ID_override_library_operations_update(ID *id,
899 IDOverrideLibrary * /*override_library*/,
900 Main *bmain,
901 ReportList *reports)
902{
904 BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
905 return;
906 }
907
908 if (ID_IS_LINKED(id)) {
909 BKE_reportf(reports, RPT_ERROR, "ID '%s' is linked, cannot edit its overrides", id->name);
910 return;
911 }
912
914
916}
917
918static void rna_ID_override_library_reset(ID *id,
919 IDOverrideLibrary * /*override_library*/,
920 Main *bmain,
921 ReportList *reports,
922 bool do_hierarchy,
923 bool set_system_override)
924{
926 BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
927 return;
928 }
929
930 if (do_hierarchy) {
931 BKE_lib_override_library_id_hierarchy_reset(bmain, id, set_system_override);
932 }
933 else {
934 BKE_lib_override_library_id_reset(bmain, id, set_system_override);
935 }
936
938}
939
940static void rna_ID_override_library_destroy(ID *id,
941 IDOverrideLibrary * /*override_library*/,
942 Main *bmain,
943 ReportList *reports,
944 bool do_hierarchy)
945{
947 BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
948 return;
949 }
950
951 if (do_hierarchy) {
953 }
954 else {
955 BKE_libblock_remap(bmain, id, id->override_library->reference, ID_REMAP_SKIP_INDIRECT_USAGE);
956 BKE_id_delete(bmain, id);
957 }
958
960}
961
962static bool rna_ID_override_library_resync(ID *id,
963 IDOverrideLibrary *override_library,
964 Main *bmain,
965 ReportList *reports,
966 Scene *scene,
967 ViewLayer *view_layer,
968 Collection *override_resync_residual_storage,
969 bool do_hierarchy_enforce,
970 bool do_whole_hierarchy)
971{
972 BLI_assert(id->override_library == override_library);
973
974 if (!override_library->hierarchy_root ||
975 (override_library->flag & LIBOVERRIDE_FLAG_NO_HIERARCHY) != 0)
976 {
978 reports,
980 "Data-block '%s' is not a library override, or not part of a library override hierarchy",
981 id->name);
982 return false;
983 }
984
985 ID *id_root = do_whole_hierarchy ? override_library->hierarchy_root : id;
986 BlendFileReadReport bf_reports = {};
987 bf_reports.reports = reports;
988
989 const bool success = BKE_lib_override_library_resync(bmain,
990 scene,
991 view_layer,
992 id_root,
993 override_resync_residual_storage,
994 do_hierarchy_enforce,
995 &bf_reports);
996
998 return success;
999}
1000
1001static IDOverrideLibraryProperty *rna_ID_override_library_properties_add(
1002 IDOverrideLibrary *override_library, ReportList *reports, const char rna_path[])
1003{
1004 bool created;
1006 override_library, rna_path, &created);
1007
1008 if (!created) {
1009 BKE_report(reports, RPT_DEBUG, "No new override property created, property already exists");
1010 }
1011
1013 return result;
1014}
1015
1016static void rna_ID_override_library_properties_remove(IDOverrideLibrary *override_library,
1017 ReportList *reports,
1018 IDOverrideLibraryProperty *override_property)
1019{
1020 if (BLI_findindex(&override_library->properties, override_property) == -1) {
1021 BKE_report(reports, RPT_ERROR, "Override property cannot be removed");
1022 return;
1023 }
1024
1025 BKE_lib_override_library_property_delete(override_library, override_property);
1026
1028}
1029
1030static IDOverrideLibraryPropertyOperation *rna_ID_override_library_property_operations_add(
1031 IDOverrideLibraryProperty *override_property,
1032 ReportList *reports,
1033 int operation,
1034 const bool use_id,
1035 const char *subitem_refname,
1036 const char *subitem_locname,
1037 ID *subitem_refid,
1038 ID *subitem_locid,
1039 int subitem_refindex,
1040 int subitem_locindex)
1041{
1042 bool created;
1043 bool strict;
1045 override_property,
1046 eID_OverrideLib_Op(operation),
1047 subitem_refname,
1048 subitem_locname,
1049 use_id ? std::optional(subitem_refid) : std::nullopt,
1050 use_id ? std::optional(subitem_locid) : std::nullopt,
1051 subitem_refindex,
1052 subitem_locindex,
1053 false,
1054 &strict,
1055 &created);
1056 if (!created) {
1057 BKE_report(reports, RPT_DEBUG, "No new override operation created, operation already exists");
1058 }
1059
1061 return result;
1062}
1063
1064static void rna_ID_override_library_property_operations_remove(
1065 IDOverrideLibraryProperty *override_property,
1066 ReportList *reports,
1067 IDOverrideLibraryPropertyOperation *override_operation)
1068{
1069 if (BLI_findindex(&override_property->operations, override_operation) == -1) {
1070 BKE_report(reports, RPT_ERROR, "Override operation cannot be removed");
1071 return;
1072 }
1073
1074 BKE_lib_override_library_property_operation_delete(override_property, override_operation);
1075
1077}
1078
1079static void rna_ID_deephash_get(PointerRNA *ptr, char *value)
1080{
1081 ID *id = ptr->data_as<ID>();
1082 memcpy(value, id->deep_hash.data, sizeof(id->deep_hash.data));
1083 value[sizeof(id->deep_hash.data)] = '\0';
1084}
1085
1086static int rna_ID_deephash_len(PointerRNA *ptr)
1087{
1088 ID *id = ptr->data_as<ID>();
1089 return sizeof(id->deep_hash.data);
1090}
1091
1092static void rna_ID_update_tag(ID *id, Main *bmain, ReportList *reports, int flag)
1093{
1094/* XXX, new function for this! */
1095# if 0
1096 if (ob->type == OB_FONT) {
1097 Curve *cu = ob->data;
1098 freedisplist(&cu->disp);
1099 BKE_vfont_to_curve(bmain, sce, ob, FO_EDIT, nullptr);
1100 }
1101# endif
1102
1103 if (flag == 0) {
1104 /* pass */
1105 }
1106 else {
1107 int allow_flag = 0;
1108
1109 /* ensure flag us correct for the type */
1110 switch (GS(id->name)) {
1111 case ID_OB:
1112 /* TODO(sergey): This is kind of difficult to predict since different
1113 * object types supports different flags. Maybe does not worth checking
1114 * for this at all. Or maybe let dependency graph to return whether
1115 * the tag was valid or not. */
1116 allow_flag = ID_RECALC_ALL;
1117 break;
1118/* Could add particle updates later */
1119# if 0
1120 case ID_PA:
1121 allow_flag = OB_RECALC_ALL | PSYS_RECALC;
1122 break;
1123# endif
1124 case ID_AC:
1125 allow_flag = ID_RECALC_ANIMATION;
1126 break;
1127 default:
1128 if (id_can_have_animdata(id)) {
1129 allow_flag = ID_RECALC_ANIMATION;
1130 }
1131 }
1132
1133 if (flag & ~allow_flag) {
1134 StructRNA *srna = ID_code_to_RNA_type(GS(id->name));
1135 BKE_reportf(reports,
1136 RPT_ERROR,
1137 allow_flag ? N_("%s is not compatible with the specified 'refresh' options") :
1138 N_("%s is not compatible with any 'refresh' options"),
1139 RNA_struct_identifier(srna));
1140 return;
1141 }
1142 }
1143
1144 DEG_id_tag_update_ex(bmain, id, flag);
1145}
1146
1147static void rna_ID_user_clear(ID *id)
1148{
1150 id->us = 0; /* don't save */
1151}
1152
1153static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
1154{
1155 if ((GS(id->name) == GS(new_id->name)) && (id != new_id)) {
1156 /* For now, do not allow remapping data in linked data from here... */
1159
1161 }
1162}
1163
1164static ID *rna_ID_make_local(
1165 ID *self, Main *bmain, bool /*clear_proxy*/, bool clear_liboverride, bool clear_asset_data)
1166{
1167 if (ID_IS_LINKED(self)) {
1168 int flags = 0;
1169 if (clear_asset_data) {
1171 }
1172
1173 BKE_lib_id_make_local(bmain, self, flags);
1174 }
1175 else if (ID_IS_OVERRIDE_LIBRARY_REAL(self)) {
1177 }
1178
1179 ID *ret_id = self->newid ? self->newid : self;
1181
1182 if (clear_liboverride && ID_IS_OVERRIDE_LIBRARY_REAL(ret_id)) {
1184 }
1185
1186 return ret_id;
1187}
1188
1189static AnimData *rna_ID_animation_data_create(ID *id, Main *bmain)
1190{
1193 return adt;
1194}
1195
1196static void rna_ID_animation_data_free(ID *id, Main *bmain)
1197{
1198 BKE_animdata_free(id, true);
1200}
1201
1202# ifdef WITH_PYTHON
1203void **rna_ID_instance(PointerRNA *ptr)
1204{
1205 ID *id = static_cast<ID *>(ptr->data);
1206 return &id->py_instance;
1207}
1208# endif
1209
1210static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1211{
1212 IDProperty *prop = static_cast<IDProperty *>(ptr->data);
1214 iter, ptr, IDP_property_array_get(prop), sizeof(IDProperty), prop->len, 0, nullptr);
1215}
1216
1217static int rna_IDPArray_length(PointerRNA *ptr)
1218{
1219 IDProperty *prop = static_cast<IDProperty *>(ptr->data);
1220 return prop->len;
1221}
1222
1223bool rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assign_ptr)
1224{
1225 ID *id = ptr->owner_id;
1226 short *totcol = BKE_id_material_len_p(id);
1227 Material *mat_id = id_cast<Material *>(assign_ptr->owner_id);
1228 if (totcol && (key >= 0 && key < *totcol)) {
1231 BKE_id_material_assign(G_MAIN, id, mat_id, key + 1);
1232 return true;
1233 }
1234 else {
1235 return false;
1236 }
1237}
1238
1239static void rna_IDMaterials_append_id(ID *id, Main *bmain, Material *ma)
1240{
1241 BKE_id_material_append(bmain, id, ma);
1242
1245}
1246
1247static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports, int index_i)
1248{
1249 Material *ma;
1250 short *totcol = BKE_id_material_len_p(id);
1251 const short totcol_orig = *totcol;
1252 if (index_i < 0) {
1253 index_i += (*totcol);
1254 }
1255
1256 if ((index_i < 0) || (index_i >= (*totcol))) {
1257 BKE_report(reports, RPT_ERROR, "Index out of range");
1258 return nullptr;
1259 }
1260
1261 ma = BKE_id_material_pop(bmain, id, index_i);
1262
1263 if (*totcol == totcol_orig) {
1264 BKE_report(reports, RPT_ERROR, "No material to removed");
1265 return nullptr;
1266 }
1267
1271
1272 return ma;
1273}
1274
1275static void rna_IDMaterials_clear_id(ID *id, Main *bmain)
1276{
1277 BKE_id_material_clear(bmain, id);
1278
1282}
1283
1284static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
1285{
1286 Library *lib = static_cast<Library *>(ptr->data);
1288 BKE_library_filepath_set(G_MAIN, lib, value);
1289}
1290
1291/* ***** ImagePreview ***** */
1292
1293static void rna_ImagePreview_is_custom_set(PointerRNA *ptr, int value, enum eIconSizes size)
1294{
1295 ID *id = ptr->owner_id;
1296 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1297
1298 if (id != nullptr) {
1299 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1300 }
1301
1302 if ((value && (prv_img->flag[size] & PRV_USER_EDITED)) ||
1303 (!value && !(prv_img->flag[size] & PRV_USER_EDITED)))
1304 {
1305 return;
1306 }
1307
1308 if (value) {
1309 prv_img->flag[size] |= PRV_USER_EDITED;
1310 }
1311 else {
1312 prv_img->flag[size] &= ~PRV_USER_EDITED;
1313 }
1314
1315 prv_img->flag[size] |= PRV_CHANGED;
1316
1317 BKE_previewimg_clear_single(prv_img, size);
1318}
1319
1320static void rna_ImagePreview_size_get(PointerRNA *ptr, int *values, enum eIconSizes size)
1321{
1322 ID *id = ptr->owner_id;
1323 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1324
1325 if (id != nullptr) {
1326 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1327 }
1328
1329 BKE_previewimg_ensure(prv_img, size);
1330
1331 values[0] = prv_img->w[size];
1332 values[1] = prv_img->h[size];
1333}
1334
1335static void rna_ImagePreview_size_set(PointerRNA *ptr, const int *values, enum eIconSizes size)
1336{
1337 ID *id = ptr->owner_id;
1338 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1339
1340 if (id != nullptr) {
1341 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1342 }
1343
1344 BKE_previewimg_clear_single(prv_img, size);
1345
1346 if (values[0] && values[1]) {
1347 prv_img->rect[size] = MEM_new_array_zeroed<uint>(size_t(values[0]) * size_t(values[1]),
1348 "prv_rect");
1349
1350 prv_img->w[size] = values[0];
1351 prv_img->h[size] = values[1];
1352 }
1353
1354 prv_img->flag[size] |= (PRV_CHANGED | PRV_USER_EDITED);
1355}
1356
1357static int rna_ImagePreview_pixels_get_length(const PointerRNA *ptr,
1359 enum eIconSizes size)
1360{
1361 ID *id = ptr->owner_id;
1362 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1363
1364 if (id != nullptr) {
1365 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1366 }
1367
1368 BKE_previewimg_ensure(prv_img, size);
1369
1370 length[0] = prv_img->w[size] * prv_img->h[size];
1371
1372 return length[0];
1373}
1374
1375static void rna_ImagePreview_pixels_get(PointerRNA *ptr, int *values, enum eIconSizes size)
1376{
1377 ID *id = ptr->owner_id;
1378 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1379
1380 if (id != nullptr) {
1381 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1382 }
1383
1384 BKE_previewimg_ensure(prv_img, size);
1385
1386 memcpy(values, prv_img->rect[size], prv_img->w[size] * prv_img->h[size] * sizeof(uint));
1387}
1388
1389static void rna_ImagePreview_pixels_set(PointerRNA *ptr, const int *values, enum eIconSizes size)
1390{
1391 ID *id = ptr->owner_id;
1392 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1393
1394 if (id != nullptr) {
1395 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1396 }
1397
1398 memcpy(prv_img->rect[size], values, prv_img->w[size] * prv_img->h[size] * sizeof(uint));
1399 prv_img->flag[size] |= PRV_USER_EDITED;
1400}
1401
1402static int rna_ImagePreview_pixels_float_get_length(const PointerRNA *ptr,
1404 enum eIconSizes size)
1405{
1406 ID *id = ptr->owner_id;
1407 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1408
1409 BLI_assert(sizeof(uint) == 4);
1410
1411 if (id != nullptr) {
1412 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1413 }
1414
1415 BKE_previewimg_ensure(prv_img, size);
1416
1417 length[0] = prv_img->w[size] * prv_img->h[size] * 4;
1418
1419 return length[0];
1420}
1421
1422static void rna_ImagePreview_pixels_float_get(PointerRNA *ptr, float *values, enum eIconSizes size)
1423{
1424 ID *id = ptr->owner_id;
1425 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1426
1427 uchar *data = reinterpret_cast<uchar *>(prv_img->rect[size]);
1428 const size_t len = prv_img->w[size] * prv_img->h[size] * 4;
1429 size_t i;
1430
1431 BLI_assert(sizeof(uint) == 4);
1432
1433 if (id != nullptr) {
1434 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1435 }
1436
1437 BKE_previewimg_ensure(prv_img, size);
1438
1439 for (i = 0; i < len; i++) {
1440 values[i] = data[i] * (1.0f / 255.0f);
1441 }
1442}
1443
1444static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr,
1445 const float *values,
1446 enum eIconSizes size)
1447{
1448 ID *id = ptr->owner_id;
1449 PreviewImage *prv_img = static_cast<PreviewImage *>(ptr->data);
1450
1451 uchar *data = reinterpret_cast<uchar *>(prv_img->rect[size]);
1452 const size_t len = prv_img->w[size] * prv_img->h[size] * 4;
1453 size_t i;
1454
1455 BLI_assert(sizeof(uint) == 4);
1456
1457 if (id != nullptr) {
1458 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1459 }
1460
1461 for (i = 0; i < len; i++) {
1462 data[i] = unit_float_to_uchar_clamp(values[i]);
1463 }
1464 prv_img->flag[size] |= PRV_USER_EDITED;
1465}
1466
1467static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, bool value)
1468{
1469 rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_PREVIEW);
1470}
1471
1472static void rna_ImagePreview_image_size_get(PointerRNA *ptr, int *values)
1473{
1474 rna_ImagePreview_size_get(ptr, values, ICON_SIZE_PREVIEW);
1475}
1476
1477static void rna_ImagePreview_image_size_set(PointerRNA *ptr, const int *values)
1478{
1479 rna_ImagePreview_size_set(ptr, values, ICON_SIZE_PREVIEW);
1480}
1481
1482static int rna_ImagePreview_image_pixels_get_length(const PointerRNA *ptr,
1484{
1485 return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_PREVIEW);
1486}
1487
1488static void rna_ImagePreview_image_pixels_get(PointerRNA *ptr, int *values)
1489{
1490 rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_PREVIEW);
1491}
1492
1493static void rna_ImagePreview_image_pixels_set(PointerRNA *ptr, const int *values)
1494{
1495 rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_PREVIEW);
1496}
1497
1498static int rna_ImagePreview_image_pixels_float_get_length(const PointerRNA *ptr,
1500{
1501 return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_PREVIEW);
1502}
1503
1504static void rna_ImagePreview_image_pixels_float_get(PointerRNA *ptr, float *values)
1505{
1506 rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_PREVIEW);
1507}
1508
1509static void rna_ImagePreview_image_pixels_float_set(PointerRNA *ptr, const float *values)
1510{
1511 rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_PREVIEW);
1512}
1513
1514static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, bool value)
1515{
1516 rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_ICON);
1517}
1518
1519static void rna_ImagePreview_icon_size_get(PointerRNA *ptr, int *values)
1520{
1521 rna_ImagePreview_size_get(ptr, values, ICON_SIZE_ICON);
1522}
1523
1524static void rna_ImagePreview_icon_size_set(PointerRNA *ptr, const int *values)
1525{
1526 rna_ImagePreview_size_set(ptr, values, ICON_SIZE_ICON);
1527}
1528
1529static int rna_ImagePreview_icon_pixels_get_length(const PointerRNA *ptr,
1531{
1532 return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_ICON);
1533}
1534
1535static void rna_ImagePreview_icon_pixels_get(PointerRNA *ptr, int *values)
1536{
1537 rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_ICON);
1538}
1539
1540static void rna_ImagePreview_icon_pixels_set(PointerRNA *ptr, const int *values)
1541{
1542 rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_ICON);
1543}
1544
1545static int rna_ImagePreview_icon_pixels_float_get_length(const PointerRNA *ptr,
1547{
1548 return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_ICON);
1549}
1550
1551static void rna_ImagePreview_icon_pixels_float_get(PointerRNA *ptr, float *values)
1552{
1553 rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_ICON);
1554}
1555
1556static void rna_ImagePreview_icon_pixels_float_set(PointerRNA *ptr, const float *values)
1557{
1558 rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_ICON);
1559}
1560
1561static int rna_ImagePreview_icon_id_get(PointerRNA *ptr)
1562{
1563 /* Using a callback here allows us to only generate icon matching
1564 * that preview when icon_id is requested. */
1565 return BKE_icon_preview_ensure(ptr->owner_id, static_cast<PreviewImage *>(ptr->data));
1566}
1567static void rna_ImagePreview_icon_reload(PreviewImage *prv)
1568{
1569 /* will lazy load on next use, but only in case icon is not user-modified! */
1570 if (!(prv->flag[ICON_SIZE_ICON] & PRV_USER_EDITED) &&
1571 !(prv->flag[ICON_SIZE_PREVIEW] & PRV_USER_EDITED))
1572 {
1574 }
1575}
1576
1577static PointerRNA rna_IDPreview_get(PointerRNA *ptr)
1578{
1579 ID *id = static_cast<ID *>(ptr->data);
1580 PreviewImage *prv_img = BKE_previewimg_id_get(id);
1581
1582 return RNA_pointer_create_with_parent(*ptr, RNA_ImagePreview, prv_img);
1583}
1584
1585static IDProperty **rna_IDPropertyWrapPtr_idprops(PointerRNA *ptr)
1586{
1587 if (ptr == nullptr) {
1588 return nullptr;
1589 }
1590 return reinterpret_cast<IDProperty **>(&ptr->data);
1591}
1592
1593static void rna_Library_version_get(PointerRNA *ptr, int *value)
1594{
1595 Library *lib = static_cast<Library *>(ptr->data);
1596 value[0] = lib->runtime->versionfile / 100;
1597 value[1] = lib->runtime->versionfile % 100;
1598 value[2] = lib->runtime->subversionfile;
1599}
1600
1601static void rna_Library_archive_libraries_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1602{
1603 iter->parent = *ptr;
1604 Library *lib = static_cast<Library *>(ptr->data);
1605
1606 Library **archive_libraries_iter = lib->runtime->archived_libraries.begin();
1607 iter->internal.custom = archive_libraries_iter;
1608
1609 iter->valid = archive_libraries_iter != lib->runtime->archived_libraries.end();
1610}
1611
1612static void rna_Library_archive_libraries_next(CollectionPropertyIterator *iter)
1613{
1614 Library *lib = static_cast<Library *>(iter->parent.data);
1615 Library **archive_libraries_iter = static_cast<Library **>(iter->internal.custom);
1616
1617 archive_libraries_iter++;
1618 iter->internal.custom = archive_libraries_iter;
1619
1620 iter->valid = archive_libraries_iter != lib->runtime->archived_libraries.end();
1621}
1622
1623static PointerRNA rna_Library_archive_libraries_get(CollectionPropertyIterator *iter)
1624{
1625 Library **archive_libraries_iter = static_cast<Library **>(iter->internal.custom);
1626 return RNA_pointer_create_with_parent(iter->parent, RNA_Library, *archive_libraries_iter);
1627}
1628
1629static int rna_Library_archive_libraries_length(PointerRNA *ptr)
1630{
1631 Library *lib = static_cast<Library *>(ptr->data);
1632 return int(lib->runtime->archived_libraries.size());
1633}
1634
1635static bool rna_Library_archive_libraries_lookupint(PointerRNA *ptr, int key, PointerRNA *r_ptr)
1636{
1637 Library *lib = static_cast<Library *>(ptr->data);
1638 if (key < 0 || key >= lib->runtime->archived_libraries.size()) {
1639 return false;
1640 }
1641
1642 Library *archive_library = lib->runtime->archived_libraries[key];
1643 rna_pointer_create_with_ancestors(*ptr, RNA_Library, archive_library, *r_ptr);
1644 return true;
1645}
1646
1647static PointerRNA rna_Library_parent_get(PointerRNA *ptr)
1648{
1649 Library *lib = ptr->data_as<Library>();
1650 Library *parent = lib->runtime->parent;
1651 return RNA_id_pointer_create(reinterpret_cast<ID *>(parent));
1652}
1653
1654static void rna_Library_reload(Library *lib, bContext *C, ReportList *reports)
1655{
1656# ifdef WITH_PYTHON
1658# endif
1659
1660 WM_lib_reload(lib, C, reports);
1661
1662# ifdef WITH_PYTHON
1664# endif
1665}
1666
1667} // namespace blender
1668
1669#else
1670
1671namespace blender {
1672
1674{
1675 StructRNA *srna;
1676 PropertyRNA *prop;
1677
1678 /* this is struct is used for holding the virtual
1679 * PropertyRNA's for ID properties */
1680 srna = RNA_def_struct(brna, "PropertyGroupItem", nullptr);
1681 RNA_def_struct_sdna(srna, "IDProperty");
1683 srna, "ID Property", "Property that stores arbitrary, user defined properties");
1684
1685 /* IDP_STRING */
1686 prop = RNA_def_property(srna, "string", PROP_STRING, PROP_NONE);
1688
1689 /* IDP_INT */
1690 prop = RNA_def_property(srna, "int", PROP_INT, PROP_NONE);
1692
1693 prop = RNA_def_property(srna, "int_array", PROP_INT, PROP_NONE);
1695 RNA_def_property_array(prop, 1);
1696
1697 /* IDP_FLOAT */
1698 prop = RNA_def_property(srna, "float", PROP_FLOAT, PROP_NONE);
1700
1701 prop = RNA_def_property(srna, "float_array", PROP_FLOAT, PROP_NONE);
1703 RNA_def_property_array(prop, 1);
1704
1705 /* IDP_DOUBLE */
1706 prop = RNA_def_property(srna, "double", PROP_FLOAT, PROP_NONE);
1708
1709 prop = RNA_def_property(srna, "double_array", PROP_FLOAT, PROP_NONE);
1711 RNA_def_property_array(prop, 1);
1712
1713 /* IDP_BOOLEAN */
1714 prop = RNA_def_property(srna, "bool", PROP_BOOLEAN, PROP_NONE);
1716
1717 prop = RNA_def_property(srna, "bool_array", PROP_BOOLEAN, PROP_NONE);
1719 RNA_def_property_array(prop, 1);
1720
1721 /* IDP_ENUM */
1722 prop = RNA_def_property(srna, "enum", PROP_ENUM, PROP_NONE);
1725
1726 /* IDP_GROUP */
1727 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1730 RNA_def_property_struct_type(prop, "PropertyGroup");
1731
1732 prop = RNA_def_property(srna, "collection", PROP_COLLECTION, PROP_NONE);
1734 RNA_def_property_struct_type(prop, "PropertyGroup");
1735
1736 prop = RNA_def_property(srna, "idp_array", PROP_COLLECTION, PROP_NONE);
1737 RNA_def_property_struct_type(prop, "PropertyGroup");
1739 "rna_IDPArray_begin",
1740 "rna_iterator_array_next",
1741 "rna_iterator_array_end",
1742 "rna_iterator_array_get",
1743 "rna_IDPArray_length",
1744 nullptr,
1745 nullptr,
1746 nullptr);
1748
1749/* never tested, maybe its useful to have this? */
1750# if 0
1751 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1754 RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting");
1755 RNA_def_struct_name_property(srna, prop);
1756# endif
1757
1758 /* IDP_ID */
1759 prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1761 RNA_def_property_struct_type(prop, "ID");
1762
1763 /* ID property groups > level 0, since level 0 group is merged
1764 * with native RNA properties. the builtin_properties will take
1765 * care of the properties here */
1766 srna = RNA_def_struct(brna, "PropertyGroup", nullptr);
1767 RNA_def_struct_sdna(srna, "IDPropertyGroup");
1768 RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties");
1769 /* For property groups, both 'user-defined' and system-defined properties are the same.
1770 * The user-defined access is kept to allow 'dict-type' subscripting in python. */
1771 RNA_def_struct_idprops_func(srna, "rna_PropertyGroup_idprops");
1772 RNA_def_struct_system_idprops_func(srna, "rna_PropertyGroup_idprops");
1774 srna, "rna_PropertyGroup_register", "rna_PropertyGroup_unregister", nullptr);
1775 RNA_def_struct_refine_func(srna, "rna_PropertyGroup_refine");
1776
1777 /* Important so that python types can have their name used in list views.
1778 *
1779 * Note that python types can override this by defining their own `name` string property, see
1780 * also #pyrna_register_class.
1781 */
1782 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1786 "Name",
1787 "Unique name used in the code and scripting, can be re-defined in "
1788 "Python sub-classes if needed");
1789 RNA_def_struct_name_property(srna, prop);
1790}
1791
1793{
1794 StructRNA *srna;
1795 FunctionRNA *func;
1796 PropertyRNA *parm;
1797
1798 /* For mesh/meta-ball/curve materials. */
1799 srna = RNA_def_struct(brna, "IDMaterials", nullptr);
1800 RNA_def_struct_sdna(srna, "ID");
1801 RNA_def_struct_ui_text(srna, "ID Materials", "Collection of materials");
1802
1803 func = RNA_def_function(srna, "append", "rna_IDMaterials_append_id");
1805 RNA_def_function_ui_description(func, "Add a new material to the data-block");
1806 parm = RNA_def_pointer(func, "material", "Material", "", "Material to add");
1808
1809 func = RNA_def_function(srna, "pop", "rna_IDMaterials_pop_id");
1811 RNA_def_function_ui_description(func, "Remove a material from the data-block");
1812 parm = RNA_def_int(
1813 func, "index", -1, -MAXMAT, MAXMAT, "", "Index of material to remove", 0, MAXMAT);
1814 parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove");
1815 RNA_def_function_return(func, parm);
1816
1817 func = RNA_def_function(srna, "clear", "rna_IDMaterials_clear_id");
1819 RNA_def_function_ui_description(func, "Remove all materials from the data-block");
1820}
1821
1823{
1824 StructRNA *srna;
1825 FunctionRNA *func;
1826 PropertyRNA *prop;
1827
1828 srna = RNA_def_struct(brna, "ImagePreview", nullptr);
1829 RNA_def_struct_sdna(srna, "PreviewImage");
1830 RNA_def_struct_ui_text(srna, "Image Preview", "Preview image and icon");
1831
1832 prop = RNA_def_property(srna, "is_image_custom", PROP_BOOLEAN, PROP_NONE);
1833 RNA_def_property_boolean_sdna(prop, nullptr, "flag[ICON_SIZE_PREVIEW]", PRV_USER_EDITED);
1834 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ImagePreview_is_image_custom_set");
1836 "Custom Image",
1837 "True if this preview image has been modified by py script, "
1838 "and is no more auto-generated by Blender");
1839
1840 prop = RNA_def_int_vector(
1841 srna, "image_size", 2, nullptr, 0, 0, "Image Size", "Width and height in pixels", 0, 0);
1844 prop, "rna_ImagePreview_image_size_get", "rna_ImagePreview_image_size_set", nullptr);
1845
1846 prop = RNA_def_property(srna, "image_pixels", PROP_INT, PROP_NONE);
1848 RNA_def_property_multi_array(prop, 1, nullptr);
1849 RNA_def_property_ui_text(prop, "Image Pixels", "Image pixels, as bytes (always 32-bit RGBA)");
1850 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_get_length");
1852 prop, "rna_ImagePreview_image_pixels_get", "rna_ImagePreview_image_pixels_set", nullptr);
1853
1854 prop = RNA_def_property(srna, "image_pixels_float", PROP_FLOAT, PROP_NONE);
1856 RNA_def_property_multi_array(prop, 1, nullptr);
1858 prop, "Float Image Pixels", "Image pixels components, as floats (RGBA concatenated values)");
1859 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_float_get_length");
1861 "rna_ImagePreview_image_pixels_float_get",
1862 "rna_ImagePreview_image_pixels_float_set",
1863 nullptr);
1864
1865 prop = RNA_def_property(srna, "is_icon_custom", PROP_BOOLEAN, PROP_NONE);
1866 RNA_def_property_boolean_sdna(prop, nullptr, "flag[ICON_SIZE_ICON]", PRV_USER_EDITED);
1867 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ImagePreview_is_icon_custom_set");
1869 "Custom Icon",
1870 "True if this preview icon has been modified by py script, "
1871 "and is no more auto-generated by Blender");
1872
1873 prop = RNA_def_int_vector(
1874 srna, "icon_size", 2, nullptr, 0, 0, "Icon Size", "Width and height in pixels", 0, 0);
1877 prop, "rna_ImagePreview_icon_size_get", "rna_ImagePreview_icon_size_set", nullptr);
1878
1879 prop = RNA_def_property(srna, "icon_pixels", PROP_INT, PROP_NONE);
1881 RNA_def_property_multi_array(prop, 1, nullptr);
1882 RNA_def_property_ui_text(prop, "Icon Pixels", "Icon pixels, as bytes (always 32-bit RGBA)");
1883 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_get_length");
1885 prop, "rna_ImagePreview_icon_pixels_get", "rna_ImagePreview_icon_pixels_set", nullptr);
1886
1887 prop = RNA_def_property(srna, "icon_pixels_float", PROP_FLOAT, PROP_NONE);
1889 RNA_def_property_multi_array(prop, 1, nullptr);
1891 prop, "Float Icon Pixels", "Icon pixels components, as floats (RGBA concatenated values)");
1892 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_float_get_length");
1894 "rna_ImagePreview_icon_pixels_float_get",
1895 "rna_ImagePreview_icon_pixels_float_set",
1896 nullptr);
1897
1898 prop = RNA_def_int(srna,
1899 "icon_id",
1900 0,
1901 INT_MIN,
1902 INT_MAX,
1903 "Icon ID",
1904 "Unique integer identifying this preview as an icon (zero means invalid)",
1905 INT_MIN,
1906 INT_MAX);
1908 RNA_def_property_int_funcs(prop, "rna_ImagePreview_icon_id_get", nullptr, nullptr);
1909
1910 func = RNA_def_function(srna, "reload", "rna_ImagePreview_icon_reload");
1911 RNA_def_function_ui_description(func, "Reload the preview from its source path");
1912}
1913
1915{
1916 StructRNA *srna;
1917 PropertyRNA *prop;
1918
1919 static const EnumPropertyItem override_library_property_flag_items[] = {
1921 "MANDATORY",
1922 0,
1923 "Mandatory",
1924 "For templates, prevents the user from removing predefined operation (NOT USED)"},
1926 "LOCKED",
1927 0,
1928 "Locked",
1929 "Prevents the user from modifying that override operation (NOT USED)"},
1931 "IDPOINTER_MATCH_REFERENCE",
1932 0,
1933 "Match Reference",
1934 "The ID pointer overridden by this operation is expected to match the reference hierarchy"},
1936 "IDPOINTER_ITEM_USE_ID",
1937 0,
1938 "ID Item Use ID Pointer",
1939 "RNA collections of IDs only, the reference to the item also uses the ID pointer itself, "
1940 "not only its name"},
1941 {0, nullptr, 0, nullptr, nullptr},
1942 };
1943
1944 srna = RNA_def_struct(brna, "IDOverrideLibraryPropertyOperation", nullptr);
1946 "ID Library Override Property Operation",
1947 "Description of an override operation over an overridden property");
1948
1949 prop = RNA_def_enum(srna,
1950 "operation",
1953 "Operation",
1954 "What override operation is performed");
1955 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1956
1957 prop = RNA_def_enum_flag(
1958 srna, "flag", override_library_property_flag_items, 0, "Flags", "Status flags");
1959 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1960
1961 prop = RNA_def_string(srna,
1962 "subitem_reference_name",
1963 nullptr,
1964 INT_MAX,
1965 "Subitem Reference Name",
1966 "Used to handle changes into collection");
1967 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1969 "rna_ID_override_library_property_operation_refname_get",
1970 "rna_ID_override_library_property_operation_refname_length",
1971 nullptr);
1972
1973 prop = RNA_def_string(srna,
1974 "subitem_local_name",
1975 nullptr,
1976 INT_MAX,
1977 "Subitem Local Name",
1978 "Used to handle changes into collection");
1979 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1981 "rna_ID_override_library_property_operation_locname_get",
1982 "rna_ID_override_library_property_operation_locname_length",
1983 nullptr);
1984
1985 prop = RNA_def_pointer(srna,
1986 "subitem_reference_id",
1987 "ID",
1988 "Subitem Reference ID",
1989 "Collection of IDs only, used to disambiguate between potential IDs with "
1990 "same name from different libraries");
1991 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1992
1993 prop = RNA_def_pointer(srna,
1994 "subitem_local_id",
1995 "ID",
1996 "Subitem Local ID",
1997 "Collection of IDs only, used to disambiguate between potential IDs with "
1998 "same name from different libraries");
1999 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
2000
2001 prop = RNA_def_int(srna,
2002 "subitem_reference_index",
2003 -1,
2004 -1,
2005 INT_MAX,
2006 "Subitem Reference Index",
2007 "Used to handle changes into collection",
2008 -1,
2009 INT_MAX);
2010 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
2011
2012 prop = RNA_def_int(srna,
2013 "subitem_local_index",
2014 -1,
2015 -1,
2016 INT_MAX,
2017 "Subitem Local Index",
2018 "Used to handle changes into collection",
2019 -1,
2020 INT_MAX);
2021 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
2022
2023 prop = RNA_def_string(srna,
2024 "label",
2025 nullptr,
2026 0,
2027 "UI Label",
2028 "UI label to display in dedicated view of the Outliner, in place of the "
2029 "actual UI widget to edit the value");
2030 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
2032 "rna_ID_override_library_property_operation_label_get",
2033 "rna_ID_override_library_property_operation_label_length",
2034 nullptr);
2035
2036 prop = RNA_def_string(srna,
2037 "tooltip",
2038 nullptr,
2039 0,
2040 "UI Tooltip",
2041 "UI tooltip to display in dedicated view of the Outliner, when the label "
2042 "itself cannot provide all required information");
2043 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
2045 "rna_ID_override_library_property_operation_tooltip_get",
2046 "rna_ID_override_library_property_operation_tooltip_length",
2047 nullptr);
2048}
2049
2051{
2052 StructRNA *srna;
2053 FunctionRNA *func;
2054 PropertyRNA *parm;
2055
2056 RNA_def_property_srna(cprop, "IDOverrideLibraryPropertyOperations");
2057 srna = RNA_def_struct(brna, "IDOverrideLibraryPropertyOperations", nullptr);
2058 RNA_def_struct_sdna(srna, "IDOverrideLibraryProperty");
2059 RNA_def_struct_ui_text(srna, "Override Operations", "Collection of override operations");
2060
2061 /* Add Property */
2062 func = RNA_def_function(srna, "add", "rna_ID_override_library_property_operations_add");
2063 RNA_def_function_ui_description(func, "Add a new operation");
2065 parm = RNA_def_enum(func,
2066 "operation",
2069 "Operation",
2070 "What override operation is performed");
2072 parm = RNA_def_boolean(
2073 func,
2074 "use_id",
2075 false,
2076 "Use ID Pointer Subitem",
2077 "Whether the found or created liboverride operation should use ID pointers or not");
2078 parm = RNA_def_string(func,
2079 "subitem_reference_name",
2080 nullptr,
2081 INT_MAX,
2082 "Subitem Reference Name",
2083 "Used to handle insertions or ID replacements into collection");
2084 parm = RNA_def_string(func,
2085 "subitem_local_name",
2086 nullptr,
2087 INT_MAX,
2088 "Subitem Local Name",
2089 "Used to handle insertions or ID replacements into collection");
2090 parm = RNA_def_pointer(func,
2091 "subitem_reference_id",
2092 "ID",
2093 "Subitem Reference ID",
2094 "Used to handle ID replacements into collection");
2095 parm = RNA_def_pointer(func,
2096 "subitem_local_id",
2097 "ID",
2098 "Subitem Local ID",
2099 "Used to handle ID replacements into collection");
2100 parm = RNA_def_int(func,
2101 "subitem_reference_index",
2102 -1,
2103 -1,
2104 INT_MAX,
2105 "Subitem Reference Index",
2106 "Used to handle insertions or ID replacements into collection",
2107 -1,
2108 INT_MAX);
2109 parm = RNA_def_int(func,
2110 "subitem_local_index",
2111 -1,
2112 -1,
2113 INT_MAX,
2114 "Subitem Local Index",
2115 "Used to handle insertions or ID replacements into collection",
2116 -1,
2117 INT_MAX);
2118 parm = RNA_def_pointer(func,
2119 "property",
2120 "IDOverrideLibraryPropertyOperation",
2121 "New Operation",
2122 "Created operation");
2124 RNA_def_function_return(func, parm);
2125
2126 func = RNA_def_function(srna, "remove", "rna_ID_override_library_property_operations_remove");
2127 RNA_def_function_ui_description(func, "Remove and delete an operation");
2129 parm = RNA_def_pointer(func,
2130 "operation",
2131 "IDOverrideLibraryPropertyOperation",
2132 "Operation",
2133 "Override operation to be deleted");
2135}
2136
2138{
2139 StructRNA *srna;
2140 PropertyRNA *prop;
2141
2142 srna = RNA_def_struct(brna, "IDOverrideLibraryProperty", nullptr);
2144 srna, "ID Library Override Property", "Description of an overridden property");
2145
2146 /* String pointer, we *should* add get/set/etc.
2147 * But nullptr rna_path would be a nasty bug anyway. */
2148 prop = RNA_def_string(srna,
2149 "rna_path",
2150 nullptr,
2151 INT_MAX,
2152 "RNA Path",
2153 "RNA path leading to that property, from owning ID");
2154 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
2155
2156 prop = RNA_def_collection(srna,
2157 "operations",
2158 "IDOverrideLibraryPropertyOperation",
2159 "Operations",
2160 "List of overriding operations for a property");
2163
2165}
2166
2168{
2169 StructRNA *srna;
2170 FunctionRNA *func;
2171 PropertyRNA *parm;
2172
2173 RNA_def_property_srna(cprop, "IDOverrideLibraryProperties");
2174 srna = RNA_def_struct(brna, "IDOverrideLibraryProperties", nullptr);
2175 RNA_def_struct_sdna(srna, "IDOverrideLibrary");
2176 RNA_def_struct_ui_text(srna, "Override Properties", "Collection of override properties");
2177
2178 /* Add Property */
2179 func = RNA_def_function(srna, "add", "rna_ID_override_library_properties_add");
2181 func, "Add a property to the override library when it doesn't exist yet");
2183 parm = RNA_def_pointer(func,
2184 "property",
2185 "IDOverrideLibraryProperty",
2186 "New Property",
2187 "Newly created override property or existing one");
2189 RNA_def_function_return(func, parm);
2190 parm = RNA_def_string(
2191 func, "rna_path", nullptr, 256, "RNA Path", "RNA-Path of the property to add");
2193
2194 func = RNA_def_function(srna, "remove", "rna_ID_override_library_properties_remove");
2195 RNA_def_function_ui_description(func, "Remove and delete a property");
2197 parm = RNA_def_pointer(func,
2198 "property",
2199 "IDOverrideLibraryProperty",
2200 "Property",
2201 "Override property to be deleted");
2203}
2204
2206{
2207 StructRNA *srna;
2208 PropertyRNA *prop;
2209 FunctionRNA *func;
2210 PropertyRNA *parm;
2211
2212 srna = RNA_def_struct(brna, "IDOverrideLibrary", nullptr);
2214 srna, "ID Library Override", "Struct gathering all data needed by overridden linked IDs");
2215
2216 prop = RNA_def_pointer(
2217 srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override");
2219
2221 srna,
2222 "hierarchy_root",
2223 "ID",
2224 "Hierarchy Root ID",
2225 "Library override ID used as root of the override hierarchy this ID is a member of");
2226
2227 prop = RNA_def_boolean(srna,
2228 "is_in_hierarchy",
2229 true,
2230 "Is In Hierarchy",
2231 "Whether this library override is defined as part of a library "
2232 "hierarchy, or as a single, isolated and autonomous override");
2236
2237 prop = RNA_def_boolean(srna,
2238 "is_system_override",
2239 false,
2240 "Is System Override",
2241 "Whether this library override exists only for the override hierarchy, "
2242 "or if it is actually editable by the user");
2246
2247 prop = RNA_def_collection(srna,
2248 "properties",
2249 "IDOverrideLibraryProperty",
2250 "Properties",
2251 "List of overridden properties");
2254
2255 /* Update function. */
2256 func = RNA_def_function(srna, "operations_update", "rna_ID_override_library_operations_update");
2259 "Update the library override operations based on the "
2260 "differences between this override ID and its reference");
2261
2262 func = RNA_def_function(srna, "reset", "rna_ID_override_library_reset");
2264 "Reset this override to match again its linked reference ID");
2267 func,
2268 "do_hierarchy",
2269 true,
2270 "",
2271 "Also reset all the dependencies of this override to match their reference linked IDs");
2272 RNA_def_boolean(func,
2273 "set_system_override",
2274 false,
2275 "",
2276 "Reset all user-editable overrides as (non-editable) system overrides");
2277
2278 func = RNA_def_function(srna, "destroy", "rna_ID_override_library_destroy");
2280 func, "Delete this override ID and remap its usages to its linked reference ID instead");
2282 RNA_def_boolean(func,
2283 "do_hierarchy",
2284 true,
2285 "",
2286 "Also delete all the dependencies of this override and remap their usages to "
2287 "their reference linked IDs");
2288
2289 func = RNA_def_function(srna, "resync", "rna_ID_override_library_resync");
2291 func, "Resync the data-block and its sub-hierarchy, or the whole hierarchy if requested");
2293 parm = RNA_def_boolean(
2294 func, "success", false, "Success", "Whether the resync process was successful or not");
2295 RNA_def_function_return(func, parm);
2296 parm = RNA_def_pointer(
2297 func,
2298 "scene",
2299 "Scene",
2300 "",
2301 "The scene to operate in (for contextual things like keeping active object active, ensuring "
2302 "all overridden objects remain instantiated, etc.)");
2304 parm = RNA_def_pointer(func,
2305 "view_layer",
2306 "ViewLayer",
2307 "",
2308 "The view layer to operate in (same usage as the ``scene`` data, in case "
2309 "it is not provided the scene's collection will be used instead)");
2310 parm = RNA_def_pointer(
2311 func,
2312 "residual_storage",
2313 "Collection",
2314 "",
2315 "Collection where to store objects that are instantiated in any other collection anymore "
2316 "(garbage collection, will be created if needed and none is provided)");
2317 RNA_def_boolean(func,
2318 "do_hierarchy_enforce",
2319 false,
2320 "",
2321 "Enforce restoring the dependency hierarchy between data-blocks to match the "
2322 "one from the reference linked hierarchy (WARNING: if some ID pointers have "
2323 "been purposely overridden, these will be reset to their default value)");
2325 func,
2326 "do_whole_hierarchy",
2327 false,
2328 "",
2329 "Resync the whole hierarchy this data-block belongs to, not only its own sub-hierarchy");
2330
2332}
2333
2334static void rna_def_ID(BlenderRNA *brna)
2335{
2336 StructRNA *srna;
2337 FunctionRNA *func;
2338 PropertyRNA *prop, *parm;
2339
2340 static const EnumPropertyItem update_flag_items[] = {
2341 {ID_RECALC_TRANSFORM, "OBJECT", 0, "Object", ""},
2342 {ID_RECALC_GEOMETRY, "DATA", 0, "Data", ""},
2343 {ID_RECALC_ANIMATION, "TIME", 0, "Time", ""},
2344 {0, nullptr, 0, nullptr, nullptr},
2345 };
2346
2347 static const EnumPropertyItem rename_mode_items[] = {
2349 "NEVER",
2350 0,
2351 "Never Rename",
2352 "Never rename an existing ID whose name would conflict, the currently renamed ID will get "
2353 "a numeric suffix appended to its new name"},
2355 "ALWAYS",
2356 0,
2357 "Always Rename",
2358 "Always rename an existing ID whose name would conflict, ensuring that the currently "
2359 "renamed ID will get requested name"},
2361 "SAME_ROOT",
2362 0,
2363 "Rename If Same Root",
2364 "Only rename an existing ID whose name would conflict if its name root (everything besides "
2365 "the numerical suffix) is the same as the existing name of the currently renamed ID"},
2366 {0, nullptr, 0, nullptr, nullptr},
2367 };
2368
2369 static const EnumPropertyItem rename_result_items[] = {
2371 "UNCHANGED",
2372 0,
2373 "Unchanged",
2374 "The ID was not renamed, e.g. because it is already named as requested"},
2376 "UNCHANGED_COLLISION",
2377 0,
2378 "Unchanged Due to Collision",
2379 "The ID was not renamed, because requested name would have collided with another existing "
2380 "ID's name, and the automatically adjusted name was the same as the current ID's name"},
2382 "RENAMED_NO_COLLISION",
2383 0,
2384 "Renamed Without Collision",
2385 "The ID was renamed as requested, without creating any name collision"},
2387 "RENAMED_COLLISION_ADJUSTED",
2388 0,
2389 "Renamed With Collision",
2390 "The ID was renamed with adjustment of the requested name, to avoid a name collision"},
2392 "RENAMED_COLLISION_FORCED",
2393 0,
2394 "Renamed Enforced With Collision",
2395 "The ID was renamed as requested, also renaming another ID to avoid a name collision"},
2396 {0, nullptr, 0, nullptr, nullptr},
2397 };
2398
2399 srna = RNA_def_struct(brna, "ID", nullptr);
2401 srna,
2402 "ID",
2403 "Base type for data-blocks, defining a unique name, linking from other libraries "
2404 "and garbage collection");
2406 RNA_def_struct_refine_func(srna, "rna_ID_refine");
2407 RNA_def_struct_idprops_func(srna, "rna_ID_idprops");
2408 RNA_def_struct_system_idprops_func(srna, "rna_ID_system_idprops");
2409
2410 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2412 prop, "Name", "Unique data-block ID name (within a same type and library)");
2413 RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
2415 RNA_def_property_editable_func(prop, "rna_ID_name_editable");
2416 RNA_def_property_update(prop, NC_ID | NA_RENAME, nullptr);
2418 RNA_def_struct_name_property(srna, prop);
2419
2420 prop = RNA_def_property(srna, "name_full", PROP_STRING, PROP_NONE);
2422 prop, "Full Name", "Unique data-block ID name, including library one if any");
2423 RNA_def_property_string_funcs(prop, "rna_ID_name_full_get", "rna_ID_name_full_length", nullptr);
2426
2427 prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
2428 RNA_def_property_ui_text(prop, "Type", "Type identifier of this data-block");
2431 RNA_def_property_enum_funcs(prop, "rna_ID_type_get", nullptr, nullptr);
2434
2435 prop = RNA_def_property(srna, "session_uid", PROP_INT, PROP_NONE);
2437 prop,
2438 "Session UID",
2439 "A session-wide unique identifier for the data block that remains the "
2440 "same across renames and internal reallocations, unchanged when reloading the file");
2442
2443 prop = RNA_def_property(srna, "deep_hash", PROP_STRING, PROP_BYTESTRING);
2444 RNA_def_property_string_sdna(prop, nullptr, "deep_hash.data");
2446 prop,
2447 "Linked Packed Deep Hash",
2448 "Hash representing a unique version of a packed linked data and all of its dependencies");
2450 RNA_def_property_string_funcs(prop, "rna_ID_deephash_get", "rna_ID_deephash_len", nullptr);
2452
2453 prop = RNA_def_property(srna, "is_evaluated", PROP_BOOLEAN, PROP_NONE);
2455 prop,
2456 "Is Evaluated",
2457 "Whether this ID is runtime-only, evaluated data-block, or actual data from .blend file");
2458 RNA_def_property_boolean_funcs(prop, "rna_ID_is_evaluated_get", nullptr);
2460
2461 prop = RNA_def_property(srna, "original", PROP_POINTER, PROP_NONE);
2462 RNA_def_property_struct_type(prop, "ID");
2464 prop,
2465 "Original ID",
2466 "Actual data-block from .blend file (Main database) that generated that evaluated one");
2467 RNA_def_property_pointer_funcs(prop, "rna_ID_original_get", nullptr, nullptr, nullptr);
2471
2472 prop = RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED);
2473 RNA_def_property_int_sdna(prop, nullptr, "us");
2475 RNA_def_property_ui_text(prop, "Users", "Number of times this data-block is referenced");
2476
2477 prop = RNA_def_property(srna, "use_fake_user", PROP_BOOLEAN, PROP_NONE);
2478 RNA_def_property_boolean_sdna(prop, nullptr, "flag", ID_FLAG_FAKEUSER);
2479 RNA_def_property_ui_text(prop, "Fake User", "Save this data-block even if it has no users");
2480 RNA_def_property_ui_icon(prop, ICON_FAKE_USER_OFF, true);
2481 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ID_fake_user_set");
2482
2483 prop = RNA_def_property(srna, "use_extra_user", PROP_BOOLEAN, PROP_NONE);
2484 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_EXTRAUSER);
2486 prop,
2487 "Extra User",
2488 "Indicates whether an extra user is set or not (mainly for internal/debug usages)");
2489 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ID_extra_user_set");
2490
2491 prop = RNA_def_property(srna, "is_embedded_data", PROP_BOOLEAN, PROP_NONE);
2495 prop,
2496 "Embedded Data",
2497 "This data-block is not an independent one, but is actually a sub-data of another ID "
2498 "(typical example: root node trees or master collections)");
2499
2500 prop = RNA_def_property(srna, "is_linked_packed", PROP_BOOLEAN, PROP_NONE);
2504 prop, "Linked Packed", "This data-block is linked and packed into the .blend file");
2505
2506 prop = RNA_def_property(srna, "is_missing", PROP_BOOLEAN, PROP_NONE);
2507 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_MISSING);
2510 "Missing Data",
2511 "This data-block is a place-holder for missing linked data (i.e. it is "
2512 "[an override of] a linked data that could not be found anymore)");
2513
2514 prop = RNA_def_property(srna, "is_runtime_data", PROP_BOOLEAN, PROP_NONE);
2515 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_RUNTIME);
2516 RNA_def_property_editable_func(prop, "rna_ID_is_runtime_editable");
2517 RNA_def_property_boolean_funcs(prop, "rna_ID_is_runtime_get", nullptr);
2520 "Runtime Data",
2521 "This data-block is runtime data, i.e. it won't be saved in .blend "
2522 "file. Note that e.g. evaluated IDs are always runtime, so this value "
2523 "is only editable for data-blocks in Main data-base.");
2524
2525 prop = RNA_def_property(srna, "is_editable", PROP_BOOLEAN, PROP_NONE);
2526 RNA_def_property_boolean_funcs(prop, "rna_ID_is_editable_get", nullptr);
2529 "Editable",
2530 "This data-block is editable in the user interface. Linked data-blocks "
2531 "are not editable, except if they were loaded as editable assets.");
2532
2533 prop = RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE);
2534 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_DOIT);
2537 "Tag",
2538 "Tools can use this to tag data for their own purposes "
2539 "(initial state is undefined)");
2540
2541 prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE);
2542 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_INDIRECT);
2544 RNA_def_property_ui_text(prop, "Is Indirect", "Is this ID block linked indirectly");
2545
2546 prop = RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE);
2547 RNA_def_property_pointer_sdna(prop, nullptr, "lib");
2550 RNA_def_property_ui_text(prop, "Library", "Library file the data-block is linked from");
2551
2552 prop = RNA_def_pointer(
2553 srna,
2554 "library_weak_reference",
2555 "LibraryWeakReference",
2556 "Library Weak Reference",
2557 "Weak reference to the data-block in a library .blend file this "
2558 "originated from. For re-use of already appended data and linked editable assets");
2561
2562 prop = RNA_def_property(srna, "asset_data", PROP_POINTER, PROP_NONE);
2564 RNA_def_property_pointer_funcs(prop, nullptr, "rna_ID_asset_data_set", nullptr, nullptr);
2566 RNA_def_property_ui_text(prop, "Asset Data", "Additional data for an asset data-block");
2567
2568 prop = RNA_def_pointer(
2569 srna, "override_library", "IDOverrideLibrary", "Library Override", "Library override data");
2573
2574 prop = RNA_def_pointer(srna,
2575 "preview",
2576 "ImagePreview",
2577 "Preview",
2578 "Preview image and icon of this data-block (always None if not supported "
2579 "for this type of data)");
2582 RNA_def_property_pointer_funcs(prop, "rna_IDPreview_get", nullptr, nullptr, nullptr);
2583
2584 /* functions */
2585 func = RNA_def_function(srna, "rename", "rna_ID_rename");
2587 func, "More refined handling in case the new name collides with another ID's name");
2589 parm = RNA_def_string(func,
2590 "name",
2591 nullptr,
2592 MAX_NAME,
2593 "",
2594 "New name to rename the ID to, if empty will re-use the current ID name");
2596 parm = RNA_def_enum(func,
2597 "mode",
2598 rename_mode_items,
2600 "",
2601 "How to handle name collision, in case the requested new name is already "
2602 "used by another ID of the same type");
2603 parm = RNA_def_enum(func,
2604 "id_rename_result",
2605 rename_result_items,
2607 "",
2608 "How did the renaming of the data-block went on");
2609 RNA_def_function_return(func, parm);
2610
2611 func = RNA_def_function(srna, "evaluated_get", "rna_ID_evaluated_get");
2613 func,
2614 "Get corresponding evaluated ID from the given dependency graph. Note that this does not "
2615 "ensure the dependency graph is fully evaluated, it just returns the result of the last "
2616 "evaluation.");
2617 parm = RNA_def_pointer(
2618 func, "depsgraph", "Depsgraph", "", "Dependency graph to perform lookup in");
2620 parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
2622 RNA_def_function_return(func, parm);
2623
2624 func = RNA_def_function(srna, "copy", "rna_ID_copy");
2626 func,
2627 "Create a copy of this data-block (not supported for all data-blocks). "
2628 "The result is added to the Blend-File Data (Main database), with all references to other "
2629 "data-blocks ensured to be from within the same Blend-File Data.");
2631 parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
2632 RNA_def_function_return(func, parm);
2633
2634 func = RNA_def_function(srna, "asset_mark", "rna_ID_asset_mark");
2636 func,
2637 "Enable easier reuse of the data-block through the Asset Browser, with the help of "
2638 "customizable metadata (like previews, descriptions and tags)");
2639
2640 func = RNA_def_function(srna, "asset_clear", "rna_ID_asset_clear");
2642 func,
2643 "Delete all asset metadata and turn the asset data-block back into a normal data-block");
2644
2645 func = RNA_def_function(srna, "asset_generate_preview", "rna_ID_asset_generate_preview");
2647 func, "Generate preview image (might be scheduled in a background thread)");
2649
2650 func = RNA_def_function(srna, "override_create", "rna_ID_override_create");
2652 "Create an overridden local copy of this linked data-block (not "
2653 "supported for all data-blocks)");
2655 parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the ID");
2656 RNA_def_function_return(func, parm);
2657 RNA_def_boolean(func,
2658 "remap_local_usages",
2659 false,
2660 "",
2661 "Whether local usages of the linked ID should be remapped to the new "
2662 "library override of it");
2663
2664 func = RNA_def_function(srna, "override_hierarchy_create", "rna_ID_override_hierarchy_create");
2666 func,
2667 "Create an overridden local copy of this linked data-block, and most of its dependencies "
2668 "when it is a Collection or and Object");
2670 parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the root ID");
2671 RNA_def_function_return(func, parm);
2672 parm = RNA_def_pointer(
2673 func, "scene", "Scene", "", "In which scene the new overrides should be instantiated");
2675 parm = RNA_def_pointer(func,
2676 "view_layer",
2677 "ViewLayer",
2678 "",
2679 "In which view layer the new overrides should be instantiated");
2681 RNA_def_pointer(func,
2682 "reference",
2683 "ID",
2684 "",
2685 "Another ID (usually an Object or Collection) used as a hint to decide where to "
2686 "instantiate the new overrides");
2687 RNA_def_boolean(func,
2688 "do_fully_editable",
2689 false,
2690 "",
2691 "Make all library overrides generated by this call fully editable by the user "
2692 "(none will be 'system overrides')");
2693
2694 func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
2696 "Clear the user count of a data-block so its not saved, "
2697 "on reload the data will be removed");
2698
2699 func = RNA_def_function(srna, "user_remap", "rna_ID_user_remap");
2701 func, "Replace all usage in the .blend file of this ID by new given one");
2703 parm = RNA_def_pointer(func, "new_id", "ID", "", "New ID to use");
2705
2706 func = RNA_def_function(srna, "make_local", "rna_ID_make_local");
2708 func,
2709 "Make this data-block local, return local one "
2710 "(may be a copy of the original, in case it is also indirectly used)");
2712 parm = RNA_def_boolean(func, "clear_proxy", true, "", "Deprecated, has no effect");
2713 parm = RNA_def_boolean(func,
2714 "clear_liboverride",
2715 false,
2716 "",
2717 "Remove potential library override data from the newly made local data");
2719 func,
2720 "clear_asset_data",
2721 true,
2722 "",
2723 "Remove potential asset metadata so the newly local data-block is not treated as asset "
2724 "data-block and won't show up in asset libraries");
2725 parm = RNA_def_pointer(func, "id", "ID", "", "This ID, or the new ID if it was copied");
2727 RNA_def_function_return(func, parm);
2728
2729 func = RNA_def_function(srna, "user_of_id", "BKE_library_ID_use_ID");
2731 "Count the number of times that ID uses/references given one");
2732 parm = RNA_def_pointer(func, "id", "ID", "", "ID to count usages");
2734 parm = RNA_def_int(func,
2735 "count",
2736 0,
2737 0,
2738 INT_MAX,
2739 "",
2740 "Number of usages/references of given id by current data-block",
2741 0,
2742 INT_MAX);
2743 RNA_def_function_return(func, parm);
2744
2745 func = RNA_def_function(srna, "animation_data_create", "rna_ID_animation_data_create");
2748 func, "Create animation data to this ID, note that not all ID types support this");
2749 parm = RNA_def_pointer(func, "anim_data", "AnimData", "", "New animation data or None");
2750 RNA_def_function_return(func, parm);
2751
2752 func = RNA_def_function(srna, "animation_data_clear", "rna_ID_animation_data_free");
2754 RNA_def_function_ui_description(func, "Clear animation on this ID");
2755
2756 func = RNA_def_function(srna, "update_tag", "rna_ID_update_tag");
2759 "Tag the ID to update its display data, "
2760 "e.g. when calling :class:`bpy.types.ViewLayer.update`");
2761 RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform");
2762
2763 func = RNA_def_function(srna, "preview_ensure", "BKE_previewimg_id_ensure");
2765 "Ensure that this ID has preview data (if ID type supports it)");
2766 parm = RNA_def_pointer(
2767 func, "preview_image", "ImagePreview", "", "The existing or created preview");
2768 RNA_def_function_return(func, parm);
2769
2770# ifdef WITH_PYTHON
2771 RNA_def_struct_register_funcs(srna, nullptr, nullptr, "rna_ID_instance");
2772# endif
2773}
2774
2775static void rna_def_library(BlenderRNA *brna)
2776{
2777 StructRNA *srna;
2778 FunctionRNA *func;
2779 PropertyRNA *prop;
2780
2781 srna = RNA_def_struct(brna, "Library", "ID");
2782 RNA_def_struct_ui_text(srna, "Library", "External .blend file from which data is linked");
2783 RNA_def_struct_ui_icon(srna, ICON_LIBRARY_DATA_DIRECT);
2784
2785 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
2786 RNA_def_property_string_sdna(prop, nullptr, "filepath");
2789 "File Path",
2790 "Path to the library .blend file. WARNING: Typically, this value "
2791 "should be considered read-only, changing this path without proper "
2792 "processing afterwards can leave Blender data in an invalid state");
2793 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Library_filepath_set");
2794
2795 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2796 RNA_def_property_pointer_funcs(prop, "rna_Library_parent_get", nullptr, nullptr, nullptr);
2797 RNA_def_property_struct_type(prop, "Library");
2799 RNA_def_property_ui_text(prop, "Parent", "");
2800
2801 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
2802 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
2803 RNA_def_property_ui_text(prop, "Packed File", "");
2804
2805 prop = RNA_def_int_vector(srna,
2806 "version",
2807 3,
2808 nullptr,
2809 0,
2810 INT_MAX,
2811 "Version",
2812 "Version of Blender the library .blend was saved with",
2813 0,
2814 INT_MAX);
2815 RNA_def_property_int_funcs(prop, "rna_Library_version_get", nullptr, nullptr);
2818
2819 prop = RNA_def_property(srna, "needs_liboverride_resync", PROP_BOOLEAN, PROP_NONE);
2820 RNA_def_property_boolean_sdna(prop, nullptr, "runtime->tag", LIBRARY_TAG_RESYNC_REQUIRED);
2822 "Library Overrides Need resync",
2823 "True if this library contains library overrides that are linked in "
2824 "current blend-file, and that had to be recursively resynced on load "
2825 "(it is recommended to open and re-save that library blend-file then)");
2826
2827 prop = RNA_def_property(srna, "is_editable", PROP_BOOLEAN, PROP_NONE);
2828 RNA_def_property_boolean_sdna(prop, nullptr, "runtime->tag", LIBRARY_ASSET_EDITABLE);
2831 "Editable",
2832 "Data-blocks in this library are editable despite being linked. "
2833 "Used by brush assets and their dependencies.");
2834
2835 prop = RNA_def_property(srna, "is_archive", PROP_BOOLEAN, PROP_NONE);
2839 "Is Archive",
2840 "This library is an 'archive' storage for packed linked IDs "
2841 "originally linked from its 'archive parent' library.");
2842
2843 prop = RNA_def_property(srna, "archive_parent_library", PROP_POINTER, PROP_NONE);
2844 RNA_def_property_pointer_sdna(prop, nullptr, "archive_parent_library");
2845 RNA_def_property_struct_type(prop, "Library");
2848 "Parent Archive Library",
2849 "Source library from which this archive of packed IDs was generated");
2850
2851 prop = RNA_def_property(srna, "archive_libraries", PROP_COLLECTION, PROP_NONE);
2852 RNA_def_property_struct_type(prop, "Library");
2854 "rna_Library_archive_libraries_begin",
2855 "rna_Library_archive_libraries_next",
2856 nullptr,
2857 "rna_Library_archive_libraries_get",
2858 "rna_Library_archive_libraries_length",
2859 "rna_Library_archive_libraries_lookupint",
2860 nullptr,
2861 nullptr);
2864 prop,
2865 "Archive Libraries",
2866 "Archive libraries of packed IDs, generated (and owned) by this source library");
2867
2868 func = RNA_def_function(srna, "reload", "rna_Library_reload");
2870 RNA_def_function_ui_description(func, "Reload this library and all its linked data-blocks");
2871}
2872
2874{
2875 StructRNA *srna;
2876 PropertyRNA *prop;
2877
2878 srna = RNA_def_struct(brna, "LibraryWeakReference", nullptr);
2880 srna,
2881 "LibraryWeakReference",
2882 "Read-only external reference to a linked data-block and its library file");
2883
2884 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
2885 RNA_def_property_string_sdna(prop, nullptr, "library_filepath");
2887 RNA_def_property_ui_text(prop, "File Path", "Path to the library .blend file");
2888
2889 prop = RNA_def_property(srna, "id_name", PROP_STRING, PROP_FILEPATH);
2890 RNA_def_property_string_sdna(prop, nullptr, "library_id_name");
2892 prop,
2893 "ID name",
2894 "Full ID name in the library .blend file (including the two leading 'id type' chars)");
2895}
2896
2902{
2903 StructRNA *srna;
2904
2905 srna = RNA_def_struct(brna, "IDPropertyWrapPtr", nullptr);
2906 /* For property groups, both 'user-defined' and system-defined properties are the same.
2907 * The user-defined access is kept to allow 'dict-type' subscripting in python. */
2908 RNA_def_struct_idprops_func(srna, "rna_IDPropertyWrapPtr_idprops");
2909 RNA_def_struct_system_idprops_func(srna, "rna_IDPropertyWrapPtr_idprops");
2911}
2912
2914{
2915 StructRNA *srna;
2916
2917 /* built-in unknown type */
2918 srna = RNA_def_struct(brna, "UnknownType", nullptr);
2920 srna, "Unknown Type", "Stub RNA type used for pointers to unknown or internal data");
2921
2922 /* built-in any type */
2923 srna = RNA_def_struct(brna, "AnyType", nullptr);
2924 RNA_def_struct_ui_text(srna, "Any Type", "RNA type used for pointers to any possible data");
2925
2926 rna_def_ID(brna);
2931 rna_def_library(brna);
2934}
2935
2936} // namespace blender
2937
2938#endif
#define G_MAIN
#define IDP_property_array_get(prop)
#define MAX_ID_FULL_NAME
General operations, lookup, etc. for materials.
external readfile function prototypes.
#define BLT_I18NCONTEXT_ID_ID
#define BPy_BEGIN_ALLOW_THREADS
Definition BPY_extern.hh:52
#define BPy_END_ALLOW_THREADS
Definition BPY_extern.hh:56
ID and Library types, which are fundamental for SDNA.
#define FILTER_ID_GD_LEGACY
Definition DNA_ID.h:1204
#define ID_IS_PACKED(_id)
Definition DNA_ID.h:703
#define FILTER_ID_OB
Definition DNA_ID.h:1216
#define FILTER_ID_MC
Definition DNA_ID.h:1212
#define FILTER_ID_SPK
Definition DNA_ID.h:1220
#define FILTER_ID_CF
Definition DNA_ID.h:1227
#define FILTER_ID_AC
Definition DNA_ID.h:1199
#define FILTER_ID_MA
Definition DNA_ID.h:1210
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition DNA_ID.h:729
#define FILTER_ID_CA
Definition DNA_ID.h:1202
#define FILTER_ID_SO
Definition DNA_ID.h:1221
#define FILTER_ID_PT
Definition DNA_ID.h:1231
#define ID_IS_OVERRIDABLE_LIBRARY(_id)
Definition DNA_ID.h:721
#define FILTER_ID_CU_LEGACY
Definition DNA_ID.h:1203
#define FILTER_ID_BR
Definition DNA_ID.h:1201
#define FILTER_ID_WS
Definition DNA_ID.h:1228
#define FILTER_ID_MB
Definition DNA_ID.h:1211
#define FILTER_ID_VF
Definition DNA_ID.h:1224
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define MAX_ID_NAME
Definition DNA_ID.h:367
#define FILTER_ID_LA
Definition DNA_ID.h:1207
#define FILTER_ID_GR
Definition DNA_ID.h:1205
#define FILTER_ID_TE
Definition DNA_ID.h:1222
#define FILTER_ID_LT
Definition DNA_ID.h:1209
#define FILTER_ID_LS
Definition DNA_ID.h:1208
#define FILTER_ID_PA
Definition DNA_ID.h:1226
#define FILTER_ID_CV
Definition DNA_ID.h:1230
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define FILTER_ID_ME
Definition DNA_ID.h:1213
#define FILTER_ID_AR
Definition DNA_ID.h:1200
#define MAX_IDPROP_NAME
Definition DNA_ID.h:174
#define FILTER_ID_MSK
Definition DNA_ID.h:1214
#define FILTER_ID_PC
Definition DNA_ID.h:1218
#define FILTER_ID_GP
Definition DNA_ID.h:1238
#define FILTER_ID_PAL
Definition DNA_ID.h:1217
#define FILTER_ID_IM
Definition DNA_ID.h:1206
#define FILTER_ID_SCE
Definition DNA_ID.h:1219
#define FILTER_ID_LP
Definition DNA_ID.h:1229
#define FILTER_ID_VO
Definition DNA_ID.h:1232
#define FILTER_ID_WO
Definition DNA_ID.h:1225
#define FILTER_ID_NT
Definition DNA_ID.h:1215
#define FILTER_ID_TXT
Definition DNA_ID.h:1223
#define MAX_NAME
Definition DNA_defs.h:63
#define MAXMAT
#define RNA_MAX_ARRAY_DIMENSION
Definition RNA_define.hh:29
#define C
Definition RandGen.cpp:29
#define NC_WINDOW
Definition WM_types.hh:388
#define NC_ID
Definition WM_types.hh:408
#define ND_DRAW
Definition WM_types.hh:502
#define NC_WM
Definition WM_types.hh:387
#define ND_LIB_OVERRIDE_CHANGED
Definition WM_types.hh:435
#define NA_ADDED
Definition WM_types.hh:636
#define NA_EDITED
Definition WM_types.hh:634
#define NC_ASSET
Definition WM_types.hh:417
#define NA_REMOVED
Definition WM_types.hh:637
#define NA_RENAME
Definition WM_types.hh:638
#define ND_OB_SHADING
Definition WM_types.hh:476
#define NC_OBJECT
Definition WM_types.hh:392
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
Definition btVector3.h:257
#define INT_MAX
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
int size(const AssetLibraryReference *library_reference)
bool copy_to_id(const AssetMetaData *asset_data, ID *destination)
void generate_preview(const bContext *C, ID *id)
void refresh_for_srna_unregister(Main *bmain, StructRNA *srna_to_unreg)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
static void rna_def_ID(BlenderRNA *brna)
Definition rna_ID.cc:2334
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void rna_ID_name_set(PointerRNA *ptr, const char *value)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
void rna_ID_name_get(PointerRNA *ptr, char *value)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
@ LIBRARY_TAG_RESYNC_REQUIRED
@ LIBRARY_ASSET_EDITABLE
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
const EnumPropertyItem rna_enum_id_type_items[]
Definition rna_ID.cc:33
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void BKE_previewimg_clear(PreviewImage *prv)
@ ICON_SIZE_ICON
@ ICON_SIZE_PREVIEW
@ RPT_ERROR_INVALID_INPUT
Definition BKE_report.hh:42
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void BKE_id_delete(Main *bmain, void *idv, const BKEIDDeleteOptions &options={}) ATTR_NONNULL()
@ STRUCT_ID_REFCOUNT
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
bool BKE_lib_override_library_create(Main *bmain, Scene *scene, ViewLayer *view_layer, Library *owner_library, ID *id_root_reference, ID *id_hierarchy_root_reference, ID *id_instance_hint, ID **r_id_root_override, const bool do_fully_editable)
unsigned int uint
Definition BKE_text.h:55
void BKE_previewimg_clear_single(PreviewImage *prv, enum eIconSizes size)
bool BKE_vfont_is_builtin(const VFont *vfont)
Definition vfont.cc:278
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
PointerRNA RNA_id_pointer_create(ID *id)
static void rna_def_ID_override_library_property_operations(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_ID.cc:2050
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
StructRNA * ID_code_to_RNA_type(short idcode)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_struct_system_idprops_func(StructRNA *srna, const char *system_idproperties)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, int remap_flags) ATTR_NONNULL(1
Definition lib_remap.cc:701
short * BKE_id_material_len_p(ID *id)
ID * BKE_id_copy_for_use_in_bmain(Main *bmain, const ID *id)
Definition lib_id.cc:925
@ FUNC_USE_REPORTS
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:980
@ FUNC_USE_MAIN
@ FUNC_USE_CONTEXT
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
static void rna_def_ID_materials(BlenderRNA *brna)
Definition rna_ID.cc:1792
short RNA_type_to_ID_code(const StructRNA *type)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void rna_pointer_create_with_ancestors(const PointerRNA &parent, StructRNA *type, void *data, PointerRNA &r_ptr)
const IDFilterEnumPropertyItem rna_enum_id_type_filter_items[]
Definition rna_ID.cc:126
ID * BKE_lib_override_library_create_from_id(Main *bmain, ID *reference_id, bool do_tagged_remap)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
@ ID_REMAP_SKIP_NEVER_NULL_USAGE
@ ID_REMAP_SKIP_INDIRECT_USAGE
bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_layer, ID *id_root, Collection *override_resync_residual_storage, bool do_hierarchy_enforce, BlendFileReadReport *reports)
static const EnumPropertyItem rna_enum_override_library_property_operation_items[]
Definition rna_ID.cc:76
static void rna_def_ID_override_library_properties(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_ID.cc:2167
bool id_can_have_animdata(const ID *id)
Definition anim_data.cc:78
void id_fake_user_set(ID *id)
Definition lib_id.cc:471
eID_OverrideLib_Op
Definition DNA_ID.h:182
@ LIBOVERRIDE_OP_ADD
Definition DNA_ID.h:192
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:200
@ LIBOVERRIDE_OP_SUBTRACT
Definition DNA_ID.h:194
@ LIBOVERRIDE_OP_MULTIPLY
Definition DNA_ID.h:196
@ LIBOVERRIDE_OP_NOOP
Definition DNA_ID.h:185
@ LIBOVERRIDE_OP_CUSTOM
Definition DNA_ID.h:212
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:188
@ LIBOVERRIDE_OP_INSERT_BEFORE
Definition DNA_ID.h:202
void id_us_clear_real(ID *id)
Definition lib_id.cc:406
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
@ LIBOVERRIDE_FLAG_NO_HIERARCHY
Definition DNA_ID.h:303
@ LIBOVERRIDE_FLAG_SYSTEM_DEFINED
Definition DNA_ID.h:308
StructRNA RNA_PropertyGroup
AnimData * BKE_animdata_ensure_id(ID *id)
Definition anim_data.cc:107
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:588
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:609
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:596
void rna_ID_fake_user_set(PointerRNA *ptr, bool value)
IDProperty ** rna_PropertyGroup_idprops(PointerRNA *ptr)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
static void rna_def_image_preview(BlenderRNA *brna)
Definition rna_ID.cc:1822
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
static void rna_def_library(BlenderRNA *brna)
Definition rna_ID.cc:2775
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
StructRNA * rna_ID_refine(PointerRNA *ptr)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
void BKE_id_material_assign(Main *bmain, ID *id, Material *ma, short act)
unsigned char uchar
Definition BKE_text.h:58
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
@ PROP_COLLECTION
Definition RNA_types.hh:216
void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void DEG_id_tag_update(ID *id, unsigned int flags)
bool rna_PropertyGroup_unregister(Main *bmain, StructRNA *type)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void BKE_animdata_free(ID *id, bool do_id_user)
Definition anim_data.cc:174
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void BKE_id_material_append(Main *bmain, ID *id, Material *ma)
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
bool BKE_vfont_to_curve(Object *ob, eEditFontMode mode)
StructRNA * rna_PropertyGroup_refine(PointerRNA *ptr)
PreviewImage * BKE_previewimg_id_ensure(ID *id)
void BKE_lib_override_library_make_local(Main *bmain, ID *id)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Material * BKE_id_material_pop(Main *bmain, ID *id, int index)
void BKE_id_newptr_and_tag_clear(ID *id)
Definition lib_id.cc:487
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
Definition icons.cc:347
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void BKE_lib_override_library_property_operation_delete(IDOverrideLibraryProperty *liboverride_property, IDOverrideLibraryPropertyOperation *liboverride_property_operation)
static void rna_def_library_weak_reference(BlenderRNA *brna)
Definition rna_ID.cc:2873
void BKE_lib_override_library_id_reset(Main *bmain, ID *id_root, bool do_reset_system_override)
const EnumPropertyItem rna_enum_dummy_DEFAULT_items[]
Definition rna_rna.cc:34
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
@ LIBRARY_FLAG_IS_ARCHIVE
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
void(*)(void *data) StructFreeFunc
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
void BKE_main_id_tag_all(Main *mainvar, int tag, bool value)
Definition lib_id.cc:1314
static void rna_def_ID_override_library(BlenderRNA *brna)
Definition rna_ID.cc:2205
void BKE_id_material_clear(Main *bmain, ID *id)
StructRNA * rna_PropertyGroup_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
PreviewImage * BKE_previewimg_id_get(const ID *id)
PropertyRNA * RNA_def_collection(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
const char * RNA_struct_identifier(const StructRNA *type)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
Definition library.cc:249
void id_us_ensure_real(ID *id)
Definition lib_id.cc:388
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
const StructRNA * RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type)
void RNA_def_struct_flag(StructRNA *srna, StructFlag flag)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
T * DEG_get_original(T *id)
void ** rna_ID_instance(PointerRNA *ptr)
static void rna_def_ID_override_library_property(BlenderRNA *brna)
Definition rna_ID.cc:2137
IDOverrideLibraryProperty * BKE_lib_override_library_property_get(IDOverrideLibrary *liboverride, const char *rna_path, bool *r_created)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ ID_RECALC_ALL
Definition DNA_ID.h:1190
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_DYNAMIC
Definition RNA_types.hh:498
@ PROP_THICK_WRAP
Definition RNA_types.hh:493
@ PROP_IDPROPERTY
Definition RNA_types.hh:496
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:465
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:526
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
@ PROP_HIDDEN
Definition RNA_types.hh:408
@ PROP_LIB_EXCEPTION
Definition RNA_types.hh:382
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@ ID_TAG_NO_MAIN
Definition DNA_ID.h:981
@ ID_TAG_MISSING
Definition DNA_ID.h:870
@ ID_TAG_INDIRECT
Definition DNA_ID.h:851
@ ID_TAG_TEMP_MAIN
Definition DNA_ID.h:974
@ ID_TAG_RUNTIME
Definition DNA_ID.h:862
@ ID_TAG_COPIED_ON_EVAL
Definition DNA_ID.h:1000
@ ID_TAG_LOCALIZED
Definition DNA_ID.h:990
@ ID_TAG_EXTRAUSER
Definition DNA_ID.h:881
@ ID_TAG_DOIT
Definition DNA_ID.h:1029
void BPY_free_srna_pytype(StructRNA *srna)
Definition bpy_rna.cc:10480
int rna_ID_name_length(PointerRNA *ptr)
void RNA_def_ID(BlenderRNA *brna)
Definition rna_ID.cc:2913
IDProperty ** rna_ID_idprops(PointerRNA *ptr)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id, char separator_char)
Definition lib_id.cc:2691
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
void BKE_previewimg_ensure(PreviewImage *prv, int size)
void DEG_relations_tag_update(Main *bmain)
IDNewNameResult BKE_id_rename(Main &bmain, ID &id, StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
Definition lib_id.cc:2654
@ ID_FLAG_FAKEUSER
Definition DNA_ID.h:770
@ ID_FLAG_EMBEDDED_DATA
Definition DNA_ID.h:775
@ ID_FLAG_LINKED_AND_PACKED
Definition DNA_ID.h:806
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
@ LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR
@ PRV_USER_EDITED
Definition DNA_ID.h:620
@ PRV_CHANGED
Definition DNA_ID.h:618
static void rna_def_ID_override_library_property_operation(BlenderRNA *brna)
Definition rna_ID.cc:1914
static void rna_def_ID_properties(BlenderRNA *brna)
Definition rna_ID.cc:1673
void BKE_lib_override_library_operations_create(Main *bmain, ID *local, int *r_report_flags)
bool BKE_lib_id_make_local(Main *bmain, ID *id, int flags)
Definition lib_id.cc:672
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_BYTESTRING
Definition RNA_types.hh:295
@ PROP_FILEPATH
Definition RNA_types.hh:284
@ PROP_UNSIGNED
Definition RNA_types.hh:306
@ PARM_REQUIRED
Definition RNA_types.hh:631
void BKE_lib_override_library_property_delete(IDOverrideLibrary *liboverride, IDOverrideLibraryProperty *liboverride_property)
static void rna_def_idproperty_wrap_ptr(BlenderRNA *brna)
Definition rna_ID.cc:2901
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
bool BKE_id_is_in_global_main(ID *id)
Definition lib_id.cc:2759
void id_us_min(ID *id)
Definition lib_id.cc:441
void BKE_lib_override_library_id_hierarchy_reset(Main *bmain, ID *id_root, bool do_reset_system_override)
void id_fake_user_clear(ID *id)
Definition lib_id.cc:479
void RNA_def_property_array(PropertyRNA *prop, int length)
IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(IDOverrideLibraryProperty *liboverride_property, eID_OverrideLib_Op operation, const char *subitem_refname, const char *subitem_locname, const std::optional< ID * > &subitem_refid, const std::optional< ID * > &subitem_locid, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict, bool *r_created)
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_ITEM_USE_ID
Definition DNA_ID.h:232
@ LIBOVERRIDE_OP_FLAG_MANDATORY
Definition DNA_ID.h:218
@ LIBOVERRIDE_OP_FLAG_LOCKED
Definition DNA_ID.h:220
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE
Definition DNA_ID.h:226
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, void *data, size_t itemsize, int64_t length, bool free_ptr, IteratorSkipFunc skip)
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
IDProperty ** rna_ID_system_idprops(PointerRNA *ptr)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
BlenderRNA RNA_blender_rna_get()
bool rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assign_ptr)
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
struct ID * newid
Definition DNA_ID.h:419
IDProperty * system_properties
Definition DNA_ID.h:490
IDProperty * properties
Definition DNA_ID.h:481
void * py_instance
Definition DNA_ID.h:519
IDHash deep_hash
Definition DNA_ID.h:475
bke::library::LibraryRuntime * runtime
Definition DNA_ID.h:591
#define N_(msgid)