Backport from trunk:
Replaced combined movement direction enumerations (i.e. MoveUpRight) with OR-combinations (i.e. MoveUp|MoveLeft) plus MovementDirection and Reference enumerators are now QFlags (using Q_DECLARE_FLAGS) svn path=/branches/KDE/4.4/kdelibs/; revision=1084111
This commit is contained in:
parent
27a524216f
commit
2a7ab28951
@ -63,28 +63,28 @@ public:
|
||||
/**
|
||||
* Animation movement reference (used by \ref RotationAnimation).
|
||||
*/
|
||||
enum Reference{
|
||||
Center,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
enum ReferenceFlag {
|
||||
Center = 0,
|
||||
Up = 0x1,
|
||||
Down = 0x2,
|
||||
Left = 0x4,
|
||||
Right = 0x8
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(Reference, ReferenceFlag)
|
||||
|
||||
/**
|
||||
* The movement direction of an animation.
|
||||
* Animation movement direction.
|
||||
*/
|
||||
enum MovementDirection {
|
||||
MoveUp = 0, /**< Move up */
|
||||
MoveUpRight, /**< Move up and right */
|
||||
MoveRight, /**< Move right */
|
||||
MoveDownRight, /**< Move down and right */
|
||||
MoveDown, /**< Move down */
|
||||
MoveDownLeft, /**< Move down and left */
|
||||
MoveLeft, /**< Move left */
|
||||
MoveUpLeft /**< Move up and left */
|
||||
enum MovementDirectionFlag {
|
||||
MoveAny = 0,
|
||||
MoveUp = 0x1,
|
||||
MoveRight = 0x2,
|
||||
MoveDown = 0x4,
|
||||
MoveLeft = 0x8
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(MovementDirection, MovementDirectionFlag)
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
|
@ -40,22 +40,22 @@ RotationStackedAnimation::~RotationStackedAnimation()
|
||||
delete m_wLayout.data();
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
|
||||
void RotationStackedAnimation::setMovementDirection(const Animation::MovementDirection &direction)
|
||||
{
|
||||
m_animDirection = static_cast<MovementDirection>(direction);
|
||||
m_animDirection = direction;
|
||||
}
|
||||
|
||||
qint8 RotationStackedAnimation::movementDirection() const
|
||||
Animation::MovementDirection RotationStackedAnimation::movementDirection() const
|
||||
{
|
||||
return static_cast<qint8>(m_animDirection);
|
||||
return m_animDirection;
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::setReference(const qint8 &reference)
|
||||
void RotationStackedAnimation::setReference(const Animation::Reference &reference)
|
||||
{
|
||||
m_reference = reference;
|
||||
}
|
||||
|
||||
qint8 RotationStackedAnimation::reference() const
|
||||
Animation::Reference RotationStackedAnimation::reference() const
|
||||
{
|
||||
return m_reference;
|
||||
}
|
||||
@ -104,11 +104,11 @@ void RotationStackedAnimation::updateState(
|
||||
vector.first = QVector3D(widgetFrontWidth/2, widgetFrontHeight/2, 0);
|
||||
vector.second = QVector3D(widgetBackWidth/2, widgetBackHeight/2, 0);
|
||||
|
||||
if (m_animDirection == MoveLeft || m_animDirection == MoveRight) {
|
||||
if (m_animDirection.testFlag(MoveLeft) || m_animDirection.testFlag(MoveRight)) {
|
||||
m_frontRotation->setAxis(Qt::YAxis);
|
||||
m_backRotation->setAxis(Qt::YAxis);
|
||||
|
||||
if (m_animDirection == MoveLeft) {
|
||||
if (m_animDirection.testFlag(MoveLeft)) {
|
||||
/* TODO: the order way */
|
||||
|
||||
} else {
|
||||
|
@ -43,9 +43,9 @@ namespace Plasma {
|
||||
class RotationStackedAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qint8 movementDirection READ movementDirection WRITE setMovementDirection)
|
||||
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
|
||||
Q_PROPERTY(Reference reference READ reference WRITE setReference)
|
||||
Q_PROPERTY(QGraphicsLayoutItem* layout READ layout)
|
||||
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
|
||||
Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget)
|
||||
|
||||
public:
|
||||
@ -57,25 +57,25 @@ public:
|
||||
* Set the animation direction
|
||||
* @arg direction animation direction
|
||||
*/
|
||||
void setMovementDirection(const qint8 &direction);
|
||||
void setMovementDirection(const Animation::MovementDirection &direction);
|
||||
|
||||
/**
|
||||
* Get the animation direction
|
||||
*/
|
||||
qint8 movementDirection() const;
|
||||
Animation::MovementDirection movementDirection() const;
|
||||
|
||||
/**
|
||||
* Set rotation reference (e.g. Center, Up, Down, Left, Right) can
|
||||
* be combined (i.e. Center|Up)
|
||||
* @arg reference The reference
|
||||
*/
|
||||
void setReference(const qint8 &reference);
|
||||
void setReference(const Animation::Reference &reference);
|
||||
|
||||
/**
|
||||
* Rotation reference (e.g. Center, Up, Down, Left, Right) can
|
||||
* be combined (i.e. Center|Up)
|
||||
*/
|
||||
qint8 reference() const;
|
||||
Animation::Reference reference() const;
|
||||
|
||||
/**
|
||||
* Get the layout where the widgetToAnimate and backWidget are.
|
||||
@ -100,11 +100,11 @@ protected:
|
||||
|
||||
private:
|
||||
/** Reference, the default is Up (see \ref Animation::Reference) */
|
||||
qint8 m_reference;
|
||||
Animation::Reference m_reference;
|
||||
/**
|
||||
* Animation direction: where the animation will move.
|
||||
*/
|
||||
MovementDirection m_animDirection;
|
||||
Animation::MovementDirection m_animDirection;
|
||||
/** Initial rotation angle from front widget */
|
||||
int m_frontStartAngle;
|
||||
/** End value of the rotation angle of the front widget */
|
||||
|
@ -48,14 +48,14 @@ SlideAnimation::SlideAnimation(QObject *parent,
|
||||
setEasingCurve(QEasingCurve::OutCirc);
|
||||
}
|
||||
|
||||
void SlideAnimation::setMovementDirection(const qint8 &direction)
|
||||
void SlideAnimation::setMovementDirection(const Animation::MovementDirection &direction)
|
||||
{
|
||||
m_animDirection = static_cast<MovementDirection>(direction);
|
||||
m_animDirection = direction;
|
||||
}
|
||||
|
||||
qint8 SlideAnimation::movementDirection() const
|
||||
Animation::MovementDirection SlideAnimation::movementDirection() const
|
||||
{
|
||||
return static_cast<qint8>(m_animDirection);
|
||||
return m_animDirection;
|
||||
}
|
||||
|
||||
void SlideAnimation::updateCurrentTime(int currentTime)
|
||||
@ -80,47 +80,28 @@ void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
|
||||
qreal newY = m_startPos.y();
|
||||
|
||||
int actualDistance = (direction() == QAbstractAnimation::Forward?distance():-distance());
|
||||
switch (movementDirection()) {
|
||||
case MoveUp:
|
||||
|
||||
bool moveAnyOnly = true;
|
||||
|
||||
if (m_animDirection.testFlag(MoveUp)) {
|
||||
newY -= actualDistance;
|
||||
break;
|
||||
|
||||
case MoveRight:
|
||||
newX += actualDistance;
|
||||
break;
|
||||
|
||||
case MoveDown:
|
||||
moveAnyOnly = false;
|
||||
} else if (m_animDirection.testFlag(MoveDown)) {
|
||||
newY += actualDistance;
|
||||
break;
|
||||
moveAnyOnly = false;
|
||||
}
|
||||
|
||||
case MoveLeft:
|
||||
newX -= actualDistance;
|
||||
break;
|
||||
|
||||
case MoveUpRight:
|
||||
if (m_animDirection.testFlag(MoveRight)) {
|
||||
newX += actualDistance;
|
||||
newY -= actualDistance;
|
||||
break;
|
||||
|
||||
case MoveDownRight:
|
||||
newX += actualDistance;
|
||||
newY += actualDistance;
|
||||
break;
|
||||
|
||||
case MoveDownLeft:
|
||||
moveAnyOnly = false;
|
||||
} else if (m_animDirection.testFlag(MoveLeft)) {
|
||||
newX -= actualDistance;
|
||||
newY += actualDistance;
|
||||
break;
|
||||
moveAnyOnly = false;
|
||||
}
|
||||
|
||||
|
||||
case MoveUpLeft:
|
||||
newX -= actualDistance;
|
||||
newY -= actualDistance;
|
||||
break;
|
||||
|
||||
default:
|
||||
kDebug()<<"Compound direction is not supported";
|
||||
return;
|
||||
if (moveAnyOnly && m_animDirection.testFlag(MoveAny)) {
|
||||
newX = actualDistance;
|
||||
newY = actualDistance;
|
||||
}
|
||||
|
||||
if (direction() == QAbstractAnimation::Forward) {
|
||||
|
@ -42,8 +42,8 @@ class SlideAnimationPrivate;
|
||||
class SlideAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qint8 movementDirection READ movementDirection WRITE setMovementDirection)
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
|
||||
|
||||
public:
|
||||
explicit SlideAnimation(QObject *parent = 0, MovementDirection direction = MoveUp, qreal distance = 0);
|
||||
@ -64,12 +64,12 @@ public:
|
||||
* Set the animation direction
|
||||
* @arg direction animation direction
|
||||
*/
|
||||
void setMovementDirection(const qint8 &direction);
|
||||
void setMovementDirection(const Animation::MovementDirection &direction);
|
||||
|
||||
/**
|
||||
* Get the animation direction
|
||||
*/
|
||||
qint8 movementDirection() const;
|
||||
Animation::MovementDirection movementDirection() const;
|
||||
|
||||
protected:
|
||||
void updateCurrentTime(int currentTime);
|
||||
@ -79,7 +79,7 @@ private:
|
||||
/**
|
||||
* Animation direction: where the animation will move.
|
||||
*/
|
||||
MovementDirection m_animDirection;
|
||||
Animation::MovementDirection m_animDirection;
|
||||
|
||||
/**
|
||||
* Animation distance: displacement factor for animations where
|
||||
|
Loading…
x
Reference in New Issue
Block a user