Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickmultipointhandler_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKPOINTERMULTIHANDLER_H
6#define QQUICKPOINTERMULTIHANDLER_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/qevent.h>
20#include <QtQuick/qquickitem.h>
21
24
26
27class QQuickMultiPointHandlerPrivate;
28
29class Q_QUICK_EXPORT QQuickMultiPointHandler : public QQuickPointerDeviceHandler
30{
31 Q_OBJECT
32 Q_PROPERTY(int minimumPointCount READ minimumPointCount WRITE setMinimumPointCount NOTIFY minimumPointCountChanged)
33 Q_PROPERTY(int maximumPointCount READ maximumPointCount WRITE setMaximumPointCount NOTIFY maximumPointCountChanged)
34 Q_PROPERTY(QQuickHandlerPoint centroid READ centroid NOTIFY centroidChanged)
35
36public:
37 explicit QQuickMultiPointHandler(QQuickItem *parent = nullptr, int minimumPointCount = 2, int maximumPointCount = -1);
38
39 int minimumPointCount() const;
40 void setMinimumPointCount(int c);
41
42 int maximumPointCount() const;
43 void setMaximumPointCount(int maximumPointCount);
44
45 const QQuickHandlerPoint &centroid() const;
46
47Q_SIGNALS:
48 void minimumPointCountChanged();
49 void maximumPointCountChanged();
50 void centroidChanged();
51
52protected:
53 struct PointData {
54 PointData() : id(0), angle(0) {}
55 PointData(quint64 id, qreal angle) : id(id), angle(angle) {}
56 quint64 id;
57 qreal angle;
58 };
59
60 bool wantsPointerEvent(QPointerEvent *event) override;
61 void handlePointerEventImpl(QPointerEvent *event) override;
62 void onActiveChanged() override;
63 void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point) override;
64 QList<QQuickHandlerPoint> &currentPoints();
65 QQuickHandlerPoint &mutableCentroid();
66 bool hasCurrentPoints(QPointerEvent *event);
67 QVector<QEventPoint> eligiblePoints(QPointerEvent *event);
68 qreal averageTouchPointDistance(const QPointF &ref);
69 qreal averageStartingDistance(const QPointF &ref);
70 qreal averageTouchPointAngle(const QPointF &ref);
71 qreal averageStartingAngle(const QPointF &ref);
72 QVector<PointData> angles(const QPointF &ref) const;
73 static qreal averageAngleDelta(const QVector<PointData> &old, const QVector<PointData> &newAngles);
74 void acceptPoints(const QVector<QEventPoint> &points);
75 bool grabPoints(QPointerEvent *event, const QVector<QEventPoint> &points);
76 void moveTarget(QPointF pos);
77
78 Q_DECLARE_PRIVATE(QQuickMultiPointHandler)
79};
80
81QT_END_NAMESPACE
82
83#endif // QQUICKPOINTERMULTIHANDLER_H
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
static QT_BEGIN_NAMESPACE const qreal DragAngleToleranceDegrees