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 {
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();
}

View file

@ -21,7 +21,8 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
namespace Greenshot.Helpers {
/// <summary>
/// Base class for the animation logic, this only implements Properties and a constructor
@ -32,6 +33,7 @@ namespace Greenshot.Helpers {
protected T first;
protected T last;
protected T current;
protected Queue<T> queue = new Queue<T>();
protected double frames;
protected double currentFrame = 0;
@ -54,6 +56,10 @@ namespace Greenshot.Helpers {
public void ChangeDestination(T last) {
ChangeDestination(last, frames);
}
public void QueueDestination(T queuedDestination) {
queue.Enqueue(queuedDestination);
}
public void ChangeDestination(T last, double frames) {
this.first = current;
@ -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 {
get {
return currentFrame < frames;
if (currentFrame < frames) {
return true;
}
return queue.Count > 0;
}
}
@ -132,9 +157,7 @@ namespace Greenshot.Helpers {
}
public override Rectangle Next() {
if (hasNext) {
currentFrame++;
if (NextFrame) {
double easingValue = EasingValue;
double dx = last.X - first.X;
double dy = last.Y - first.Y;
@ -166,9 +189,7 @@ namespace Greenshot.Helpers {
: base(first, last, frames, easingType, easingMode) {
}
public override Point Next() {
if (hasNext) {
currentFrame++;
if (NextFrame) {
double easingValue = EasingValue;
double dx = last.X - first.X;
double dy = last.Y - first.Y;
@ -197,9 +218,7 @@ namespace Greenshot.Helpers {
}
public override Size Next() {
if (hasNext) {
currentFrame++;
if (NextFrame) {
double easingValue = EasingValue;
double dw = last.Width - first.Width;
double dh = last.Height - first.Height;