summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxtransform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx/qfxtransform.cpp')
-rw-r--r--src/declarative/fx/qfxtransform.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 7b76367..d99af27 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -179,6 +179,20 @@ void QFxAxis::setEndZ(qreal z)
emit updated();
}
+/*!
+ \qmlclass Rotation
+ \brief A Rotation object provides a way to rotate an Item around a point.
+
+ The following example rotates a Rect around its interior point 25, 25:
+ \qml
+ Rect {
+ width: 100; height: 100
+ color: "blue"
+ transform: Rotation { originX: 25; originY: 25; angle: 45}
+ }
+ \endqml
+*/
+
QFxRotation::QFxRotation(QObject *parent)
: QFxTransform(parent), _originX(0), _originY(0), _angle(0), _dirty(true)
{
@@ -188,6 +202,12 @@ QFxRotation::~QFxRotation()
{
}
+/*!
+ \qmlproperty real Rotation::originX
+ \qmlproperty real Rotation::originY
+
+ The point to rotate around.
+*/
qreal QFxRotation::originX() const
{
return _originX;
@@ -210,6 +230,11 @@ void QFxRotation::setOriginY(qreal oy)
update();
}
+/*!
+ \qmlproperty real Rotation::angle
+
+ The angle, in degrees, to rotate.
+*/
qreal QFxRotation::angle() const
{
return _angle;
@@ -217,8 +242,11 @@ qreal QFxRotation::angle() const
void QFxRotation::setAngle(qreal angle)
{
+ if (_angle == angle)
+ return;
_angle = angle;
update();
+ emit angleChanged();
}
bool QFxRotation::isIdentity() const
@@ -244,7 +272,9 @@ QMatrix4x4 QFxRotation::transform() const
if (_dirty) {
_transform = QMatrix4x4();
_dirty = false;
- _transform.rotate(_angle, _originX, _originY);
+ _transform.translate(_originX, _originY);
+ _transform.rotate(_angle, 0, 0, 1);
+ _transform.translate(-_originX, -_originY);
}
return _transform;
}