aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsgflickable.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-09-09 16:48:03 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-12 04:04:42 +0200
commitd5686fa2ac2248d5a31237573fa08697f18f035f (patch)
tree33daeefb1b730669272332f76c20210379bc82dc /src/declarative/items/qsgflickable.cpp
parent181e8800cfcaebbdea82ae677c327735082327a1 (diff)
Experimental 'pixelAligned' property for Flickable.
Change-Id: I671af87c4d2db3403ab506ae32608c91d6982338 Reviewed-on: http://codereview.qt-project.org/4506 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/declarative/items/qsgflickable.cpp')
-rw-r--r--src/declarative/items/qsgflickable.cpp21
1 files changed, 19 insertions, 2 deletions
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)