diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 185 |
1 files changed, 164 insertions, 21 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index d3331e6ca52..11e45bc688d 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -58,7 +58,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_CU, "CURVE", ICON_CURVE_DATA, "Curve", ""}, {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""}, {ID_GD, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""}, - {ID_GR, "GROUP", ICON_GROUP, "Group", ""}, + {ID_GR, "COLLECTION", ICON_GROUP, "Collection", ""}, {ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""}, {ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""}, {ID_LA, "LAMP", ICON_LAMP_DATA, "Lamp", ""}, @@ -75,14 +75,15 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""}, {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""}, {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""}, + {ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_CUBEMAP, "Light Probe", ""}, {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""}, - {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""}, - {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, + {ID_SO, "SOUND", ICON_SOUND, "Sound", ""}, {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, {ID_TXT, "TEXT", ICON_TEXT, "Text", ""}, {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, {ID_WM, "WINDOWMANAGER", ICON_FULLSCREEN, "Window Manager", ""}, {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, + {ID_WS, "WORKSPACE", ICON_SPLITSCREEN, "Workspace", ""}, {0, NULL, 0, NULL, NULL} }; @@ -96,14 +97,42 @@ const EnumPropertyItem rna_enum_id_type_items[] = { #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_library_query.h" +#include "BKE_library_override.h" #include "BKE_library_remap.h" #include "BKE_animsys.h" #include "BKE_material.h" -#include "BKE_depsgraph.h" #include "BKE_global.h" /* XXX, remove me */ +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "WM_api.h" +void rna_ID_override_static_property_operation_refname_get(PointerRNA *ptr, char *value) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + strcpy(value, (opop->subitem_reference_name == NULL) ? "" : opop->subitem_reference_name); +} + +int rna_ID_override_static_property_operation_refname_length(PointerRNA *ptr) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + return (opop->subitem_reference_name == NULL) ? 0 : strlen(opop->subitem_reference_name); +} + +void rna_ID_override_static_property_operation_locname_get(PointerRNA *ptr, char *value) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + strcpy(value, (opop->subitem_local_name == NULL) ? "" : opop->subitem_local_name); +} + +int rna_ID_override_static_property_operation_locname_length(PointerRNA *ptr) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + return (opop->subitem_local_name == NULL) ? 0 : strlen(opop->subitem_local_name); +} + + /* name functions that ignore the first two ID characters */ void rna_ID_name_get(PointerRNA *ptr, char *value) { @@ -150,7 +179,7 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_Camera) return ID_CA; if (base_type == &RNA_Curve) return ID_CU; if (base_type == &RNA_GreasePencil) return ID_GD; - if (base_type == &RNA_Group) return ID_GR; + if (base_type == &RNA_Collection) return ID_GR; if (base_type == &RNA_Image) return ID_IM; if (base_type == &RNA_Key) return ID_KE; if (base_type == &RNA_Lamp) return ID_LA; @@ -167,6 +196,7 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_ParticleSettings) return ID_PA; if (base_type == &RNA_Palette) return ID_PAL; if (base_type == &RNA_PaintCurve) return ID_PC; + if (base_type == &RNA_LightProbe) return ID_LP; if (base_type == &RNA_Scene) return ID_SCE; if (base_type == &RNA_Screen) return ID_SCR; if (base_type == &RNA_Sound) return ID_SO; @@ -174,6 +204,7 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_Texture) return ID_TE; if (base_type == &RNA_Text) return ID_TXT; if (base_type == &RNA_VectorFont) return ID_VF; + if (base_type == &RNA_WorkSpace) return ID_WS; if (base_type == &RNA_World) return ID_WO; if (base_type == &RNA_WindowManager) return ID_WM; @@ -192,7 +223,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_CF: return &RNA_CacheFile; case ID_CU: return &RNA_Curve; case ID_GD: return &RNA_GreasePencil; - case ID_GR: return &RNA_Group; + case ID_GR: return &RNA_Collection; case ID_IM: return &RNA_Image; case ID_KE: return &RNA_Key; case ID_LA: return &RNA_Lamp; @@ -209,6 +240,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_PA: return &RNA_ParticleSettings; case ID_PAL: return &RNA_Palette; case ID_PC: return &RNA_PaintCurve; + case ID_LP: return &RNA_LightProbe; case ID_SCE: return &RNA_Scene; case ID_SCR: return &RNA_Screen; case ID_SO: return &RNA_Sound; @@ -218,6 +250,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_VF: return &RNA_VectorFont; case ID_WM: return &RNA_WindowManager; case ID_WO: return &RNA_World; + case ID_WS: return &RNA_WorkSpace; /* deprecated */ case ID_IP: break; @@ -304,6 +337,15 @@ static ID *rna_ID_copy(ID *id, Main *bmain) return NULL; } +static ID *rna_ID_override_create(ID *id, Main *bmain) +{ + if (id->lib == NULL) { + return NULL; + } + + return BKE_override_static_create_from_id(bmain, id); +} + static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) { /* XXX, new function for this! */ @@ -342,7 +384,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) } } - DAG_id_tag_update(id, flag); + DEG_id_tag_update(id, flag); } static void rna_ID_user_clear(ID *id) @@ -378,14 +420,14 @@ static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, int clear_prox static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain) { AnimData *adt = BKE_animdata_add_id(id); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); return adt; } static void rna_ID_animation_data_free(ID *id, Main *bmain) { BKE_animdata_free(id, true); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } #ifdef WITH_PYTHON @@ -451,7 +493,7 @@ static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports return NULL; } - DAG_id_tag_update(id, OB_RECALC_DATA); + DEG_id_tag_update(id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_DRAW, id); WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id); @@ -462,7 +504,7 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, int remove_material_sl { BKE_material_clear_id(bmain, id, remove_material_slot); - DAG_id_tag_update(id, OB_RECALC_DATA); + DEG_id_tag_update(id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_DRAW, id); WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id); } @@ -960,6 +1002,107 @@ static void rna_def_image_preview(BlenderRNA *brna) RNA_def_function_ui_description(func, "Reload the preview from its source path"); } +static void rna_def_ID_override_static_property_operation(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static const EnumPropertyItem static_override_property_operation_items[] = { + {IDOVERRIDESTATIC_OP_NOOP, "NOOP", 0, "No-Op", "Does nothing, prevents adding actual overrides (NOT USED)"}, + {IDOVERRIDESTATIC_OP_REPLACE, "REPLACE", 0, "Replace", "Replace value of reference by overriding one"}, + {IDOVERRIDESTATIC_OP_ADD, "DIFF_ADD", 0, "Differential", + "Stores and apply difference between reference and local value (NOT USED)"}, + {IDOVERRIDESTATIC_OP_SUBTRACT, "DIFF_SUB", 0, "Differential", + "Stores and apply difference between reference and local value (NOT USED)"}, + {IDOVERRIDESTATIC_OP_MULTIPLY, "FACT_MULTIPLY", 0, "Factor", + "Stores and apply multiplication factor between reference and local value (NOT USED)"}, + {IDOVERRIDESTATIC_OP_INSERT_AFTER, "INSERT_AFTER", 0, "Insert After", + "Insert a new item into collection after the one referenced in subitem_reference_name or _index"}, + {IDOVERRIDESTATIC_OP_INSERT_BEFORE, "INSERT_BEFORE", 0, "Insert Before", + "Insert a new item into collection after the one referenced in subitem_reference_name or _index (NOT USED)"}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem static_override_property_flag_items[] = { + {IDOVERRIDESTATIC_FLAG_MANDATORY, "MANDATORY", 0, "Mandatory", + "For templates, prevents the user from removing pre-defined operation (NOT USED)"}, + {IDOVERRIDESTATIC_FLAG_LOCKED, "LOCKED", 0, "Locked", + "Prevents the user from modifying that override operation (NOT USED)"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "IDOverrideStaticPropertyOperation", NULL); + RNA_def_struct_ui_text(srna, "ID Static Override Property Operation", + "Description of an override operation over an overridden property"); + + prop = RNA_def_enum(srna, "operation", static_override_property_operation_items, IDOVERRIDESTATIC_OP_REPLACE, + "Operation", "What override operation is performed"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + prop = RNA_def_enum(srna, "flag", static_override_property_flag_items, 0, + "Flags", "Optional flags (NOT USED)"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + prop = RNA_def_string(srna, "subitem_reference_name", NULL, INT_MAX, "Subitem Reference Name", + "Used to handle insertions into collection"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + RNA_def_property_string_funcs(prop, "rna_ID_override_static_property_operation_refname_get", + "rna_ID_override_static_property_operation_refname_length", NULL); + + prop = RNA_def_string(srna, "subitem_local_name", NULL, INT_MAX, "Subitem Local Name", + "Used to handle insertions into collection"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + RNA_def_property_string_funcs(prop, "rna_ID_override_static_property_operation_locname_get", + "rna_ID_override_static_property_operation_locname_length", NULL); + + prop = RNA_def_int(srna, "subitem_reference_index", -1, -1, INT_MAX, "Subitem Reference Index", + "Used to handle insertions into collection", -1, INT_MAX); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + prop = RNA_def_int(srna, "subitem_local_index", -1, -1, INT_MAX, "Subitem Local Index", + "Used to handle insertions into collection", -1, INT_MAX); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ +} + +static void rna_def_ID_override_static_property(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "IDOverrideStaticProperty", NULL); + RNA_def_struct_ui_text(srna, "ID Static Override Property", "Description of an overridden property"); + + /* String pointer, we *should* add get/set/etc. But NULL rna_path would be a nasty bug anyway... */ + prop = RNA_def_string(srna, "rna_path", NULL, INT_MAX, "RNA Path", + "RNA path leading to that property, from owning ID"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + RNA_def_collection(srna, "operations", "IDOverrideStaticPropertyOperation", "Operations", + "List of overriding operations for a property"); + + rna_def_ID_override_static_property_operation(brna); +} + +static void rna_def_ID_override_static(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "IDOverrideStatic", NULL); + RNA_def_struct_ui_text(srna, "ID Static Override", "Struct gathering all data needed by statically overridden IDs"); + + RNA_def_pointer(srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override"); + + prop = RNA_def_boolean(srna, "auto_generate", true, "Auto Generate Override", + "Automatically generate overriding operations by detecting changes in properties"); + RNA_def_property_boolean_sdna(prop, NULL, "flag", STATICOVERRIDE_AUTO); + + RNA_def_collection(srna, "properties", "IDOverrideStaticProperty", "Properties", + "List of overridden properties"); + + rna_def_ID_override_static_property(brna); +} + static void rna_def_ID(BlenderRNA *brna) { StructRNA *srna; @@ -1006,16 +1149,6 @@ static void rna_def_ID(BlenderRNA *brna) "Tools can use this to tag data for their own purposes " "(initial state is undefined)"); - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "recalc", ID_RECALC); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Is Updated", "Data-block is tagged for recalculation"); - - prop = RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "recalc", ID_RECALC_DATA); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Is Updated Data", "Data-block data is tagged for recalculation"); - prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_INDIRECT); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1026,6 +1159,9 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Library", "Library file the data-block is linked from"); + prop = RNA_def_pointer(srna, "override_static", "IDOverrideStatic", "Static Override", "Static override data"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop = RNA_def_pointer(srna, "preview", "ImagePreview", "Preview", "Preview image and icon of this data-block (None if not supported for this type of data)"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1038,6 +1174,12 @@ static void rna_def_ID(BlenderRNA *brna) parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "override_create", "rna_ID_override_create"); + RNA_def_function_ui_description(func, "Create an overridden local copy of this linked data-block (not supported for all data-blocks)"); + RNA_def_function_flag(func, FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the ID"); + RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear"); RNA_def_function_ui_description(func, "Clear the user count of a data-block so its not saved, " "on reload the data will be removed"); @@ -1142,6 +1284,7 @@ void RNA_def_ID(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Any Type", "RNA type used for pointers to any possible data"); rna_def_ID(brna); + rna_def_ID_override_static(brna); rna_def_image_preview(brna); rna_def_ID_properties(brna); rna_def_ID_materials(brna); |