diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-11-29 17:31:31 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-11-29 19:23:25 +0300 |
commit | 638afb9bd428fb697fb5136e8bb5f31b05458db7 (patch) | |
tree | 2c00bf3c3d394e37db9286306ba4e6506e31a31e /source/blender/makesrna/intern/rna_define.c | |
parent | 6d003ef81272be144e97e2767ee4fe526aca582c (diff) |
ID Static Override, part II: RNA changes.
This is essentially a huge refactor/extension of our existing RNA
compare & copy code, since static override needs more advanced handling here.
Note that not all new features are implemented yet, advanced things like
collections insertion/deletion are still TODO (medium priority).
This completes the ground work for overrides, remaining commits will be
about UI and some basic/testing activation of overrides for a limited
set of data-blocks & properties.
For details see https://developer.blender.org/D2417
Diffstat (limited to 'source/blender/makesrna/intern/rna_define.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index c8a6a503fd9..03e58f8f78e 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1270,6 +1270,14 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier #endif } + /* Override handling. */ + if (DefRNA.preprocess) { + prop->override_diff = (RNAPropOverrideDiff)"rna_property_override_diff_default"; + prop->override_store = (RNAPropOverrideStore)"rna_property_override_store_default"; + prop->override_apply = (RNAPropOverrideApply)"rna_property_override_apply_default"; + } + /* TODO: do we want that for runtime-defined stuff too? I’d say no, but... maybe yes :/ */ + rna_addtail(&cont->properties, prop); return prop; @@ -2222,6 +2230,29 @@ void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editabl if (editable) prop->itemeditable = (ItemEditableFunc)editable; } +/** + * Set custom callbacks for override operations handling. + * + * \note \a diff callback will also be used by RNA comparison/equality functions. + */ +void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply) +{ + if (!DefRNA.preprocess) { + fprintf(stderr, "%s: only during preprocessing.\n", __func__); + return; + } + + if (diff) { + prop->override_diff = (RNAPropOverrideDiff)diff; + } + if (store) { + prop->override_store = (RNAPropOverrideStore)store; + } + if (apply) { + prop->override_apply = (RNAPropOverrideApply)apply; + } +} + void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func) { if (!DefRNA.preprocess) { |