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 : totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
115 totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0),
116 isNewSequence(true)
117 {
118 }
119
120 QPinchGesture::ChangeFlags totalChangeFlags;
121 QPinchGesture::ChangeFlags changeFlags;
122
123 QPointF startCenterPoint;
124 QPointF lastCenterPoint;
125 QPointF centerPoint;
126
127 qreal totalScaleFactor;
128 qreal lastScaleFactor;
129 qreal scaleFactor;
130
131 qreal totalRotationAngle;
132 qreal lastRotationAngle;
133 qreal rotationAngle;
134
135 bool isNewSequence;
136 QPointF startPosition[2];
137};
138
139class QSwipeGesturePrivate : public QGesturePrivate
140{
141 Q_DECLARE_PUBLIC(QSwipeGesture)
142
143public:
144 enum State {
145 NoGesture,
146 Started,
147 ThreePointsReached
148 };
149
150 QSwipeGesturePrivate()
151 : horizontalDirection(QSwipeGesture::NoDirection),
152 verticalDirection(QSwipeGesture::NoDirection),
153 swipeAngle(0),
154 state(NoGesture), velocityValue(0)
155 {
156 }
157
158 qreal velocity() const { return velocityValue; }
159 void setVelocity(qreal value) { velocityValue = value; }
160
161 QSwipeGesture::SwipeDirection horizontalDirection;
162 QSwipeGesture::SwipeDirection verticalDirection;
163 qreal swipeAngle;
164
165 QPoint lastPositions[3];
166 State state;
167 qreal velocityValue;
168 QElapsedTimer time;
169};
170
171class QTapGesturePrivate : public QGesturePrivate
172{
173 Q_DECLARE_PUBLIC(QTapGesture)
174
175public:
176 QTapGesturePrivate()
177 {
178 }
179
180 QPointF position;
181};
182
183class QTapAndHoldGesturePrivate : public QGesturePrivate
184{
185 Q_DECLARE_PUBLIC(QTapAndHoldGesture)
186
187public:
188 QTapAndHoldGesturePrivate()
189 : timerId(0)
190 {
191 }
192
193 QPointF position;
194 int timerId;
195 static int Timeout;
196};
197
198QT_END_NAMESPACE
199
200#endif // QT_NO_GESTURES
201
202#endif // QGESTURE_P_H
203