Commit 52594677 authored by Don Gagne's avatar Don Gagne

Merge pull request #2369 from DonLakeFlyer/LiveDrag

Continuous drag of mission items
parents cc5689ba 894b21c8
......@@ -195,20 +195,29 @@ QGCView {
id: itemDragger
x: missionItemIndicator ? (missionItemIndicator.x + missionItemIndicator.anchorPoint.x - (itemDragger.width / 2)) : 100
y: missionItemIndicator ? (missionItemIndicator.y + missionItemIndicator.anchorPoint.y - (itemDragger.height / 2)) : 100
width: _radius * 2
height: _radius * 2
//radius: _radius
//border.width: 2
//border.color: "white"
width: ScreenTools.defaultFontPixelHeight * 2
height: ScreenTools.defaultFontPixelHeight * 2
color: "transparent"
visible: false
z: QGroundControl.zOrderMapItems + 1 // Above item icons
property var missionItem
property var missionItemIndicator
readonly property real _radius: ScreenTools.defaultFontPixelHeight * 4
readonly property real _arrowHeight: ScreenTools.defaultFontPixelHeight
property bool preventCoordinateBindingLoop: false
onXChanged: liveDrag()
onYChanged: liveDrag()
function liveDrag() {
if (!itemDragger.preventCoordinateBindingLoop && Drag.active) {
var point = Qt.point(itemDragger.x + (itemDragger.width / 2), itemDragger.y + (itemDragger.height / 2))
var coordinate = editorMap.toCoordinate(point)
coordinate.altitude = itemDragger.missionItem.coordinate.altitude
itemDragger.preventCoordinateBindingLoop = true
itemDragger.missionItem.coordinate = coordinate
itemDragger.preventCoordinateBindingLoop = false
}
}
function clearItem() {
itemDragger.visible = false
......@@ -216,64 +225,6 @@ QGCView {
itemDragger.missionItemIndicator = undefined
}
Image {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
height: parent._arrowHeight
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
source: "/qmlimages/ArrowHead.svg"
}
Image {
id: arrowUp
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
height: parent._arrowHeight
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
source: "/qmlimages/ArrowHead.svg"
transform: Rotation { origin.x: arrowUp.width / 2; origin.y: arrowUp.height / 2; angle: 90}
}
Image {
id: arrowDown
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
height: parent._arrowHeight
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
source: "/qmlimages/ArrowHead.svg"
transform: Rotation { origin.x: arrowDown.width / 2; origin.y: arrowDown.height / 2; angle: 180}
}
Image {
id: arrowLeft
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
height: parent._arrowHeight
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
source: "/qmlimages/ArrowHead.svg"
transform: Rotation { origin.x: arrowLeft.width / 2; origin.y: arrowLeft.height / 2; angle: -90}
}
Rectangle {
width: _radius * 2
height: _radius * 2
radius: _radius
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
border.width: 1
border.color: "white"
readonly property real _radius: ScreenTools.defaultFontPixelWidth / 4
}
Drag.active: itemDrag.drag.active
Drag.hotSpot.x: width / 2
Drag.hotSpot.y: height / 2
......@@ -286,19 +237,6 @@ QGCView {
drag.minimumY: 0
drag.maximumX: itemDragger.parent.width - parent.width
drag.maximumY: itemDragger.parent.height - parent.height
property bool dragActive: drag.active
onDragActiveChanged: {
if (!drag.active) {
var point = Qt.point(itemDragger.x + (itemDragger.width / 2), itemDragger.y + (itemDragger.height / 2))
var coordinate = editorMap.toCoordinate(point)
coordinate.altitude = itemDragger.missionItem.coordinate.altitude
itemDragger.missionItem.coordinate = coordinate
editorMap.latitude = itemDragger.missionItem.coordinate.latitude
editorMap.longitude = itemDragger.missionItem.coordinate.longitude
}
}
}
}
......
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