[Bf-blender-cvs] [a801487ef50] master: Fix T65076: Missing EasingType implementation on the Dopesheet

Sybren A. Stüvel noreply at git.blender.org
Tue Mar 10 14:03:13 CET 2020


Commit: a801487ef5049d9f4ecf947942761566bc64a176
Author: Sybren A. Stüvel
Date:   Tue Mar 10 14:02:16 2020 +0100
Branches: master
https://developer.blender.org/rBa801487ef5049d9f4ecf947942761566bc64a176

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

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_dopesheet.py
M	source/blender/editors/animation/keyframes_edit.c
M	source/blender/editors/include/ED_keyframes_edit.h
M	source/blender/editors/space_action/action_edit.c
M	source/blender/editors/space_action/action_intern.h
M	source/blender/editors/space_action/action_ops.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index bf1ff0604ad..ca7c3245713 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2035,6 +2035,7 @@ def km_dopesheet(params):
         ("action.handle_type", {"type": 'V', "value": 'PRESS'}, None),
         ("action.interpolation_type", {"type": 'T', "value": 'PRESS'}, None),
         ("action.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None),
+        ("action.easing_type", {"type": 'E', "value": 'PRESS', "ctrl": True}, None),
         ("action.keyframe_type", {"type": 'R', "value": 'PRESS'}, None),
         ("action.sample", {"type": 'O', "value": 'PRESS', "shift": True, "alt": True}, None),
         op_menu("DOPESHEET_MT_delete", {"type": 'X', "value": 'PRESS'}),
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 41adea0b922..f12d8597d37 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -498,6 +498,7 @@ class DOPESHEET_MT_key(Menu):
         layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type")
         layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
         layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
+        layout.operator_menu_enum("action.easing_type", "type", text="Easing Mode")
 
         layout.separator()
         layout.operator("action.clean").channels = False
@@ -600,6 +601,7 @@ class DOPESHEET_MT_context_menu(Menu):
         layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type")
         layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
         layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
+        layout.operator_menu_enum("action.easing_type", "type", text="Easing Mode")
 
         layout.separator()
 
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);



More information about the Bf-blender-cvs mailing list