summaryrefslogtreecommitdiff
path: root/src/location/declarativemaps/qquickgeomapgesturearea_p.h
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-01-24 16:16:20 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-01-30 11:45:49 +0000
commit4f338577a8dba92e69e8eea23d255d46e52c9c85 (patch)
tree89e8b12550b49de544ccef17e638152f24229832 /src/location/declarativemaps/qquickgeomapgesturearea_p.h
parent19fa507fc6c75e472d88f97353ded9340c084de8 (diff)
downloadqtlocation-4f338577a8dba92e69e8eea23d255d46e52c9c85.tar.gz
Add tilt and bearing gestures to QQuickGeoMapGestureArea
This patch adds two new gestures to the Map gesture area, that are two finger rotation and two finger parallel vertical sliding. The first gesture changes the bearing of the map, while the second gesture changes the tilt angle. The rotation gesture can co-exist with both pan and pinch. In other words it's possible to put down two fingers on the map, and rotate, pinch and pan at the same time. The tilt gesture, on the other hand, excludes the others when initiated, and also does not start, if any of the other actions is in progress. Change-Id: I0ef003caf0efe4addcf2e5ad563212f3c53db9ba Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qquickgeomapgesturearea_p.h')
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea_p.h79
1 files changed, 74 insertions, 5 deletions
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea_p.h b/src/location/declarativemaps/qquickgeomapgesturearea_p.h
index 5d3efc8d..5cafec0d 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea_p.h
+++ b/src/location/declarativemaps/qquickgeomapgesturearea_p.h
@@ -120,6 +120,8 @@ class Q_LOCATION_PRIVATE_EXPORT QQuickGeoMapGestureArea: public QQuickItem
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool pinchActive READ isPinchActive NOTIFY pinchActiveChanged)
Q_PROPERTY(bool panActive READ isPanActive NOTIFY panActiveChanged)
+ Q_PROPERTY(bool rotationActive READ isRotationActive NOTIFY rotationActiveChanged)
+ Q_PROPERTY(bool tiltActive READ isTiltActive NOTIFY tiltActiveChanged)
Q_PROPERTY(AcceptedGestures acceptedGestures READ acceptedGestures WRITE setAcceptedGestures NOTIFY acceptedGesturesChanged)
Q_PROPERTY(qreal maximumZoomLevelChange READ maximumZoomLevelChange WRITE setMaximumZoomLevelChange NOTIFY maximumZoomLevelChangeChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
@@ -133,7 +135,9 @@ public:
NoGesture = 0x0000,
PinchGesture = 0x0001,
PanGesture = 0x0002,
- FlickGesture = 0x004
+ FlickGesture = 0x0004,
+ RotationGesture = 0x0008,
+ TiltGesture = 0x0010
};
Q_DECLARE_FLAGS(AcceptedGestures, GeoMapGesture)
@@ -142,6 +146,8 @@ public:
void setAcceptedGestures(AcceptedGestures acceptedGestures);
bool isPinchActive() const;
+ bool isRotationActive() const;
+ bool isTiltActive() const;
bool isPanActive() const;
bool isActive() const;
@@ -176,6 +182,8 @@ public:
Q_SIGNALS:
void panActiveChanged();
void pinchActiveChanged();
+ void rotationActiveChanged();
+ void tiltActiveChanged();
void enabledChanged();
void maximumZoomLevelChangeChanged();
void acceptedGesturesChanged();
@@ -187,6 +195,12 @@ Q_SIGNALS:
void panFinished();
void flickStarted();
void flickFinished();
+ void rotationStarted(QGeoMapPinchEvent *pinch);
+ void rotationUpdated(QGeoMapPinchEvent *pinch);
+ void rotationFinished(QGeoMapPinchEvent *pinch);
+ void tiltStarted(QGeoMapPinchEvent *pinch);
+ void tiltUpdated(QGeoMapPinchEvent *pinch);
+ void tiltFinished(QGeoMapPinchEvent *pinch);
void preventStealingChanged();
private:
void update();
@@ -198,6 +212,20 @@ private:
void startTwoTouchPoints();
void updateTwoTouchPoints();
+ // All two fingers vertical parallel panning related code, which encompasses tilting
+ void tiltStateMachine();
+ bool canStartTilt();
+ void startTilt();
+ void updateTilt();
+ void endTilt();
+
+ // All two fingers rotation related code, which encompasses rotation
+ void rotationStateMachine();
+ bool canStartRotation();
+ void startRotation();
+ void updateRotation();
+ void endRotation();
+
// All pinch related code, which encompasses zoom
void pinchStateMachine();
bool canStartPinch();
@@ -216,6 +244,10 @@ private:
bool pinchEnabled() const;
void setPinchEnabled(bool enabled);
+ bool rotationEnabled() const;
+ void setRotationEnabled(bool enabled);
+ bool tiltEnabled() const;
+ void setTiltEnabled(bool enabled);
bool panEnabled() const;
void setPanEnabled(bool enabled);
bool flickEnabled() const;
@@ -235,12 +267,16 @@ private:
QDeclarativeGeoMap *m_declarativeMap;
bool m_enabled;
+ // This should be intended as a "two fingers gesture" struct
struct Pinch
{
- Pinch() : m_enabled(true), m_startDist(0), m_lastAngle(0.0) {}
+ Pinch() : m_pinchEnabled(true), m_rotationEnabled(true), m_tiltEnabled(true),
+ m_startDist(0), m_lastAngle(0.0) {}
QGeoMapPinchEvent m_event;
- bool m_enabled;
+ bool m_pinchEnabled;
+ bool m_rotationEnabled;
+ bool m_tiltEnabled;
struct Zoom
{
Zoom() : m_minimum(0.0), m_maximum(30.0), m_start(0.0), m_previous(0.0),
@@ -252,6 +288,21 @@ private:
qreal maximumChange;
} m_zoom;
+ struct Rotation
+ {
+ Rotation() : m_startBearing(0.0), m_previousTouchAngle(0.0), m_totalAngle(0.0) {}
+ qreal m_startBearing;
+ qreal m_previousTouchAngle; // needed for detecting crossing +- 180 in a safer way
+ qreal m_totalAngle;
+ } m_rotation;
+
+ struct Tilt
+ {
+ Tilt() {}
+ QPointF m_startTouchCentroid;
+ qreal m_startTilt;
+ } m_tilt;
+
QPointF m_lastPoint1;
QPointF m_lastPoint2;
qreal m_startDist;
@@ -262,10 +313,13 @@ private:
struct Pan
{
+ Pan() : m_maxVelocity(2500), m_deceleration(2500), m_animation(0), m_flickEnabled(true), m_panEnabled(true) {}
+
qreal m_maxVelocity;
qreal m_deceleration;
QQuickGeoCoordinateAnimation *m_animation;
- bool m_enabled;
+ bool m_flickEnabled;
+ bool m_panEnabled;
} m_flick;
@@ -284,8 +338,9 @@ private:
QGeoCoordinate m_startCoord;
QGeoCoordinate m_touchCenterCoord;
qreal m_twoTouchAngle;
+ qreal m_twoTouchAngleStart;
qreal m_distanceBetweenTouchPoints;
- QPointF m_sceneCenter;
+ QPointF m_touchPointsCentroid;
bool m_preventStealing;
bool m_panEnabled;
@@ -304,6 +359,20 @@ private:
pinchActive
} m_pinchState;
+ enum RotationState
+ {
+ rotationInactive,
+ rotationInactiveTwoPoints,
+ rotationActive
+ } m_rotationState;
+
+ enum TiltState
+ {
+ tiltInactive,
+ tiltInactiveTwoPoints,
+ tiltActive
+ } m_tiltState;
+
enum FlickState
{
flickInactive,