diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-03-26 07:02:53 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-03-26 07:02:53 (GMT) |
commit | b8952aef84c78949959728674db39eafb19efee7 (patch) | |
tree | a258b882059cf7e749e447e230a56e7a8e17c55d /src | |
parent | 56309fe1461c4ea3ca654e535a525165c28a0f12 (diff) | |
download | Qt-b8952aef84c78949959728674db39eafb19efee7.zip Qt-b8952aef84c78949959728674db39eafb19efee7.tar.gz Qt-b8952aef84c78949959728674db39eafb19efee7.tar.bz2 |
Test and fix order of transform application.
Remove Translate.z since Qt cannot sensibly support it yet.
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem.cpp | 9 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetranslate.cpp | 33 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetranslate_p.h | 4 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 16 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem_p.h | 1 |
5 files changed, 26 insertions, 37 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 048e1a8..611535c 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -89,11 +89,12 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Translate QGraphicsTranslate \since 4.7 - \brief The Translate object provides a way to move an Item without changing its x or y. + \brief The Translate object provides a way to move an Item without changing its x or y properties. The Translate object independent control over position in addition to the Item's x and y properties. - The following example moves the X axis of the Rectangle, relative to its interior point 25, 25: + The following example moves the Y axis of the Rectangles while still allowing the Row element + to lay the items out as if they had not been transformed: \qml Row { Rectangle { @@ -1562,8 +1563,8 @@ int QDeclarativeItemPrivate::transform_count(QDeclarativeListProperty<QGraphicsT void QDeclarativeItemPrivate::transform_append(QDeclarativeListProperty<QGraphicsTransform> *list, QGraphicsTransform *item) { QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object); - if (object) - QGraphicsItemPrivate::get(object)->appendGraphicsTransform(item); + if (object) // QGraphicsItem applies the list in the wrong order, so we prepend. + QGraphicsItemPrivate::get(object)->prependGraphicsTransform(item); } QGraphicsTransform *QDeclarativeItemPrivate::transform_at(QDeclarativeListProperty<QGraphicsTransform> *list, int idx) diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp index dd6ca92..1c96fa4 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp +++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp @@ -50,10 +50,9 @@ class QDeclarativeTranslatePrivate : public QGraphicsTransformPrivate { public: QDeclarativeTranslatePrivate() - : x(0), y(0), z(0) {} + : x(0), y(0) {} qreal x; qreal y; - qreal z; }; /*! @@ -77,7 +76,7 @@ QDeclarativeTranslate::~QDeclarativeTranslate() The translation can be any real number; the default value is 0.0. - \sa y, z + \sa y */ qreal QDeclarativeTranslate::x() const { @@ -100,7 +99,7 @@ void QDeclarativeTranslate::setX(qreal x) The translation can be any real number; the default value is 0.0. - \sa x, z + \sa x */ qreal QDeclarativeTranslate::y() const { @@ -118,35 +117,12 @@ void QDeclarativeTranslate::setY(qreal y) } /*! - \property QDeclarativeTranslate::z - \brief the depth translation. - - The translation can be any real number; the default value is 0.0. - - \sa x, y -*/ -qreal QDeclarativeTranslate::z() const -{ - Q_D(const QDeclarativeTranslate); - return d->z; -} -void QDeclarativeTranslate::setZ(qreal z) -{ - Q_D(QDeclarativeTranslate); - if (d->z == z) - return; - d->z = z; - update(); - emit positionChanged(); -} - -/*! \reimp */ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const { Q_D(const QDeclarativeTranslate); - matrix->translate(d->x, d->y, d->z); + matrix->translate(d->x, d->y, 0); } /*! @@ -155,7 +131,6 @@ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const QDeclarativeTranslate emits this signal when its position changes. \sa QDeclarativeTranslate::x, QDeclarativeTranslate::y - \sa QDeclarativeTranslate::z */ QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetranslate_p.h b/src/declarative/graphicsitems/qdeclarativetranslate_p.h index 54bfc3d..1371f71 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate_p.h +++ b/src/declarative/graphicsitems/qdeclarativetranslate_p.h @@ -58,7 +58,6 @@ class Q_GUI_EXPORT QDeclarativeTranslate : public QGraphicsTransform Q_PROPERTY(qreal x READ x WRITE setX NOTIFY positionChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY positionChanged) - Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY positionChanged) public: QDeclarativeTranslate(QObject *parent = 0); @@ -70,9 +69,6 @@ public: qreal y() const; void setY(qreal); - qreal z() const; - void setZ(qreal); - void applyTo(QMatrix4x4 *matrix) const; Q_SIGNALS: diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b407eef..36203de 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3843,6 +3843,22 @@ void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transf /*! \internal */ +void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t) +{ + if (!transformData) + transformData = new QGraphicsItemPrivate::TransformData; + if (!transformData->graphicsTransforms.contains(t)) + transformData->graphicsTransforms.prepend(t); + + Q_Q(QGraphicsItem); + t->d_func()->setItem(q); + transformData->onlyTransform = false; + dirtySceneTransform = 1; +} + +/*! + \internal +*/ void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t) { if (!transformData) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index b53c545..b6be79d 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -276,6 +276,7 @@ public: virtual void setPosHelper(const QPointF &pos); void setTransformHelper(const QTransform &transform); + void prependGraphicsTransform(QGraphicsTransform *t); void appendGraphicsTransform(QGraphicsTransform *t); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); |