1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.widgets.gesture; 15 extern(C++): 16 17 import qt.config; 18 import qt.helpers; 19 version(QT_NO_GESTURES){}else 20 { 21 import qt.core.coreevent; 22 import qt.core.flags; 23 import qt.core.global; 24 import qt.core.list; 25 import qt.core.map; 26 import qt.core.namespace; 27 import qt.core.object; 28 import qt.core.point; 29 import qt.widgets.widget; 30 } 31 32 version(QT_NO_GESTURES){}else 33 { 34 35 /+ Q_DECLARE_METATYPE(Qt::GestureState) 36 Q_DECLARE_METATYPE(Qt::GestureType) +/ 37 38 39 40 extern(C++, class) struct QGesturePrivate; 41 class /+ Q_WIDGETS_EXPORT +/ QGesture : QObject 42 { 43 mixin(Q_OBJECT); 44 /+ Q_DECLARE_PRIVATE(QGesture) +/ 45 46 /+ Q_PROPERTY(Qt::GestureState state READ state) 47 Q_PROPERTY(Qt::GestureType gestureType READ gestureType) 48 Q_PROPERTY(QGesture::GestureCancelPolicy gestureCancelPolicy READ gestureCancelPolicy WRITE setGestureCancelPolicy) 49 Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot) 50 Q_PROPERTY(bool hasHotSpot READ hasHotSpot) +/ 51 52 public: 53 /+ explicit +/this(QObject parent = null); 54 ~this(); 55 56 final /+ Qt:: +/qt.core.namespace.GestureType gestureType() const; 57 58 final /+ Qt:: +/qt.core.namespace.GestureState state() const; 59 60 final QPointF hotSpot() const; 61 final void setHotSpot(ref const(QPointF) value); 62 final bool hasHotSpot() const; 63 final void unsetHotSpot(); 64 65 enum GestureCancelPolicy { 66 CancelNone = 0, 67 CancelAllInContext 68 } 69 70 final void setGestureCancelPolicy(GestureCancelPolicy policy); 71 final GestureCancelPolicy gestureCancelPolicy() const; 72 73 protected: 74 this(ref QGesturePrivate dd, QObject parent); 75 76 private: 77 /+ friend class QGestureEvent; +/ 78 /+ friend class QGestureRecognizer; +/ 79 /+ friend class QGestureManager; +/ 80 /+ friend class QGraphicsScenePrivate; +/ 81 } 82 83 extern(C++, class) struct QPanGesturePrivate; 84 class /+ Q_WIDGETS_EXPORT +/ QPanGesture : QGesture 85 { 86 mixin(Q_OBJECT); 87 /+ Q_DECLARE_PRIVATE(QPanGesture) +/ 88 89 /+ Q_PROPERTY(QPointF lastOffset READ lastOffset WRITE setLastOffset) 90 Q_PROPERTY(QPointF offset READ offset WRITE setOffset) 91 Q_PROPERTY(QPointF delta READ delta STORED false) 92 Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration) 93 Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity) 94 Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity) +/ 95 96 public: 97 /+ explicit +/this(QObject parent = null); 98 ~this(); 99 100 final QPointF lastOffset() const; 101 final QPointF offset() const; 102 final QPointF delta() const; 103 final qreal acceleration() const; 104 105 final void setLastOffset(ref const(QPointF) value); 106 final void setOffset(ref const(QPointF) value); 107 final void setAcceleration(qreal value); 108 109 /+ friend class QPanGestureRecognizer; +/ 110 /+ friend class QWinNativePanGestureRecognizer; +/ 111 } 112 113 extern(C++, class) struct QPinchGesturePrivate; 114 class /+ Q_WIDGETS_EXPORT +/ QPinchGesture : QGesture 115 { 116 mixin(Q_OBJECT); 117 /+ Q_DECLARE_PRIVATE(QPinchGesture) +/ 118 119 public: 120 enum ChangeFlag { 121 ScaleFactorChanged = 0x1, 122 RotationAngleChanged = 0x2, 123 CenterPointChanged = 0x4 124 } 125 /+ Q_FLAG(ChangeFlag) +/ 126 /+ Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) +/ 127 alias ChangeFlags = QFlags!(ChangeFlag); /+ Q_FLAG(ChangeFlags) +/ 128 129 /+ Q_PROPERTY(ChangeFlags totalChangeFlags READ totalChangeFlags WRITE setTotalChangeFlags) 130 Q_PROPERTY(ChangeFlags changeFlags READ changeFlags WRITE setChangeFlags) 131 132 Q_PROPERTY(qreal totalScaleFactor READ totalScaleFactor WRITE setTotalScaleFactor) 133 Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor WRITE setLastScaleFactor) 134 Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor) 135 136 Q_PROPERTY(qreal totalRotationAngle READ totalRotationAngle WRITE setTotalRotationAngle) 137 Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle WRITE setLastRotationAngle) 138 Q_PROPERTY(qreal rotationAngle READ rotationAngle WRITE setRotationAngle) 139 140 Q_PROPERTY(QPointF startCenterPoint READ startCenterPoint WRITE setStartCenterPoint) 141 Q_PROPERTY(QPointF lastCenterPoint READ lastCenterPoint WRITE setLastCenterPoint) 142 Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint) +/ 143 144 public: 145 /+ explicit +/this(QObject parent = null); 146 ~this(); 147 148 final ChangeFlags totalChangeFlags() const; 149 final void setTotalChangeFlags(ChangeFlags value); 150 151 final ChangeFlags changeFlags() const; 152 final void setChangeFlags(ChangeFlags value); 153 154 final QPointF startCenterPoint() const; 155 final QPointF lastCenterPoint() const; 156 final QPointF centerPoint() const; 157 final void setStartCenterPoint(ref const(QPointF) value); 158 final void setLastCenterPoint(ref const(QPointF) value); 159 final void setCenterPoint(ref const(QPointF) value); 160 161 final qreal totalScaleFactor() const; 162 final qreal lastScaleFactor() const; 163 final qreal scaleFactor() const; 164 final void setTotalScaleFactor(qreal value); 165 final void setLastScaleFactor(qreal value); 166 final void setScaleFactor(qreal value); 167 168 final qreal totalRotationAngle() const; 169 final qreal lastRotationAngle() const; 170 final qreal rotationAngle() const; 171 final void setTotalRotationAngle(qreal value); 172 final void setLastRotationAngle(qreal value); 173 final void setRotationAngle(qreal value); 174 175 /+ friend class QPinchGestureRecognizer; +/ 176 } 177 /+pragma(inline, true) QFlags!(QPinchGesture.ChangeFlags.enum_type) operator |(QPinchGesture.ChangeFlags.enum_type f1, QPinchGesture.ChangeFlags.enum_type f2)/+noexcept+/{return QFlags!(QPinchGesture.ChangeFlags.enum_type)(f1)|f2;}+/ 178 /+pragma(inline, true) QFlags!(QPinchGesture.ChangeFlags.enum_type) operator |(QPinchGesture.ChangeFlags.enum_type f1, QFlags!(QPinchGesture.ChangeFlags.enum_type) f2)/+noexcept+/{return f2|f1;}+/ 179 /+pragma(inline, true) QIncompatibleFlag operator |(QPinchGesture.ChangeFlags.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/ 180 181 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags) 182 183 Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags) +/ 184 185 186 extern(C++, class) struct QSwipeGesturePrivate; 187 class /+ Q_WIDGETS_EXPORT +/ QSwipeGesture : QGesture 188 { 189 mixin(Q_OBJECT); 190 /+ Q_DECLARE_PRIVATE(QSwipeGesture) +/ 191 192 /+ Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false) 193 Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false) 194 Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle) 195 Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity) +/ 196 197 public: 198 enum SwipeDirection { NoDirection, Left, Right, Up, Down } 199 /+ Q_ENUM(SwipeDirection) +/ 200 201 /+ explicit +/this(QObject parent = null); 202 ~this(); 203 204 final SwipeDirection horizontalDirection() const; 205 final SwipeDirection verticalDirection() const; 206 207 final qreal swipeAngle() const; 208 final void setSwipeAngle(qreal value); 209 210 /+ friend class QSwipeGestureRecognizer; +/ 211 } 212 213 extern(C++, class) struct QTapGesturePrivate; 214 class /+ Q_WIDGETS_EXPORT +/ QTapGesture : QGesture 215 { 216 mixin(Q_OBJECT); 217 /+ Q_DECLARE_PRIVATE(QTapGesture) +/ 218 219 /+ Q_PROPERTY(QPointF position READ position WRITE setPosition) +/ 220 221 public: 222 /+ explicit +/this(QObject parent = null); 223 ~this(); 224 225 final QPointF position() const; 226 final void setPosition(ref const(QPointF) pos); 227 228 /+ friend class QTapGestureRecognizer; +/ 229 } 230 231 extern(C++, class) struct QTapAndHoldGesturePrivate; 232 class /+ Q_WIDGETS_EXPORT +/ QTapAndHoldGesture : QGesture 233 { 234 mixin(Q_OBJECT); 235 /+ Q_DECLARE_PRIVATE(QTapAndHoldGesture) +/ 236 237 /+ Q_PROPERTY(QPointF position READ position WRITE setPosition) +/ 238 239 public: 240 /+ explicit +/this(QObject parent = null); 241 ~this(); 242 243 final QPointF position() const; 244 final void setPosition(ref const(QPointF) pos); 245 246 static void setTimeout(int msecs); 247 static int timeout(); 248 249 /+ friend class QTapAndHoldGestureRecognizer; +/ 250 } 251 252 /+ class QGesture; +/ 253 extern(C++, class) struct QGestureEventPrivate; 254 /+class /+ Q_WIDGETS_EXPORT +/ QGestureEvent : QEvent 255 { 256 public: 257 /+ explicit +/this(ref const(QList!(QGesture)) gestures); 258 ~this(); 259 260 final QList!(QGesture) gestures() const; 261 final QGesture gesture(/+ Qt:: +/qt.core.namespace.GestureType type) const; 262 263 final QList!(QGesture) activeGestures() const; 264 final QList!(QGesture) canceledGestures() const; 265 266 /+ using QEvent::setAccepted; +/ 267 /+ using QEvent::isAccepted; +/ 268 /+ using QEvent::accept; +/ 269 /+ using QEvent::ignore; +/ 270 271 final void setAccepted(QGesture , bool); 272 final void accept(QGesture ); 273 final void ignore(QGesture ); 274 final bool isAccepted(QGesture ) const; 275 276 final void setAccepted(/+ Qt:: +/qt.core.namespace.GestureType, bool); 277 final void accept(/+ Qt:: +/qt.core.namespace.GestureType); 278 final void ignore(/+ Qt:: +/qt.core.namespace.GestureType); 279 final bool isAccepted(/+ Qt:: +/qt.core.namespace.GestureType) const; 280 281 final void setWidget(QWidget widget); 282 final QWidget widget() const; 283 284 /+ #if QT_CONFIG(graphicsview) +/ 285 final QPointF mapToGraphicsScene(ref const(QPointF) gesturePoint) const; 286 /+ #endif +/ 287 288 private: 289 QList!(QGesture) m_gestures; 290 QWidget m_widget; 291 QMap!(/+ Qt:: +/qt.core.namespace.GestureType, bool) m_accepted; 292 QMap!(/+ Qt:: +/qt.core.namespace.GestureType, QWidget) m_targetWidgets; 293 294 /+ friend class QApplication; +/ 295 /+ friend class QGestureManager; +/ 296 }+/ 297 298 /+ # ifndef QT_NO_DEBUG_STREAM 299 Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QGesture *); 300 Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QGestureEvent *); 301 # endif 302 303 304 Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy) +/ 305 } 306