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 | |
4 | #ifndef QGESTURE_P_H |
5 | #define QGESTURE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists for the convenience |
12 | // of other Qt classes. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtWidgets/private/qtwidgetsglobal_p.h> |
19 | #include "qrect.h" |
20 | #include "qpoint.h" |
21 | #include "qgesture.h" |
22 | #include "qelapsedtimer.h" |
23 | #include "private/qobject_p.h" |
24 | |
25 | #ifndef QT_NO_GESTURES |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QGesturePrivate : public QObjectPrivate |
30 | { |
31 | Q_DECLARE_PUBLIC(QGesture) |
32 | |
33 | public: |
34 | QGesturePrivate() |
35 | : gestureType(Qt::CustomGesture), state(Qt::NoGesture), |
36 | isHotSpotSet(false), gestureCancelPolicy(0) |
37 | { |
38 | } |
39 | |
40 | Qt::GestureType gestureType; |
41 | Qt::GestureState state; |
42 | QPointF hotSpot; |
43 | QPointF sceneHotSpot; |
44 | uint isHotSpotSet : 1; |
45 | uint gestureCancelPolicy : 2; |
46 | }; |
47 | |
48 | class QPanGesturePrivate : public QGesturePrivate |
49 | { |
50 | Q_DECLARE_PUBLIC(QPanGesture) |
51 | |
52 | public: |
53 | QPanGesturePrivate() |
54 | : acceleration(0), xVelocity(0), yVelocity(0), pointCount(2) |
55 | { |
56 | } |
57 | |
58 | qreal horizontalVelocity() const { return xVelocity; } |
59 | void setHorizontalVelocity(qreal value) { xVelocity = value; } |
60 | qreal verticalVelocity() const { return yVelocity; } |
61 | void setVerticalVelocity(qreal value) { yVelocity = value; } |
62 | |
63 | QPointF lastOffset; |
64 | QPointF offset; |
65 | QPoint startPosition; |
66 | qreal acceleration; |
67 | qreal xVelocity; |
68 | qreal yVelocity; |
69 | int pointCount; // ### fixme Qt 5.5: Add accessor to QPanGesture. |
70 | }; |
71 | |
72 | class QPinchGesturePrivate : public QGesturePrivate |
73 | { |
74 | Q_DECLARE_PUBLIC(QPinchGesture) |
75 | |
76 | public: |
77 | QPinchGesturePrivate() |
78 | : totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), |
79 | totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), |
80 | isNewSequence(true) |
81 | { |
82 | } |
83 | |
84 | QPinchGesture::ChangeFlags totalChangeFlags; |
85 | QPinchGesture::ChangeFlags changeFlags; |
86 | |
87 | QPointF startCenterPoint; |
88 | QPointF lastCenterPoint; |
89 | QPointF centerPoint; |
90 | |
91 | qreal totalScaleFactor; |
92 | qreal lastScaleFactor; |
93 | qreal scaleFactor; |
94 | |
95 | qreal totalRotationAngle; |
96 | qreal lastRotationAngle; |
97 | qreal rotationAngle; |
98 | |
99 | bool isNewSequence; |
100 | QPointF startPosition[2]; |
101 | }; |
102 | |
103 | class QSwipeGesturePrivate : public QGesturePrivate |
104 | { |
105 | Q_DECLARE_PUBLIC(QSwipeGesture) |
106 | |
107 | public: |
108 | enum State { |
109 | NoGesture, |
110 | Started, |
111 | ThreePointsReached |
112 | }; |
113 | |
114 | QSwipeGesturePrivate() |
115 | : horizontalDirection(QSwipeGesture::NoDirection), |
116 | verticalDirection(QSwipeGesture::NoDirection), |
117 | swipeAngle(0), |
118 | state(NoGesture), velocityValue(0) |
119 | { |
120 | } |
121 | |
122 | qreal velocity() const { return velocityValue; } |
123 | void setVelocity(qreal value) { velocityValue = value; } |
124 | |
125 | QSwipeGesture::SwipeDirection horizontalDirection; |
126 | QSwipeGesture::SwipeDirection verticalDirection; |
127 | qreal swipeAngle; |
128 | |
129 | QPoint lastPositions[3]; |
130 | State state; |
131 | qreal velocityValue; |
132 | QElapsedTimer time; |
133 | }; |
134 | |
135 | class QTapGesturePrivate : public QGesturePrivate |
136 | { |
137 | Q_DECLARE_PUBLIC(QTapGesture) |
138 | |
139 | public: |
140 | QTapGesturePrivate() |
141 | { |
142 | } |
143 | |
144 | QPointF position; |
145 | }; |
146 | |
147 | class QTapAndHoldGesturePrivate : public QGesturePrivate |
148 | { |
149 | Q_DECLARE_PUBLIC(QTapAndHoldGesture) |
150 | |
151 | public: |
152 | QTapAndHoldGesturePrivate() |
153 | : timerId(0) |
154 | { |
155 | } |
156 | |
157 | QPointF position; |
158 | int timerId; |
159 | static int Timeout; |
160 | }; |
161 | |
162 | QT_END_NAMESPACE |
163 | |
164 | #endif // QT_NO_GESTURES |
165 | |
166 | #endif // QGESTURE_P_H |
167 | |