aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-06-12 20:23:10 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-01-21 00:31:45 +0100
commit7ee429dd7a12dc38a4e4af8888325d111883a2ff (patch)
treefa3beeda8b1f342fdf05199dc4580a43c073ddef /src/quick
parentfdec43a1ff7d8ff8a9cd014e7282e95d262fe5ed (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')
-rw-r--r--src/quick/items/qquickflickable.cpp10
-rw-r--r--src/quick/items/qquickflickable_p.h11
-rw-r--r--src/quick/items/qquickgridview.cpp2
-rw-r--r--src/quick/items/qquicklistview.cpp2
4 files changed, 17 insertions, 8 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.
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index c996d18b01..6b58584751 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -94,7 +94,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
Q_CLASSINFO("DefaultProperty", "flickableData")
Q_ENUMS(FlickableDirection)
- Q_ENUMS(BoundsBehavior)
+ Q_FLAGS(BoundsBehavior)
public:
QQuickFlickable(QQuickItem *parent=0);
@@ -103,7 +103,14 @@ public:
QQmlListProperty<QObject> flickableData();
QQmlListProperty<QQuickItem> flickableChildren();
- enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
+ enum BoundsBehaviorFlag {
+ StopAtBounds = 0x0,
+ DragOverBounds = 0x1,
+ OvershootBounds = 0x2,
+ DragAndOvershootBounds = DragOverBounds | OvershootBounds
+ };
+ Q_DECLARE_FLAGS(BoundsBehavior, BoundsBehaviorFlag)
+
BoundsBehavior boundsBehavior() const;
void setBoundsBehavior(BoundsBehavior);
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index e3af926e22..e19d635b00 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -1036,7 +1036,7 @@ bool QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
if (snapMode == QQuickGridView::NoSnap && highlightRange != QQuickGridView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
- bool overShoot = boundsBehavior == QQuickFlickable::DragAndOvershootBounds;
+ bool overShoot = boundsBehavior & QQuickFlickable::OvershootBounds;
if (maxDistance > 0 || overShoot) {
// This mode requires the grid to stop exactly on a row boundary.
qreal v = velocity;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 8afd5793fc..ba8203124b 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -1572,7 +1572,7 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
if (snapMode == QQuickListView::NoSnap && highlightRange != QQuickListView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
- bool overShoot = boundsBehavior == QQuickFlickable::DragAndOvershootBounds;
+ bool overShoot = boundsBehavior & QQuickFlickable::OvershootBounds;
if (maxDistance > 0 || overShoot) {
// These modes require the list to stop exactly on an item boundary.
// The initial flick will estimate the boundary to stop on.