From ed5c03e6b233cc9946a00d7d1cbbb118fc94aa38 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 1 Feb 2010 18:02:53 +0000 Subject: [PATCH] Added support for animation movement direction combinations (i.e. MoveUp|MoveLeft) to Slide svn path=/trunk/KDE/kdelibs/; revision=1083640 --- animations/slide.cpp | 56 +++++++++++++------------------------------- animations/slide_p.h | 2 +- 2 files changed, 17 insertions(+), 41 deletions(-) diff --git a/animations/slide.cpp b/animations/slide.cpp index 7e7c3db2a..309fa3772 100644 --- a/animations/slide.cpp +++ b/animations/slide.cpp @@ -60,12 +60,12 @@ SlideAnimation::SlideAnimation(QObject *parent, void SlideAnimation::setMovementDirection(const qint8 &direction) { - m_animDirection = static_cast(direction); + m_animDirection = direction; } qint8 SlideAnimation::movementDirection() const { - return static_cast(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) { diff --git a/animations/slide_p.h b/animations/slide_p.h index 9787d58a3..17b7cdca7 100644 --- a/animations/slide_p.h +++ b/animations/slide_p.h @@ -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