aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-02-16 15:54:09 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-21 06:49:10 +0100
commitb672f1974d3291cd0ad56c3c54f5398accc392b8 (patch)
treee467665ec54d650d0b5edb4ad01043f46003cecb /src/quick/util
parenta37f19fa6d19e43b3a64587f224658a9fd63631a (diff)
Flicking a pathview with large delegate spacing is inconsistent
The deceleration is inconsistent and dragging slowly is jerky. This was largely due to the poor resolution of the path points. pointAt() now interpolates, and the dragging logic is more accurate. Also removed the rounding of item positioning so that side-by-side items don't bounce around. Task-number: QTBUG-24312 Change-Id: I956aff0b83c3c1211d5657159c3de1e4ef0b5171 Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/quick/util')
-rw-r--r--src/quick/util/qdeclarativepath.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/quick/util/qdeclarativepath.cpp b/src/quick/util/qdeclarativepath.cpp
index 2c526f9699..2ee534880c 100644
--- a/src/quick/util/qdeclarativepath.cpp
+++ b/src/quick/util/qdeclarativepath.cpp
@@ -654,12 +654,31 @@ QPointF QDeclarativePath::pointAt(qreal p) const
if (d->_pointCache.isEmpty())
return QPointF();
}
- int idx = qRound(p*d->_pointCache.size());
- if (idx >= d->_pointCache.size())
- idx = d->_pointCache.size() - 1;
- else if (idx < 0)
- idx = 0;
- return d->_pointCache.at(idx);
+
+ const int pointCacheSize = d->_pointCache.size();
+ qreal idxf = p*pointCacheSize;
+ int idx1 = qFloor(idxf);
+ qreal delta = idxf - idx1;
+ if (idx1 >= pointCacheSize)
+ idx1 = pointCacheSize - 1;
+ else if (idx1 < 0)
+ idx1 = 0;
+
+ if (delta == 0.0)
+ return d->_pointCache.at(idx1);
+
+ // interpolate between the two points.
+ int idx2 = qCeil(idxf);
+ if (idx2 >= pointCacheSize)
+ idx2 = pointCacheSize - 1;
+ else if (idx2 < 0)
+ idx2 = 0;
+
+ QPointF p1 = d->_pointCache.at(idx1);
+ QPointF p2 = d->_pointCache.at(idx2);
+ QPointF pos = p1 * (1.0-delta) + p2 * delta;
+
+ return pos;
}
qreal QDeclarativePath::attributeAt(const QString &name, qreal percent) const