diff options
author | Robert Griebl <rgriebl@trolltech.com> | 2010-04-08 19:56:21 +0200 |
---|---|---|
committer | Robert Griebl <rgriebl@trolltech.com> | 2010-04-08 19:56:21 +0200 |
commit | c1a713436556df407f6227acc2e4488a32fb43ee (patch) | |
tree | 32dfc9c741533af4677aba7f03d55608ef84427f | |
parent | fb9250499bf31f52c5ce3082dc8f6fdc8c5ad622 (diff) |
Remember the fractional part of the scroll position.
-rw-r--r-- | qscrollareakineticscroller.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/qscrollareakineticscroller.cpp b/qscrollareakineticscroller.cpp index 7b28dee..ecef0c6 100644 --- a/qscrollareakineticscroller.cpp +++ b/qscrollareakineticscroller.cpp @@ -78,6 +78,7 @@ public: bool ignoreEvents; QPoint lastOvershoot; // don't change the type to QPointF or we might never shoot completely back. QPointer<QWidget> childWidget; // the widget where the mouse was pressed + QPointF fractionalPosition; QElapsedTimer timer; @@ -144,6 +145,7 @@ void QScrollAreaKineticScroller::setWidget(QAbstractScrollArea *widget) reset(); d->area = widget; d->lastOvershoot = QPoint(); + d->fractionalPosition = QPointF(); setParent(d->area); if (d->area) { @@ -327,6 +329,7 @@ QPointF QScrollAreaKineticScroller::contentPosition() const p.setX(s->value()); if (QScrollBar *s = d->area->verticalScrollBar()) p.setY(s->value()); + p += d->fractionalPosition; } return p; } @@ -345,6 +348,8 @@ void QScrollAreaKineticScroller::setContentPosition(const QPointF &p, const QPoi if (!delta.isNull()) d->area->viewport()->move(d->area->viewport()->pos() + delta); d->lastOvershoot -= delta; + + d->fractionalPosition = QPointF(p.x() - int(p.x()), p.y() - int(p.y())); } } |