diff options
author | Andreas Aardal Hanssen <andreas@hanssen.name> | 2013-07-29 21:11:14 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-05 15:03:28 (GMT) |
commit | 7bf4381a95bb4812f5a74419099a1a18f7a536a7 (patch) | |
tree | 643b19ca58244904cf650198f1fd29f1aa92ffdd /src/gui/graphicsview | |
parent | 78b4162a352ddac398b8af7f8be33b009c333244 (diff) | |
download | Qt-7bf4381a95bb4812f5a74419099a1a18f7a536a7.zip Qt-7bf4381a95bb4812f5a74419099a1a18f7a536a7.tar.gz Qt-7bf4381a95bb4812f5a74419099a1a18f7a536a7.tar.bz2 |
Fix double transform for items ignoring parent transformations.
Previously, the topmost untransformable's scene transform, which
includes the item's position and local transformation, was used to
determine the item's anchoring position. This position was then
passed on to be multiplied by the item's transform again. This
works fine for toplevel untransformable items that don't have any
transform set at all, but those who do would have their transforms
applied twice - one to determine the anchoring position, and again
to transform the item itself. Since only translation transformations
can affect the first operation (the anchoring pos), this bug only
applies to items that set ItemIgnoresTransformations and use a
local transform that includes translation.
Task-number: QTBUG-21618
Change-Id: I3f3c4f2357e2ca6cd0c75cb5b7e428c0803d9e73
Reviewed-by: Alexis Menard <alexis@webkit.org>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 4f31793..fccd706 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4217,9 +4217,14 @@ QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) c return QTransform(); } - // First translate the base untransformable item. - untransformedAncestor->d_ptr->ensureSceneTransform(); - QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0)); + // Determine the inherited origin. Find the parent of the topmost untransformable. + // Use its scene transform to map the position of the untransformable. Then use + // that viewport position as the anchoring point for the untransformable subtree. + QGraphicsItem *parentOfUntransformedAncestor = untransformedAncestor->parentItem(); + QTransform inheritedMatrix; + if (parentOfUntransformedAncestor) + inheritedMatrix = parentOfUntransformedAncestor->sceneTransform(); + QPointF mappedPoint = (inheritedMatrix * viewportTransform).map(untransformedAncestor->pos()); // COMBINE QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y()); |