6#include <private/qquickitem_p.h>
41#if QT_CONFIG(gestures)
54 if (candidatePoints.size() !=
d->currentPoints.size()) {
55 d->currentPoints.clear();
67 const int c = candidatePoints.size();
68 d->currentPoints.resize(
c);
69 for (
int i = 0;
i <
c; ++
i) {
70 d->currentPoints[
i].reset(
event, candidatePoints[
i]);
72 d->currentPoints[
i].localize(par);
75 d->currentPoints.clear();
91 QPointF sceneGrabPos =
d->centroid.sceneGrabPosition();
92 d->centroid.reset(
d->currentPoints);
93 d->centroid.m_sceneGrabPosition = sceneGrabPos;
101 d->centroid.m_sceneGrabPosition =
d->centroid.m_scenePosition;
121 d->currentPoints.clear();
124 switch (transition) {
126 for (
auto &pt :
d->currentPoints)
127 if (pt.id() == point.
id()) {
147 QVector<QEventPoint>
ret;
150 bool stealingAllowed =
event->isBeginEvent() ||
event->isEndEvent();
151 for (
int i = 0;
i <
event->pointCount(); ++
i) {
152 auto &
p =
event->point(
i);
157 if (!stealingAllowed) {
158 QObject *exclusiveGrabber =
event->exclusiveGrabber(
p);
159 if (exclusiveGrabber && exclusiveGrabber !=
this && !
canGrab(
event,
p))
184 return d->minimumPointCount;
190 if (
d->minimumPointCount ==
c)
193 d->minimumPointCount =
c;
195 if (
d->maximumPointCount < 0)
217 return d->maximumPointCount >= 0 ?
d->maximumPointCount :
d->minimumPointCount;
258 return d->currentPoints;
264 if (
event->pointCount() <
d->currentPoints.size() ||
d->currentPoints.size() == 0)
286 return ret /
d->currentPoints.size();
298 return ret /
d->currentPoints.size();
304 QVector<PointData>
angles;
305 angles.reserve(
d->currentPoints.size());
315 qreal avgAngleDelta = 0;
318 auto oldBegin = old.constBegin();
322 auto it = std::find_if(oldBegin, old.constEnd(), [
id] (
PointData pd) { return pd.id == id; });
324 if (
it != old.constEnd()) {
330 angleD = remainder(newData.angle - oldData.angle,
qreal(360));
337 avgAngleDelta += angleD;
340 avgAngleDelta /= numSamples;
342 return avgAngleDelta;
358 for (
auto &point :
points) {
365 for (
const auto &point : std::as_const(
points))
375 d->xMetaProperty().write(
t,
pos.x());
376 d->yMetaProperty().write(
t,
pos.y());
377 d->centroid.m_position =
t->mapFromScene(
d->centroid.m_scenePosition);
379 qWarning() <<
"moveTarget: target is null";
385 , minimumPointCount(minPointCount)
386 , maximumPointCount(maxPointCount)
394 const QMetaObject *targetMeta =
q->target()->metaObject();
395 xProperty = targetMeta->property(targetMeta->indexOfProperty(
"x"));
404 const QMetaObject *targetMeta =
q->target()->metaObject();
405 yProperty = targetMeta->property(targetMeta->indexOfProperty(
"y"));
412#include "moc_qquickmultipointhandler_p.cpp"
The QEventPoint class provides information about a point in a QPointerEvent.
int id
the ID number of this event point.
QPointF scenePosition
the scene position of this point.
State state
the current state of the event point.
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
\inmodule QtCore\reentrant
A base class for pointer events.
GrabTransition
This enum represents a transition of exclusive or passive grab from one object (possibly nullptr) to ...
static bool isMouseEvent(const QPointerEvent *ev)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
QMetaProperty & xMetaProperty() const
QQuickMultiPointHandlerPrivate(int minPointCount, int maxPointCount)
QMetaProperty & yMetaProperty() const
bool hasCurrentPoints(QPointerEvent *event)
void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point) override
Notification that the grab has changed in some way which is relevant to this handler.
void handlePointerEventImpl(QPointerEvent *event) override
This function can be overridden to implement whatever behavior a specific subclass is intended to hav...
QQuickHandlerPoint & mutableCentroid()
Returns a modifiable reference to the point that will be returned by the \l centroid property.
QList< QQuickHandlerPoint > & currentPoints()
bool wantsPointerEvent(QPointerEvent *event) override
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
void onActiveChanged() override
qreal averageTouchPointDistance(const QPointF &ref)
qreal averageStartingDistance(const QPointF &ref)
void setMinimumPointCount(int c)
void minimumPointCountChanged()
void setMaximumPointCount(int maximumPointCount)
void maximumPointCountChanged()
QQuickHandlerPoint centroid
void acceptPoints(const QVector< QEventPoint > &points)
QVector< PointData > angles(const QPointF &ref) const
QQuickMultiPointHandler(QQuickItem *parent=nullptr, int minimumPointCount=2, int maximumPointCount=-1)
\qmltype MultiPointHandler
QVector< QEventPoint > eligiblePoints(QPointerEvent *event)
bool grabPoints(QPointerEvent *event, const QVector< QEventPoint > &points)
void moveTarget(QPointF pos)
static qreal averageAngleDelta(const QVector< PointData > &old, const QVector< PointData > &newAngles)
bool wantsPointerEvent(QPointerEvent *event) override
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
virtual bool canGrab(QPointerEvent *event, const QEventPoint &point)
Check whether it's OK to take an exclusive grab of the point.
QQuickItem * parentItem() const
\qmlproperty Item QtQuick::PointerHandler::parent
virtual bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point)
Returns true if the given point (as part of event) could be relevant at all to this handler,...
virtual void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point)
Notification that the grab has changed in some way which is relevant to this handler.
virtual void handlePointerEventImpl(QPointerEvent *event)
This function can be overridden to implement whatever behavior a specific subclass is intended to hav...
bool setExclusiveGrab(QPointerEvent *ev, const QEventPoint &point, bool grab=true)
Acquire or give up the exclusive grab of the given point, according to the grab state,...
void setActive(bool active)
The QVector2D class represents a vector or vertex in 2D space.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
GLenum GLuint GLenum GLsizei length
GLfixed GLfixed GLint GLint GLfixed points
GLdouble GLdouble GLdouble GLdouble q
unsigned long long quint64