diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-11-22 18:46:15 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-11-22 18:54:43 +0300 |
commit | b037ba2665f4b08d91e0d7d1b350c8bb562ca320 (patch) | |
tree | b9957cc53e449b599a4aee110e845a032aa5a46f /source/blender/editors/animation/keyframes_edit.c | |
parent | 177dfc6384b926dd19e3b7e98a995ccb4da9167c (diff) |
UI: Changes to Graph Editor selection and transform
When introducing "drag-all-selected" support all over Blender, we
figured this wouldn't work well with the Graph Editor
selection/transform behavior.
Hence, William and I worked on the following changes, although we used
this chance to improve the behavior in general too.
For more info see T70634.
* Handles now always move with the key, regardless if they are selected
or not.
* Selecting the key doesn't select the handles anymore, their selection
is separate.
* Multiple keys and handles can now be dragged.
* Dragging a handle moves all selected handles **on the same side**.
* Tweak-dragging any handle can never affect any keyframe location,
only handles.
* G/R/S should behave as before.
* Changing the handle type with a key selected always applies the change
to both handles.
* Box selection with Ctrl+Drag now allows deselecting handles (used to
act on entire triple only).
* Box selection //Include Handles// option now only acts on visible
handles, wasn't the case with Only Selected Keyframes Handles enabled.
* Box selection //Include Handles// is now enabled by default in all
bundled keymaps.
The changes have been tested for some days by the animators here in the
Blender Animation Studio. Some changes are based on their feedback.
Also, this improves/adds comments for related code.
Differential Revision: https://developer.blender.org/D6235
Reviewed by: Sybren Stüvel, William Reynish
Diffstat (limited to 'source/blender/editors/animation/keyframes_edit.c')
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 87 |
1 files changed, 67 insertions, 20 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index f8328e9f07f..dc413e936eb 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -501,10 +501,16 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) ok |= KEYFRAME_OK_KEY; \ \ if (ked && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { \ - if (check(0)) \ - ok |= KEYFRAME_OK_H1; \ - if (check(2)) \ - ok |= KEYFRAME_OK_H2; \ + /* Only act on visible items, so check handle visiblity state. */ \ + const bool handles_visible = ((ked->iterflags & KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE) ? \ + (BEZT_ISSEL_ANY(bezt)) : \ + true); \ + if (handles_visible) { \ + if (check(0)) \ + ok |= KEYFRAME_OK_H1; \ + if (check(2)) \ + ok |= KEYFRAME_OK_H2; \ + } \ } \ } \ (void)0 @@ -1054,7 +1060,11 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type) /* Sets the selected bezier handles to type 'auto' */ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { + /* If the key is selected, always apply to both handles. */ + if (bezt->f2 & SELECT) { + bezt->h1 = bezt->h2 = HD_AUTO; + } + else { if (bezt->f1 & SELECT) { bezt->h1 = HD_AUTO; } @@ -1064,6 +1074,7 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) ENSURE_HANDLES_MATCH(bezt); } + return 0; } @@ -1072,7 +1083,11 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) */ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { + /* If the key is selected, always apply to both handles. */ + if (bezt->f2 & SELECT) { + bezt->h1 = bezt->h2 = HD_AUTO_ANIM; + } + else { if (bezt->f1 & SELECT) { bezt->h1 = HD_AUTO_ANIM; } @@ -1082,18 +1097,26 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b ENSURE_HANDLES_MATCH(bezt); } + return 0; } /* Sets the selected bezier handles to type 'vector' */ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) { - bezt->h1 = HD_VECT; + /* If the key is selected, always apply to both handles. */ + if (bezt->f2 & SELECT) { + bezt->h1 = bezt->h2 = HD_VECT; } - if (bezt->f3 & SELECT) { - bezt->h2 = HD_VECT; + else { + if (bezt->f1 & SELECT) { + bezt->h1 = HD_VECT; + } + if (bezt->f3 & SELECT) { + bezt->h2 = HD_VECT; + } } + return 0; } @@ -1114,24 +1137,38 @@ static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt) /* Sets selected bezier handles to type 'align' */ static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) { - bezt->h1 = HD_ALIGN; + /* If the key is selected, always apply to both handles. */ + if (bezt->f2 & SELECT) { + bezt->h1 = bezt->h2 = HD_ALIGN; } - if (bezt->f3 & SELECT) { - bezt->h2 = HD_ALIGN; + else { + if (bezt->f1 & SELECT) { + bezt->h1 = HD_ALIGN; + } + if (bezt->f3 & SELECT) { + bezt->h2 = HD_ALIGN; + } } + return 0; } /* Sets selected bezier handles to type 'free' */ static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) { - bezt->h1 = HD_FREE; + /* If the key is selected, always apply to both handles. */ + if (bezt->f2 & SELECT) { + bezt->h1 = bezt->h2 = HD_FREE; } - if (bezt->f3 & SELECT) { - bezt->h2 = HD_FREE; + else { + if (bezt->f1 & SELECT) { + bezt->h1 = HD_FREE; + } + if (bezt->f3 & SELECT) { + bezt->h2 = HD_FREE; + } } + return 0; } @@ -1422,8 +1459,13 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode) static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt) { + /* Only act on visible items, so check handle visiblity state. */ + const bool handles_visible = ked && ((ked->iterflags & KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE) ? + (BEZT_ISSEL_ANY(bezt)) : + true); + /* if we've got info on what to select, use it, otherwise select all */ - if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { + if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES) && handles_visible) { if (ked->curflags & KEYFRAME_OK_KEY) { bezt->f2 |= SELECT; } @@ -1443,8 +1485,13 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt) static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt) { + /* Only act on visible items, so check handle visiblity state. */ + const bool handles_visible = ked && ((ked->iterflags & KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE) ? + (BEZT_ISSEL_ANY(bezt)) : + true); + /* if we've got info on what to deselect, use it, otherwise deselect all */ - if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { + if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES) && handles_visible) { if (ked->curflags & KEYFRAME_OK_KEY) { bezt->f2 &= ~SELECT; } |