Moving rotation related parameters to common location (now it should
be possible to use AbstractAnimation properties to use rotation animation). svn path=/trunk/KDE/kdelibs/; revision=1038337
This commit is contained in:
parent
e802b2d224
commit
a1bf0fd085
@ -88,6 +88,39 @@ bool AbstractAnimation::isVisible() const
|
||||
return d->animVisible;
|
||||
}
|
||||
|
||||
|
||||
Qt::Axis AbstractAnimation::axis() const
|
||||
{
|
||||
return d->axis;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setAxis(const Qt::Axis &axis)
|
||||
{
|
||||
d->axis = axis;
|
||||
}
|
||||
|
||||
qint8 AbstractAnimation::reference() const
|
||||
{
|
||||
return d->reference;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setReference(const qint8 &reference)
|
||||
{
|
||||
d->reference = reference;
|
||||
}
|
||||
|
||||
qreal AbstractAnimation::angle() const
|
||||
{
|
||||
return d->angle;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setAngle(const qreal &angle)
|
||||
{
|
||||
d->angle = angle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //namespace Plasma
|
||||
|
||||
#include <../abstractanimation.moc>
|
||||
|
@ -51,9 +51,26 @@ class PLASMA_EXPORT AbstractAnimation : public QObject
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible)
|
||||
Q_PROPERTY(QGraphicsWidget *widgetToAnimate READ widgetToAnimate WRITE setWidgetToAnimate)
|
||||
/**
|
||||
* TODO: add missing properties (e.g. angle, axis, reference, etc)
|
||||
*/
|
||||
Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis)
|
||||
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
|
||||
Q_PROPERTY(qreal angle READ angle WRITE setAngle)
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/* FIXME: find a better place and name for it. */
|
||||
enum Reference{
|
||||
Center,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
|
||||
AbstractAnimation(QObject *parent = 0);
|
||||
virtual ~AbstractAnimation();
|
||||
|
||||
@ -117,6 +134,42 @@ public:
|
||||
*/
|
||||
bool isVisible() const;
|
||||
|
||||
/**
|
||||
* get animation rotation axis (e.g. YAxis, ZAxis, XAxis)
|
||||
*/
|
||||
Qt::Axis axis() const;
|
||||
|
||||
/**
|
||||
* set animation rotation axis
|
||||
* @arg axis Rotation (e.g. YAxis, ZAxis, XAxis)
|
||||
*/
|
||||
void setAxis(const Qt::Axis &axis);
|
||||
|
||||
/**
|
||||
* Rotation reference (e.g. Center, Up, Down, Left, Right) can
|
||||
* be combined (i.e. Center|Up)
|
||||
*/
|
||||
qint8 reference() const;
|
||||
|
||||
/**
|
||||
* Set rotation reference (e.g. Center, Up, Down, Left, Right) can
|
||||
* be combined (i.e. Center|Up)
|
||||
* @arg reference The reference
|
||||
*/
|
||||
void setReference(const qint8 &reference);
|
||||
|
||||
/**
|
||||
* Animation rotation angle (e.g. 45, 180, etc)
|
||||
*/
|
||||
qreal angle() const;
|
||||
|
||||
/**
|
||||
* Set animation rotation angle (e.g. 45, 180, etc)
|
||||
* @arg angle The angle
|
||||
*/
|
||||
void setAngle(const qreal &angle);
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,9 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
#include "rotation.h"
|
||||
|
||||
/* TODO:
|
||||
* - revise coding style
|
||||
*/
|
||||
#include <QGraphicsRotation>
|
||||
|
||||
namespace Plasma
|
||||
@ -37,18 +40,15 @@ class 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;
|
||||
setAngle(angle);
|
||||
setAxis(axis);
|
||||
setReference(reference);
|
||||
|
||||
d->rotation = new QGraphicsRotation(this);
|
||||
}
|
||||
@ -58,36 +58,6 @@ RotationAnimation::~RotationAnimation()
|
||||
delete d;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
@ -98,8 +68,8 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
const qreal widgetWidth = m_object->size().width();
|
||||
const qreal widgetHeight = m_object->size().height();
|
||||
|
||||
if (d->axis == Qt::XAxis) {
|
||||
switch(d->reference) {
|
||||
if (axis() == Qt::XAxis) {
|
||||
switch (reference()) {
|
||||
case Center:
|
||||
vector.setY(widgetHeight/2);
|
||||
break;
|
||||
@ -110,8 +80,8 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
vector.setY(widgetHeight);
|
||||
break;
|
||||
}
|
||||
} else if(d->axis == Qt::YAxis) {
|
||||
switch(d->reference) {
|
||||
} else if(axis() == Qt::YAxis) {
|
||||
switch (reference()) {
|
||||
case Center:
|
||||
vector.setX(widgetWidth/2);
|
||||
break;
|
||||
@ -122,8 +92,8 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
vector.setX(widgetWidth);
|
||||
break;
|
||||
}
|
||||
}else if (d->axis == Qt::ZAxis) {
|
||||
switch(d->reference) {
|
||||
} else if (axis() == Qt::ZAxis) {
|
||||
switch (reference()) {
|
||||
case Center:
|
||||
vector.setX(widgetWidth/2);
|
||||
vector.setY(widgetHeight/2);
|
||||
@ -152,7 +122,7 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
}
|
||||
|
||||
d->rotation->setOrigin(vector);
|
||||
d->rotation->setAxis(d->axis);
|
||||
d->rotation->setAxis(axis());
|
||||
|
||||
QList<QGraphicsTransform *> transformation;
|
||||
transformation.append(d->rotation);
|
||||
@ -160,7 +130,7 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
|
||||
QPropertyAnimation *rotationAnimation= new QPropertyAnimation(d->rotation,
|
||||
"angle", m_object);
|
||||
rotationAnimation->setEndValue(d->angle);
|
||||
rotationAnimation->setEndValue(angle());
|
||||
rotationAnimation->setDuration(duration());
|
||||
|
||||
return rotationAnimation;
|
||||
|
@ -31,20 +31,6 @@ class RotationAnimationPrivate;
|
||||
|
||||
class PLASMA_EXPORT RotationAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis)
|
||||
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
|
||||
Q_PROPERTY(qreal angle READ angle WRITE setAngle)
|
||||
|
||||
public:
|
||||
enum Reference{
|
||||
Center,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
public:
|
||||
RotationAnimation(const qint8 &reference = Center,
|
||||
const Qt::Axis &axis = Qt::ZAxis, const qreal &angle = 180);
|
||||
@ -52,15 +38,6 @@ class PLASMA_EXPORT RotationAnimation : public Animation
|
||||
|
||||
QPropertyAnimation* render(QObject* parent = 0);
|
||||
|
||||
Qt::Axis axis() const;
|
||||
void setAxis(const Qt::Axis &axis);
|
||||
|
||||
qint8 reference() const;
|
||||
void setReference(const qint8 &reference);
|
||||
|
||||
qreal angle() const;
|
||||
void setAngle(const qreal &angle);
|
||||
|
||||
private:
|
||||
RotationAnimationPrivate *const d;
|
||||
};
|
||||
|
@ -57,6 +57,22 @@ public:
|
||||
*/
|
||||
QEasingCurve::Type easingCurve;
|
||||
|
||||
/**
|
||||
* Animation rotation angle (e.g. 45, 180, etc)
|
||||
*/
|
||||
qreal angle;
|
||||
|
||||
/**
|
||||
* Rotation axis (e.g. X, Y, Z)
|
||||
*/
|
||||
Qt::Axis axis;
|
||||
|
||||
/**
|
||||
* Rotation reference (e.g. Center, Up, Down, Left, Right) can
|
||||
* be combined (i.e. Center|Up)
|
||||
*/
|
||||
qint8 reference;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user