1/****************************************************************************
2**
3** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtGui 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 Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QGESTURE_H
43#define QGESTURE_H
44
45#include <QtCore/qobject.h>
46#include <QtCore/qlist.h>
47#include <QtCore/qdatetime.h>
48#include <QtCore/qpoint.h>
49#include <QtCore/qrect.h>
50#include <QtCore/qmetatype.h>
51
52#ifndef QT_NO_GESTURES
53
54QT_BEGIN_HEADER
55
56Q_DECLARE_METATYPE(Qt::GestureState)
57Q_DECLARE_METATYPE(Qt::GestureType)
58
59QT_BEGIN_NAMESPACE
60
61QT_MODULE(Gui)
62
63class QGesturePrivate;
64class Q_GUI_EXPORT QGesture : public QObject
65{
66 Q_OBJECT
67 Q_DECLARE_PRIVATE(QGesture)
68
69 Q_PROPERTY(Qt::GestureState state READ state)
70 Q_PROPERTY(Qt::GestureType gestureType READ gestureType)
71 Q_PROPERTY(QGesture::GestureCancelPolicy gestureCancelPolicy READ gestureCancelPolicy WRITE setGestureCancelPolicy)
72 Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot)
73 Q_PROPERTY(bool hasHotSpot READ hasHotSpot)
74
75public:
76 explicit QGesture(QObject *parent = 0);
77 ~QGesture();
78
79 Qt::GestureType gestureType() const;
80
81 Qt::GestureState state() const;
82
83 QPointF hotSpot() const;
84 void setHotSpot(const QPointF &value);
85 bool hasHotSpot() const;
86 void unsetHotSpot();
87
88 enum GestureCancelPolicy {
89 CancelNone = 0,
90 CancelAllInContext
91 };
92
93 void setGestureCancelPolicy(GestureCancelPolicy policy);
94 GestureCancelPolicy gestureCancelPolicy() const;
95
96protected:
97 QGesture(QGesturePrivate &dd, QObject *parent);
98
99private:
100 friend class QGestureEvent;
101 friend class QGestureRecognizer;
102 friend class QGestureManager;
103 friend class QGraphicsScenePrivate;
104};
105
106class QPanGesturePrivate;
107class Q_GUI_EXPORT QPanGesture : public QGesture
108{
109 Q_OBJECT
110 Q_DECLARE_PRIVATE(QPanGesture)
111
112 Q_PROPERTY(QPointF lastOffset READ lastOffset WRITE setLastOffset)
113 Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
114 Q_PROPERTY(QPointF delta READ delta STORED false)
115 Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration)
116 Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity)
117 Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
118
119public:
120 QPanGesture(QObject *parent = 0);
121
122 QPointF lastOffset() const;
123 QPointF offset() const;
124 QPointF delta() const;
125 qreal acceleration() const;
126
127 void setLastOffset(const QPointF &value);
128 void setOffset(const QPointF &value);
129 void setAcceleration(qreal value);
130
131 friend class QPanGestureRecognizer;
132 friend class QWinNativePanGestureRecognizer;
133};
134
135class QPinchGesturePrivate;
136class Q_GUI_EXPORT QPinchGesture : public QGesture
137{
138 Q_OBJECT
139 Q_DECLARE_PRIVATE(QPinchGesture)
140 Q_FLAGS(ChangeFlags ChangeFlag)
141
142public:
143 enum ChangeFlag {
144 ScaleFactorChanged = 0x1,
145 RotationAngleChanged = 0x2,
146 CenterPointChanged = 0x4
147 };
148 Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
149
150 Q_PROPERTY(ChangeFlags totalChangeFlags READ totalChangeFlags WRITE setTotalChangeFlags)
151 Q_PROPERTY(ChangeFlags changeFlags READ changeFlags WRITE setChangeFlags)
152
153 Q_PROPERTY(qreal totalScaleFactor READ totalScaleFactor WRITE setTotalScaleFactor)
154 Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor WRITE setLastScaleFactor)
155 Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor)
156
157 Q_PROPERTY(qreal totalRotationAngle READ totalRotationAngle WRITE setTotalRotationAngle)
158 Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle WRITE setLastRotationAngle)
159 Q_PROPERTY(qreal rotationAngle READ rotationAngle WRITE setRotationAngle)
160
161 Q_PROPERTY(QPointF startCenterPoint READ startCenterPoint WRITE setStartCenterPoint)
162 Q_PROPERTY(QPointF lastCenterPoint READ lastCenterPoint WRITE setLastCenterPoint)
163 Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint)
164
165public:
166 QPinchGesture(QObject *parent = 0);
167
168 ChangeFlags totalChangeFlags() const;
169 void setTotalChangeFlags(ChangeFlags value);
170
171 ChangeFlags changeFlags() const;
172 void setChangeFlags(ChangeFlags value);
173
174 QPointF startCenterPoint() const;
175 QPointF lastCenterPoint() const;
176 QPointF centerPoint() const;
177 void setStartCenterPoint(const QPointF &value);
178 void setLastCenterPoint(const QPointF &value);
179 void setCenterPoint(const QPointF &value);
180
181 qreal totalScaleFactor() const;
182 qreal lastScaleFactor() const;
183 qreal scaleFactor() const;
184 void setTotalScaleFactor(qreal value);
185 void setLastScaleFactor(qreal value);
186 void setScaleFactor(qreal value);
187
188 qreal totalRotationAngle() const;
189 qreal lastRotationAngle() const;
190 qreal rotationAngle() const;
191 void setTotalRotationAngle(qreal value);
192 void setLastRotationAngle(qreal value);
193 void setRotationAngle(qreal value);
194
195 friend class QPinchGestureRecognizer;
196};
197
198Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags)
199
200QT_END_NAMESPACE
201
202Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags)
203
204QT_BEGIN_NAMESPACE
205
206class QSwipeGesturePrivate;
207class Q_GUI_EXPORT QSwipeGesture : public QGesture
208{
209 Q_OBJECT
210 Q_DECLARE_PRIVATE(QSwipeGesture)
211 Q_ENUMS(SwipeDirection)
212
213 Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false)
214 Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false)
215 Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle)
216 Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity)
217
218public:
219 enum SwipeDirection { NoDirection, Left, Right, Up, Down };
220 QSwipeGesture(QObject *parent = 0);
221
222 SwipeDirection horizontalDirection() const;
223 SwipeDirection verticalDirection() const;
224
225 qreal swipeAngle() const;
226 void setSwipeAngle(qreal value);
227
228 friend class QSwipeGestureRecognizer;
229};
230
231class QTapGesturePrivate;
232class Q_GUI_EXPORT QTapGesture : public QGesture
233{
234 Q_OBJECT
235 Q_DECLARE_PRIVATE(QTapGesture)
236
237 Q_PROPERTY(QPointF position READ position WRITE setPosition)
238
239public:
240 QTapGesture(QObject *parent = 0);
241
242 QPointF position() const;
243 void setPosition(const QPointF &pos);
244
245 friend class QTapGestureRecognizer;
246};
247
248class QTapAndHoldGesturePrivate;
249class Q_GUI_EXPORT QTapAndHoldGesture : public QGesture
250{
251 Q_OBJECT
252 Q_DECLARE_PRIVATE(QTapAndHoldGesture)
253
254 Q_PROPERTY(QPointF position READ position WRITE setPosition)
255
256public:
257 QTapAndHoldGesture(QObject *parent = 0);
258
259 QPointF position() const;
260 void setPosition(const QPointF &pos);
261
262 static void setTimeout(int msecs);
263 static int timeout();
264
265 friend class QTapAndHoldGestureRecognizer;
266};
267
268QT_END_NAMESPACE
269
270Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy)
271QT_END_HEADER
272
273#endif // QT_NO_GESTURES
274
275#endif // QGESTURE_H
276