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:
authorJoshua Leung <aligorith@gmail.com>2018-05-31 15:51:24 +0300
committerJoshua Leung <aligorith@gmail.com>2018-05-31 15:51:28 +0300
commit54e92bbd29c048f09bd05f8fc22004f838ce3fdb (patch)
treee0b0ccaf3bde2250f896dc6dfa311f17b8b1a323 /source/blender/editors/space_action/action_edit.c
parent4e96bff938b123c96cbc88e546c259bbf5ad52d8 (diff)
Fix: View All in Action Editor zoomed in far enough to enter "crazy mode" with a single keyframe
Now, when there's just a single keyframe, pressing HomeKey will instead just center the view instead of trying to do "frame range" + margin.
Diffstat (limited to 'source/blender/editors/space_action/action_edit.c')
-rw-r--r--source/blender/editors/space_action/action_edit.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index f7c668ac929..7f0882c505e 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -384,12 +384,22 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
if (only_sel && (found == false))
return OPERATOR_CANCELLED;
- v2d->cur.xmin = min;
- v2d->cur.xmax = max;
-
- extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
- v2d->cur.xmin -= extra;
- v2d->cur.xmax += extra;
+ if (fabsf(max - min) < 1.0f) {
+ /* Exception - center the single keyfrme */
+ float xwidth = BLI_rctf_size_x(&v2d->cur);
+
+ v2d->cur.xmin = min - xwidth / 2.0f;
+ v2d->cur.xmax = max + xwidth / 2.0f;
+ }
+ else {
+ /* Normal case - stretch the two keyframes out to fill the space, with extra spacing */
+ v2d->cur.xmin = min;
+ v2d->cur.xmax = max;
+
+ extra = 0.125f * BLI_rctf_size_x(&v2d->cur);
+ v2d->cur.xmin -= extra;
+ v2d->cur.xmax += extra;
+ }
/* set vertical range */
if (only_sel == false) {