From 54e92bbd29c048f09bd05f8fc22004f838ce3fdb Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 31 May 2018 14:51:24 +0200 Subject: 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. --- source/blender/editors/space_action/action_edit.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/space_action/action_edit.c') 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) { -- cgit v1.2.3