Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c127
1 files changed, 127 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 6df03d19538..8f8ad077935 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -741,6 +741,58 @@ static void rna_ID_override_template_create(ID *id, ReportList *reports)
BKE_lib_override_library_template_create(id);
}
+static void rna_ID_override_library_operations_update(ID *id,
+ IDOverrideLibrary *UNUSED(override_library),
+ Main *bmain,
+ ReportList *reports)
+{
+ if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
+ BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
+ return;
+ }
+
+ BKE_lib_override_library_operations_create(bmain, id);
+}
+
+static void rna_ID_override_library_reset(ID *id,
+ IDOverrideLibrary *UNUSED(override_library),
+ Main *bmain,
+ ReportList *reports,
+ bool do_hierarchy)
+{
+ if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
+ BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
+ return;
+ }
+
+ if (do_hierarchy) {
+ BKE_lib_override_library_id_hierarchy_reset(bmain, id);
+ }
+ else {
+ BKE_lib_override_library_id_reset(bmain, id);
+ }
+}
+
+static void rna_ID_override_library_destroy(ID *id,
+ IDOverrideLibrary *UNUSED(override_library),
+ Main *bmain,
+ ReportList *reports,
+ bool do_hierarchy)
+{
+ if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
+ BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
+ return;
+ }
+
+ if (do_hierarchy) {
+ BKE_lib_override_library_delete(bmain, id);
+ }
+ else {
+ BKE_libblock_remap(bmain, id, id->override_library->reference, ID_REMAP_SKIP_INDIRECT_USAGE);
+ BKE_id_delete(bmain, id);
+ }
+}
+
static IDOverrideLibraryProperty *rna_ID_override_library_properties_add(
IDOverrideLibrary *override_library, ReportList *reports, const char rna_path[])
{
@@ -755,6 +807,18 @@ static IDOverrideLibraryProperty *rna_ID_override_library_properties_add(
return result;
}
+static void rna_ID_override_library_properties_remove(IDOverrideLibrary *override_library,
+ ReportList *reports,
+ IDOverrideLibraryProperty *override_property)
+{
+ if (BLI_findindex(&override_library->properties, override_property) == -1) {
+ BKE_report(reports, RPT_ERROR, "Override property cannot be removed");
+ return;
+ }
+
+ BKE_lib_override_library_property_delete(override_library, override_property);
+}
+
static IDOverrideLibraryPropertyOperation *rna_ID_override_library_property_operations_add(
IDOverrideLibraryProperty *override_property,
ReportList *reports,
@@ -782,6 +846,19 @@ static IDOverrideLibraryPropertyOperation *rna_ID_override_library_property_oper
return result;
}
+static void rna_ID_override_library_property_operations_remove(
+ IDOverrideLibraryProperty *override_property,
+ ReportList *reports,
+ IDOverrideLibraryPropertyOperation *override_operation)
+{
+ if (BLI_findindex(&override_property->operations, override_operation) == -1) {
+ BKE_report(reports, RPT_ERROR, "Override operation cannot be removed");
+ return;
+ }
+
+ BKE_lib_override_library_property_operation_delete(override_property, override_operation);
+}
+
static void rna_ID_update_tag(ID *id, Main *bmain, ReportList *reports, int flag)
{
/* XXX, new function for this! */
@@ -1633,6 +1710,16 @@ static void rna_def_ID_override_library_property_operations(BlenderRNA *brna, Pr
"New Operation",
"Created operation");
RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_ID_override_library_property_operations_remove");
+ RNA_def_function_ui_description(func, "Remove and delete an operation");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func,
+ "operation",
+ "IDOverrideLibraryPropertyOperation",
+ "Operation",
+ "Override operation to be deleted");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
static void rna_def_ID_override_library_property(BlenderRNA *brna)
@@ -1689,12 +1776,23 @@ static void rna_def_ID_override_library_properties(BlenderRNA *brna, PropertyRNA
parm = RNA_def_string(
func, "rna_path", NULL, 256, "RNA Path", "RNA-Path of the property to add");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
+ func = RNA_def_function(srna, "remove", "rna_ID_override_library_properties_remove");
+ RNA_def_function_ui_description(func, "Remove and delete a property");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func,
+ "property",
+ "IDOverrideLibraryProperty",
+ "Property",
+ "Override property to be deleted");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
static void rna_def_ID_override_library(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
srna = RNA_def_struct(brna, "IDOverrideLibrary", NULL);
RNA_def_struct_ui_text(
@@ -1710,6 +1808,35 @@ static void rna_def_ID_override_library(BlenderRNA *brna)
"List of overridden properties");
rna_def_ID_override_library_properties(brna, prop);
+ /* Update function. */
+ func = RNA_def_function(srna, "operations_update", "rna_ID_override_library_operations_update");
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func,
+ "Update the library override operations based on the "
+ "differences between this override ID and its reference");
+
+ func = RNA_def_function(srna, "reset", "rna_ID_override_library_reset");
+ RNA_def_function_ui_description(func,
+ "Reset this override to match again its linked reference ID");
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
+ RNA_def_boolean(
+ func,
+ "do_hierarchy",
+ true,
+ "",
+ "Also reset all the dependencies of this override to match their reference linked IDs");
+
+ func = RNA_def_function(srna, "destroy", "rna_ID_override_library_destroy");
+ RNA_def_function_ui_description(
+ func, "Delete this override ID and remap its usages to its linked reference ID instead");
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
+ RNA_def_boolean(func,
+ "do_hierarchy",
+ true,
+ "",
+ "Also delete all the dependencies of this override and remap their usages to "
+ "their reference linked IDs");
+
rna_def_ID_override_library_property(brna);
}