From d5686fa2ac2248d5a31237573fa08697f18f035f Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 9 Sep 2011 16:48:03 +1000 Subject: Experimental 'pixelAligned' property for Flickable. Change-Id: I671af87c4d2db3403ab506ae32608c91d6982338 Reviewed-on: http://codereview.qt-project.org/4506 Reviewed-by: Qt Sanity Bot Reviewed-by: Alan Alpert --- src/declarative/items/qsgflickable.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/declarative/items/qsgflickable.cpp') diff --git a/src/declarative/items/qsgflickable.cpp b/src/declarative/items/qsgflickable.cpp index d62197f7d6..962eb9617a 100644 --- a/src/declarative/items/qsgflickable.cpp +++ b/src/declarative/items/qsgflickable.cpp @@ -174,6 +174,7 @@ QSGFlickablePrivate::QSGFlickablePrivate() , hMoved(false), vMoved(false) , movingHorizontally(false), movingVertically(false) , stealMouse(false), pressed(false), interactive(true), calcVelocity(false) + , pixelAligned(false) , deceleration(QML_FLICK_DEFAULTDECELERATION) , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100) , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(400) @@ -777,6 +778,21 @@ void QSGFlickable::setFlickableDirection(FlickableDirection direction) } } +bool QSGFlickable::pixelAligned() const +{ + Q_D(const QSGFlickable); + return d->pixelAligned; +} + +void QSGFlickable::setPixelAligned(bool align) +{ + Q_D(QSGFlickable); + if (align != d->pixelAligned) { + d->pixelAligned = align; + emit pixelAlignedChanged(); + } +} + void QSGFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) { Q_Q(QSGFlickable); @@ -1097,14 +1113,15 @@ void QSGFlickablePrivate::clearDelayedPress() } } +//XXX pixelAligned ignores the global position of the Flickable, i.e. assumes Flickable itself is pixel aligned. void QSGFlickablePrivate::setViewportX(qreal x) { - contentItem->setX(x); + contentItem->setX(pixelAligned ? qRound(x) : x); } void QSGFlickablePrivate::setViewportY(qreal y) { - contentItem->setY(y); + contentItem->setY(pixelAligned ? qRound(y) : y); } void QSGFlickable::timerEvent(QTimerEvent *event) -- cgit v1.2.3