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:
parent
cb7f6a2f2b
commit
ed5c03e6b2
|
@ -60,12 +60,12 @@ SlideAnimation::SlideAnimation(QObject *parent,
|
||||||
|
|
||||||
void SlideAnimation::setMovementDirection(const qint8 &direction)
|
void SlideAnimation::setMovementDirection(const qint8 &direction)
|
||||||
{
|
{
|
||||||
m_animDirection = static_cast<MovementDirection>(direction);
|
m_animDirection = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint8 SlideAnimation::movementDirection() const
|
qint8 SlideAnimation::movementDirection() const
|
||||||
{
|
{
|
||||||
return static_cast<qint8>(m_animDirection);
|
return m_animDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideAnimation::updateCurrentTime(int currentTime)
|
void SlideAnimation::updateCurrentTime(int currentTime)
|
||||||
|
@ -92,52 +92,28 @@ void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
|
||||||
QPointF actualDistance = (direction() == \
|
QPointF actualDistance = (direction() == \
|
||||||
QAbstractAnimation::Forward ? \
|
QAbstractAnimation::Forward ? \
|
||||||
distancePointF():-distancePointF());
|
distancePointF():-distancePointF());
|
||||||
switch (movementDirection()) {
|
|
||||||
case MoveUp:
|
bool moveAnyOnly = true;
|
||||||
|
|
||||||
|
if ((m_animDirection & MoveUp) == MoveUp) {
|
||||||
newY -= actualDistance.x();
|
newY -= actualDistance.x();
|
||||||
break;
|
moveAnyOnly = false;
|
||||||
|
} else if ((m_animDirection & MoveDown) == MoveDown) {
|
||||||
case MoveRight:
|
|
||||||
newX += actualDistance.x();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveDown:
|
|
||||||
newY += actualDistance.x();
|
newY += actualDistance.x();
|
||||||
break;
|
moveAnyOnly = false;
|
||||||
|
}
|
||||||
|
|
||||||
case MoveLeft:
|
if ((m_animDirection & MoveRight) == MoveRight) {
|
||||||
newX -= actualDistance.x();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveUpRight:
|
|
||||||
newX += actualDistance.x();
|
newX += actualDistance.x();
|
||||||
newY -= actualDistance.y();
|
moveAnyOnly = false;
|
||||||
break;
|
} else if ((m_animDirection & MoveLeft) == MoveLeft) {
|
||||||
|
|
||||||
case MoveDownRight:
|
|
||||||
newX += actualDistance.x();
|
|
||||||
newY += actualDistance.y();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveDownLeft:
|
|
||||||
newX -= actualDistance.x();
|
newX -= actualDistance.x();
|
||||||
newY += actualDistance.y();
|
moveAnyOnly = false;
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
if (moveAnyOnly && (m_animDirection & MoveAny) == MoveAny) {
|
||||||
case MoveUpLeft:
|
|
||||||
newX -= actualDistance.x();
|
|
||||||
newY -= actualDistance.y();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveAny:
|
|
||||||
newX = actualDistance.x();
|
newX = actualDistance.x();
|
||||||
newY = actualDistance.y();
|
newY = actualDistance.y();
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
kDebug()<<"Compound direction is not supported";
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction() == QAbstractAnimation::Forward) {
|
if (direction() == QAbstractAnimation::Forward) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* Animation direction: where the animation will move.
|
* Animation direction: where the animation will move.
|
||||||
*/
|
*/
|
||||||
MovementDirection m_animDirection;
|
qint8 m_animDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation distance: displacement factor for animations where
|
* Animation distance: displacement factor for animations where
|
||||||
|
|
Loading…
Reference in New Issue
Block a user