diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-02-25 00:07:11 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-02-25 07:09:05 (GMT) |
commit | e6c85641ddc6068b1d50a52b95b136f366cad15a (patch) | |
tree | 979ff3f3afbfb742e557d05275759898966ad41c /src | |
parent | c8823023db4a280f3d12c983451a05f8da3780dd (diff) | |
download | Qt-e6c85641ddc6068b1d50a52b95b136f366cad15a.zip Qt-e6c85641ddc6068b1d50a52b95b136f366cad15a.tar.gz Qt-e6c85641ddc6068b1d50a52b95b136f366cad15a.tar.bz2 |
Handle smooth reparenting where the item being reparented has a complex
transform.
Fixes pathview <-> details transition in flickr demo.
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/util/qdeclarativestateoperations.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 6001a84..98edf85 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -80,7 +80,7 @@ void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, Q //### for backwards direction, can we just restore original x, y, scale, rotation Q_Q(QDeclarativeParentChange); bool ok; - const QTransform &transform = target->itemTransform(targetParent, &ok); + const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok); if (transform.type() >= QTransform::TxShear || !ok) { qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under complex transform"); ok = false; @@ -111,8 +111,9 @@ void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, Q } } - qreal xt = transform.dx(); - qreal yt = transform.dy(); + const QPointF &point = transform.map(QPointF(target->x(),target->y())); + qreal x = point.x(); + qreal y = point.y(); if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { qreal tempxt = target->transformOriginPoint().x(); qreal tempyt = target->transformOriginPoint().y(); @@ -121,18 +122,18 @@ void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, Q t.rotate(rotation); t.scale(scale, scale); t.translate(tempxt, tempyt); - QPointF offset = t.map(QPointF(0,0)); - xt += offset.x(); - yt += offset.y(); + const QPointF &offset = t.map(QPointF(0,0)); + x += offset.x(); + y += offset.y(); } target->setParentItem(targetParent); if (ok) { - //qDebug() << xt << yt << rotation << scale; - target->setX(xt); - target->setY(yt); - target->setRotation(rotation); - target->setScale(scale); + //qDebug() << x << y << rotation << scale; + target->setX(x); + target->setY(y); + target->setRotation(target->rotation() + rotation); + target->setScale(target->scale() * scale); } } else if (target) { target->setParentItem(targetParent); |