From 672590cd3bab47cb0d9d97eeb45f523dd5eb65d1 Mon Sep 17 00:00:00 2001 From: RKrom Date: Mon, 3 Dec 2012 14:08:06 +0000 Subject: [PATCH] Changes for the animation after discussions with Thomas. Mainly that the animation of the interactive capture STARTS from the Mouse-Cursor outwards. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2348 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Forms/CaptureForm.cs | 18 ++++++---- Greenshot/Helpers/AnimationHelper.cs | 53 +++++++++++++++++----------- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index bde9643d3..fefba1978 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -448,7 +448,7 @@ namespace Greenshot.Forms { if (captureMode == CaptureMode.Window) { // Using a 50 Pixel offset to the left, top, to make sure the text is invalidated too const int SAFETY_SIZE = 25; - if (windowAnimator.hasNext) { + if (windowAnimator != null && windowAnimator.hasNext) { Rectangle invalidateRectangle = windowAnimator.Current; invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE); Invalidate(invalidateRectangle); @@ -458,7 +458,11 @@ namespace Greenshot.Forms { } if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) { // Window changes, make new animation from current to target - windowAnimator.ChangeDestination(captureRect, 14); + if (windowAnimator.Last.Size == Size.Empty) { + windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, 10, EasingType.Quintic, EasingMode.EaseOut); + } else { + windowAnimator.ChangeDestination(captureRect, 10); + } Rectangle invalidateRectangle = new Rectangle(lastCaptureRect.Location, lastCaptureRect.Size); invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE); Invalidate(invalidateRectangle); @@ -517,8 +521,8 @@ namespace Greenshot.Forms { // convert to be relative to top left corner of all screen bounds screenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location); - - Rectangle targetRectangle = zoomAnimator.Last; + + Rectangle targetRectangle = zoomAnimator.Final; targetRectangle.Offset(pos); if (screenBounds.Contains(targetRectangle)) { // All okay @@ -538,8 +542,10 @@ namespace Greenshot.Forms { } else { destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, -zoomOffset.Y - zoomSize.Width); } - zoomAnimator.ChangeDestination(new Rectangle(new Point(-10, -10), new Size(20, 20))); - zoomAnimator.QueueDestination(new Rectangle(destinationLocation, zoomSize)); + // Change animation to destination "small with the mouse-cursor at the center" + //zoomAnimator.ChangeDestination(new Rectangle(new Point(-10, -10), new Size(20, 20))); + //zoomAnimator.QueueDestinationLeg(new Rectangle(destinationLocation, zoomSize)); + zoomAnimator.ChangeDestination(new Rectangle(destinationLocation, zoomSize)); ret = zoomAnimator.Next(); } return ret; diff --git a/Greenshot/Helpers/AnimationHelper.cs b/Greenshot/Helpers/AnimationHelper.cs index 320e20df1..3335283ac 100644 --- a/Greenshot/Helpers/AnimationHelper.cs +++ b/Greenshot/Helpers/AnimationHelper.cs @@ -36,7 +36,24 @@ namespace Greenshot.Helpers { protected Queue queue = new Queue(); protected double frames; protected double currentFrame = 0; - + + /// + /// Constructor + /// + /// + /// + /// + /// + /// + public AnimatorBase(T first, T last, int frames, EasingType easingType, EasingMode easingMode) { + this.first = first; + this.last = last; + this.frames = frames; + this.current = first; + this.EasingType = easingType; + this.EasingMode = easingMode; + } + /// /// The amount of frames /// @@ -59,11 +76,23 @@ namespace Greenshot.Helpers { } /// - /// Last animation value + /// Last animation value, of this "leg" /// public T Last { get { return last; } } + + /// + /// Final animation value, this is including the legs + /// + public T Final { + get { + if (queue.Count == 0) { + return last; + } + return queue.ToArray()[queue.Count - 1]; + } + } /// /// This restarts the current animation and changes the last frame @@ -83,13 +112,14 @@ namespace Greenshot.Helpers { this.currentFrame = 0; this.frames = frames; this.last = newDestination; + queue.Clear(); } /// /// Queue the destination, it will be used after the current animation is finished /// /// - public void QueueDestination(T queuedDestination) { + public void QueueDestinationLeg(T queuedDestination) { queue.Enqueue(queuedDestination); } @@ -126,23 +156,6 @@ namespace Greenshot.Helpers { } } - /// - /// Constructor - /// - /// - /// - /// - /// - /// - public AnimatorBase(T first, T last, int frames, EasingType easingType, EasingMode easingMode) { - this.first = first; - this.last = last; - this.frames = frames; - this.current = first; - this.EasingType = easingType; - this.EasingMode = easingMode; - } - /// /// Get the current (previous) frame object ///