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/editors/space_graph/graph_buttons.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/editors/space_graph/graph_buttons.c')
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 45c43a5853d..bbdca5280d4 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -235,40 +235,27 @@ static void graph_panel_properties(const bContext *C, Panel *panel)
/* ******************* active Keyframe ************** */
/* get 'active' keyframe for panel editing */
-static bool get_active_fcurve_keyframe_edit(FCurve *fcu,
+static bool get_active_fcurve_keyframe_edit(const FCurve *fcu,
BezTriple **r_bezt,
BezTriple **r_prevbezt)
{
- BezTriple *b;
- int i;
-
/* zero the pointers */
*r_bezt = *r_prevbezt = NULL;
- /* sanity checks */
- if ((fcu->bezt == NULL) || (fcu->totvert == 0)) {
+ const int active_keyframe_index = BKE_fcurve_active_keyframe_index(fcu);
+ if (active_keyframe_index == FCURVE_ACTIVE_KEYFRAME_NONE) {
return false;
}
- /* find first selected keyframe for now, and call it the active one
- * - this is a reasonable assumption, given that whenever anyone
- * wants to edit numerically, there is likely to only be 1 vert selected
- */
- for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) {
- if (BEZT_ISSEL_ANY(b)) {
- /* found
- * - 'previous' is either the one before, of the keyframe itself (which is still fine)
- * XXX: we can just make this null instead if needed
- */
- *r_prevbezt = (i > 0) ? b - 1 : b;
- *r_bezt = b;
-
- return true;
- }
- }
+ /* The active keyframe should be selected. */
+ BLI_assert(BEZT_ISSEL_ANY(&fcu->bezt[active_keyframe_index]));
+
+ *r_bezt = &fcu->bezt[active_keyframe_index];
+ /* Previous is either one before the active, or the point itself if it's the first. */
+ const int prev_index = max_ii(active_keyframe_index - 1, 0);
+ *r_prevbezt = &fcu->bezt[prev_index];
- /* not found */
- return false;
+ return true;
}
/* update callback for active keyframe properties - base updates stuff */