aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickmultipointhandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-09-21 11:44:07 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-09-29 10:15:08 +0000
commit38ae3bb1c2154c6be289c74d6415eead258745dc (patch)
treed97a7316051572058706d502e5db7d8a8bf8e803 /src/quick/handlers/qquickmultipointhandler.cpp
parenta4439d6baf6996fd018575f5ed752b4d4429f92a (diff)
replace MultiPointHandler::requiredPointCount with min/max range props
This is more flexible in case someone wants a PinchHandler to respond in the same way for either 2 or 3 touchpoints, for example. Change-Id: I360ce6f0239d86aa92dbebc225e3646883e71100 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickmultipointhandler.cpp')
-rw-r--r--src/quick/handlers/qquickmultipointhandler.cpp57
1 files changed, 41 insertions, 16 deletions
diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp
index 2ced136026..d0b4edf0ac 100644
--- a/src/quick/handlers/qquickmultipointhandler.cpp
+++ b/src/quick/handlers/qquickmultipointhandler.cpp
@@ -59,9 +59,10 @@ QT_BEGIN_NAMESPACE
for any type of handler which requires and acts upon a specific number
of multiple touchpoints.
*/
-QQuickMultiPointHandler::QQuickMultiPointHandler(QObject *parent, int requiredPointCount)
+QQuickMultiPointHandler::QQuickMultiPointHandler(QObject *parent, int minimumPointCount)
: QQuickPointerDeviceHandler(parent)
- , m_requiredPointCount(requiredPointCount)
+ , m_minimumPointCount(minimumPointCount)
+ , m_maximumPointCount(-1)
, m_pointDistanceThreshold(0)
{
}
@@ -79,7 +80,7 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event)
return true;
const QVector<QQuickEventPoint *> candidatePoints = eligiblePoints(event);
- const bool ret = (candidatePoints.size() == m_requiredPointCount);
+ const bool ret = (candidatePoints.size() >= minimumPointCount() && candidatePoints.size() <= maximumPointCount());
if (ret)
m_currentPoints = candidatePoints;
return ret;
@@ -109,28 +110,52 @@ QVector<QQuickEventPoint *> QQuickMultiPointHandler::eligiblePoints(QQuickPointe
}
/*!
- \qmlproperty int MultiPointHandler::requiredPointCount
+ \qmlproperty int MultiPointHandler::minimumPointCount
- The number of touchpoints that are required to activate this handler. If
- a smaller number of touchpoints are in contact with the
- \l {PointerHandler::parent}{parent}, they will be ignored. If a larger number
- of touchpoints are in contact, the required number of points will be
- chosen in the order that they are pressed, and the remaining points will
- be ignored. Any ignored points are eligible to activate other Pointer
- Handlers, which have different constraints, on the same Item or on other
- Items.
+ The minimum number of touchpoints required to activate this handler.
+
+ If a smaller number of touchpoints are in contact with the
+ \l {PointerHandler::parent}{parent}, they will be ignored.
+
+ Any ignored points are eligible to activate other Pointer Handlers that
+ have different constraints, on the same Item or on other Items.
The default value is 2.
*/
-void QQuickMultiPointHandler::setRequiredPointCount(int c)
+void QQuickMultiPointHandler::setMinimumPointCount(int c)
{
- if (m_requiredPointCount == c)
+ if (m_minimumPointCount == c)
return;
- m_requiredPointCount = c;
- emit requiredPointCountChanged();
+ m_minimumPointCount = c;
+ emit minimumPointCountChanged();
+ if (m_maximumPointCount < 0)
+ emit maximumPointCountChanged();
}
+/*!
+ \qmlproperty int MultiPointHandler::maximumPointCount
+
+ The maximum number of touchpoints this handler can utilize.
+
+ If a larger number of touchpoints are in contact with the
+ \l {PointerHandler::parent}{parent}, the required number of points will be
+ chosen in the order that they are pressed, and the remaining points will
+ be ignored.
+
+ Any ignored points are eligible to activate other Pointer Handlers that
+ have different constraints, on the same Item or on other Items.
+
+ The default value is the same as \l minimumPointCount.
+*/
+void QQuickMultiPointHandler::setMaximumPointCount(int maximumPointCount)
+{
+ if (m_maximumPointCount == maximumPointCount)
+ return;
+
+ m_maximumPointCount = maximumPointCount;
+ emit maximumPointCountChanged();
+}
/*!
\qmlproperty real MultiPointHandler::pointDistanceThreshold