port rotationanimation to new animation design: remove render and qpropertyanimation
svn path=/trunk/KDE/kdelibs/; revision=1058636
This commit is contained in:
parent
d6ce82052f
commit
61adef1780
@ -51,19 +51,15 @@ public:
|
||||
* be combined (i.e. Center|Up)
|
||||
*/
|
||||
qint8 reference;
|
||||
|
||||
QWeakPointer<QPropertyAnimation> animation;
|
||||
|
||||
|
||||
};
|
||||
|
||||
void RotationAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
if (d->animation.data()) {
|
||||
delete d->animation.data();
|
||||
d->animation.clear();
|
||||
if(widget == widgetToAnimate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
}
|
||||
|
||||
RotationAnimation::RotationAnimation(QObject *parent,
|
||||
@ -84,11 +80,44 @@ RotationAnimation::~RotationAnimation()
|
||||
delete d;
|
||||
}
|
||||
|
||||
QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
Qt::Axis RotationAnimation::axis() const
|
||||
{
|
||||
return d->axis;
|
||||
}
|
||||
|
||||
void RotationAnimation::setAxis(const Qt::Axis &axis)
|
||||
{
|
||||
d->axis = axis;
|
||||
}
|
||||
|
||||
qint8 RotationAnimation::reference() const
|
||||
{
|
||||
return d->reference;
|
||||
}
|
||||
|
||||
void RotationAnimation::setReference(const qint8 &reference)
|
||||
{
|
||||
d->reference = reference;
|
||||
}
|
||||
|
||||
qreal RotationAnimation::angle() const
|
||||
{
|
||||
return d->angle;
|
||||
}
|
||||
|
||||
void RotationAnimation::setAngle(const qreal &angle)
|
||||
{
|
||||
d->angle = angle;
|
||||
}
|
||||
|
||||
void RotationAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
QGraphicsWidget *m_object = widgetToAnimate();
|
||||
|
||||
if (!m_object) {
|
||||
return;
|
||||
}
|
||||
|
||||
QVector3D vector(0, 0, 0);
|
||||
|
||||
const qreal widgetWidth = m_object->size().width();
|
||||
@ -156,47 +185,21 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
transformation.append(d->rotation);
|
||||
m_object->setTransformations(transformation);
|
||||
|
||||
QPropertyAnimation *rotationAnimation = d->animation.data();
|
||||
if (!rotationAnimation) {
|
||||
rotationAnimation = new QPropertyAnimation(d->rotation, "angle", m_object);
|
||||
d->animation = rotationAnimation;
|
||||
if ((oldState == Stopped) && (newState == Running)) {
|
||||
d->rotation->setAngle(direction() == Forward ? 0 : angle());
|
||||
} else if (newState == Stopped) {
|
||||
d->rotation->setAngle(direction() == Forward ? angle() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
rotationAnimation->setStartValue(0);
|
||||
rotationAnimation->setEndValue(angle());
|
||||
rotationAnimation->setDuration(duration());
|
||||
|
||||
return rotationAnimation;
|
||||
}
|
||||
|
||||
Qt::Axis RotationAnimation::axis() const
|
||||
void RotationAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
return d->axis;
|
||||
QGraphicsWidget *w = widgetToAnimate();
|
||||
if (w) {
|
||||
qreal delta = currentTime / qreal(duration());
|
||||
delta = angle() * delta;
|
||||
d->rotation->setAngle(delta);
|
||||
}
|
||||
|
||||
void RotationAnimation::setAxis(const Qt::Axis &axis)
|
||||
{
|
||||
d->axis = axis;
|
||||
}
|
||||
|
||||
qint8 RotationAnimation::reference() const
|
||||
{
|
||||
return d->reference;
|
||||
}
|
||||
|
||||
void RotationAnimation::setReference(const qint8 &reference)
|
||||
{
|
||||
d->reference = reference;
|
||||
}
|
||||
|
||||
qreal RotationAnimation::angle() const
|
||||
{
|
||||
return d->angle;
|
||||
}
|
||||
|
||||
void RotationAnimation::setAngle(const qreal &angle)
|
||||
{
|
||||
d->angle = angle;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,6 +87,10 @@ public:
|
||||
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
protected:
|
||||
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||
void updateCurrentTime(int currentTime);
|
||||
|
||||
private:
|
||||
RotationAnimationPrivate *const d;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user