Commit c16149c0 authored by Don Gagne's avatar Don Gagne

Improve touch support for map item dragging

parent b3dac085
......@@ -244,10 +244,11 @@ Map {
"import QtQuick 2.5; " +
"import QtLocation 5.3; " +
"import QGroundControl.ScreenTools 1.0; " +
"" +
"Rectangle {" +
" id: vertexDrag; " +
" width: _sideLength; " +
" height: _sideLength; " +
" width: _sideLength + _expandMargin; " +
" height: _sideLength + _expandMargin; " +
" color: 'red'; " +
"" +
" property var coordinate; " +
......@@ -256,27 +257,27 @@ Map {
" readonly property real _sideLength: ScreenTools.defaultFontPixelWidth * 2; " +
" readonly property real _halfSideLength: _sideLength / 2; " +
"" +
" property real _expandMargin: ScreenTools.isMobile ? ScreenTools.defaultFontPixelWidth : 0;" +
"" +
" Drag.active: dragMouseArea.drag.active; " +
" Drag.hotSpot.x: _halfSideLength; " +
" Drag.hotSpot.y: _halfSideLength; " +
"" +
" onXChanged: updateCoordinate(); " +
" onYChanged: updateCoordinate(); " +
"" +
" function updateCoordinate() { " +
" vertexDrag.coordinate = _map.toCoordinate(Qt.point(vertexDrag.x + _halfSideLength, vertexDrag.y + _halfSideLength), false); " +
" vertexDrag.coordinate = _map.toCoordinate(Qt.point(vertexDrag.x + _expandMargin + _halfSideLength, vertexDrag.y + _expandMargin + _halfSideLength), false); " +
" polygonDrawer._callbackObject.polygonAdjustVertex(vertexDrag.index, vertexDrag.coordinate); " +
" } " +
"" +
" function updatePosition() { " +
" var vertexPoint = _map.fromCoordinate(coordinate, false); " +
" vertexDrag.x = vertexPoint.x - _halfSideLength; " +
" vertexDrag.y = vertexPoint.y - _halfSideLength; " +
" vertexDrag.x = vertexPoint.x - _expandMargin - _halfSideLength; " +
" vertexDrag.y = vertexPoint.y - _expandMargin - _halfSideLength; " +
" } " +
"" +
" Connections { " +
" target: _map; " +
" onCenterChanged: updatePosition(); " +
" target: _map; " +
" onCenterChanged: updatePosition(); " +
" onZoomLevelChanged: updatePosition(); " +
" } " +
"" +
......
......@@ -181,9 +181,7 @@ Item {
}
}
Drag.active: itemDrag.drag.active
Drag.hotSpot.x: mapQuickItem.anchorPoint.x
Drag.hotSpot.y: mapQuickItem.anchorPoint.y
Drag.active: itemDrag.drag.active
MouseArea {
id: itemDrag
......
......@@ -82,22 +82,23 @@ Item {
Rectangle {
id: itemDragger
x: _itemVisual.x
y: _itemVisual.y
width: _itemVisual.width
height: _itemVisual.height
x: _itemVisual.x - _expandMargin
y: _itemVisual.y - _expandMargin
width: _itemVisual.width + (_expandMargin * 2)
height: _itemVisual.height + (_expandMargin * 2)
color: "transparent"
z: QGroundControl.zOrderMapItems + 1 // Above item icons
property bool dragLoiter
property bool _preventCoordinateBindingLoop: false
property real _expandMargin: ScreenTools.isMobile ? ScreenTools.defaultFontPixelWidth : 0
onXChanged: liveDrag()
onYChanged: liveDrag()
function liveDrag() {
if (!itemDragger._preventCoordinateBindingLoop && Drag.active) {
var point = Qt.point(itemDragger.x + _itemVisual.anchorPoint.x, itemDragger.y + _itemVisual.anchorPoint.y)
var point = Qt.point(itemDragger.x + _expandMargin + _itemVisual.anchorPoint.x, itemDragger.y + _expandMargin + _itemVisual.anchorPoint.y)
var coordinate = map.toCoordinate(point)
itemDragger._preventCoordinateBindingLoop = true
coordinate.altitude = _missionItem.coordinate.altitude
......@@ -106,9 +107,7 @@ Item {
}
}
Drag.active: itemDrag.drag.active
Drag.hotSpot.x: _itemVisual.anchorPoint.x
Drag.hotSpot.y: _itemVisual.anchorPoint.y
Drag.active: itemDrag.drag.active
MouseArea {
id: itemDrag
......
......@@ -23,6 +23,7 @@ Canvas {
property real _width: small ? ScreenTools.defaultFontPixelHeight * ScreenTools.smallFontPointRatio * 1.25 : ScreenTools.defaultFontPixelHeight * 1.25
property bool _singleChar: _label.text.length <= 1
onColorChanged: requestPaint()
QGCPalette { id: qgcPal }
......@@ -73,7 +74,13 @@ Canvas {
}
MouseArea {
anchors.fill: parent
onClicked: parent.clicked()
anchors.leftMargin: -_expandMargin
anchors.rightMargin: _expandMargin
anchors.topMargin: -_expandMargin
anchors.bottomMargin: _expandMargin
anchors.fill: parent
onClicked: parent.clicked()
property real _expandMargin: ScreenTools.isMobile ? ScreenTools.defaultFontPixelWidth : 0
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment