diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-08-26 11:49:18 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-08-27 12:06:13 (GMT) |
commit | 42b1e49335377175b73a499236a800fca40a1d3e (patch) | |
tree | 4ed9868696e18521c5338c921dbbfa76d9a3f916 /src/gui/kernel/qstandardgestures.cpp | |
parent | 220bb878d78eadfdfd390ca51c1a24378859d4ba (diff) | |
download | Qt-42b1e49335377175b73a499236a800fca40a1d3e.zip Qt-42b1e49335377175b73a499236a800fca40a1d3e.tar.gz Qt-42b1e49335377175b73a499236a800fca40a1d3e.tar.bz2 |
Cocoa: implement pan gestures to follow mouse
Diffstat (limited to 'src/gui/kernel/qstandardgestures.cpp')
-rw-r--r-- | src/gui/kernel/qstandardgestures.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index ac8c0c3..0bd8133 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -214,19 +214,14 @@ bool QPanGesture::filterEvent(QEvent *event) switch (event->type()) { case QEvent::TouchBegin: { - if (ev->touchPoints().size() == 1) + if (ev->touchPoints().size() == 1) { + d->lastPosition = QCursor::pos(); d->singleTouchPanTimer.start(panBeginDelay, this); + } break;} case QEvent::TouchEnd: { - if (state() != Qt::NoGesture) { - if (ev->touchPoints().size() == 1) { - QTouchEvent::TouchPoint p = ev->touchPoints().at(0); - QPointF dist = p.pos() - p.lastPos(); - d->lastOffset = QSizeF(dist.x(), dist.y()); - d->totalOffset += d->lastOffset; - } + if (state() != Qt::NoGesture) updateState(Qt::GestureFinished); - } reset(); break;} case QEvent::TouchUpdate: { @@ -239,13 +234,18 @@ bool QPanGesture::filterEvent(QEvent *event) const QPoint p = ev->touchPoints().at(0).pos().toPoint(); if ((startPos - p).manhattanLength() > panBeginRadius) reset(); + else + d->lastPosition = QCursor::pos(); } else { - QTouchEvent::TouchPoint p = ev->touchPoints().at(0); - QPointF dist = p.pos() - p.lastPos(); + QPointF mousePos = QCursor::pos(); + QPointF dist = mousePos - d->lastPosition; + d->lastPosition = mousePos; d->lastOffset = QSizeF(dist.x(), dist.y()); d->totalOffset += d->lastOffset; updateState(Qt::GestureUpdated); } + } else if (state() == Qt::NoGesture) { + reset(); } break;} default: @@ -262,10 +262,11 @@ void QPanGesture::reset() { Q_D(QPanGesture); d->lastOffset = d->totalOffset = QSize(0, 0); - d->lastPosition = QPoint(); + d->lastPosition = QPoint(0, 0); #if defined(QT_MAC_USE_COCOA) d->singleTouchPanTimer.stop(); + d->prevMousePos = QPointF(0, 0); #endif QGesture::reset(); |