diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-05-19 05:27:44 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-05-19 05:27:44 (GMT) |
commit | da5cb2883e2b0e4a52a0aecba2c82808e64668f8 (patch) | |
tree | 9e1506f7f2b9e5318f5025147acfe1f8de9c65f1 | |
parent | f9aa68b172ddcaa63e5a1bc4d91649d0734d3b15 (diff) | |
download | Qt-da5cb2883e2b0e4a52a0aecba2c82808e64668f8.zip Qt-da5cb2883e2b0e4a52a0aecba2c82808e64668f8.tar.gz Qt-da5cb2883e2b0e4a52a0aecba2c82808e64668f8.tar.bz2 |
Docs and minor fixes for the Rotation element.
-rw-r--r-- | doc/src/declarative/elements.qdoc | 1 | ||||
-rw-r--r-- | examples/declarative/dial/DialLibrary/Dial.qml | 34 | ||||
-rw-r--r-- | src/declarative/fx/qfxtransform.cpp | 28 | ||||
-rw-r--r-- | src/declarative/fx/qfxtransform.h | 5 |
4 files changed, 50 insertions, 18 deletions
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 976e2f1..3298699 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -140,6 +140,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list +\o \l Rotation \o \l Squish \o \l Rotation3D \endlist diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml index 2e214a8..e3fd382 100644 --- a/examples/declarative/dial/DialLibrary/Dial.qml +++ b/examples/declarative/dial/DialLibrary/Dial.qml @@ -4,26 +4,26 @@ Item { width: 210; height: 210 Image { id: Background; source: "background.svg" } - Item { - x: 104; y: 102 - rotation: Needle.rotation - Image { - source: "needle_shadow.svg" - x: -104; y: -102 + + Image { + source: "needle_shadow.svg" + transform: Rotation { + originX: 104; originY: 102 + angle: NeedleRotation.angle } } - Item { + Image { id: Needle - x: 102; y: 98 - rotation: -130 - rotation: Follow { - spring: 1.4 - damping: .15 - source: Math.min(Math.max(-130, value*2.2 - 130), 133) - } - Image { - source: "needle.svg" - x: -102; y: -98 + source: "needle.svg" + transform: Rotation { + id: NeedleRotation + originX: 102; originY: 98 + angle: -130 + angle: Follow { + spring: 1.4 + damping: .15 + source: Math.min(Math.max(-130, value*2.2 - 130), 133) + } } } Image { source: "overlay.svg" } diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index 7b76367..bc59e0a 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 diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h index a3a1a83..2e17ed5 100644 --- a/src/declarative/fx/qfxtransform.h +++ b/src/declarative/fx/qfxtransform.h @@ -115,7 +115,7 @@ class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform Q_PROPERTY(qreal originX READ originX WRITE setOriginX) Q_PROPERTY(qreal originY READ originY WRITE setOriginY) - Q_PROPERTY(qreal angle READ angle WRITE setAngle) + Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged()) public: QFxRotation(QObject *parent=0); ~QFxRotation(); @@ -132,6 +132,9 @@ public: virtual bool isIdentity() const; virtual QSimpleCanvas::Matrix transform() const; +Q_SIGNALS: + void angleChanged(); + private Q_SLOTS: void update(); private: |