summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativegridview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-09 02:01:02 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-09 02:01:02 (GMT)
commitf7a684d72652814960601692f4bc9f7240ce2186 (patch)
tree1b46a1a780fa79e0cc79206313ba4b298cde0a16 /src/declarative/graphicsitems/qdeclarativegridview.cpp
parent3deecc3084cd7fe3a1bb3f5941e5ec6eb66f97fa (diff)
downloadQt-f7a684d72652814960601692f4bc9f7240ce2186.zip
Qt-f7a684d72652814960601692f4bc9f7240ce2186.tar.gz
Qt-f7a684d72652814960601692f4bc9f7240ce2186.tar.bz2
When flicking with snap, bias towards moving at least one item.
Task-number: QTBUG-8839
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativegridview.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 60ffbe2..f35b903 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -755,14 +755,15 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
vTime = timeline.time();
}
} else if (snapMode != QDeclarativeGridView::NoSnap) {
- qreal pos = qMax(qMin(snapPosAt(position()) - highlightRangeStart, -maxExtent), -minExtent);
- qreal dist = qAbs(data.move + pos);
+ qreal pos = -snapPosAt(-(data.move.value() - highlightRangeStart)) + highlightRangeStart;
+ pos = qMin(qMax(pos, maxExtent), minExtent);
+ qreal dist = qAbs(data.move.value() - pos);
if (dist > 0) {
timeline.reset(data.move);
if (fixupDuration)
- timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
+ timeline.move(data.move, pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
else
- data.move.setValue(-pos);
+ data.move.setValue(pos);
vTime = timeline.time();
}
} else {
@@ -788,7 +789,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (FxGridItem *item = firstVisibleItem())
maxDistance = qAbs(item->rowPos() + data.move.value());
} else if (data.move.value() < minExtent) {
- maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0));
+ maxDistance = qAbs(minExtent - data.move.value());
}
if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = minExtent;
@@ -797,7 +798,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
qreal pos = snapPosAt(-data.move.value()) + rowSize();
maxDistance = qAbs(pos + data.move.value());
} else if (data.move.value() > maxExtent) {
- maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity, vSize):0);
+ maxDistance = qAbs(maxExtent - data.move.value());
}
if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
@@ -816,7 +817,8 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
qreal maxAccel = v2 / (2.0f * maxDistance);
qreal overshootDist = 0.0;
if (maxAccel < accel) {
- qreal dist = v2 / (accel * 2.0);
+ // + rowSize()/4 to encourage moving at least one item in the flick direction
+ qreal dist = v2 / (accel * 2.0) + rowSize()/4;
if (v > 0)
dist = -dist;
data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart;