now slide works as expected, important issue to investigate:
updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState) appears to have oldState and NewState swapped svn path=/trunk/KDE/kdelibs/; revision=1058948
This commit is contained in:
parent
ff8e7511c5
commit
9b0eb0538d
@ -28,21 +28,61 @@ namespace Plasma
|
||||
void SlideAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
|
||||
syncProperties();
|
||||
}
|
||||
|
||||
void SlideAnimation::syncProperties()
|
||||
void SlideAnimation::setDistance(qreal distance)
|
||||
{
|
||||
m_animDistance = distance;
|
||||
}
|
||||
|
||||
qreal SlideAnimation::distance() const
|
||||
{
|
||||
return m_animDistance;
|
||||
}
|
||||
|
||||
SlideAnimation::~SlideAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
SlideAnimation::SlideAnimation(QObject *parent,
|
||||
AnimationDirection direction,
|
||||
qreal distance)
|
||||
: Animation(parent)
|
||||
{
|
||||
setMovementDirection(direction);
|
||||
setDistance(distance);
|
||||
}
|
||||
|
||||
void SlideAnimation::setMovementDirection(const qint8 &direction)
|
||||
{
|
||||
m_animDirection = static_cast<Plasma::AnimationDirection>(direction);
|
||||
}
|
||||
|
||||
qint8 SlideAnimation::movementDirection() const
|
||||
{
|
||||
return static_cast<qint8>(m_animDirection);
|
||||
}
|
||||
|
||||
void SlideAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = widgetToAnimate();
|
||||
if (w && state() == QAbstractAnimation::Running) {
|
||||
qreal delta = currentTime / qreal(duration());
|
||||
w->setPos(m_startPos * (1-delta) + (m_target * delta));
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: oldstate and newstate appears to be swapped in the documentation
|
||||
void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
|
||||
{
|
||||
if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) {
|
||||
if (!widgetToAnimate()) {
|
||||
return;
|
||||
}
|
||||
qreal x = widgetToAnimate()->x();
|
||||
qreal y = widgetToAnimate()->y();
|
||||
m_startPos = QPointF(x, y);
|
||||
m_startPos = widgetToAnimate()->pos();
|
||||
|
||||
qreal newX = x;
|
||||
qreal newY = y;
|
||||
qreal newX = m_startPos.x();
|
||||
qreal newY = m_startPos.y();
|
||||
|
||||
kDebug()<<movementDirection();
|
||||
switch (movementDirection()) {
|
||||
@ -90,53 +130,6 @@ void SlideAnimation::syncProperties()
|
||||
|
||||
m_target = QPointF(newX, newY);
|
||||
}
|
||||
|
||||
void SlideAnimation::setDistance(qreal distance)
|
||||
{
|
||||
m_animDistance = distance;
|
||||
syncProperties();
|
||||
}
|
||||
|
||||
qreal SlideAnimation::distance() const
|
||||
{
|
||||
return m_animDistance;
|
||||
}
|
||||
|
||||
SlideAnimation::~SlideAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
SlideAnimation::SlideAnimation(QObject *parent,
|
||||
AnimationDirection direction,
|
||||
qreal distance)
|
||||
: Animation(parent)
|
||||
{
|
||||
setMovementDirection(direction);
|
||||
setDistance(distance);
|
||||
}
|
||||
|
||||
void SlideAnimation::setMovementDirection(const qint8 &direction)
|
||||
{
|
||||
m_animDirection = static_cast<Plasma::AnimationDirection>(direction);
|
||||
syncProperties();
|
||||
}
|
||||
|
||||
qint8 SlideAnimation::movementDirection() const
|
||||
{
|
||||
return static_cast<qint8>(m_animDirection);
|
||||
}
|
||||
|
||||
void SlideAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = widgetToAnimate();
|
||||
if (w) {
|
||||
qreal delta = currentTime / qreal(duration());
|
||||
if (qFuzzyCompare((qreal)1.0, delta) || qFuzzyCompare((qreal)1.0, 1+delta)) {
|
||||
syncProperties();
|
||||
}
|
||||
|
||||
w->setPos(m_startPos * (1-delta) + (m_target * delta));
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -77,8 +77,8 @@ public:
|
||||
|
||||
protected:
|
||||
void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
|
||||
void syncProperties();
|
||||
void updateCurrentTime(int currentTime);
|
||||
void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user