diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index faffb32ac89b69bb4e740537126025df914f8618..f1d8bf2e72d601fe94b2a4b05588de936bf29f71 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -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 - } - } } }