diff options
author | Matt Vogt <matthew.vogt@jollamobile.com> | 2012-11-19 11:03:20 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-19 02:52:44 +0100 |
commit | 0c74cbcccb52e296667c6bc171084f4946daef61 (patch) | |
tree | a8b2622e4731f7c2b3a3c4d9ce67b56eaee4d7e5 /src | |
parent | e7ebed77d60a05983ec7f9e6d221324b2e7f1a22 (diff) |
Allow margin changes during Flickable drag operation
Previously, the dimensions of the flickable were captured at mouse
press and reused during dragging, which causes problems if the margins
of the Flickable are altered during the drag. Adjust the captured
values so that margin changes are correctly handled.
Change-Id: I1ce608dcc1302ea8639bf18a81361b27749b217b
Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index a15f77d3ce..a0bd1fab8e 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -974,10 +974,10 @@ void QQuickFlickablePrivate::handleMousePressEvent(QMouseEvent *event) hData.reset(); vData.reset(); - hData.dragMinBound = q->minXExtent(); - vData.dragMinBound = q->minYExtent(); - hData.dragMaxBound = q->maxXExtent(); - vData.dragMaxBound = q->maxYExtent(); + hData.dragMinBound = q->minXExtent() - hData.startMargin; + vData.dragMinBound = q->minYExtent() - vData.startMargin; + hData.dragMaxBound = q->maxXExtent() + hData.endMargin; + vData.dragMaxBound = q->maxYExtent() + vData.endMargin; fixupMode = Normal; lastPos = QPointF(); pressPos = event->localPos(); @@ -1021,8 +1021,11 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) if (!vMoved) vData.dragStartOffset = dy; qreal newY = dy + vData.pressPos - vData.dragStartOffset; - const qreal minY = vData.dragMinBound; - const qreal maxY = vData.dragMaxBound; + // Recalculate bounds in case margins have changed, but use the content + // size estimate taken at the start of the drag in case the drag causes + // the estimate to be altered + const qreal minY = vData.dragMinBound + vData.startMargin; + const qreal maxY = vData.dragMaxBound - vData.endMargin; if (newY > minY) newY = minY + (newY - minY) / 2; if (newY < maxY && maxY - minY <= 0) @@ -1055,8 +1058,8 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) if (!hMoved) hData.dragStartOffset = dx; qreal newX = dx + hData.pressPos - hData.dragStartOffset; - const qreal minX = hData.dragMinBound; - const qreal maxX = hData.dragMaxBound; + const qreal minX = hData.dragMinBound + hData.startMargin; + const qreal maxX = hData.dragMaxBound - hData.endMargin; if (newX > minX) newX = minX + (newX - minX) / 2; if (newX < maxX && maxX - minX <= 0) |