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