[Bf-blender-cvs] [eccfa53ad42] temp-T81874-box-select-active-keyframe: Fix T81874: Box Select Keyframes doesnt set an active keyframe

Sybren A. Stüvel noreply at git.blender.org
Mon Oct 26 15:07:50 CET 2020


Commit: eccfa53ad42ca98b6b7b8eec55fa4720b6ab43b2
Author: Sybren A. Stüvel
Date:   Mon Oct 26 14:49:14 2020 +0100
Branches: temp-T81874-box-select-active-keyframe
https://developer.blender.org/rBeccfa53ad42ca98b6b7b8eec55fa4720b6ab43b2

Fix T81874: Box Select Keyframes doesnt set an active keyframe

Set the active keyframe on box/circle/lasso select in the graph editor.

For every FCurve that is influenced by the select operator that doesn't
have an active keyframe yet, the right-most keyframe is marked as the
active Keyframe.

Note that what is seen as the active keyframe for the graph editor also
depends on the active FCurve, which is not changed by box/circle/lasso
select.

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

M	source/blender/editors/space_graph/graph_select.c

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

diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 57aaa1fefce..5dabdafd27b 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -501,6 +501,24 @@ void GRAPH_OT_select_all(wmOperatorType *ot)
  * The selection backend is also reused for the Lasso and Circle select operators.
  */
 
+static short fcurve_activate_keyframe(KeyframeEditData *ked, struct BezTriple *bezt)
+{
+  BKE_fcurve_active_keyframe_set(ked->fcu, bezt);
+  return 0;
+}
+
+/* Mark the last-selected keyframe as "active".
+ * Does nothing when the FCurve already has an active keyframe. */
+static void fcurve_activate_last_selected_key(KeyframeEditData *ked,
+                                              FCurve *fcu,
+                                              const KeyframeEditFunc ok_cb)
+{
+  if (BKE_fcurve_active_keyframe_index(fcu) != FCURVE_ACTIVE_KEYFRAME_NONE) {
+    return;
+  }
+  ANIM_fcurve_keyframes_loop(ked, fcu, ok_cb, fcurve_activate_keyframe, NULL);
+}
+
 /* Box Select only selects keyframes now, as overshooting handles often get caught too,
  * which means that they may be inadvertently moved as well. However, incl_handles overrides
  * this, and allow handles to be considered independently too.
@@ -612,6 +630,10 @@ static void box_select_graphkeys(bAnimContext *ac,
           fcu->flag |= FCURVE_SELECTED;
         }
       }
+
+      if (ELEM(selectmode, SELECT_ADD, SELECT_REPLACE)) {
+        fcurve_activate_last_selected_key(&ked, fcu, ok_cb);
+      }
     }
 
     /* un-apply NLA mapping from all the keyframes */



More information about the Bf-blender-cvs mailing list