summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxitem.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-07-14 05:59:41 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-07-14 05:59:41 (GMT)
commitcfe3f5eeb4c72afeab6bf12e27bcfd695156fa20 (patch)
treeb07ee72247a9e9678adc7b168479bb8c3f1b3932 /src/declarative/fx/qfxitem.cpp
parentfe484163e79c416636f382f80a21e662e8704793 (diff)
downloadQt-cfe3f5eeb4c72afeab6bf12e27bcfd695156fa20.zip
Qt-cfe3f5eeb4c72afeab6bf12e27bcfd695156fa20.tar.gz
Qt-cfe3f5eeb4c72afeab6bf12e27bcfd695156fa20.tar.bz2
Fix transform handling.
Diffstat (limited to 'src/declarative/fx/qfxitem.cpp')
-rw-r--r--src/declarative/fx/qfxitem.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index c15685e..f343f4e 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -1465,11 +1465,7 @@ void QFxItem::setRotation(qreal rotation)
if (d->_rotation == rotation)
return;
d->_rotation = rotation;
- QPointF to = d->transformOrigin();
- QTransform trans = QTransform::fromTranslate(to.x(), to.y());
- trans.rotate(d->_rotation);
- trans.translate(-to.x(), -to.y());
- setTransform(trans);
+ setTransform(d->transform);
emit rotationChanged();
}
@@ -2333,14 +2329,7 @@ void QFxItem::setScale(qreal s)
return;
d->scale = s;
- QTransform t;
- QPointF to = transformOriginPoint();
- if (to.x() != 0. || to.y() != 0.)
- t.translate(to.x(), to.y());
- t.scale(s, s);
- if (to.x() != 0. || to.y() != 0.)
- t.translate(-to.x(), -to.y());
- setTransform(t * d->transform);
+ setTransform(d->transform);
emit scaleChanged();
}
@@ -2376,11 +2365,30 @@ QTransform QFxItem::transform() const
return d->transform;
}
+//### optimize (perhaps cache scale and rot transforms, and have dirty flags)
+//### we rely on there not being an "if (d->transform == m) return;" check
void QFxItem::setTransform(const QTransform &m)
{
Q_D(QFxItem);
d->transform = m;
- QGraphicsItem::setTransform(QTransform::fromScale(d->scale, d->scale) * d->transform);
+ QTransform scaleTransform, rotTransform;
+ if (d->scale != 1) {
+ QPointF to = transformOriginPoint();
+ if (to.x() != 0. || to.y() != 0.)
+ scaleTransform.translate(to.x(), to.y());
+ scaleTransform.scale(d->scale, d->scale);
+ if (to.x() != 0. || to.y() != 0.)
+ scaleTransform.translate(-to.x(), -to.y());
+ }
+ if (d->_rotation != 0) {
+ QPointF to = d->transformOrigin();
+ if (to.x() != 0. || to.y() != 0.)
+ rotTransform.translate(to.x(), to.y());
+ rotTransform.rotate(d->_rotation);
+ if (to.x() != 0. || to.y() != 0.)
+ rotTransform.translate(-to.x(), -to.y());
+ }
+ QGraphicsItem::setTransform(scaleTransform * rotTransform * d->transform);
}
QFxItem *QFxItem::mouseGrabberItem() const