Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-03-10 16:02:16 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-03-10 16:02:40 +0300
commita801487ef5049d9f4ecf947942761566bc64a176 (patch)
tree9089e5770eaea2e578cb5172cb70e9a92c4385ae /source
parentca717f0489af6854f3f4bedb3c1e82ea0a8dff1c (diff)
Fix T65076: Missing EasingType implementation on the Dopesheet
EasingType was implemented rBdaccaa713b6e for the GraphEditor (but never made it to the Dopesheet). If you can select Easing Mode in the DopeSheet, then you should also be able to select the associated Easing Type. Thanks @lichtwerk for the initial implementation. Maniphest Tasks: T65076 Differential Revision: https://developer.blender.org/D6094
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/animation/keyframes_edit.c18
-rw-r--r--source/blender/editors/include/ED_keyframes_edit.h8
-rw-r--r--source/blender/editors/space_action/action_edit.c82
-rw-r--r--source/blender/editors/space_action/action_intern.h1
-rw-r--r--source/blender/editors/space_action/action_ops.c1
5 files changed, 80 insertions, 30 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 9c65d5fcd2d..7a24eb484ac 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -456,6 +456,24 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked,
return 0;
}
+void ANIM_animdata_keyframe_callback(bAnimContext *ac,
+ eAnimFilter_Flags filter,
+ KeyframeEditFunc callback_fn)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, callback_fn, calchandles_fcurve);
+ ale->update |= ANIM_UPDATE_DEFAULT;
+ }
+
+ ANIM_animdata_update(ac, &anim_data);
+ ANIM_animdata_freelist(&anim_data);
+}
+
/* ************************************************************************** */
/* Keyframe Integrity Tools */
diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h
index d0d07fc3245..3ae0c254000 100644
--- a/source/blender/editors/include/ED_keyframes_edit.h
+++ b/source/blender/editors/include/ED_keyframes_edit.h
@@ -28,6 +28,8 @@
extern "C" {
#endif
+#include "ED_anim_api.h" /* for enum eAnimFilter_Flags */
+
struct BezTriple;
struct FCurve;
struct Scene;
@@ -251,6 +253,12 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked,
KeyframeEditFunc key_cb,
FcuEditFunc fcu_cb);
+/* Calls callback_fn() for each keyframe in each fcurve in the filtered animation context.
+ * Assumes the callback updates keys. */
+void ANIM_animdata_keyframe_callback(struct bAnimContext *ac,
+ eAnimFilter_Flags filter,
+ KeyframeEditFunc callback_fn);
+
/* functions for making sure all keyframes are in good order */
void ANIM_editkeyframes_refresh(struct bAnimContext *ac);
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index e17bf00106a..d7ad2066561 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1311,35 +1311,6 @@ void ACTION_OT_extrapolation_type(wmOperatorType *ot)
/* ******************** Set Interpolation-Type Operator *********************** */
-/* this function is responsible for setting interpolation mode for keyframes */
-static void setipo_action_keys(bAnimContext *ac, short mode)
-{
- ListBase anim_data = {NULL, NULL};
- bAnimListElem *ale;
- int filter;
- KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode);
-
- /* filter data */
- filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
- ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
- ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
- /* Loop through setting BezTriple interpolation
- * Note: we do not supply KeyframeEditData to the looper yet.
- * Currently that's not necessary here.
- */
- for (ale = anim_data.first; ale; ale = ale->next) {
- ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
-
- ale->update |= ANIM_UPDATE_DEFAULT;
- }
-
- ANIM_animdata_update(ac, &anim_data);
- ANIM_animdata_freelist(&anim_data);
-}
-
-/* ------------------- */
-
static int actkeys_ipo_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
@@ -1359,7 +1330,10 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
mode = RNA_enum_get(op->ptr, "type");
/* set handle type */
- setipo_action_keys(&ac, mode);
+ ANIM_animdata_keyframe_callback(&ac,
+ (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE |
+ ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS),
+ ANIM_editkeyframes_ipo(mode));
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
@@ -1388,6 +1362,54 @@ void ACTION_OT_interpolation_type(wmOperatorType *ot)
ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", "");
}
+/* ******************** Set Easing Operator *********************** */
+
+static int actkeys_easing_exec(bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+ short mode;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* get handle setting mode */
+ mode = RNA_enum_get(op->ptr, "type");
+
+ /* set handle type */
+ ANIM_animdata_keyframe_callback(&ac,
+ (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE |
+ ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS),
+ ANIM_editkeyframes_easing(mode));
+
+ /* set notifier that keyframe properties have changed */
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void ACTION_OT_easing_type(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Keyframe Easing Type";
+ ot->idname = "ACTION_OT_easing_type";
+ ot->description =
+ "Set easing type for the F-Curve segments starting from the selected keyframes";
+
+ /* api callbacks */
+ ot->invoke = WM_menu_invoke;
+ ot->exec = actkeys_easing_exec;
+ ot->poll = ED_operator_action_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* id-props */
+ ot->prop = RNA_def_enum(
+ ot->srna, "type", rna_enum_beztriple_interpolation_easing_items, 0, "Type", "");
+}
+
/* ******************** Set Handle-Type Operator *********************** */
/* this function is responsible for setting handle-type of selected keyframes */
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 006ba86a50a..bf1b90bbe98 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -99,6 +99,7 @@ void ACTION_OT_keyframe_type(struct wmOperatorType *ot);
void ACTION_OT_handle_type(struct wmOperatorType *ot);
void ACTION_OT_interpolation_type(struct wmOperatorType *ot);
void ACTION_OT_extrapolation_type(struct wmOperatorType *ot);
+void ACTION_OT_easing_type(struct wmOperatorType *ot);
void ACTION_OT_frame_jump(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index cba86ac5131..744c6c75463 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -63,6 +63,7 @@ void action_operatortypes(void)
WM_operatortype_append(ACTION_OT_handle_type);
WM_operatortype_append(ACTION_OT_interpolation_type);
WM_operatortype_append(ACTION_OT_extrapolation_type);
+ WM_operatortype_append(ACTION_OT_easing_type);
WM_operatortype_append(ACTION_OT_keyframe_type);
WM_operatortype_append(ACTION_OT_sample);
WM_operatortype_append(ACTION_OT_clean);