diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-10 12:27:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-10 12:47:43 +0300 |
commit | 1a12c9edab4ac89c8a87c20ad3a2195d0e681bc8 (patch) | |
tree | 1cd7e5771f4dd232fec39f678071836da8a1789e /source/blender/editors/animation/keyingsets.c | |
parent | 99f1e3d57fa1ee1f4400c299f1247ac5c614b6f0 (diff) |
Keyframing: add operators that use keying-set ID's
Unfortunately we can't use insert/delete_keyframe operators in keymaps
because the enums aren't known at the time of keymap registration
and the keying sets are dynamic and use a poll function.
Add a version of insert/delete operators that takes a string
instead of an enum. Needed for D4626.
Also extract int to keying-set into a utility function.
Diffstat (limited to 'source/blender/editors/animation/keyingsets.c')
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index d532e22e7f7..654543c9d5d 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -784,6 +784,40 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNU return item; } +/** + * Get the keying set from enum values generated in #ANIM_keying_sets_enum_itemf. + * + * Type is the Keying Set the user specified to use when calling the operator: + * - type == 0: use scene's active Keying Set + * - type > 0: use a user-defined Keying Set from the active scene + * - type < 0: use a builtin Keying Set + */ +KeyingSet *ANIM_keyingset_get_from_enum_type(Scene *scene, int type) +{ + KeyingSet *ks = NULL; + + if (type == 0) { + type = scene->active_keyingset; + } + + if (type > 0) { + ks = BLI_findlink(&scene->keyingsets, type - 1); + } + else { + ks = BLI_findlink(&builtin_keyingsets, -type - 1); + } + return ks; +} + +KeyingSet *ANIM_keyingset_get_from_idname(Scene *scene, const char *idname) +{ + KeyingSet *ks = BLI_findstring(&scene->keyingsets, idname, offsetof(KeyingSet, idname)); + if (ks == NULL) { + ks = BLI_findstring(&builtin_keyingsets, idname, offsetof(KeyingSet, idname)); + } + return ks; +} + /* ******************************************* */ /* KEYFRAME MODIFICATION */ |