Added support for animation movement direction combinations (i.e. MoveUp|MoveLeft) to Slide

svn path=/trunk/KDE/kdelibs/; revision=1083640
This commit is contained in:
Bruno de Oliveira Abinader 2010-02-01 18:02:53 +00:00
parent cb7f6a2f2b
commit ed5c03e6b2
2 changed files with 17 additions and 41 deletions

View File

@ -60,12 +60,12 @@ SlideAnimation::SlideAnimation(QObject *parent,
void SlideAnimation::setMovementDirection(const qint8 &direction)
{
m_animDirection = static_cast<MovementDirection>(direction);
m_animDirection = direction;
}
qint8 SlideAnimation::movementDirection() const
{
return static_cast<qint8>(m_animDirection);
return m_animDirection;
}
void SlideAnimation::updateCurrentTime(int currentTime)
@ -92,52 +92,28 @@ void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
QPointF actualDistance = (direction() == \
QAbstractAnimation::Forward ? \
distancePointF():-distancePointF());
switch (movementDirection()) {
case MoveUp:
bool moveAnyOnly = true;
if ((m_animDirection & MoveUp) == MoveUp) {
newY -= actualDistance.x();
break;
case MoveRight:
newX += actualDistance.x();
break;
case MoveDown:
moveAnyOnly = false;
} else if ((m_animDirection & MoveDown) == MoveDown) {
newY += actualDistance.x();
break;
moveAnyOnly = false;
}
case MoveLeft:
newX -= actualDistance.x();
break;
case MoveUpRight:
if ((m_animDirection & MoveRight) == MoveRight) {
newX += actualDistance.x();
newY -= actualDistance.y();
break;
case MoveDownRight:
newX += actualDistance.x();
newY += actualDistance.y();
break;
case MoveDownLeft:
moveAnyOnly = false;
} else if ((m_animDirection & MoveLeft) == MoveLeft) {
newX -= actualDistance.x();
newY += actualDistance.y();
break;
moveAnyOnly = false;
}
case MoveUpLeft:
newX -= actualDistance.x();
newY -= actualDistance.y();
break;
case MoveAny:
if (moveAnyOnly && (m_animDirection & MoveAny) == MoveAny) {
newX = actualDistance.x();
newY = actualDistance.y();
break;
default:
kDebug()<<"Compound direction is not supported";
return;
}
if (direction() == QAbstractAnimation::Forward) {

View File

@ -83,7 +83,7 @@ private:
/**
* Animation direction: where the animation will move.
*/
MovementDirection m_animDirection;
qint8 m_animDirection;
/**
* Animation distance: displacement factor for animations where