1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qgesture.h"
|
---|
43 | #include "private/qgesture_p.h"
|
---|
44 | #include "private/qstandardgestures_p.h"
|
---|
45 |
|
---|
46 | #ifndef QT_NO_GESTURES
|
---|
47 |
|
---|
48 | QT_BEGIN_NAMESPACE
|
---|
49 |
|
---|
50 | /*!
|
---|
51 | \class QGesture
|
---|
52 | \since 4.6
|
---|
53 | \ingroup gestures
|
---|
54 |
|
---|
55 | \brief The QGesture class represents a gesture, containing properties that
|
---|
56 | describe the corresponding user input.
|
---|
57 |
|
---|
58 | Gesture objects are not constructed directly by developers. They are created by
|
---|
59 | the QGestureRecognizer object that is registered with the application; see
|
---|
60 | QGestureRecognizer::registerRecognizer().
|
---|
61 |
|
---|
62 | For an overview of gesture handling in Qt and information on using gestures
|
---|
63 | in your applications, see the \l{Gestures Programming} document.
|
---|
64 |
|
---|
65 | \section1 Gesture Properties
|
---|
66 |
|
---|
67 | The class has a list of properties that can be queried by the user to get
|
---|
68 | some gesture-specific arguments. For example, the pinch gesture has a scale
|
---|
69 | factor that is exposed as a property.
|
---|
70 |
|
---|
71 | Developers of custom gesture recognizers can add additional properties in
|
---|
72 | order to provide additional information about a gesture. This can be done
|
---|
73 | by adding new dynamic properties to a QGesture object, or by subclassing
|
---|
74 | the QGesture class (or one of its subclasses).
|
---|
75 |
|
---|
76 | \section1 Lifecycle of a Gesture Object
|
---|
77 |
|
---|
78 | A QGesture instance is implicitly created when needed and is owned by Qt.
|
---|
79 | Developers should never destroy them or store them for later use as Qt may
|
---|
80 | destroy particular instances of them and create new ones to replace them.
|
---|
81 |
|
---|
82 | The registered gesture recognizer monitors the input events for the target
|
---|
83 | object via its \l{QGestureRecognizer::}{recognize()} function, updating the
|
---|
84 | properties of the gesture object as required.
|
---|
85 |
|
---|
86 | The gesture object may be delivered to the target object in a QGestureEvent if
|
---|
87 | the corresponding gesture is active or has just been canceled. Each event that
|
---|
88 | is delivered contains a list of gesture objects, since support for more than
|
---|
89 | one gesture may be enabled for the target object. Due to the way events are
|
---|
90 | handled in Qt, gesture events may be filtered by other objects.
|
---|
91 |
|
---|
92 | \sa QGestureEvent, QGestureRecognizer
|
---|
93 | */
|
---|
94 |
|
---|
95 | /*!
|
---|
96 | Constructs a new gesture object with the given \a parent.
|
---|
97 |
|
---|
98 | QGesture objects are created by gesture recognizers in the
|
---|
99 | QGestureRecognizer::create() function.
|
---|
100 | */
|
---|
101 | QGesture::QGesture(QObject *parent)
|
---|
102 | : QObject(*new QGesturePrivate, parent)
|
---|
103 | {
|
---|
104 | d_func()->gestureType = Qt::CustomGesture;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /*!
|
---|
108 | \internal
|
---|
109 | */
|
---|
110 | QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
|
---|
111 | : QObject(dd, parent)
|
---|
112 | {
|
---|
113 | }
|
---|
114 |
|
---|
115 | /*!
|
---|
116 | Destroys the gesture object.
|
---|
117 | */
|
---|
118 | QGesture::~QGesture()
|
---|
119 | {
|
---|
120 | }
|
---|
121 |
|
---|
122 | /*!
|
---|
123 | \property QGesture::state
|
---|
124 | \brief the current state of the gesture
|
---|
125 | */
|
---|
126 |
|
---|
127 | /*!
|
---|
128 | \property QGesture::gestureType
|
---|
129 | \brief the type of the gesture
|
---|
130 | */
|
---|
131 |
|
---|
132 | /*!
|
---|
133 | \property QGesture::hotSpot
|
---|
134 |
|
---|
135 | \brief The point that is used to find the receiver for the gesture event.
|
---|
136 |
|
---|
137 | The hot-spot is a point in the global coordinate system, use
|
---|
138 | QWidget::mapFromGlobal() or QGestureEvent::mapToGraphicsScene() to get a
|
---|
139 | local hot-spot.
|
---|
140 |
|
---|
141 | The hot-spot should be set by the gesture recognizer to allow gesture event
|
---|
142 | delivery to a QGraphicsObject.
|
---|
143 | */
|
---|
144 |
|
---|
145 | /*!
|
---|
146 | \property QGesture::hasHotSpot
|
---|
147 | \brief whether the gesture has a hot-spot
|
---|
148 | */
|
---|
149 |
|
---|
150 | Qt::GestureType QGesture::gestureType() const
|
---|
151 | {
|
---|
152 | return d_func()->gestureType;
|
---|
153 | }
|
---|
154 |
|
---|
155 | Qt::GestureState QGesture::state() const
|
---|
156 | {
|
---|
157 | return d_func()->state;
|
---|
158 | }
|
---|
159 |
|
---|
160 | QPointF QGesture::hotSpot() const
|
---|
161 | {
|
---|
162 | return d_func()->hotSpot;
|
---|
163 | }
|
---|
164 |
|
---|
165 | void QGesture::setHotSpot(const QPointF &value)
|
---|
166 | {
|
---|
167 | Q_D(QGesture);
|
---|
168 | d->hotSpot = value;
|
---|
169 | d->isHotSpotSet = true;
|
---|
170 | }
|
---|
171 |
|
---|
172 | bool QGesture::hasHotSpot() const
|
---|
173 | {
|
---|
174 | return d_func()->isHotSpotSet;
|
---|
175 | }
|
---|
176 |
|
---|
177 | void QGesture::unsetHotSpot()
|
---|
178 | {
|
---|
179 | d_func()->isHotSpotSet = false;
|
---|
180 | }
|
---|
181 |
|
---|
182 | /*!
|
---|
183 | \property QGesture::gestureCancelPolicy
|
---|
184 | \brief the policy for deciding what happens on accepting a gesture
|
---|
185 |
|
---|
186 | On accepting one gesture Qt can automatically cancel other gestures
|
---|
187 | that belong to other targets. The policy is normally set to not cancel
|
---|
188 | any other gestures and can be set to cancel all active gestures in the
|
---|
189 | context. For example for all child widgets.
|
---|
190 | */
|
---|
191 |
|
---|
192 | /*!
|
---|
193 | \enum QGesture::GestureCancelPolicy
|
---|
194 |
|
---|
195 | This enum describes how accepting a gesture can cancel other gestures
|
---|
196 | automatically.
|
---|
197 |
|
---|
198 | \value CancelNone On accepting this gesture no other gestures will be affected.
|
---|
199 |
|
---|
200 | \value CancelAllInContext On accepting this gesture all gestures that are
|
---|
201 | active in the context (respecting the Qt::GestureFlag that were specified
|
---|
202 | when subscribed to the gesture) will be cancelled.
|
---|
203 | */
|
---|
204 |
|
---|
205 | void QGesture::setGestureCancelPolicy(GestureCancelPolicy policy)
|
---|
206 | {
|
---|
207 | Q_D(QGesture);
|
---|
208 | d->gestureCancelPolicy = static_cast<uint>(policy);
|
---|
209 | }
|
---|
210 |
|
---|
211 | QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const
|
---|
212 | {
|
---|
213 | Q_D(const QGesture);
|
---|
214 | return static_cast<GestureCancelPolicy>(d->gestureCancelPolicy);
|
---|
215 | }
|
---|
216 |
|
---|
217 | /*!
|
---|
218 | \class QPanGesture
|
---|
219 | \since 4.6
|
---|
220 | \brief The QPanGesture class describes a panning gesture made by the user.
|
---|
221 | \ingroup gestures
|
---|
222 |
|
---|
223 | \image pangesture.png
|
---|
224 |
|
---|
225 | For an overview of gesture handling in Qt and information on using gestures
|
---|
226 | in your applications, see the \l{Gestures Programming} document.
|
---|
227 |
|
---|
228 | \sa QPinchGesture, QSwipeGesture
|
---|
229 | */
|
---|
230 |
|
---|
231 | /*!
|
---|
232 | \property QPanGesture::lastOffset
|
---|
233 | \brief the last offset recorded for this gesture
|
---|
234 |
|
---|
235 | The last offset contains the change in position of the user's input as
|
---|
236 | reported in the \l offset property when a previous gesture event was
|
---|
237 | delivered for this gesture.
|
---|
238 |
|
---|
239 | If no previous event was delivered with information about this gesture
|
---|
240 | (i.e., this gesture object contains information about the first movement
|
---|
241 | in the gesture) then this property contains a zero size.
|
---|
242 | */
|
---|
243 |
|
---|
244 | /*!
|
---|
245 | \property QPanGesture::offset
|
---|
246 | \brief the total offset from the first input position to the current input
|
---|
247 | position
|
---|
248 |
|
---|
249 | The offset measures the total change in position of the user's input
|
---|
250 | covered by the gesture on the input device.
|
---|
251 | */
|
---|
252 |
|
---|
253 | /*!
|
---|
254 | \property QPanGesture::delta
|
---|
255 | \brief the offset from the previous input position to the current input
|
---|
256 |
|
---|
257 | This is essentially the same as the difference between offset() and
|
---|
258 | lastOffset().
|
---|
259 | */
|
---|
260 |
|
---|
261 | /*!
|
---|
262 | \property QPanGesture::acceleration
|
---|
263 | \brief the acceleration in the motion of the touch point for this gesture
|
---|
264 | */
|
---|
265 |
|
---|
266 | /*!
|
---|
267 | \property QPanGesture::horizontalVelocity
|
---|
268 | \brief the horizontal component of the motion of the touch point for this
|
---|
269 | gesture
|
---|
270 | \since 4.7.1
|
---|
271 | \internal
|
---|
272 |
|
---|
273 | \sa verticalVelocity, acceleration
|
---|
274 | */
|
---|
275 |
|
---|
276 | /*!
|
---|
277 | \property QPanGesture::verticalVelocity
|
---|
278 | \brief the vertical component of the motion of the touch point for this
|
---|
279 | gesture
|
---|
280 | \since 4.7.1
|
---|
281 | \internal
|
---|
282 |
|
---|
283 | \sa horizontalVelocity, acceleration
|
---|
284 | */
|
---|
285 |
|
---|
286 | /*!
|
---|
287 | \internal
|
---|
288 | */
|
---|
289 | QPanGesture::QPanGesture(QObject *parent)
|
---|
290 | : QGesture(*new QPanGesturePrivate, parent)
|
---|
291 | {
|
---|
292 | d_func()->gestureType = Qt::PanGesture;
|
---|
293 | }
|
---|
294 |
|
---|
295 |
|
---|
296 | QPointF QPanGesture::lastOffset() const
|
---|
297 | {
|
---|
298 | return d_func()->lastOffset;
|
---|
299 | }
|
---|
300 |
|
---|
301 | QPointF QPanGesture::offset() const
|
---|
302 | {
|
---|
303 | return d_func()->offset;
|
---|
304 | }
|
---|
305 |
|
---|
306 | QPointF QPanGesture::delta() const
|
---|
307 | {
|
---|
308 | Q_D(const QPanGesture);
|
---|
309 | return d->offset - d->lastOffset;
|
---|
310 | }
|
---|
311 |
|
---|
312 | qreal QPanGesture::acceleration() const
|
---|
313 | {
|
---|
314 | return d_func()->acceleration;
|
---|
315 | }
|
---|
316 |
|
---|
317 | void QPanGesture::setLastOffset(const QPointF &value)
|
---|
318 | {
|
---|
319 | d_func()->lastOffset = value;
|
---|
320 | }
|
---|
321 |
|
---|
322 | void QPanGesture::setOffset(const QPointF &value)
|
---|
323 | {
|
---|
324 | d_func()->offset = value;
|
---|
325 | }
|
---|
326 |
|
---|
327 | void QPanGesture::setAcceleration(qreal value)
|
---|
328 | {
|
---|
329 | d_func()->acceleration = value;
|
---|
330 | }
|
---|
331 |
|
---|
332 | /*!
|
---|
333 | \class QPinchGesture
|
---|
334 | \since 4.6
|
---|
335 | \brief The QPinchGesture class describes a pinch gesture made my the user.
|
---|
336 | \ingroup touch
|
---|
337 | \ingroup gestures
|
---|
338 |
|
---|
339 | A pinch gesture is a form of touch user input in which the user typically
|
---|
340 | touches two points on the input device with a thumb and finger, before moving
|
---|
341 | them closer together or further apart to change the scale factor, zoom, or level
|
---|
342 | of detail of the user interface.
|
---|
343 |
|
---|
344 | For an overview of gesture handling in Qt and information on using gestures
|
---|
345 | in your applications, see the \l{Gestures Programming} document.
|
---|
346 |
|
---|
347 | \image pinchgesture.png
|
---|
348 |
|
---|
349 | Instead of repeatedly applying the same pinching gesture, the user may
|
---|
350 | continue to touch the input device in one place, and apply a second touch
|
---|
351 | to a new point, continuing the gesture. When this occurs, gesture events
|
---|
352 | will continue to be delivered to the target object, containing an instance
|
---|
353 | of QPinchGesture in the Qt::GestureUpdated state.
|
---|
354 |
|
---|
355 | \sa QPanGesture, QSwipeGesture
|
---|
356 | */
|
---|
357 |
|
---|
358 | /*!
|
---|
359 | \enum QPinchGesture::ChangeFlag
|
---|
360 |
|
---|
361 | This enum describes the changes that can occur to the properties of
|
---|
362 | the gesture object.
|
---|
363 |
|
---|
364 | \value ScaleFactorChanged The scale factor held by scaleFactor changed.
|
---|
365 | \value RotationAngleChanged The rotation angle held by rotationAngle changed.
|
---|
366 | \value CenterPointChanged The center point held by centerPoint changed.
|
---|
367 |
|
---|
368 | \sa changeFlags, totalChangeFlags
|
---|
369 | */
|
---|
370 |
|
---|
371 | /*!
|
---|
372 | \property QPinchGesture::totalChangeFlags
|
---|
373 | \brief the property of the gesture that has change
|
---|
374 |
|
---|
375 | This property indicates which of the other properties has changed since the
|
---|
376 | gesture has started. You can use this information to determine which aspect
|
---|
377 | of your user interface needs to be updated.
|
---|
378 |
|
---|
379 | \sa changeFlags, scaleFactor, rotationAngle, centerPoint
|
---|
380 | */
|
---|
381 |
|
---|
382 | /*!
|
---|
383 | \property QPinchGesture::changeFlags
|
---|
384 | \brief the property of the gesture that has changed in the current step
|
---|
385 |
|
---|
386 | This property indicates which of the other properties has changed since
|
---|
387 | the previous gesture event included information about this gesture. You
|
---|
388 | can use this information to determine which aspect of your user interface
|
---|
389 | needs to be updated.
|
---|
390 |
|
---|
391 | \sa totalChangeFlags, scaleFactor, rotationAngle, centerPoint
|
---|
392 | */
|
---|
393 |
|
---|
394 | /*!
|
---|
395 | \property QPinchGesture::totalScaleFactor
|
---|
396 | \brief the total scale factor
|
---|
397 |
|
---|
398 | The total scale factor measures the total change in scale factor from the
|
---|
399 | original value to the current scale factor.
|
---|
400 |
|
---|
401 | \sa scaleFactor, lastScaleFactor
|
---|
402 | */
|
---|
403 | /*!
|
---|
404 | \property QPinchGesture::lastScaleFactor
|
---|
405 | \brief the last scale factor recorded for this gesture
|
---|
406 |
|
---|
407 | The last scale factor contains the scale factor reported in the
|
---|
408 | \l scaleFactor property when a previous gesture event included
|
---|
409 | information about this gesture.
|
---|
410 |
|
---|
411 | If no previous event was delivered with information about this gesture
|
---|
412 | (i.e., this gesture object contains information about the first movement
|
---|
413 | in the gesture) then this property contains zero.
|
---|
414 |
|
---|
415 | \sa scaleFactor, totalScaleFactor
|
---|
416 | */
|
---|
417 | /*!
|
---|
418 | \property QPinchGesture::scaleFactor
|
---|
419 | \brief the current scale factor
|
---|
420 |
|
---|
421 | The scale factor measures the scale factor associated with the distance
|
---|
422 | between two of the user's inputs on a touch device.
|
---|
423 |
|
---|
424 | \sa totalScaleFactor, lastScaleFactor
|
---|
425 | */
|
---|
426 |
|
---|
427 | /*!
|
---|
428 | \property QPinchGesture::totalRotationAngle
|
---|
429 | \brief the total angle covered by the gesture
|
---|
430 |
|
---|
431 | This total angle measures the complete angle covered by the gesture. Usually, this
|
---|
432 | is equal to the value held by the \l rotationAngle property, except in the case where
|
---|
433 | the user performs multiple rotations by removing and repositioning one of the touch
|
---|
434 | points, as described above. In this case, the total angle will be the sum of the
|
---|
435 | rotation angles for the multiple stages of the gesture.
|
---|
436 |
|
---|
437 | \sa rotationAngle, lastRotationAngle
|
---|
438 | */
|
---|
439 | /*!
|
---|
440 | \property QPinchGesture::lastRotationAngle
|
---|
441 | \brief the last reported angle covered by the gesture motion
|
---|
442 |
|
---|
443 | The last rotation angle is the angle as reported in the \l rotationAngle property
|
---|
444 | when a previous gesture event was delivered for this gesture.
|
---|
445 |
|
---|
446 | \sa rotationAngle, totalRotationAngle
|
---|
447 | */
|
---|
448 | /*!
|
---|
449 | \property QPinchGesture::rotationAngle
|
---|
450 | \brief the angle covered by the gesture motion
|
---|
451 |
|
---|
452 | \sa totalRotationAngle, lastRotationAngle
|
---|
453 | */
|
---|
454 |
|
---|
455 | /*!
|
---|
456 | \property QPinchGesture::startCenterPoint
|
---|
457 | \brief the starting position of the center point
|
---|
458 |
|
---|
459 | \sa centerPoint, lastCenterPoint
|
---|
460 | */
|
---|
461 | /*!
|
---|
462 | \property QPinchGesture::lastCenterPoint
|
---|
463 | \brief the last position of the center point recorded for this gesture
|
---|
464 |
|
---|
465 | \sa centerPoint, startCenterPoint
|
---|
466 | */
|
---|
467 | /*!
|
---|
468 | \property QPinchGesture::centerPoint
|
---|
469 | \brief the current center point
|
---|
470 |
|
---|
471 | The center point is the midpoint between the two input points in the gesture.
|
---|
472 |
|
---|
473 | \sa startCenterPoint, lastCenterPoint
|
---|
474 | */
|
---|
475 |
|
---|
476 | /*!
|
---|
477 | \internal
|
---|
478 | */
|
---|
479 | QPinchGesture::QPinchGesture(QObject *parent)
|
---|
480 | : QGesture(*new QPinchGesturePrivate, parent)
|
---|
481 | {
|
---|
482 | d_func()->gestureType = Qt::PinchGesture;
|
---|
483 | }
|
---|
484 |
|
---|
485 | QPinchGesture::ChangeFlags QPinchGesture::totalChangeFlags() const
|
---|
486 | {
|
---|
487 | return d_func()->totalChangeFlags;
|
---|
488 | }
|
---|
489 |
|
---|
490 | void QPinchGesture::setTotalChangeFlags(QPinchGesture::ChangeFlags value)
|
---|
491 | {
|
---|
492 | d_func()->totalChangeFlags = value;
|
---|
493 | }
|
---|
494 |
|
---|
495 | QPinchGesture::ChangeFlags QPinchGesture::changeFlags() const
|
---|
496 | {
|
---|
497 | return d_func()->changeFlags;
|
---|
498 | }
|
---|
499 |
|
---|
500 | void QPinchGesture::setChangeFlags(QPinchGesture::ChangeFlags value)
|
---|
501 | {
|
---|
502 | d_func()->changeFlags = value;
|
---|
503 | }
|
---|
504 |
|
---|
505 | QPointF QPinchGesture::startCenterPoint() const
|
---|
506 | {
|
---|
507 | return d_func()->startCenterPoint;
|
---|
508 | }
|
---|
509 |
|
---|
510 | QPointF QPinchGesture::lastCenterPoint() const
|
---|
511 | {
|
---|
512 | return d_func()->lastCenterPoint;
|
---|
513 | }
|
---|
514 |
|
---|
515 | QPointF QPinchGesture::centerPoint() const
|
---|
516 | {
|
---|
517 | return d_func()->centerPoint;
|
---|
518 | }
|
---|
519 |
|
---|
520 | void QPinchGesture::setStartCenterPoint(const QPointF &value)
|
---|
521 | {
|
---|
522 | d_func()->startCenterPoint = value;
|
---|
523 | }
|
---|
524 |
|
---|
525 | void QPinchGesture::setLastCenterPoint(const QPointF &value)
|
---|
526 | {
|
---|
527 | d_func()->lastCenterPoint = value;
|
---|
528 | }
|
---|
529 |
|
---|
530 | void QPinchGesture::setCenterPoint(const QPointF &value)
|
---|
531 | {
|
---|
532 | d_func()->centerPoint = value;
|
---|
533 | }
|
---|
534 |
|
---|
535 |
|
---|
536 | qreal QPinchGesture::totalScaleFactor() const
|
---|
537 | {
|
---|
538 | return d_func()->totalScaleFactor;
|
---|
539 | }
|
---|
540 |
|
---|
541 | qreal QPinchGesture::lastScaleFactor() const
|
---|
542 | {
|
---|
543 | return d_func()->lastScaleFactor;
|
---|
544 | }
|
---|
545 |
|
---|
546 | qreal QPinchGesture::scaleFactor() const
|
---|
547 | {
|
---|
548 | return d_func()->scaleFactor;
|
---|
549 | }
|
---|
550 |
|
---|
551 | void QPinchGesture::setTotalScaleFactor(qreal value)
|
---|
552 | {
|
---|
553 | d_func()->totalScaleFactor = value;
|
---|
554 | }
|
---|
555 |
|
---|
556 | void QPinchGesture::setLastScaleFactor(qreal value)
|
---|
557 | {
|
---|
558 | d_func()->lastScaleFactor = value;
|
---|
559 | }
|
---|
560 |
|
---|
561 | void QPinchGesture::setScaleFactor(qreal value)
|
---|
562 | {
|
---|
563 | d_func()->scaleFactor = value;
|
---|
564 | }
|
---|
565 |
|
---|
566 |
|
---|
567 | qreal QPinchGesture::totalRotationAngle() const
|
---|
568 | {
|
---|
569 | return d_func()->totalRotationAngle;
|
---|
570 | }
|
---|
571 |
|
---|
572 | qreal QPinchGesture::lastRotationAngle() const
|
---|
573 | {
|
---|
574 | return d_func()->lastRotationAngle;
|
---|
575 | }
|
---|
576 |
|
---|
577 | qreal QPinchGesture::rotationAngle() const
|
---|
578 | {
|
---|
579 | return d_func()->rotationAngle;
|
---|
580 | }
|
---|
581 |
|
---|
582 | void QPinchGesture::setTotalRotationAngle(qreal value)
|
---|
583 | {
|
---|
584 | d_func()->totalRotationAngle = value;
|
---|
585 | }
|
---|
586 |
|
---|
587 | void QPinchGesture::setLastRotationAngle(qreal value)
|
---|
588 | {
|
---|
589 | d_func()->lastRotationAngle = value;
|
---|
590 | }
|
---|
591 |
|
---|
592 | void QPinchGesture::setRotationAngle(qreal value)
|
---|
593 | {
|
---|
594 | d_func()->rotationAngle = value;
|
---|
595 | }
|
---|
596 |
|
---|
597 | /*!
|
---|
598 | \class QSwipeGesture
|
---|
599 | \since 4.6
|
---|
600 | \brief The QSwipeGesture class describes a swipe gesture made by the user.
|
---|
601 | \ingroup gestures
|
---|
602 |
|
---|
603 | \image swipegesture.png
|
---|
604 |
|
---|
605 | For an overview of gesture handling in Qt and information on using gestures
|
---|
606 | in your applications, see the \l{Gestures Programming} document.
|
---|
607 |
|
---|
608 | \sa QPanGesture, QPinchGesture
|
---|
609 | */
|
---|
610 |
|
---|
611 | /*!
|
---|
612 | \enum QSwipeGesture::SwipeDirection
|
---|
613 |
|
---|
614 | This enum describes the possible directions for the gesture's motion
|
---|
615 | along the horizontal and vertical axes.
|
---|
616 |
|
---|
617 | \value NoDirection The gesture had no motion associated with it on a particular axis.
|
---|
618 | \value Left The gesture involved a horizontal motion to the left.
|
---|
619 | \value Right The gesture involved a horizontal motion to the right.
|
---|
620 | \value Up The gesture involved an upward vertical motion.
|
---|
621 | \value Down The gesture involved a downward vertical motion.
|
---|
622 | */
|
---|
623 |
|
---|
624 | /*!
|
---|
625 | \property QSwipeGesture::horizontalDirection
|
---|
626 | \brief the horizontal direction of the gesture
|
---|
627 |
|
---|
628 | If the gesture has a horizontal component, the horizontal direction
|
---|
629 | is either Left or Right; otherwise, it is NoDirection.
|
---|
630 |
|
---|
631 | \sa verticalDirection, swipeAngle
|
---|
632 | */
|
---|
633 |
|
---|
634 | /*!
|
---|
635 | \property QSwipeGesture::verticalDirection
|
---|
636 | \brief the vertical direction of the gesture
|
---|
637 |
|
---|
638 | If the gesture has a vertical component, the vertical direction
|
---|
639 | is either Up or Down; otherwise, it is NoDirection.
|
---|
640 |
|
---|
641 | \sa horizontalDirection, swipeAngle
|
---|
642 | */
|
---|
643 |
|
---|
644 | /*!
|
---|
645 | \property QSwipeGesture::swipeAngle
|
---|
646 | \brief the angle of the motion associated with the gesture
|
---|
647 |
|
---|
648 | If the gesture has either a horizontal or vertical component, the
|
---|
649 | swipe angle describes the angle between the direction of motion and the
|
---|
650 | x-axis as defined using the standard widget
|
---|
651 | \l{Coordinate System}{coordinate system}.
|
---|
652 |
|
---|
653 | \sa horizontalDirection, verticalDirection
|
---|
654 | */
|
---|
655 |
|
---|
656 | /*!
|
---|
657 | \property QSwipeGesture::velocity
|
---|
658 | \since 4.7.1
|
---|
659 | \internal
|
---|
660 | */
|
---|
661 |
|
---|
662 | /*!
|
---|
663 | \internal
|
---|
664 | */
|
---|
665 | QSwipeGesture::QSwipeGesture(QObject *parent)
|
---|
666 | : QGesture(*new QSwipeGesturePrivate, parent)
|
---|
667 | {
|
---|
668 | d_func()->gestureType = Qt::SwipeGesture;
|
---|
669 | }
|
---|
670 |
|
---|
671 | QSwipeGesture::SwipeDirection QSwipeGesture::horizontalDirection() const
|
---|
672 | {
|
---|
673 | Q_D(const QSwipeGesture);
|
---|
674 | if (d->swipeAngle < 0 || d->swipeAngle == 90 || d->swipeAngle == 270)
|
---|
675 | return QSwipeGesture::NoDirection;
|
---|
676 | else if (d->swipeAngle < 90 || d->swipeAngle > 270)
|
---|
677 | return QSwipeGesture::Right;
|
---|
678 | else
|
---|
679 | return QSwipeGesture::Left;
|
---|
680 | }
|
---|
681 |
|
---|
682 | QSwipeGesture::SwipeDirection QSwipeGesture::verticalDirection() const
|
---|
683 | {
|
---|
684 | Q_D(const QSwipeGesture);
|
---|
685 | if (d->swipeAngle <= 0 || d->swipeAngle == 180)
|
---|
686 | return QSwipeGesture::NoDirection;
|
---|
687 | else if (d->swipeAngle < 180)
|
---|
688 | return QSwipeGesture::Up;
|
---|
689 | else
|
---|
690 | return QSwipeGesture::Down;
|
---|
691 | }
|
---|
692 |
|
---|
693 | qreal QSwipeGesture::swipeAngle() const
|
---|
694 | {
|
---|
695 | return d_func()->swipeAngle;
|
---|
696 | }
|
---|
697 |
|
---|
698 | void QSwipeGesture::setSwipeAngle(qreal value)
|
---|
699 | {
|
---|
700 | d_func()->swipeAngle = value;
|
---|
701 | }
|
---|
702 |
|
---|
703 | /*!
|
---|
704 | \class QTapGesture
|
---|
705 | \since 4.6
|
---|
706 | \brief The QTapGesture class describes a tap gesture made by the user.
|
---|
707 | \ingroup gestures
|
---|
708 |
|
---|
709 | For an overview of gesture handling in Qt and information on using gestures
|
---|
710 | in your applications, see the \l{Gestures Programming} document.
|
---|
711 |
|
---|
712 | \sa QPanGesture, QPinchGesture
|
---|
713 | */
|
---|
714 |
|
---|
715 | /*!
|
---|
716 | \property QTapGesture::position
|
---|
717 | \brief the position of the tap
|
---|
718 | */
|
---|
719 |
|
---|
720 | /*!
|
---|
721 | \internal
|
---|
722 | */
|
---|
723 | QTapGesture::QTapGesture(QObject *parent)
|
---|
724 | : QGesture(*new QTapGesturePrivate, parent)
|
---|
725 | {
|
---|
726 | d_func()->gestureType = Qt::TapGesture;
|
---|
727 | }
|
---|
728 |
|
---|
729 | QPointF QTapGesture::position() const
|
---|
730 | {
|
---|
731 | return d_func()->position;
|
---|
732 | }
|
---|
733 |
|
---|
734 | void QTapGesture::setPosition(const QPointF &value)
|
---|
735 | {
|
---|
736 | d_func()->position = value;
|
---|
737 | }
|
---|
738 | /*!
|
---|
739 | \class QTapAndHoldGesture
|
---|
740 | \since 4.6
|
---|
741 | \brief The QTapAndHoldGesture class describes a tap-and-hold (aka LongTap)
|
---|
742 | gesture made by the user.
|
---|
743 | \ingroup gestures
|
---|
744 |
|
---|
745 | For an overview of gesture handling in Qt and information on using gestures
|
---|
746 | in your applications, see the \l{Gestures Programming} document.
|
---|
747 |
|
---|
748 | \sa QPanGesture, QPinchGesture
|
---|
749 | */
|
---|
750 |
|
---|
751 | /*!
|
---|
752 | \property QTapAndHoldGesture::position
|
---|
753 | \brief the position of the tap
|
---|
754 | */
|
---|
755 |
|
---|
756 | /*!
|
---|
757 | \internal
|
---|
758 | */
|
---|
759 | QTapAndHoldGesture::QTapAndHoldGesture(QObject *parent)
|
---|
760 | : QGesture(*new QTapAndHoldGesturePrivate, parent)
|
---|
761 | {
|
---|
762 | d_func()->gestureType = Qt::TapAndHoldGesture;
|
---|
763 | }
|
---|
764 |
|
---|
765 | QPointF QTapAndHoldGesture::position() const
|
---|
766 | {
|
---|
767 | return d_func()->position;
|
---|
768 | }
|
---|
769 |
|
---|
770 | void QTapAndHoldGesture::setPosition(const QPointF &value)
|
---|
771 | {
|
---|
772 | d_func()->position = value;
|
---|
773 | }
|
---|
774 |
|
---|
775 | /*!
|
---|
776 | Set the timeout, in milliseconds, before the gesture triggers.
|
---|
777 |
|
---|
778 | The recognizer will detect a touch down and and if \a msecs
|
---|
779 | later the touch is still down, it will trigger the QTapAndHoldGesture.
|
---|
780 | The default value is 700 milliseconds.
|
---|
781 | */
|
---|
782 | // static
|
---|
783 | void QTapAndHoldGesture::setTimeout(int msecs)
|
---|
784 | {
|
---|
785 | QTapAndHoldGesturePrivate::Timeout = msecs;
|
---|
786 | }
|
---|
787 |
|
---|
788 | /*!
|
---|
789 | Gets the timeout, in milliseconds, before the gesture triggers.
|
---|
790 |
|
---|
791 | The recognizer will detect a touch down and and if timeout()
|
---|
792 | later the touch is still down, it will trigger the QTapAndHoldGesture.
|
---|
793 | The default value is 700 milliseconds.
|
---|
794 | */
|
---|
795 | // static
|
---|
796 | int QTapAndHoldGesture::timeout()
|
---|
797 | {
|
---|
798 | return QTapAndHoldGesturePrivate::Timeout;
|
---|
799 | }
|
---|
800 |
|
---|
801 | int QTapAndHoldGesturePrivate::Timeout = 700; // in ms
|
---|
802 |
|
---|
803 | QT_END_NAMESPACE
|
---|
804 |
|
---|
805 | #include <moc_qgesture.cpp>
|
---|
806 |
|
---|
807 | #endif // QT_NO_GESTURES
|
---|