SlideAnimation: add a new movement direction movement any, it is useful when the user just know where is the finish position of widget like tabbar slide animation
svn path=/trunk/KDE/kdelibs/; revision=1078733
This commit is contained in:
parent
2d2dc8a37a
commit
d42e7f8b7b
@ -82,7 +82,8 @@ public:
|
||||
MoveDown, /**< Move down */
|
||||
MoveDownLeft, /**< Move down and left */
|
||||
MoveLeft, /**< Move left */
|
||||
MoveUpLeft /**< Move up and left */
|
||||
MoveUpLeft, /**< Move up and left */
|
||||
MoveAny /**< Move in any direction*/
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,10 +27,20 @@ namespace Plasma
|
||||
|
||||
void SlideAnimation::setDistance(qreal distance)
|
||||
{
|
||||
m_animDistance = distance;
|
||||
m_animDistance = QPointF(distance, 0.0);
|
||||
}
|
||||
|
||||
qreal SlideAnimation::distance() const
|
||||
{
|
||||
return m_animDistance.x();
|
||||
}
|
||||
|
||||
void SlideAnimation::setDistancePointF(const QPointF &distance)
|
||||
{
|
||||
m_animDistance = distance;
|
||||
}
|
||||
|
||||
QPointF SlideAnimation::distancePointF() const
|
||||
{
|
||||
return m_animDistance;
|
||||
}
|
||||
@ -79,43 +89,50 @@ void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
|
||||
qreal newX = m_startPos.x();
|
||||
qreal newY = m_startPos.y();
|
||||
|
||||
int actualDistance = (direction() == QAbstractAnimation::Forward?distance():-distance());
|
||||
QPointF actualDistance = (direction() == \
|
||||
QAbstractAnimation::Forward ? \
|
||||
distancePointF():-distancePointF());
|
||||
switch (movementDirection()) {
|
||||
case MoveUp:
|
||||
newY -= actualDistance;
|
||||
newY -= actualDistance.x();
|
||||
break;
|
||||
|
||||
case MoveRight:
|
||||
newX += actualDistance;
|
||||
newX += actualDistance.x();
|
||||
break;
|
||||
|
||||
case MoveDown:
|
||||
newY += actualDistance;
|
||||
newY += actualDistance.x();
|
||||
break;
|
||||
|
||||
case MoveLeft:
|
||||
newX -= actualDistance;
|
||||
newX -= actualDistance.x();
|
||||
break;
|
||||
|
||||
case MoveUpRight:
|
||||
newX += actualDistance;
|
||||
newY -= actualDistance;
|
||||
newX += actualDistance.x();
|
||||
newY -= actualDistance.y();
|
||||
break;
|
||||
|
||||
case MoveDownRight:
|
||||
newX += actualDistance;
|
||||
newY += actualDistance;
|
||||
newX += actualDistance.x();
|
||||
newY += actualDistance.y();
|
||||
break;
|
||||
|
||||
case MoveDownLeft:
|
||||
newX -= actualDistance;
|
||||
newY += actualDistance;
|
||||
newX -= actualDistance.x();
|
||||
newY += actualDistance.y();
|
||||
break;
|
||||
|
||||
|
||||
case MoveUpLeft:
|
||||
newX -= actualDistance;
|
||||
newY -= actualDistance;
|
||||
newX -= actualDistance.x();
|
||||
newY -= actualDistance.y();
|
||||
break;
|
||||
|
||||
case MoveAny:
|
||||
newX = actualDistance.x();
|
||||
newY = actualDistance.y();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -44,6 +44,7 @@ class SlideAnimation : public Animation
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qint8 movementDirection READ movementDirection WRITE setMovementDirection)
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
Q_PROPERTY(QPointF distancePointF READ distancePointF WRITE setDistancePointF)
|
||||
|
||||
public:
|
||||
explicit SlideAnimation(QObject *parent = 0, MovementDirection direction = MoveUp, qreal distance = 0);
|
||||
@ -60,6 +61,9 @@ public:
|
||||
*/
|
||||
qreal distance() const;
|
||||
|
||||
void setDistancePointF(const QPointF &distance);
|
||||
QPointF distancePointF() const;
|
||||
|
||||
/**
|
||||
* Set the animation direction
|
||||
* @arg direction animation direction
|
||||
@ -85,7 +89,7 @@ private:
|
||||
* Animation distance: displacement factor for animations where
|
||||
* there is change in the position of animated widget.
|
||||
*/
|
||||
qreal m_animDistance;
|
||||
QPointF m_animDistance;
|
||||
QPointF m_startPos;
|
||||
QPointF m_targetPos;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user