diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-10-26 10:13:29 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-10-26 10:18:12 +0300 |
commit | 1b286352a31c5a1320c5b481a2edc694b9b80338 (patch) | |
tree | f3554727d15131673e57703487cfb398f1ecbc39 /source/blender/editors/space_graph | |
parent | b3edd7bdcdbb67abef6436244bb23ec3ef890869 (diff) |
Graph Editor: Snap and Mirror keyframes now respect Cursor X in Drivers mode
When using the "Current Frame" options for these operators, the Cursor X value
will now be used instead of the current frame. Perhaps the labels could be changed
too, but for now, I guess this will be good enough.
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index e423f564be2..78eb173045c 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1995,6 +1995,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked; KeyframeEditFunc edit_cb; float cursor_value = 0.0f; @@ -2003,9 +2004,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* get beztriple editing callbacks */ - edit_cb = ANIM_editkeyframes_snap(mode); - + /* init custom data for iterating over keyframes */ memset(&ked, 0, sizeof(KeyframeEditData)); ked.scene = ac->scene; if (mode == GRAPHKEYS_SNAP_NEAREST_MARKER) { @@ -2013,9 +2012,20 @@ static void snap_graph_keys(bAnimContext *ac, short mode) ked.list.last = (ac->markers) ? ac->markers->last : NULL; } else if (mode == GRAPHKEYS_SNAP_VALUE) { - SpaceIpo *sipo = (SpaceIpo *)ac->sl; cursor_value = (sipo) ? sipo->cursorVal : 0.0f; } + else if (mode == GRAPHKEYS_SNAP_CFRA) { + /* In drivers mode, use the cursor value instead + * (We need to use a different callback for that though) + */ + if (sipo->mode == SIPO_MODE_DRIVERS) { + ked.f1 = sipo->cursorTime; + mode = SNAP_KEYS_TIME; + } + } + + /* get beztriple editing callbacks */ + edit_cb = ANIM_editkeyframes_snap(mode); /* snap keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { @@ -2038,7 +2048,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode) } else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); - + ale->update |= ANIM_UPDATE_DEFAULT; } @@ -2112,18 +2122,16 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked; KeyframeEditFunc edit_cb; float cursor_value = 0.0f; - /* get beztriple editing callbacks */ - edit_cb = ANIM_editkeyframes_mirror(mode); - + /* init custom data for looping over keyframes */ memset(&ked, 0, sizeof(KeyframeEditData)); ked.scene = ac->scene; - /* for 'first selected marker' mode, need to find first selected marker first! */ - // XXX should this be made into a helper func in the API? + /* store mode-specific custom data... */ if (mode == GRAPHKEYS_MIRROR_MARKER) { TimeMarker *marker = NULL; @@ -2137,9 +2145,20 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) return; } else if (mode == GRAPHKEYS_MIRROR_VALUE) { - SpaceIpo *sipo = (SpaceIpo *)ac->sl; cursor_value = (sipo) ? sipo->cursorVal : 0.0f; } + else if (mode == GRAPHKEYS_MIRROR_CFRA) { + /* In drivers mode, use the cursor value instead + * (We need to use a different callback for that though) + */ + if (sipo->mode == SIPO_MODE_DRIVERS) { + ked.f1 = sipo->cursorTime; + mode = MIRROR_KEYS_TIME; + } + } + + /* get beztriple editing callbacks */ + edit_cb = ANIM_editkeyframes_mirror(mode); /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); @@ -2166,7 +2185,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) } else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); - + ale->update |= ANIM_UPDATE_DEFAULT; } |