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)
|
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
|
int x = start.x() + (destination.x() - start.x()) * progress;
|
||||||
Q_UNUSED(progress);
|
int y = start.y() + (destination.y() - start.y()) * progress;
|
||||||
item->translate(-destination.x(), -destination.y());
|
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();
|
//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
|
} // Plasma namespace
|
||||||
|
@ -62,8 +62,8 @@ public:
|
|||||||
virtual void activate(qreal progress, QGraphicsItem* item);
|
virtual void activate(qreal progress, QGraphicsItem* item);
|
||||||
|
|
||||||
// Item movements
|
// Item movements
|
||||||
virtual void slideIn(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 &destination);
|
virtual void slideOut(qreal progress, QGraphicsItem* item, const QPoint &start, const QPoint &destination);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
13
phase.cpp
13
phase.cpp
@ -66,6 +66,7 @@ struct MovementState
|
|||||||
int currentInterval;
|
int currentInterval;
|
||||||
int frames;
|
int frames;
|
||||||
int currentFrame;
|
int currentFrame;
|
||||||
|
QPoint start;
|
||||||
QPoint destination;
|
QPoint destination;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,10 +114,12 @@ class Phase::Private
|
|||||||
{
|
{
|
||||||
switch (state->movement) {
|
switch (state->movement) {
|
||||||
case Phase::SlideIn:
|
case Phase::SlideIn:
|
||||||
animator->slideIn(amount, state->item, state->destination);
|
kDebug() << "performMovement, SlideIn";
|
||||||
|
animator->slideIn(amount, state->item, state->start, state->destination);
|
||||||
break;
|
break;
|
||||||
case Phase::SlideOut:
|
case Phase::SlideOut:
|
||||||
animator->slideOut(amount, state->item, state->destination);
|
kDebug() << "performMovement, SlideOut";
|
||||||
|
animator->slideOut(amount, state->item, state->start, state->destination);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +225,7 @@ void Phase::animateItem(QGraphicsItem* item, Animation animation)
|
|||||||
|
|
||||||
void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination)
|
void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination)
|
||||||
{
|
{
|
||||||
//kDebug();
|
kDebug();
|
||||||
QMap<QGraphicsItem*, MovementState*>::iterator it = d->movingItems.find(item);
|
QMap<QGraphicsItem*, MovementState*>::iterator it = d->movingItems.find(item);
|
||||||
if (it != d->movingItems.end()) {
|
if (it != d->movingItems.end()) {
|
||||||
delete it.value();
|
delete it.value();
|
||||||
@ -237,7 +240,8 @@ void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &desti
|
|||||||
}
|
}
|
||||||
|
|
||||||
MovementState* state = new MovementState;
|
MovementState* state = new MovementState;
|
||||||
state->destination=destination;
|
state->destination = destination;
|
||||||
|
state->start = item->pos().toPoint();
|
||||||
state->item = item;
|
state->item = item;
|
||||||
state->movement = movement;
|
state->movement = movement;
|
||||||
state->curve = d->animator->curve(movement);
|
state->curve = d->animator->curve(movement);
|
||||||
@ -389,7 +393,6 @@ void Phase::timerEvent(QTimerEvent *event)
|
|||||||
qreal progress = state->frames;
|
qreal progress = state->frames;
|
||||||
progress = state->currentFrame / progress;
|
progress = state->currentFrame / progress;
|
||||||
progress = qMin(1.0, qMax(0.0, progress));
|
progress = qMin(1.0, qMax(0.0, progress));
|
||||||
//kDebug()<<progress;
|
|
||||||
d->performMovement(progress, state);
|
d->performMovement(progress, state);
|
||||||
state->currentInterval = state->interval;
|
state->currentInterval = state->interval;
|
||||||
animationsRemain = true;
|
animationsRemain = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user