diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2014-06-12 20:23:10 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-01-21 00:31:45 +0100 |
commit | 7ee429dd7a12dc38a4e4af8888325d111883a2ff (patch) | |
tree | fa3beeda8b1f342fdf05199dc4580a43c073ddef /src/quick/items/qquickflickable.cpp | |
parent | fdec43a1ff7d8ff8a9cd014e7282e95d262fe5ed (diff) |
Introduce Flickable.OvershootBounds behavior
Related to QTBUG-38515. It is not always desired to allow dragging over
bounds even if flicking overshoots. This makes it possible to implement
collision effects for flicks, while a drag over bounds would still do
nothing.
[ChangeLog][QtQuick][Flickable] Introduced Flickable.OvershootBounds
behavior that allows content overshooting the boundary when flicked,
but does not allow dragging content beyond the boundary of Flickable.
[ChangeLog][QtQuick][Important Behavior Changes]
Flickable.DragAndOvershootBounds value changed from 2 to 3. This will
only affect you if you've worked around enum type checking and have
the integer value explicitly in your code.
Change-Id: I63c3540ab293a9c7c801d81220f74909d3fa1e17
Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
Diffstat (limited to 'src/quick/items/qquickflickable.cpp')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index f851ef1bac..6273499e54 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -319,7 +319,7 @@ bool QQuickFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExt maxDistance = qAbs(maxExtent - data.move.value()); data.flickTarget = maxExtent; } - if (maxDistance > 0 || boundsBehavior == QQuickFlickable::DragAndOvershootBounds) { + if (maxDistance > 0 || boundsBehavior & QQuickFlickable::OvershootBounds) { qreal v = velocity; if (maxVelocity != -1 && maxVelocity < qAbs(v)) { if (v < 0) @@ -339,7 +339,7 @@ bool QQuickFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExt accel = v2 / (2.0f * qAbs(dist)); resetTimeline(data); - if (boundsBehavior == QQuickFlickable::DragAndOvershootBounds) + if (boundsBehavior & QQuickFlickable::OvershootBounds) timeline.accel(data.move, v, accel); else timeline.accel(data.move, v, accel, maxDistance); @@ -1011,7 +1011,7 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) // the estimate to be altered const qreal minY = vData.dragMinBound + vData.startMargin; const qreal maxY = vData.dragMaxBound - vData.endMargin; - if (boundsBehavior == QQuickFlickable::StopAtBounds) { + if (!(boundsBehavior & QQuickFlickable::DragOverBounds)) { if (fuzzyLessThanOrEqualTo(newY, maxY)) { newY = maxY; rejectY = vData.pressPos == maxY && vData.move.value() == maxY && dy < 0; @@ -1045,7 +1045,7 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) qreal newX = dx + hData.pressPos - hData.dragStartOffset; const qreal minX = hData.dragMinBound + hData.startMargin; const qreal maxX = hData.dragMaxBound - hData.endMargin; - if (boundsBehavior == QQuickFlickable::StopAtBounds) { + if (!(boundsBehavior & QQuickFlickable::DragOverBounds)) { if (fuzzyLessThanOrEqualTo(newX, maxX)) { newX = maxX; rejectX = hData.pressPos == maxX && hData.move.value() == maxX && dx < 0; @@ -1627,6 +1627,8 @@ QQmlListProperty<QQuickItem> QQuickFlickable::flickableChildren() of the flickable, and flicks will not overshoot. \li Flickable.DragOverBounds - the contents can be dragged beyond the boundary of the Flickable, but flicks will not overshoot. + \li Flickable.OvershootBounds - the contents can overshoot the boundary when flicked, + but the content cannot be dragged beyond the boundary of the flickable. (since \c{QtQuick 2.5}) \li Flickable.DragAndOvershootBounds (default) - the contents can be dragged beyond the boundary of the Flickable, and can overshoot the boundary when flicked. |