Animation queuing.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2342 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-02 13:08:51 +00:00
commit 7c8b0f5988
2 changed files with 32 additions and 12 deletions

View file

@ -550,7 +550,8 @@ 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(destinationLocation, zoomSize)); zoomAnimator.ChangeDestination(new Rectangle(new Point(-10, -10), new Size(20, 20)));
zoomAnimator.QueueDestination(new Rectangle(destinationLocation, zoomSize));
return zoomAnimator.Next(); return zoomAnimator.Next();
} }

View file

@ -21,6 +21,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Collections.Generic;
namespace Greenshot.Helpers { namespace Greenshot.Helpers {
/// <summary> /// <summary>
@ -32,6 +33,7 @@ namespace Greenshot.Helpers {
protected T first; protected T first;
protected T last; protected T last;
protected T current; protected T current;
protected Queue<T> queue = new Queue<T>();
protected double frames; protected double frames;
protected double currentFrame = 0; protected double currentFrame = 0;
@ -55,6 +57,10 @@ namespace Greenshot.Helpers {
ChangeDestination(last, frames); ChangeDestination(last, frames);
} }
public void QueueDestination(T queuedDestination) {
queue.Enqueue(queuedDestination);
}
public void ChangeDestination(T last, double frames) { public void ChangeDestination(T last, double frames) {
this.first = current; this.first = current;
this.currentFrame = 0; this.currentFrame = 0;
@ -105,9 +111,28 @@ namespace Greenshot.Helpers {
} }
} }
public virtual bool NextFrame {
get {
if (currentFrame < frames) {
currentFrame++;
return true;
}
if (queue.Count > 0) {
this.first = current;
this.last = queue.Dequeue();
this.currentFrame = 0;
return true;
}
return false;
}
}
public virtual bool hasNext { public virtual bool hasNext {
get { get {
return currentFrame < frames; if (currentFrame < frames) {
return true;
}
return queue.Count > 0;
} }
} }
@ -132,9 +157,7 @@ namespace Greenshot.Helpers {
} }
public override Rectangle Next() { public override Rectangle Next() {
if (hasNext) { if (NextFrame) {
currentFrame++;
double easingValue = EasingValue; double easingValue = EasingValue;
double dx = last.X - first.X; double dx = last.X - first.X;
double dy = last.Y - first.Y; double dy = last.Y - first.Y;
@ -166,9 +189,7 @@ namespace Greenshot.Helpers {
: base(first, last, frames, easingType, easingMode) { : base(first, last, frames, easingType, easingMode) {
} }
public override Point Next() { public override Point Next() {
if (hasNext) { if (NextFrame) {
currentFrame++;
double easingValue = EasingValue; double easingValue = EasingValue;
double dx = last.X - first.X; double dx = last.X - first.X;
double dy = last.Y - first.Y; double dy = last.Y - first.Y;
@ -197,9 +218,7 @@ namespace Greenshot.Helpers {
} }
public override Size Next() { public override Size Next() {
if (hasNext) { if (NextFrame) {
currentFrame++;
double easingValue = EasingValue; double easingValue = EasingValue;
double dw = last.Width - first.Width; double dw = last.Width - first.Width;
double dh = last.Height - first.Height; double dh = last.Height - first.Height;