diff options
author | Bastien Montagne <mont29> | 2020-06-03 11:37:46 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-06-03 12:18:11 +0300 |
commit | 3384bb2c663fda4e8b2f63f37ffce7152436f0a5 (patch) | |
tree | a14d87f20d123e5fe1f079b949ece025cc05f6b9 /source/blender | |
parent | 0e14eb7b31a8f55bd754c020dd542a6ac007caa3 (diff) |
RNA: add option to enable by default lib overridale flag of defined properties.
Similar to the one allowing to deactivate DNA check, etc.
Will helps reduce verbosity when making many new properties overridable.
Note that pointer properties always remain non-overridable by default,
since basically only ID pointers should be.
Reviewed By: brecht
Maniphest Tasks: T77083
Differential Revision: https://developer.blender.org/D7906
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/RNA_define.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 2 |
3 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 7a7ab1085dd..1bcf7f434f2 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -50,6 +50,7 @@ void RNA_free(BlenderRNA *brna); void RNA_define_verify_sdna(bool verify); void RNA_define_animate_sdna(bool animate); void RNA_define_fallback_property_update(int noteflag, const char *updatefunc); +void RNA_define_lib_overridable(const bool make_overridable); void RNA_init(void); void RNA_exit(void); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 9bcc8cc63b5..f59a1790e7b 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -71,6 +71,7 @@ BlenderDefRNA DefRNA = { .preprocess = false, .verify = true, .animate = true, + .make_overridable = false, }; #ifndef RNA_RUNTIME @@ -755,6 +756,15 @@ void RNA_define_verify_sdna(bool verify) DefRNA.verify = verify; } +/** + * Properties defined when this is enabled are lib-overridable by default (except for Pointer + * ones). + */ +void RNA_define_lib_overridable(const bool make_overridable) +{ + DefRNA.make_overridable = make_overridable; +} + #ifndef RNA_RUNTIME void RNA_define_animate_sdna(bool animate) { @@ -1414,6 +1424,14 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, } } +#ifndef RNA_RUNTIME + if (type != PROP_POINTER) { + if (DefRNA.make_overridable) { + prop->flag_override |= PROPOVERRIDE_OVERRIDABLE_LIBRARY; + } + } +#endif + if (type == PROP_STRING) { /* used so generated 'get/length/set' functions skip a NULL check * in some cases we want it */ diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index f7d453cdc32..44f118a8744 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -123,6 +123,8 @@ typedef struct BlenderDefRNA { bool preprocess; bool verify; bool animate; + /** Whether RNA properties defined should be overridable or not by default. */ + bool make_overridable; /* Keep last. */ #ifndef RNA_RUNTIME |