[Bf-blender-cvs] [54e92bbd29c] blender2.8: Fix: View All in Action Editor zoomed in far enough to enter "crazy mode" with a single keyframe

Joshua Leung noreply at git.blender.org
Thu May 31 14:51:35 CEST 2018


Commit: 54e92bbd29c048f09bd05f8fc22004f838ce3fdb
Author: Joshua Leung
Date:   Thu May 31 14:51:24 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB54e92bbd29c048f09bd05f8fc22004f838ce3fdb

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.

===================================================================

M	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) {



More information about the Bf-blender-cvs mailing list