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
This commit is contained in:
RKrom 2012-12-03 14:08:06 +00:00
commit 672590cd3b
2 changed files with 45 additions and 26 deletions

View file

@ -448,7 +448,7 @@ namespace Greenshot.Forms {
if (captureMode == CaptureMode.Window) { if (captureMode == CaptureMode.Window) {
// Using a 50 Pixel offset to the left, top, to make sure the text is invalidated too // Using a 50 Pixel offset to the left, top, to make sure the text is invalidated too
const int SAFETY_SIZE = 25; const int SAFETY_SIZE = 25;
if (windowAnimator.hasNext) { if (windowAnimator != null && windowAnimator.hasNext) {
Rectangle invalidateRectangle = windowAnimator.Current; Rectangle invalidateRectangle = windowAnimator.Current;
invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE); invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE);
Invalidate(invalidateRectangle); Invalidate(invalidateRectangle);
@ -458,7 +458,11 @@ namespace Greenshot.Forms {
} }
if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) { if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) {
// Window changes, make new animation from current to target // 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); Rectangle invalidateRectangle = new Rectangle(lastCaptureRect.Location, lastCaptureRect.Size);
invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE); invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE);
Invalidate(invalidateRectangle); Invalidate(invalidateRectangle);
@ -518,7 +522,7 @@ namespace Greenshot.Forms {
screenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location); screenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location);
Rectangle targetRectangle = zoomAnimator.Last; Rectangle targetRectangle = zoomAnimator.Final;
targetRectangle.Offset(pos); targetRectangle.Offset(pos);
if (screenBounds.Contains(targetRectangle)) { if (screenBounds.Contains(targetRectangle)) {
// All okay // All okay
@ -538,8 +542,10 @@ namespace Greenshot.Forms {
} else { } else {
destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, -zoomOffset.Y - zoomSize.Width); destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, -zoomOffset.Y - zoomSize.Width);
} }
zoomAnimator.ChangeDestination(new Rectangle(new Point(-10, -10), new Size(20, 20))); // Change animation to destination "small with the mouse-cursor at the center"
zoomAnimator.QueueDestination(new Rectangle(destinationLocation, zoomSize)); //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(); ret = zoomAnimator.Next();
} }
return ret; return ret;

View file

@ -37,6 +37,23 @@ namespace Greenshot.Helpers {
protected double frames; protected double frames;
protected double currentFrame = 0; protected double currentFrame = 0;
/// <summary>
/// Constructor
/// </summary>
/// <param name="first"></param>
/// <param name="last"></param>
/// <param name="frames"></param>
/// <param name="easingType"></param>
/// <param name="easingMode"></param>
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;
}
/// <summary> /// <summary>
/// The amount of frames /// The amount of frames
/// </summary> /// </summary>
@ -59,12 +76,24 @@ namespace Greenshot.Helpers {
} }
/// <summary> /// <summary>
/// Last animation value /// Last animation value, of this "leg"
/// </summary> /// </summary>
public T Last { public T Last {
get { return last; } get { return last; }
} }
/// <summary>
/// Final animation value, this is including the legs
/// </summary>
public T Final {
get {
if (queue.Count == 0) {
return last;
}
return queue.ToArray()[queue.Count - 1];
}
}
/// <summary> /// <summary>
/// This restarts the current animation and changes the last frame /// This restarts the current animation and changes the last frame
/// </summary> /// </summary>
@ -83,13 +112,14 @@ namespace Greenshot.Helpers {
this.currentFrame = 0; this.currentFrame = 0;
this.frames = frames; this.frames = frames;
this.last = newDestination; this.last = newDestination;
queue.Clear();
} }
/// <summary> /// <summary>
/// Queue the destination, it will be used after the current animation is finished /// Queue the destination, it will be used after the current animation is finished
/// </summary> /// </summary>
/// <param name="queuedDestination"></param> /// <param name="queuedDestination"></param>
public void QueueDestination(T queuedDestination) { public void QueueDestinationLeg(T queuedDestination) {
queue.Enqueue(queuedDestination); queue.Enqueue(queuedDestination);
} }
@ -126,23 +156,6 @@ namespace Greenshot.Helpers {
} }
} }
/// <summary>
/// Constructor
/// </summary>
/// <param name="first"></param>
/// <param name="last"></param>
/// <param name="frames"></param>
/// <param name="easingType"></param>
/// <param name="easingMode"></param>
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;
}
/// <summary> /// <summary>
/// Get the current (previous) frame object /// Get the current (previous) frame object
/// </summary> /// </summary>