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_internal_types.h | |
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_internal_types.h')
-rw-r--r-- | source/blender/makesrna/intern/rna_internal_types.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index b43423464e9..fd0b655e41e 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -40,6 +40,9 @@ struct PointerRNA; struct FunctionRNA; struct CollectionPropertyIterator; struct bContext; +struct IDOverrideStatic; +struct IDOverrideStaticProperty; +struct IDOverrideStaticPropertyOperation; struct IDProperty; struct GHash; struct Main; @@ -117,6 +120,60 @@ typedef void (*PropStringSetFuncEx)(struct PointerRNA *ptr, struct PropertyRNA * typedef int (*PropEnumGetFuncEx)(struct PointerRNA *ptr, struct PropertyRNA *prop); typedef void (*PropEnumSetFuncEx)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value); +/* Handling override operations, and also comparison. */ +enum { + /* Do not compare properties that are not overridable. */ + RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE = 1 << 0, + /* Do not compare properties that are already overridden. */ + RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN = 1 << 1, +}; + +/** + * If \a override is NULL, merely do comparison between prop_a from ptr_a and prop_b from ptr_b, + * following comparison mode given. + * If \a override and \a rna_path are not NULL, it will add a new override operation for overridable properties + * that differ and have not yet been overridden (and set accordingly \a r_override_changed if given). + * + * \note Given PropertyRNA are final (in case of IDProps...). + * \note In non-array cases, \a len values are 0. + * \note \a override, \a rna_path and \a r_override_changed may be NULL pointers. + */ +typedef int (*RNAPropOverrideDiff)( + struct PointerRNA *ptr_a, struct PointerRNA *ptr_b, + struct PropertyRNA *prop_a, struct PropertyRNA *prop_b, + const int len_a, const int len_b, + const int mode, + struct IDOverrideStatic *override, const char *rna_path, + const int flags, bool *r_override_changed); + +/** + * Only used for differential override (add, sub, etc.). + * Store into storage the value needed to transform reference's value into local's value. + * + * \note Given PropertyRNA are final (in case of IDProps...). + * \note In non-array cases, \a len values are 0. + * \note Might change given override operation (e.g. change 'add' one into 'sub'), in case computed storage value + * is out of range (or even change it to basic 'set' operation if nothing else works). + */ +typedef bool (*RNAPropOverrideStore)( + struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, + struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, + const int len_local, const int len_reference, const int len_storage, + struct IDOverrideStaticPropertyOperation *opop); + +/** + * Apply given override operation from src to dst (using value from storage as second operand + * for differential operations). + * + * \note Given PropertyRNA are final (in case of IDProps...). + * \note In non-array cases, \a len values are 0. + */ +typedef bool (*RNAPropOverrideApply)( + struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, + struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, + const int len_dst, const int len_src, const int len_storage, + struct IDOverrideStaticPropertyOperation *opop); + /* Container - generic abstracted container of RNA properties */ typedef struct ContainerRNA { void *next, *prev; @@ -194,6 +251,11 @@ struct PropertyRNA { /* callback for testing if array-item editable (if applicable) */ ItemEditableFunc itemeditable; + /* Override handling callbacks (diff is also used for comparison). */ + RNAPropOverrideDiff override_diff; + RNAPropOverrideStore override_store; + RNAPropOverrideApply override_apply; + /* raw access */ int rawoffset; RawPropertyType rawtype; |