diff --git a/animator.cpp b/animator.cpp index b8b393fa7..67c802ab4 100644 --- a/animator.cpp +++ b/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 diff --git a/animator.h b/animator.h index 20ec5e331..9a3067bb1 100644 --- a/animator.h +++ b/animator.h @@ -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; diff --git a/phase.cpp b/phase.cpp index a1d32f672..3e396b20f 100644 --- a/phase.cpp +++ b/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::iterator it = d->movingItems.find(item); if (it != d->movingItems.end()) { delete it.value(); @@ -237,7 +240,8 @@ void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &desti } MovementState* state = new MovementState; - state->destination=destination; + 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()<performMovement(progress, state); state->currentInterval = state->interval; animationsRemain = true;