Added support for animation movement direction combinations (i.e. MoveUp|MoveLeft) to RotationStacked
svn path=/trunk/KDE/kdelibs/; revision=1083639
This commit is contained in:
parent
751e79c666
commit
cb7f6a2f2b
@ -44,47 +44,20 @@ RotationStackedAnimation::~RotationStackedAnimation()
|
|||||||
|
|
||||||
void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
|
void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
|
||||||
{
|
{
|
||||||
m_animDirection = static_cast<MovementDirection>(direction);
|
m_animDirection = direction;
|
||||||
|
|
||||||
QVector3D animDirection(0, 0, 0);
|
QVector3D animDirection(0, 0, 0);
|
||||||
|
|
||||||
switch (m_animDirection) {
|
if ((m_animDirection & MoveUp) == MoveUp) {
|
||||||
case MoveLeft:
|
|
||||||
animDirection.setY(-1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveRight:
|
|
||||||
animDirection.setY(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveAny:
|
|
||||||
case MoveUp:
|
|
||||||
animDirection.setX(1);
|
animDirection.setX(1);
|
||||||
break;
|
} else if ((m_animDirection & MoveDown) == MoveDown) {
|
||||||
|
|
||||||
case MoveDown:
|
|
||||||
animDirection.setX(-1);
|
animDirection.setX(-1);
|
||||||
break;
|
}
|
||||||
|
|
||||||
case MoveUpLeft:
|
if ((m_animDirection & MoveLeft) == MoveLeft) {
|
||||||
animDirection.setX(1);
|
|
||||||
animDirection.setY(-1);
|
animDirection.setY(-1);
|
||||||
break;
|
} else if ((m_animDirection & MoveRight) == MoveRight) {
|
||||||
|
|
||||||
case MoveUpRight:
|
|
||||||
animDirection.setX(1);
|
|
||||||
animDirection.setY(1);
|
animDirection.setY(1);
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveDownLeft:
|
|
||||||
animDirection.setX(-1);
|
|
||||||
animDirection.setY(-1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoveDownRight:
|
|
||||||
animDirection.setX(-1);
|
|
||||||
animDirection.setY(1);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frontRotation->setAxis(animDirection);
|
m_frontRotation->setAxis(animDirection);
|
||||||
@ -95,12 +68,12 @@ void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
|
|||||||
|
|
||||||
qint8 RotationStackedAnimation::movementDirection() const
|
qint8 RotationStackedAnimation::movementDirection() const
|
||||||
{
|
{
|
||||||
return static_cast<qint8>(m_animDirection);
|
return m_animDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotationStackedAnimation::setReference(const qint8 &reference)
|
void RotationStackedAnimation::setReference(const qint8 &reference)
|
||||||
{
|
{
|
||||||
m_reference = reference;
|
m_animReference = reference;
|
||||||
|
|
||||||
if (!targetWidget() || !backWidget()) {
|
if (!targetWidget() || !backWidget()) {
|
||||||
return;
|
return;
|
||||||
@ -111,22 +84,22 @@ void RotationStackedAnimation::setReference(const qint8 &reference)
|
|||||||
QVector3D frontTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
|
QVector3D frontTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
|
||||||
QVector3D backTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
|
QVector3D backTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
|
||||||
|
|
||||||
if ((m_reference & Left) == Left) {
|
if ((m_animReference & Up) == Up) {
|
||||||
frontTransformOrigin.setX(0);
|
|
||||||
backTransformOrigin.setX(0);
|
|
||||||
} else if ((m_reference & Right) == Right) {
|
|
||||||
frontTransformOrigin.setX(transformArea.width());
|
|
||||||
backTransformOrigin.setX(transformArea.width());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((m_reference & Up) == Up) {
|
|
||||||
frontTransformOrigin.setY(0);
|
frontTransformOrigin.setY(0);
|
||||||
backTransformOrigin.setY(0);
|
backTransformOrigin.setY(0);
|
||||||
} else if ((m_reference & Down) == Down) {
|
} else if ((m_animReference & Down) == Down) {
|
||||||
frontTransformOrigin.setY(transformArea.height());
|
frontTransformOrigin.setY(transformArea.height());
|
||||||
backTransformOrigin.setY(transformArea.height());
|
backTransformOrigin.setY(transformArea.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((m_animReference & Left) == Left) {
|
||||||
|
frontTransformOrigin.setX(0);
|
||||||
|
backTransformOrigin.setX(0);
|
||||||
|
} else if ((m_animReference & Right) == Right) {
|
||||||
|
frontTransformOrigin.setX(transformArea.width());
|
||||||
|
backTransformOrigin.setX(transformArea.width());
|
||||||
|
}
|
||||||
|
|
||||||
m_frontRotation->setOrigin(frontTransformOrigin);
|
m_frontRotation->setOrigin(frontTransformOrigin);
|
||||||
m_backRotation->setOrigin(backTransformOrigin);
|
m_backRotation->setOrigin(backTransformOrigin);
|
||||||
|
|
||||||
@ -135,7 +108,7 @@ void RotationStackedAnimation::setReference(const qint8 &reference)
|
|||||||
|
|
||||||
qint8 RotationStackedAnimation::reference() const
|
qint8 RotationStackedAnimation::reference() const
|
||||||
{
|
{
|
||||||
return m_reference;
|
return m_animReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsWidget *RotationStackedAnimation::backWidget()
|
QGraphicsWidget *RotationStackedAnimation::backWidget()
|
||||||
|
@ -55,26 +55,26 @@ public:
|
|||||||
~RotationStackedAnimation();
|
~RotationStackedAnimation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the animation direction
|
* Set the animation movement direction (e.g. MoveAny, MoveUp, MoveDown,
|
||||||
|
* MoveLeft, MoveRight) which can be combined (i.e. MoveUp|MoveLeft).
|
||||||
* @arg direction animation direction
|
* @arg direction animation direction
|
||||||
*/
|
*/
|
||||||
void setMovementDirection(const qint8 &direction);
|
void setMovementDirection(const qint8 &direction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the animation direction
|
* Get the animation movement direction.
|
||||||
*/
|
*/
|
||||||
qint8 movementDirection() const;
|
qint8 movementDirection() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set rotation reference (e.g. Center, Up, Down, Left, Right) can
|
* Set the animation rotation reference (e.g. Center, Up, Down, Left,
|
||||||
* be combined (i.e. Center|Up)
|
* Right) which can be combined (i.e. Center|Up).
|
||||||
* @arg reference The reference
|
* @arg reference animation reference
|
||||||
*/
|
*/
|
||||||
void setReference(const qint8 &reference);
|
void setReference(const qint8 &reference);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotation reference (e.g. Center, Up, Down, Left, Right) can
|
* Get the animation rotation reference.
|
||||||
* be combined (i.e. Center|Up)
|
|
||||||
*/
|
*/
|
||||||
qint8 reference() const;
|
qint8 reference() const;
|
||||||
|
|
||||||
@ -106,10 +106,10 @@ private:
|
|||||||
*/
|
*/
|
||||||
void updateTransformations();
|
void updateTransformations();
|
||||||
|
|
||||||
/** Reference, the default is Center (see \ref Animation::Reference) */
|
/** Animation reference (see \ref Animation::Reference) */
|
||||||
qint8 m_reference;
|
qint8 m_animReference;
|
||||||
/** Animation direction, the default is MoveUp (see \ref Animation::MovementDirection) */
|
/** Animation movement direction (see \ref Animation::MovementDirection) */
|
||||||
MovementDirection m_animDirection;
|
qint8 m_animDirection;
|
||||||
/** Object the animation(s) should act upon. */
|
/** Object the animation(s) should act upon. */
|
||||||
QWeakPointer<QGraphicsWidget> m_backWidget;
|
QWeakPointer<QGraphicsWidget> m_backWidget;
|
||||||
/** Layout where widget would be added */
|
/** Layout where widget would be added */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user