add dptr to rotation
svn path=/trunk/KDE/kdelibs/; revision=1036200
This commit is contained in:
parent
cbb1a5e686
commit
84b8265322
@ -26,54 +26,80 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
RotationAnimation::RotationAnimation(qint8 reference, const Qt::Axis &axis, const qreal &angle)
|
class RotationAnimationPrivate {
|
||||||
: m_angle(angle), m_axis(axis), m_reference(reference)
|
public:
|
||||||
|
RotationAnimationPrivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~RotationAnimationPrivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QGraphicsRotation *rotation;
|
||||||
|
qreal angle;
|
||||||
|
Qt::Axis axis;
|
||||||
|
qint8 reference;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
RotationAnimation::RotationAnimation(const qint8 &reference, const Qt::Axis &axis, const qreal &angle)
|
||||||
|
: d(new RotationAnimationPrivate)
|
||||||
{
|
{
|
||||||
|
d->angle = angle;
|
||||||
|
d->axis = axis;
|
||||||
|
d->reference = reference;
|
||||||
|
|
||||||
|
d->rotation = new QGraphicsRotation(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
RotationAnimation::~RotationAnimation()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Axis RotationAnimation::axis() const
|
Qt::Axis RotationAnimation::axis() const
|
||||||
{
|
{
|
||||||
return m_axis;
|
return d->axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotationAnimation::setAxis(const Qt::Axis &axis)
|
void RotationAnimation::setAxis(const Qt::Axis &axis)
|
||||||
{
|
{
|
||||||
m_axis = axis;
|
d->axis = axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint8 RotationAnimation::reference() const
|
qint8 RotationAnimation::reference() const
|
||||||
{
|
{
|
||||||
return m_reference;
|
return d->reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotationAnimation::setReference(const qint8 reference)
|
void RotationAnimation::setReference(const qint8 &reference)
|
||||||
{
|
{
|
||||||
m_reference = reference;
|
d->reference = reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal RotationAnimation::angle() const
|
qreal RotationAnimation::angle() const
|
||||||
{
|
{
|
||||||
return m_angle;
|
return d->angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotationAnimation::setAngle(const qreal &angle)
|
void RotationAnimation::setAngle(const qreal &angle)
|
||||||
{
|
{
|
||||||
m_angle = angle;
|
d->angle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
QGraphicsWidget *m_object = getAnimatedObject();
|
QGraphicsWidget *m_object = getAnimatedObject();
|
||||||
QGraphicsRotation *rotation = new QGraphicsRotation(m_object);
|
|
||||||
|
|
||||||
QVector3D vector(0, 0, 0);
|
QVector3D vector(0, 0, 0);
|
||||||
|
|
||||||
const qreal widgetWidth = m_object->size().width();
|
const qreal widgetWidth = m_object->size().width();
|
||||||
const qreal widgetHeight = m_object->size().height();
|
const qreal widgetHeight = m_object->size().height();
|
||||||
|
|
||||||
if (m_axis == Qt::XAxis) {
|
if (d->axis == Qt::XAxis) {
|
||||||
switch(m_reference) {
|
switch(d->reference) {
|
||||||
case Center:
|
case Center:
|
||||||
vector.setY(widgetHeight/2);
|
vector.setY(widgetHeight/2);
|
||||||
break;
|
break;
|
||||||
@ -84,8 +110,8 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
|||||||
vector.setY(widgetHeight);
|
vector.setY(widgetHeight);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(m_axis == Qt::YAxis) {
|
} else if(d->axis == Qt::YAxis) {
|
||||||
switch(m_reference) {
|
switch(d->reference) {
|
||||||
case Center:
|
case Center:
|
||||||
vector.setX(widgetWidth/2);
|
vector.setX(widgetWidth/2);
|
||||||
break;
|
break;
|
||||||
@ -96,8 +122,8 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
|||||||
vector.setX(widgetWidth);
|
vector.setX(widgetWidth);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if (m_axis == Qt::ZAxis) {
|
}else if (d->axis == Qt::ZAxis) {
|
||||||
switch(m_reference) {
|
switch(d->reference) {
|
||||||
case Center:
|
case Center:
|
||||||
vector.setX(widgetWidth/2);
|
vector.setX(widgetWidth/2);
|
||||||
vector.setY(widgetHeight/2);
|
vector.setY(widgetHeight/2);
|
||||||
@ -125,16 +151,16 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rotation->setOrigin(vector);
|
d->rotation->setOrigin(vector);
|
||||||
rotation->setAxis(m_axis);
|
d->rotation->setAxis(d->axis);
|
||||||
|
|
||||||
QList<QGraphicsTransform *> transformation;
|
QList<QGraphicsTransform *> transformation;
|
||||||
transformation.append(rotation);
|
transformation.append(d->rotation);
|
||||||
m_object->setTransformations(transformation);
|
m_object->setTransformations(transformation);
|
||||||
|
|
||||||
QPropertyAnimation *rotationAnimation= new QPropertyAnimation(rotation,
|
QPropertyAnimation *rotationAnimation= new QPropertyAnimation(d->rotation,
|
||||||
"angle", m_object);
|
"angle", m_object);
|
||||||
rotationAnimation->setEndValue(m_angle);
|
rotationAnimation->setEndValue(d->angle);
|
||||||
rotationAnimation->setDuration(getDuration());
|
rotationAnimation->setDuration(getDuration());
|
||||||
|
|
||||||
return rotationAnimation;
|
return rotationAnimation;
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
namespace Plasma {
|
namespace Plasma {
|
||||||
|
|
||||||
|
class RotationAnimationPrivate;
|
||||||
|
|
||||||
class PLASMA_EXPORT RotationAnimation : public Animation
|
class PLASMA_EXPORT RotationAnimation : public Animation
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -44,7 +46,9 @@ class PLASMA_EXPORT RotationAnimation : public Animation
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RotationAnimation(qint8 reference = Center, const Qt::Axis &axis = Qt::ZAxis, const qreal &angle = 180);
|
RotationAnimation(const qint8 &reference = Center,
|
||||||
|
const Qt::Axis &axis = Qt::ZAxis, const qreal &angle = 180);
|
||||||
|
~RotationAnimation();
|
||||||
|
|
||||||
QPropertyAnimation* render(QObject* parent = 0);
|
QPropertyAnimation* render(QObject* parent = 0);
|
||||||
|
|
||||||
@ -52,14 +56,12 @@ class PLASMA_EXPORT RotationAnimation : public Animation
|
|||||||
void setAxis(const Qt::Axis &axis);
|
void setAxis(const Qt::Axis &axis);
|
||||||
|
|
||||||
qint8 reference() const;
|
qint8 reference() const;
|
||||||
void setReference(qint8 reference);
|
void setReference(const qint8 &reference);
|
||||||
|
|
||||||
qreal angle() const;
|
qreal angle() const;
|
||||||
void setAngle(const qreal &angle);
|
void setAngle(const qreal &angle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal m_angle;
|
RotationAnimationPrivate *const d;
|
||||||
Qt::Axis m_axis;
|
|
||||||
qint8 m_reference;
|
|
||||||
};
|
};
|
||||||
} // Plasma
|
} // Plasma
|
||||||
|
Loading…
Reference in New Issue
Block a user