make slideIn and slideOut actually work, we needed the start point as well so i added that to the api.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=724244
This commit is contained in:
parent
6747103c38
commit
095b27e53b
16
animator.cpp
16
animator.cpp
@ -109,19 +109,19 @@ void Animator::frameAppear(qreal frame, QGraphicsItem* item, const QRegion& draw
|
||||
Q_UNUSED(drawable)
|
||||
}
|
||||
|
||||
void Animator::slideIn(qreal progress, QGraphicsItem *item, const QPoint &destination)
|
||||
void Animator::slideIn(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination)
|
||||
{
|
||||
//FIXME: rewrite
|
||||
Q_UNUSED(progress);
|
||||
item->translate(-destination.x(), -destination.y());
|
||||
int x = start.x() + (destination.x() - start.x()) * progress;
|
||||
int y = start.y() + (destination.y() - start.y()) * progress;
|
||||
item->setPos(x, y);
|
||||
}
|
||||
|
||||
void Animator::slideOut(qreal progress, QGraphicsItem *item, const QPoint &destination)
|
||||
void Animator::slideOut(qreal progress, QGraphicsItem *item, const QPoint &start, const QPoint &destination)
|
||||
{
|
||||
//FIXME: rewrite
|
||||
Q_UNUSED(progress);
|
||||
//kDebug();
|
||||
item->translate(destination.x(), destination.y());
|
||||
int x = start.x() + (destination.x() - start.x()) * progress;
|
||||
int y = start.y() + (destination.y() - start.y()) * progress;
|
||||
item->setPos(x, y);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
@ -62,8 +62,8 @@ public:
|
||||
virtual void activate(qreal progress, QGraphicsItem* item);
|
||||
|
||||
// Item movements
|
||||
virtual void slideIn(qreal progress, QGraphicsItem* item, const QPoint &destination);
|
||||
virtual void slideOut(qreal progress, QGraphicsItem* item, const QPoint &destination);
|
||||
virtual void slideIn(qreal progress, QGraphicsItem* item, const QPoint &start, const QPoint &destination);
|
||||
virtual void slideOut(qreal progress, QGraphicsItem* item, const QPoint &start, const QPoint &destination);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
11
phase.cpp
11
phase.cpp
@ -66,6 +66,7 @@ struct MovementState
|
||||
int currentInterval;
|
||||
int frames;
|
||||
int currentFrame;
|
||||
QPoint start;
|
||||
QPoint destination;
|
||||
};
|
||||
|
||||
@ -113,10 +114,12 @@ class Phase::Private
|
||||
{
|
||||
switch (state->movement) {
|
||||
case Phase::SlideIn:
|
||||
animator->slideIn(amount, state->item, state->destination);
|
||||
kDebug() << "performMovement, SlideIn";
|
||||
animator->slideIn(amount, state->item, state->start, state->destination);
|
||||
break;
|
||||
case Phase::SlideOut:
|
||||
animator->slideOut(amount, state->item, state->destination);
|
||||
kDebug() << "performMovement, SlideOut";
|
||||
animator->slideOut(amount, state->item, state->start, state->destination);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -222,7 +225,7 @@ void Phase::animateItem(QGraphicsItem* item, Animation animation)
|
||||
|
||||
void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination)
|
||||
{
|
||||
//kDebug();
|
||||
kDebug();
|
||||
QMap<QGraphicsItem*, MovementState*>::iterator it = d->movingItems.find(item);
|
||||
if (it != d->movingItems.end()) {
|
||||
delete it.value();
|
||||
@ -238,6 +241,7 @@ void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &desti
|
||||
|
||||
MovementState* state = new MovementState;
|
||||
state->destination = destination;
|
||||
state->start = item->pos().toPoint();
|
||||
state->item = item;
|
||||
state->movement = movement;
|
||||
state->curve = d->animator->curve(movement);
|
||||
@ -389,7 +393,6 @@ void Phase::timerEvent(QTimerEvent *event)
|
||||
qreal progress = state->frames;
|
||||
progress = state->currentFrame / progress;
|
||||
progress = qMin(1.0, qMax(0.0, progress));
|
||||
//kDebug()<<progress;
|
||||
d->performMovement(progress, state);
|
||||
state->currentInterval = state->interval;
|
||||
animationsRemain = true;
|
||||
|
Loading…
Reference in New Issue
Block a user