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
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-10-07 16:27:58 +0300
committerHans Goudey <h.goudey@me.com>2020-10-07 16:27:58 +0300
commit983ad4210b9e3dc6fe98553e686b213423e00fa1 (patch)
tree06361a54c87221515d112e94892078eced25e01f /source/blender/blenkernel/intern/fcurve.c
parentef235b0f172832403c5eaa2b2d510dd6f0dd8a14 (diff)
Fix T76595: Indicate the Active Keyframe in Graph Editor
In the graph editor there is a panel that says "Active Keyframe" for numerically editing a keyframe's values, but in the code there is no concept of the "active keyframe." Since this is a useful concept to have for some other features anyway, this commit adds an active keyframe index value to FCurves. It also displays it with a theme color for the active vertex (which didn't exist before) if the FCurve is active. The active keyframe in the graph editor is treated similarly to the active vertex in the 3D view. It is the keyframe most recently selected with a single click, and it is always selected. For now, the only real functional change is that the active keyframe appears in white and it should be more predictable which keyframe is being edited in the sidebar panel. Differential Revision: https://developer.blender.org/D7737
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index d0f23221ed0..856e0e872b3 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -830,6 +830,38 @@ bool BKE_fcurve_calc_range(
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Active Keyframe
+ * \{ */
+
+/**
+ * Set the index that stores the FCurve's active keyframe, assuming that \a active_bezt
+ * is already part of `fcu->bezt`. If NULL, set active keyframe index to "none."
+ */
+void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
+{
+ fcu->active_keyframe_index = (active_bezt == NULL) ? FCURVE_ACTIVE_KEYFRAME_NONE :
+ active_bezt - fcu->bezt;
+}
+
+/**
+ * Get the active keyframe index, with sanity checks for point bounds.
+ */
+int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
+{
+ const int active_keyframe_index = fcu->active_keyframe_index;
+
+ /* Sanity checks. */
+ if ((fcu->bezt == NULL) || (active_keyframe_index >= fcu->totvert) ||
+ (active_keyframe_index < 0)) {
+ return FCURVE_ACTIVE_KEYFRAME_NONE;
+ }
+
+ return active_keyframe_index;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Status Checks
* \{ */