BINARY INCOMPATIBLE CHANGES

* const correctness in Animator
* remove the vestiges of the FrameAppear stuff in Phase we never used
* introduce FastSlide[In|Out]
* put the duration in the hands of the Animator with duration methods

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=765004
This commit is contained in:
Aaron J. Seigo 2008-01-22 23:37:48 +00:00
parent 76747db2d9
commit 0dfb81a617
4 changed files with 48 additions and 29 deletions

View File

@ -36,35 +36,59 @@ Animator::~Animator()
{ {
} }
int Animator::framesPerSecond(Plasma::Phase::Animation animation) int Animator::framesPerSecond(Plasma::Phase::Animation animation) const
{ {
Q_UNUSED(animation) Q_UNUSED(animation)
return 0; return 0;
} }
int Animator::framesPerSecond(Plasma::Phase::Movement movement) int Animator::framesPerSecond(Plasma::Phase::Movement movement) const
{ {
Q_UNUSED(movement) Q_UNUSED(movement)
return 20; return 20;
} }
int Animator::framesPerSecond(Plasma::Phase::ElementAnimation animation) int Animator::framesPerSecond(Plasma::Phase::ElementAnimation animation) const
{ {
Q_UNUSED(animation) Q_UNUSED(animation)
return 0; return 0;
} }
Phase::CurveShape Animator::curve(Plasma::Phase::Animation) int Animator::duration(Plasma::Phase::Animation) const
{
return 200;
}
int Animator::duration(Plasma::Phase::Movement movement) const
{
switch (movement) {
case Phase::FastSlideIn:
case Phase::FastSlideOut:
return 100;
break;
default:
break;
}
return 270;
}
int Animator::duration(Plasma::Phase::ElementAnimation) const
{
return 333;
}
Phase::CurveShape Animator::curve(Plasma::Phase::Animation) const
{ {
return Phase::EaseInOutCurve; return Phase::EaseInOutCurve;
} }
Phase::CurveShape Animator::curve(Plasma::Phase::Movement) Phase::CurveShape Animator::curve(Plasma::Phase::Movement) const
{ {
return Phase::EaseInOutCurve; return Phase::EaseInOutCurve;
} }
Phase::CurveShape Animator::curve(Plasma::Phase::ElementAnimation) Phase::CurveShape Animator::curve(Plasma::Phase::ElementAnimation) const
{ {
return Phase::EaseInOutCurve; return Phase::EaseInOutCurve;
} }
@ -102,13 +126,6 @@ void Animator::activate(qreal frame, QGraphicsItem* item)
Q_UNUSED(item) Q_UNUSED(item)
} }
void Animator::frameAppear(qreal frame, QGraphicsItem* item, const QRegion& drawable)
{
Q_UNUSED(frame)
Q_UNUSED(item)
Q_UNUSED(drawable)
}
void Animator::slideIn(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination) void Animator::slideIn(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination)
{ {
double x = start.x() + (destination.x() - start.x()) * progress; double x = start.x() + (destination.x() - start.x()) * progress;

View File

@ -44,12 +44,15 @@ public:
~Animator(); ~Animator();
// Parameter definitions // Parameter definitions
virtual int framesPerSecond(Plasma::Phase::Animation); virtual int framesPerSecond(Plasma::Phase::Animation) const;
virtual int framesPerSecond(Plasma::Phase::Movement); virtual int framesPerSecond(Plasma::Phase::Movement) const;
virtual int framesPerSecond(Plasma::Phase::ElementAnimation); virtual int framesPerSecond(Plasma::Phase::ElementAnimation) const;
virtual Phase::CurveShape curve(Plasma::Phase::Animation); virtual int duration(Plasma::Phase::Animation) const;
virtual Phase::CurveShape curve(Plasma::Phase::Movement); virtual int duration(Plasma::Phase::Movement) const;
virtual Phase::CurveShape curve(Plasma::Phase::ElementAnimation); virtual int duration(Plasma::Phase::ElementAnimation) const;
virtual Phase::CurveShape curve(Plasma::Phase::Animation) const;
virtual Phase::CurveShape curve(Plasma::Phase::Movement) const;
virtual Phase::CurveShape curve(Plasma::Phase::ElementAnimation) const;
// Element animations // Element animations
virtual QPixmap elementAppear(qreal frame, const QPixmap& pixmap); virtual QPixmap elementAppear(qreal frame, const QPixmap& pixmap);
@ -58,7 +61,6 @@ public:
// Item animations // Item animations
virtual void appear(qreal progress, QGraphicsItem* item); virtual void appear(qreal progress, QGraphicsItem* item);
virtual void disappear(qreal progress, QGraphicsItem* item); virtual void disappear(qreal progress, QGraphicsItem* item);
virtual void frameAppear(qreal progress, QGraphicsItem* item, const QRegion& drawable);
virtual void activate(qreal progress, QGraphicsItem* item); virtual void activate(qreal progress, QGraphicsItem* item);
// Item movements // Item movements

View File

@ -135,9 +135,6 @@ class Phase::Private
case Phase::Activate: case Phase::Activate:
animator->activate(amount, state->item); animator->activate(amount, state->item);
break; break;
case Phase::FrameAppear:
animator->frameAppear(amount, state->item, QRegion()); //FIXME: what -is- the frame region?
break;
} }
} }
@ -145,10 +142,12 @@ class Phase::Private
{ {
switch (state->movement) { switch (state->movement) {
case Phase::SlideIn: case Phase::SlideIn:
case Phase::FastSlideIn:
//kDebug() << "performMovement, SlideIn"; //kDebug() << "performMovement, SlideIn";
animator->slideIn(amount, state->item, state->start, state->destination); animator->slideIn(amount, state->item, state->start, state->destination);
break; break;
case Phase::SlideOut: case Phase::SlideOut:
case Phase::FastSlideOut:
//kDebug() << "performMovement, SlideOut"; //kDebug() << "performMovement, SlideOut";
animator->slideOut(amount, state->item, state->start, state->destination); animator->slideOut(amount, state->item, state->start, state->destination);
break; break;
@ -254,7 +253,7 @@ void Phase::animateItem(QGraphicsItem* item, Animation animation)
//TODO: variance in times based on the value of animation //TODO: variance in times based on the value of animation
state->frames = frames / 3; state->frames = frames / 3;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = 333 / state->frames; state->interval = d->animator->duration(animation) / state->frames;
state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE; state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE;
state->currentInterval = state->interval; state->currentInterval = state->interval;
@ -292,7 +291,7 @@ void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &desti
//TODO: variance in times based on the value of animation //TODO: variance in times based on the value of animation
state->frames = frames / 2; state->frames = frames / 2;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = 240 / state->frames; state->interval = d->animator->duration(movement) / state->frames;
state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE; state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE;
state->currentInterval = state->interval; state->currentInterval = state->interval;
@ -360,7 +359,7 @@ Phase::AnimId Phase::animateElement(QGraphicsItem *item, ElementAnimation animat
//TODO: variance in times based on the value of animation //TODO: variance in times based on the value of animation
state->frames = d->animator->framesPerSecond(animation) / 5; state->frames = d->animator->framesPerSecond(animation) / 5;
state->currentFrame = 0; state->currentFrame = 0;
state->interval = 200 / state->frames; state->interval = d->animator->duration(animation) / state->frames;
state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE; state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE;
state->currentInterval = state->interval; state->currentInterval = state->interval;
state->id = ++d->animId; state->id = ++d->animId;

View File

@ -47,8 +47,7 @@ public:
{ {
Appear = 0 /*<< When some appears in the Corona */, Appear = 0 /*<< When some appears in the Corona */,
Disappear /*<< When something is about to disappear */, Disappear /*<< When something is about to disappear */,
Activate /*<< When something is activated or launched, such as an app icon being clicked */, Activate /*<< When something is activated or launched, such as an app icon being clicked */
FrameAppear /*<< Make a frame appear around an object */
}; };
enum ElementAnimation enum ElementAnimation
@ -68,7 +67,9 @@ public:
enum Movement enum Movement
{ {
SlideIn = 0, SlideIn = 0,
SlideOut SlideOut,
FastSlideIn,
FastSlideOut
}; };
typedef int AnimId; typedef int AnimId;