diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-26 01:37:00 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-26 01:37:00 (GMT) |
commit | 133b1e641ba9245fe86feb9fc17f9906dee4d74f (patch) | |
tree | f03bf1d1e5aeb331c4c93c86b5087f6fba7abe9e | |
parent | 2b0cf3b6a2f1c49f40d6f50b4d24bdd87a4807fa (diff) | |
parent | 4fbd2ad6c90fa4946595c715dedf712d77350fb8 (diff) | |
download | Qt-133b1e641ba9245fe86feb9fc17f9906dee4d74f.zip Qt-133b1e641ba9245fe86feb9fc17f9906dee4d74f.tar.gz Qt-133b1e641ba9245fe86feb9fc17f9906dee4d74f.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | doc/src/declarative/pics/3d-rotation-axis.png | bin | 14304 -> 11078 bytes | |||
-rw-r--r-- | doc/src/declarative/pics/axisrotation.png | bin | 3425 -> 8891 bytes | |||
-rw-r--r-- | doc/src/snippets/declarative/rotation.qml | 16 | ||||
-rw-r--r-- | examples/declarative/follow/tvtennis.qml (renamed from examples/declarative/follow/pong.qml) | 0 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 37 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect.cpp | 7 |
6 files changed, 36 insertions, 24 deletions
diff --git a/doc/src/declarative/pics/3d-rotation-axis.png b/doc/src/declarative/pics/3d-rotation-axis.png Binary files differindex 1b17261..b940215 100644 --- a/doc/src/declarative/pics/3d-rotation-axis.png +++ b/doc/src/declarative/pics/3d-rotation-axis.png diff --git a/doc/src/declarative/pics/axisrotation.png b/doc/src/declarative/pics/axisrotation.png Binary files differindex 409a9e9..4cddcdf 100644 --- a/doc/src/declarative/pics/axisrotation.png +++ b/doc/src/declarative/pics/axisrotation.png diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/declarative/rotation.qml index aaaebee..4a67dcb 100644 --- a/doc/src/snippets/declarative/rotation.qml +++ b/doc/src/snippets/declarative/rotation.qml @@ -4,25 +4,29 @@ Rectangle { width: 360; height: 80 color: "white" //! [0] - HorizontalLayout { - margin: 10 + Row { + x: 10; y: 10 spacing: 10 Image { source: "pics/qt.png" } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0 angle: 18 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } + smooth: true } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0 angle: 36 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } + smooth: true } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0; angle: 54 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } + smooth: true } Image { source: "pics/qt.png" - transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0; angle: 72 } + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } + smooth: true } } //! [0] diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/tvtennis.qml index d39e913..d39e913 100644 --- a/examples/declarative/follow/pong.qml +++ b/examples/declarative/follow/tvtennis.qml diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 317a284..b82a38d 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -79,15 +79,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) #include "qfxeffects.cpp" /*! - \qmlclass Transform - \brief A transformation. -*/ - -/*! \qmlclass Scale - \brief A Scale object provides a way to scale an Item. + \brief The Scale object provides a way to scale an Item. - The scale object gives more control over scaling than using Item's scale property. Specifically, + The Scale object gives more control over scaling than using Item's scale property. Specifically, it allows a different scale for the x and y axes, and allows the scale to be relative to an arbitrary point. @@ -105,13 +100,14 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) \qmlproperty real Scale::origin.x \qmlproperty real Scale::origin.y - The origin point for the scale. The scale will be relative to this point. + The point that the item is scaled from (i.e., the point that stays fixed relative to the parent as + the rest of the item grows). By default the origin is 0, 0. */ /*! \qmlproperty real Scale::xScale - The scaling factor for the X axis. + The scaling factor for the X axis. */ /*! @@ -122,7 +118,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) /*! \qmlclass Rotation - \brief A Rotation object provides a way to rotate an Item around a point using an axis in 3D space. + \brief The Rotation object provides a way to rotate an Item. + + The Rotation object gives more control over rotation than using Item's rotation property. + Specifically, it allows (z axis) rotation to be relative to an arbitrary point. The following example rotates a Rectangle around its interior point 25, 25: \qml @@ -133,7 +132,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) } \endqml - Here is an example of various rotations applied to an \l Image. + Rotation also provides a way to specify 3D-like rotations for Items. For these types of + rotations you must specify the axis to rotate around in addition to the origin point. + + The following example shows various 3D-like rotations applied to an \l Image. \snippet doc/src/snippets/declarative/rotation.qml 0 \image axisrotation.png @@ -143,7 +145,8 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) \qmlproperty real Rotation::origin.x \qmlproperty real Rotation::origin.y - The point to rotate around. + The origin point of the rotation (i.e., the point that stays fixed relative to the parent as + the rest of the item rotates). By default the origin is 0, 0. */ /*! @@ -151,16 +154,18 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) \qmlproperty real Rotation::axis.y \qmlproperty real Rotation::axis.z - A rotation axis is specified by a vector in 3D space By default the vector defines a rotation around the z-Axis. + The axis to rotate around. For simple (2D) rotation around a point, you do not need to specify an axis, + as the default axis is the z axis (\c{ axis { x: 0; y: 0; z: 0 } }). - \image 3d-rotation-axis.png + For a typical 3D-like rotation you will usually specify both the origin and the axis. + \image 3d-rotation-axis.png */ /*! \qmlproperty real Rotation::angle - The angle, in degrees, to rotate. + The angle to rotate, in degrees clockwise. */ @@ -2113,7 +2118,7 @@ void QFxItem::setBaselineOffset(qreal offset) /*! \qmlproperty real Item::rotation - This property holds the rotation of the item in degrees. + This property holds the rotation of the item in degrees clockwise. This specifies how many degrees to rotate the item around its transformOrigin. The default rotation is 0 degrees (i.e. not rotated at all). diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index f35fe3d..d4207a6 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -43,6 +43,7 @@ #include "qfxrect_p.h" #include <QPainter> +#include <QtCore/qmath.h> QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Pen,QFxPen) @@ -338,7 +339,8 @@ void QFxRect::generateRoundedRect() Q_D(QFxRect); if (d->rectImage.isNull()) { const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - d->rectImage = QPixmap(d->radius*2 + 3 + pw*2, d->radius*2 + 3 + pw*2); + const int radius = qCeil(d->radius); //ensure odd numbered width/height so we get 1-pixel center + d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); d->rectImage.fill(Qt::transparent); QPainter p(&(d->rectImage)); p.setRenderHint(QPainter::Antialiasing); @@ -361,7 +363,7 @@ void QFxRect::generateBorderedRect() Q_D(QFxRect); if (d->rectImage.isNull()) { const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - d->rectImage = QPixmap(d->getPen()->width()*2 + 3 + pw*2, d->getPen()->width()*2 + 3 + pw*2); + d->rectImage = QPixmap(pw*2 + 3, pw*2 + 3); d->rectImage.fill(Qt::transparent); QPainter p(&(d->rectImage)); p.setRenderHint(QPainter::Antialiasing); @@ -439,6 +441,7 @@ void QFxRect::drawRect(QPainter &p) QMargins margins(xOffset, yOffset, xOffset, yOffset); QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules); if (d->smooth) { |