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 <HooglyBoogly>2020-10-07 13:46:58 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-10-07 13:46:58 +0300
commite584bc320a9cf6be7a16fc159bb26b5ced5572fb (patch)
tree6275e5310ce070d469095dc79da26340423a66f8 /source/blender/blenkernel/intern/fcurve.c
parent4bb15c8eecbf8186a8948ced9349d54c1a8c5e33 (diff)
Fix T76595: Indicate the Active Keyframe in Graph Editortemp-fcurve-active-keyframe-D7737
Currently there is a panel that says "Active Keyframe" for numerically editing one keyframe's values, but in the code there is no concept of the "active keyframe." This patch adds an "active keyframe index" to each FCurve, and displays it with a theme color for the active vertex (which didn't exist before) if the FCurve is active. {F8536092 size=full} The active keyframe is not currently set for select operations other than basic click-select, which mirrors the behavior in the 3D view. Reviewed By: Severin, looch Maniphest Tasks: T76595 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
* \{ */