diff options
author | Bastien Montagne <bastien@blender.org> | 2022-02-22 19:20:18 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-03-29 18:58:40 +0300 |
commit | 5adcf6c85e4c28fcfda0048a9ec7cceae105046d (patch) | |
tree | ebc6b23cb3ede2cd3581371aaf6fae3f057eb511 /source/blender/makesrna/intern | |
parent | 101308403833aedbfef1d105424867a8f787d7b6 (diff) |
LibOverride: Add initial System Override flag.
This merely adds the flag, exposes it in RMA, and uses it in some of the
most common 'is editable' checks (RNA, `BASE_EDITABLE` macro...).
Next step: do_version and defining systemoverrides at creation.
Ref: {T95707}.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 24 |
2 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 82d90a5c54b..7fa6dad7730 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -1833,6 +1833,15 @@ static void rna_def_ID_override_library(BlenderRNA *brna) RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY); + prop = RNA_def_boolean(srna, + "is_system_override", + false, + "Is System Override", + "Whether this library override exists only for the override hierarchy, " + "or if it is actually editable by the user"); + RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); + RNA_def_property_boolean_sdna(prop, NULL, "flag", IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED); + prop = RNA_def_collection(srna, "properties", "IDOverrideLibraryProperty", diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 67fa29adb47..5690d864a75 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -32,8 +32,10 @@ #include "BKE_collection.h" #include "BKE_context.h" #include "BKE_fcurve.h" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_idtype.h" +#include "BKE_lib_override.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_report.h" @@ -1930,17 +1932,29 @@ static bool rna_property_editable_do(PointerRNA *ptr, /* Handle linked or liboverride ID cases. */ const bool is_linked_prop_exception = (prop->flag & PROP_LIB_EXCEPTION) != 0; - if (ID_IS_LINKED(id) && !is_linked_prop_exception) { + if (ID_IS_LINKED(id)) { + if (is_linked_prop_exception) { + return true; + } if (r_info != NULL && (*r_info)[0] == '\0') { *r_info = N_("Can't edit this property from a linked data-block"); } return false; } - if (ID_IS_OVERRIDE_LIBRARY(id) && !RNA_property_overridable_get(ptr, prop_orig)) { - if (r_info != NULL && (*r_info)[0] == '\0') { - *r_info = N_("Can't edit this property from an override data-block"); + if (ID_IS_OVERRIDE_LIBRARY(id)) { + const bool is_liboverride_system = BKE_lib_override_library_is_system_defined(G_MAIN, id); + if (!RNA_property_overridable_get(ptr, prop_orig)) { + if (r_info != NULL && (*r_info)[0] == '\0') { + *r_info = N_("Can't edit this property from an override data-block"); + } + return false; + } + if (is_liboverride_system && !is_linked_prop_exception) { + if (r_info != NULL && (*r_info)[0] == '\0') { + *r_info = N_("Can't edit this property from a system override data-block"); + } + return false; } - return false; } /* At this point, property is owned by a local ID and therefore fully editable. */ |