diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 13ebdb73d24a7c8c67565a9aaa7d6080780fbbb9..96ade0b61cffd6205ed90bd8e9b3f232ab784a44 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -23,6 +23,7 @@
src/QmlControls/QGCComboBox.qml
src/QmlControls/QGCColoredImage.qml
src/QmlControls/QGCToolBarButton.qml
+ src/QmlControls/QGCMovableItem.qml
src/QmlControls/SubMenuButton.qml
src/QmlControls/IndicatorButton.qml
diff --git a/src/QmlControls/QGCMovableItem.qml b/src/QmlControls/QGCMovableItem.qml
new file mode 100644
index 0000000000000000000000000000000000000000..32d84398843e3e4858f19d25322b7905215ef2be
--- /dev/null
+++ b/src/QmlControls/QGCMovableItem.qml
@@ -0,0 +1,63 @@
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+
+// This item can be dragged around within its parent.
+// Double click issues a signal the parent can use to
+// reset its default position.
+
+Item {
+ id: root
+ property bool allowDragging: true
+ property real minimumWidth: 60
+ property real minimumHeight: 60
+ property alias tForm: tform
+ signal resetRequested()
+ transform: Scale {
+ id: tform
+ }
+ MouseArea {
+ property double factor: 25
+ enabled: root.allowDragging
+ cursorShape: Qt.OpenHandCursor
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAndYAxis
+ drag.minimumX: 0
+ drag.minimumY: 0
+ drag.maximumX: root.parent.width - (root.width * tform.xScale)
+ drag.maximumY: root.parent.height - (root.height * tform.yScale)
+ drag.filterChildren: true
+ onPressed: {
+ root.anchors.left = undefined
+ root.anchors.right = undefined
+ }
+ onDoubleClicked: {
+ root.resetRequested();
+ }
+ onWheel:
+ {
+ var zoomFactor = 1;
+ if(wheel.angleDelta.y > 0)
+ zoomFactor = 1 + (1/factor)
+ else
+ zoomFactor = 1 - (1/factor)
+ var realX = wheel.x * tform.xScale
+ var realY = wheel.y * tform.yScale
+ var tx = root.x + (1-zoomFactor)*realX
+ var ty = root.y + (1-zoomFactor)*realY
+ if(tx < 0) tx = 0
+ if(ty < 0) ty = 0
+ var ts = tform.xScale * zoomFactor
+ if(root.width * ts >= root.minimumWidth) {
+ if(root.height * ts >= root.minimumHeight) {
+ if(((root.width * ts) + tx) < root.parent.width && ((root.height * ts) + ty) < root.parent.height) {
+ root.x = tx
+ root.y = ty
+ tform.xScale = ts
+ tform.yScale = ts
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/QmlControls/qmldir b/src/QmlControls/qmldir
index 3731a8bacf0a9cdbad9fd16ab1c118a05432c3d2..b62af1bcbd73ebb6588a628c0514fd3f90f65902 100644
--- a/src/QmlControls/qmldir
+++ b/src/QmlControls/qmldir
@@ -8,6 +8,7 @@ QGCTextField 1.0 QGCTextField.qml
QGCComboBox 1.0 QGCComboBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml
QGCToolBarButton 1.0 QGCToolBarButton.qml
+QGCMovableItem 1.0 QGCMovableItem.qml
SubMenuButton 1.0 SubMenuButton.qml
IndicatorButton 1.0 IndicatorButton.qml
diff --git a/src/ui/flightdisplay/FlightDisplay.qml b/src/ui/flightdisplay/FlightDisplay.qml
index 89f31ecd9c9c6ebd2e4658d2db0d5c15516f268a..7fb9cd393162f010b810275ef0eab0f62554564a 100644
--- a/src/ui/flightdisplay/FlightDisplay.qml
+++ b/src/ui/flightdisplay/FlightDisplay.qml
@@ -52,29 +52,6 @@ Rectangle {
return value ? "1" : "0";
}
- function adjustSizes() {
- var dist = 85
- var wide = 160
- var minw = 496
- if(root.width > minw)
- {
- attitudeInstrument.size = wide;
- attitudeInstrument.x = dist
- compassInstrument.size = wide;
- compassInstrument.x = root.width - wide - dist
- } else {
- var factor = (root.width / minw);
- var ndist = dist * factor;
- var nwide = wide * factor;
- if (ndist < 0)
- ndist = 0;
- attitudeInstrument.size = nwide;
- compassInstrument.size = nwide;
- attitudeInstrument.x = ndist;
- compassInstrument.x = root.width - nwide - ndist;
- }
- }
-
Component.onCompleted:
{
mapBackground.visible = getBool(flightDisplay.loadSetting("showMapBackground", "0"));
@@ -89,7 +66,6 @@ Rectangle {
currentAltitude.showClimbRate = getBool(flightDisplay.loadSetting("showCurrentClimbRate", "1"));
currentAltitude.showAltitude = getBool(flightDisplay.loadSetting("showCurrentAltitude", "1"));
mapTypeMenu.update();
- adjustSizes();
}
Menu {
@@ -299,6 +275,44 @@ Rectangle {
z: 10
}
+ QGCCompassInstrument {
+ id: compassInstrument
+ y: 5
+ x: 85
+ size: 160
+ heading: isNaN(flightDisplay.heading) ? 0 : flightDisplay.heading
+ visible: mapBackground.visible && showCompass
+ z: mapBackground.z + 1
+ onResetRequested: {
+ y = 5
+ x = 85
+ size = 160
+ tForm.xScale = 1
+ tForm.yScale = 1
+ }
+ }
+
+ QGCAttitudeInstrument {
+ id: attitudeInstrument
+ y: 5
+ size: 160
+ rollAngle: roll
+ pitchAngle: pitch
+ showPitch: showPitchIndicator
+ visible: mapBackground.visible && showAttitudeIndicator
+ anchors.right: root.right
+ anchors.rightMargin: 85
+ z: mapBackground.z + 1
+ onResetRequested: {
+ y = 5
+ anchors.right = root.right
+ anchors.rightMargin = 85
+ size = 160
+ tForm.xScale = 1
+ tForm.yScale = 1
+ }
+ }
+
QGCAttitudeWidget {
id: attitudeWidget
anchors.centerIn: parent
@@ -371,28 +385,6 @@ Rectangle {
z: 70
}
- QGCCompassInstrument {
- id: compassInstrument
- y: 5
- x: 85
- size: 160
- heading: isNaN(flightDisplay.heading) ? 0 : flightDisplay.heading
- visible: mapBackground.visible && showCompass
- z: 70
- }
-
- QGCAttitudeInstrument {
- id: attitudeInstrument
- y: 5
- x: root.width - 160 - 85
- size: 160
- rollAngle: roll
- pitchAngle: pitch
- showPitch: showPitchIndicator
- visible: mapBackground.visible && showAttitudeIndicator
- z: 80
- }
-
// Button at upper left corner
Item {
id: optionsButton
@@ -422,8 +414,4 @@ Rectangle {
}
}
}
-
- onWidthChanged: {
- adjustSizes();
- }
}
diff --git a/src/ui/qmlcommon/QGCAttitudeInstrument.qml b/src/ui/qmlcommon/QGCAttitudeInstrument.qml
index ed53a55e8522483ec1357095ae329d8afe9ca7a8..58c6b84271f5fadfbbacc1790ed1acc44d780e26 100644
--- a/src/ui/qmlcommon/QGCAttitudeInstrument.qml
+++ b/src/ui/qmlcommon/QGCAttitudeInstrument.qml
@@ -28,8 +28,9 @@ This file is part of the QGROUNDCONTROL project
*/
import QtQuick 2.4
+import QGroundControl.Controls 1.0
-Item {
+QGCMovableItem {
id: root
property real rollAngle : 0
property real pitchAngle: 0
diff --git a/src/ui/qmlcommon/QGCCompassInstrument.qml b/src/ui/qmlcommon/QGCCompassInstrument.qml
index 432ed96c597d14803a67cb48df2d951152dfdb49..0de01011fb1e39f33e32aeabcfdfc8ebfd093831 100644
--- a/src/ui/qmlcommon/QGCCompassInstrument.qml
+++ b/src/ui/qmlcommon/QGCCompassInstrument.qml
@@ -31,7 +31,7 @@ import QtQuick 2.4
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
-Item {
+QGCMovableItem {
property ScreenTools screenTools: ScreenTools { }
id: root
property real heading: 0
diff --git a/src/ui/qmlcommon/QGCMapBackground.qml b/src/ui/qmlcommon/QGCMapBackground.qml
index 362cd95b43462e72c6bc90dcd7708772342a4aae..f2a9d98ad5247cbf91ddbfe315bae6c30510c016 100644
--- a/src/ui/qmlcommon/QGCMapBackground.qml
+++ b/src/ui/qmlcommon/QGCMapBackground.qml
@@ -160,7 +160,7 @@ Rectangle {
maximum: map.maximumZoomLevel;
opacity: 1
visible: parent.visible
- z: map.z + 3
+ z: map.z + 20
anchors {
bottom: parent.bottom;
bottomMargin: 15; rightMargin: 20; leftMargin: 20
@@ -180,7 +180,7 @@ Rectangle {
id: scale
parent: zoomSlider.parent
visible: scaleText.text !== "0 m"
- z: map.z + 2
+ z: map.z + 20
opacity: 1
anchors {
bottom: zoomSlider.top;
diff --git a/src/ui/qmlcommon/QGCSlider.qml b/src/ui/qmlcommon/QGCSlider.qml
index 21ac74f80dd98e72279a5c4c417d2da75130af83..950a1c1e1f32443478fe826d49baa52bb4ea094c 100644
--- a/src/ui/qmlcommon/QGCSlider.qml
+++ b/src/ui/qmlcommon/QGCSlider.qml
@@ -72,6 +72,7 @@ Item {
radius: 4
smooth: true
color: Qt.rgba(1,1,1,0.75);
+ border.width: 1
border.color: Qt.rgba(0,0,0,0.45);
anchors.bottom: handle.top
anchors.bottomMargin: 4
@@ -85,8 +86,6 @@ Item {
anchors.horizontalCenter: labelRect.horizontalCenter
horizontalAlignment: Text.AlignHCenter
anchors.verticalCenter: labelRect.verticalCenter
- //anchors.baseline: parent.bottom
- //anchors.baselineOffset: -6
}
}