1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QGESTURE_P_H
41#define QGESTURE_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists for the convenience
48// of other Qt classes. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtWidgets/private/qtwidgetsglobal_p.h>
55#include "qrect.h"
56#include "qpoint.h"
57#include "qgesture.h"
58#include "qelapsedtimer.h"
59#include "private/qobject_p.h"
60
61#ifndef QT_NO_GESTURES
62
63QT_BEGIN_NAMESPACE
64
65class QGesturePrivate : public QObjectPrivate
66{
67 Q_DECLARE_PUBLIC(QGesture)
68
69public:
70 QGesturePrivate()
71 : gestureType(Qt::CustomGesture), state(Qt::NoGesture),
72 isHotSpotSet(false), gestureCancelPolicy(0)
73 {
74 }
75
76 Qt::GestureType gestureType;
77 Qt::GestureState state;
78 QPointF hotSpot;
79 QPointF sceneHotSpot;
80 uint isHotSpotSet : 1;
81 uint gestureCancelPolicy : 2;
82};
83
84class QPanGesturePrivate : public QGesturePrivate
85{
86 Q_DECLARE_PUBLIC(QPanGesture)
87
88public:
89 QPanGesturePrivate()
90 : acceleration(0), xVelocity(0), yVelocity(0), pointCount(2)
91 {
92 }
93
94 qreal horizontalVelocity() const { return xVelocity; }
95 void setHorizontalVelocity(qreal value) { xVelocity = value; }
96 qreal verticalVelocity() const { return yVelocity; }
97 void setVerticalVelocity(qreal value) { yVelocity = value; }
98
99 QPointF lastOffset;
100 QPointF offset;
101 QPoint startPosition;
102 qreal acceleration;
103 qreal xVelocity;
104 qreal yVelocity;
105 int pointCount; // ### fixme Qt 5.5: Add accessor to QPanGesture.
106};
107
108class QPinchGesturePrivate : public QGesturePrivate
109{
110 Q_DECLARE_PUBLIC(QPinchGesture)
111
112public:
113 QPinchGesturePrivate()
114 : totalChangeFlags(nullptr), changeFlags(nullptr),
115 totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
116 totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0),
117 isNewSequence(true)
118 {
119 }
120
121 QPinchGesture::ChangeFlags totalChangeFlags;
122 QPinchGesture::ChangeFlags changeFlags;
123
124 QPointF startCenterPoint;
125 QPointF lastCenterPoint;
126 QPointF centerPoint;
127
128 qreal totalScaleFactor;
129 qreal lastScaleFactor;
130 qreal scaleFactor;
131
132 qreal totalRotationAngle;
133 qreal lastRotationAngle;
134 qreal rotationAngle;
135
136 bool isNewSequence;
137 QPointF startPosition[2];
138};
139
140class QSwipeGesturePrivate : public QGesturePrivate
141{
142 Q_DECLARE_PUBLIC(QSwipeGesture)
143
144public:
145 enum State {
146 NoGesture,
147 Started,
148 ThreePointsReached
149 };
150
151 QSwipeGesturePrivate()
152 : horizontalDirection(QSwipeGesture::NoDirection),
153 verticalDirection(QSwipeGesture::NoDirection),
154 swipeAngle(0),
155 state(NoGesture), velocityValue(0)
156 {
157 }
158
159 qreal velocity() const { return velocityValue; }
160 void setVelocity(qreal value) { velocityValue = value; }
161
162 QSwipeGesture::SwipeDirection horizontalDirection;
163 QSwipeGesture::SwipeDirection verticalDirection;
164 qreal swipeAngle;
165
166 QPoint lastPositions[3];
167 State state;
168 qreal velocityValue;
169 QElapsedTimer time;
170};
171
172class QTapGesturePrivate : public QGesturePrivate
173{
174 Q_DECLARE_PUBLIC(QTapGesture)
175
176public:
177 QTapGesturePrivate()
178 {
179 }
180
181 QPointF position;
182};
183
184class QTapAndHoldGesturePrivate : public QGesturePrivate
185{
186 Q_DECLARE_PUBLIC(QTapAndHoldGesture)
187
188public:
189 QTapAndHoldGesturePrivate()
190 : timerId(0)
191 {
192 }
193
194 QPointF position;
195 int timerId;
196 static int Timeout;
197};
198
199QT_END_NAMESPACE
200
201#endif // QT_NO_GESTURES
202
203#endif // QGESTURE_P_H
204