From fbfc8ffbf39e2e7a540d4d576ec61bea7db63416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 2 Oct 2013 08:52:26 +0200 Subject: Implement native gestures on OS X. Add QWindowSystemInterface::GestureEvent and QNativeGestureEvent to QtGui. These events are copies of Qt4's QNativeGestureEvent, where it was an implementation detail of QGestureManager. Add gesture message handlers to QNSView and bring back the Mac gesture recognizers for QGestureManager. Task-number: QTBUG-28126 Change-Id: I1304e09e776fa7c44d133d54ca8b895ca2f544c5 Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- src/gui/kernel/qevent.cpp | 115 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) (limited to 'src/gui/kernel/qevent.cpp') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ef9a3a1225..06fa1f3550 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2263,6 +2263,121 @@ QTabletEvent::~QTabletEvent() #endif // QT_NO_TABLETEVENT +/*! + \class QNativeGestureEvent + \since 5.2 + \brief The QNativeGestureEvent class contains parameters that describe a gesture event. + \inmodule QtGui + \ingroup events + + Native gesture events are generated by the operating system, typically by + interpreting touch events. Gesture events are high-level events such + as zoom or rotate. + + \table + \header + \li Event Type + \li Description + \li Touch equence + \row + \li Qt::ZoomNativeGesture + \li Magnification delta in percent. + \li OS X: Two-finger pinch. + \row + \li Qt::SmartZoomNativeGesture + \li Boolean magnification state. + \li OS X: Two-finger douple tap (trackpad) / One-finger douple tap (magic mouse). + \row + \li Qt::RotateNativeGesture + \li Rotation delta in degrees. + \li OS X: Two-finger rotate. + \endtable + + + In addition, BeginNativeGesture and EndNativeGesture are sent before and after + gesture event streams: + + BeginNativeGesture + ZoomNativeGesture + ZoomNativeGesture + ZoomNativeGesture + EndNativeGesture + + \sa Qt::NativeGestureType, QGestureEvent +*/ + +/*! + Constructs a native gesture event of type \a type. + + The points \a localPos, \a windowPos and \a screenPos specify the + gesture position relative to the receiving widget or item, + window, and screen, respectively. + + \a realValue is the OS X event parameter, \a sequenceId and \a intValue are the Windows event parameters. +*/ +QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos, + const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) + : QInputEvent(QEvent::NativeGesture), mGestureType(type), + mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), + mSequenceId(sequenceId), mIntValue(intValue) +{ } + +/*! + \fn QNativeGestureEvent::gestureType() const + \since 5.2 + + Returns the gesture type. +*/ + +/*! + \fn QNativeGestureEvent::value() const + \since 5.2 + + Returns the gesture value. The value should be interpreted based on the + gesture type. For example, a Zoom gesture provides a scale factor while a Rotate + gesture provides a rotation delta. + + \sa QNativeGestureEvent, gestureType() +*/ + +/*! + \fn QPoint QNativeGestureEvent::globalPos() const + \since 5.2 + + Returns the position of the gesture as a QPointF in screen coordinates +*/ + +/*! + \fn QPoint QNativeGestureEvent::pos() const + \since 5.2 + + Returns the position of the mouse cursor, relative to the widget + or item that received the event. +*/ + +/*! + \fn QPointF QNativeGestureEvent::localPos() const + \since 5.2 + + Returns the position of the gesture as a QPointF, relative to the + widget or item that received the event. +*/ + +/*! + \fn QPointF QNativeGestureEvent::screenPos() const + \since 5.2 + + Returns the position of the gesture as a QPointF in screen coordinates. +*/ + +/*! + \fn QPointF QNativeGestureEvent::windowPos() const + \since 5.2 + + Returns the position of the gesture as a QPointF, relative to the + window that received the event. +*/ + #ifndef QT_NO_DRAGANDDROP /*! Creates a QDragMoveEvent of the required \a type indicating -- cgit v1.2.3