Commit dd4de906 authored by Gus Grubba's avatar Gus Grubba

Move instrument widgets off to a loader.

parent e4fddb3f
......@@ -125,8 +125,8 @@
<file alias="QGroundControl/FlightMap/QGCAttitudeHUD.qml">src/FlightMap/Widgets/QGCAttitudeHUD.qml</file>
<file alias="QGroundControl/FlightMap/QGCAttitudeWidget.qml">src/FlightMap/Widgets/QGCAttitudeWidget.qml</file>
<file alias="QGroundControl/FlightMap/QGCCompassWidget.qml">src/FlightMap/Widgets/QGCCompassWidget.qml</file>
<file alias="QGroundControl/FlightMap/QGCInstrumentWidget.qml">src/FlightMap/Widgets/QGCInstrumentWidget.qml</file>
<file alias="QGroundControl/FlightMap/QGCInstrumentWidgetAlternate.qml">src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml</file>
<file alias="QGCInstrumentWidget.qml">src/FlightMap/Widgets/QGCInstrumentWidget.qml</file>
<file alias="QGCInstrumentWidgetAlternate.qml">src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml</file>
<file alias="QGroundControl/FlightMap/QGCMapPolygonControls.qml">src/MissionEditor/QGCMapPolygonControls.qml</file>
<file alias="QGroundControl/FlightMap/QGCPitchIndicator.qml">src/FlightMap/Widgets/QGCPitchIndicator.qml</file>
<file alias="QGroundControl/FlightMap/QGCVideoBackground.qml">src/FlightMap/QGCVideoBackground.qml</file>
......
......@@ -33,25 +33,14 @@ QGCView {
QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
property bool activeVehicleJoystickEnabled: _activeVehicle ? _activeVehicle.joystickEnabled : false
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _mainIsMap: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_mainIsMapKey, true) : true
property bool _isPipVisible: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false
property real _roll: _activeVehicle ? _activeVehicle.roll.value : _defaultRoll
property real _pitch: _activeVehicle ? _activeVehicle.pitch.value : _defaultPitch
property real _heading: _activeVehicle ? _activeVehicle.heading.value : _defaultHeading
property Fact _emptyFact: Fact { }
property Fact _groundSpeedFact: _activeVehicle ? _activeVehicle.groundSpeed : _emptyFact
property Fact _airSpeedFact: _activeVehicle ? _activeVehicle.airSpeed : _emptyFact
property bool activeVehicleJoystickEnabled: _activeVehicle ? _activeVehicle.joystickEnabled : false
property real _savedZoomLevel: 0
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property real pipSize: mainWindow.width * 0.2
property real _savedZoomLevel: 0
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property real _pipSize: mainWindow.width * 0.2
readonly property bool isBackgroundDark: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true
readonly property real _defaultRoll: 0
......@@ -136,8 +125,8 @@ QGCView {
anchors.left: _panel.left
anchors.bottom: _panel.bottom
visible: _mainIsMap || _isPipVisible
width: _mainIsMap ? _panel.width : pipSize
height: _mainIsMap ? _panel.height : pipSize * (9/16)
width: _mainIsMap ? _panel.width : _pipSize
height: _mainIsMap ? _panel.height : _pipSize * (9/16)
states: [
State {
name: "pipMode"
......@@ -166,8 +155,8 @@ QGCView {
Item {
id: _flightVideo
z: _mainIsMap ? _panel.z + 2 : _panel.z + 1
width: !_mainIsMap ? _panel.width : pipSize
height: !_mainIsMap ? _panel.height : pipSize * (9/16)
width: !_mainIsMap ? _panel.width : _pipSize
height: !_mainIsMap ? _panel.height : _pipSize * (9/16)
anchors.left: _panel.left
anchors.bottom: _panel.bottom
visible: QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible)
......@@ -204,8 +193,8 @@ QGCView {
QGCPipable {
id: _flightVideoPipControl
z: _flightVideo.z + 3
width: pipSize
height: pipSize * (9/16)
width: _pipSize
height: _pipSize * (9/16)
anchors.left: _panel.left
anchors.bottom: _panel.bottom
anchors.margins: ScreenTools.defaultFontPixelHeight
......
......@@ -45,8 +45,8 @@ Item {
QGCAttitudeHUD {
id: attitudeHUD
visible: !_mainIsMap
rollAngle: _roll
pitchAngle: _pitch
rollAngle: _activeVehicle ? _activeVehicle.roll.value : 0
pitchAngle: _activeVehicle ? _activeVehicle.pitch.value : 0
width: ScreenTools.defaultFontPixelHeight * (30)
height: ScreenTools.defaultFontPixelHeight * (30)
active: QGroundControl.multiVehicleManager.activeVehicleAvailable
......
......@@ -25,22 +25,21 @@ import QGroundControl.FlightMap 1.0
Item {
id: _root
property alias guidedModeBar: _guidedModeBar
property bool gotoEnabled: _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying
property alias guidedModeBar: _guidedModeBar
property bool gotoEnabled: _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying
property var qgcView
property bool isBackgroundDark
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _isSatellite: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true
property bool _lightWidgetBorders: _isSatellite
property bool _useAlternateInstruments: QGroundControl.virtualTabletJoystick || ScreenTools.isTinyScreen
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _isSatellite: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true
property bool _lightWidgetBorders: _isSatellite
readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2
readonly property real _margins: ScreenTools.defaultFontPixelHeight * 0.5
QGCMapPalette { id: mapPal; lightColors: isBackgroundDark }
QGCPalette { id: qgcPal }
QGCPalette { id: qgcPal }
function getGadgetWidth() {
function getPreferredInstrumentWidth() {
if(ScreenTools.isMobile) {
return ScreenTools.isTinyScreen ? mainWindow.width * 0.2 : mainWindow.width * 0.15
}
......@@ -48,6 +47,28 @@ Item {
return Math.min(w, 200)
}
function _setInstrumentWidget() {
var useAlternateInstruments = QGroundControl.virtualTabletJoystick || ScreenTools.isTinyScreen
if(useAlternateInstruments) {
instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml"
instrumentsLoader.state = "topMode"
} else {
instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml"
instrumentsLoader.state = "centerMode"
}
}
Connections {
target: QGroundControl
onVirtualTabletJoystickChanged: {
_setInstrumentWidget()
}
}
Component.onCompleted: {
_setInstrumentWidget()
}
//-- Map warnings
Column {
anchors.horizontalCenter: parent.horizontalCenter
......@@ -74,54 +95,33 @@ Item {
}
//-- Instrument Panel
QGCInstrumentWidget {
id: instrumentGadget
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right
anchors.verticalCenter: parent.verticalCenter
visible: !_useAlternateInstruments
size: getGadgetWidth()
heading: _heading
rollAngle: _roll
pitchAngle: _pitch
groundSpeedFact: _groundSpeedFact
airSpeedFact: _airSpeedFact
lightBorders: _lightWidgetBorders
z: QGroundControl.zOrderWidgets
qgcView: _root.qgcView
maxHeight: parent.height - (anchors.margins * 2)
}
QGCInstrumentWidgetAlternate {
id: instrumentGadgetAlternate
Loader {
id: instrumentsLoader
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.top: parent.top
anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right
visible: _useAlternateInstruments
width: ScreenTools.isTinyScreen ? getGadgetWidth() * 1.5 : getGadgetWidth()
heading: _heading
rollAngle: _roll
pitchAngle: _pitch
groundSpeedFact: _groundSpeedFact
airSpeedFact: _airSpeedFact
lightBorders: _lightWidgetBorders
qgcView: _root.qgcView
maxHeight: parent.height - (anchors.margins * 2)
z: QGroundControl.zOrderWidgets
property var qgcView: _root.qgcView
property real maxHeight:parent.height - (anchors.margins * 2)
states: [
State {
name: "topMode"
AnchorChanges {
target: instrumentsLoader
anchors.verticalCenter: undefined
anchors.top: _root ? _root.top : undefined
}
},
State {
name: "centerMode"
AnchorChanges {
target: instrumentsLoader
anchors.top: undefined
anchors.verticalCenter: _root ? _root.verticalCenter : undefined
}
}
]
}
/*
ValuesWidget {
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: instrumentGadgetAlternate.bottom
anchors.horizontalCenter: instrumentGadgetAlternate.horizontalCenter
width: getGadgetWidth()
qgcView: _root.qgcView
textColor: _isSatellite ? "white" : "black"
visible: _useAlternateInstruments
maxHeight: virtualJoystickMultiTouch.visible ? virtualJoystickMultiTouch.y - y : parent.height - anchors.margins - y
}*/
//-- Guided mode buttons
Rectangle {
id: _guidedModeBar
......@@ -131,7 +131,7 @@ Item {
width: guidedModeColumn.width + (_margins * 2)
height: guidedModeColumn.height + (_margins * 2)
radius: ScreenTools.defaultFontPixelHeight * 0.25
color: _lightWidgetBorders ? Qt.rgba(qgcPal.mapWidgetBorderLight.r, qgcPal.mapWidgetBorderLight.g, qgcPal.mapWidgetBorderLight.b, 0.8) : Qt.rgba(qgcPal.mapWidgetBorderDark.r, qgcPal.mapWidgetBorderDark.g, qgcPal.mapWidgetBorderDark.b, 0.75)
color: _isSatellite ? Qt.rgba(qgcPal.mapWidgetBorderLight.r, qgcPal.mapWidgetBorderLight.g, qgcPal.mapWidgetBorderLight.b, 0.8) : Qt.rgba(qgcPal.mapWidgetBorderDark.r, qgcPal.mapWidgetBorderDark.g, qgcPal.mapWidgetBorderDark.b, 0.75)
visible: _activeVehicle
z: QGroundControl.zOrderWidgets
state: "Shown"
......@@ -303,7 +303,7 @@ Item {
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
color: _lightWidgetBorders ? qgcPal.mapWidgetBorderDark : qgcPal.mapWidgetBorderLight
color: _isSatellite ? qgcPal.mapWidgetBorderDark : qgcPal.mapWidgetBorderLight
text: "Click in map to move vehicle"
visible: gotoEnabled
}
......
......@@ -52,15 +52,12 @@ QGCListView {
QGCCompassWidget {
size: _widgetHeight
heading: _vehicle.heading.rawValue
vehicle: _vehicle
}
QGCAttitudeWidget {
size: _widgetHeight
active: true
rollAngle: _vehicle.roll.rawValue
pitchAngle: _vehicle.pitch.rawValue
vehicle: _vehicle
}
}
......
......@@ -17,22 +17,18 @@
import QtQuick 2.4
import QtGraphicalEffects 1.0
import QGroundControl 1.0
import QGroundControl.Controls 1.0
Item {
id: root
property bool active: false ///< true: actively connected to data provider, false: show inactive control
property real rollAngle : _defaultRollAngle
property real pitchAngle: _defaultPitchAngle
property bool showPitch: true
property var vehicle: null
property real size
readonly property real _defaultRollAngle: 0
readonly property real _defaultPitchAngle: 0
property real _rollAngle: active ? rollAngle : _defaultRollAngle
property real _pitchAngle: active ? pitchAngle : _defaultPitchAngle
property real _rollAngle: vehicle ? vehicle.roll.rawValue : 0
property real _pitchAngle: vehicle ? vehicle.pitch.rawValue : 0
width: size
height: size
......
......@@ -25,12 +25,12 @@ Item {
id: root
property real size: _defaultSize
property real heading: 0
property var vehicle: null
property real _defaultSize: ScreenTools.defaultFontPixelHeight * (10)
property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize
property int _fontSize: ScreenTools.defaultFontPointSize * _sizeRatio
property real _heading: vehicle ? vehicle.heading.rawValue : 0
width: size
height: size
......@@ -58,7 +58,7 @@ Item {
transform: Rotation {
origin.x: pointer.width / 2
origin.y: pointer.height / 2
angle: heading
angle: _heading
}
}
......@@ -79,7 +79,7 @@ Item {
color: Qt.rgba(0,0,0,0.65)
QGCLabel {
text: vehicle ? heading.toFixed(0) : qsTr("OFF")
text: vehicle ? _heading.toFixed(0) : qsTr("OFF")
font.family: vehicle ? ScreenTools.demiboldFontFamily : ScreenTools.normalFontFamily
font.pointSize: _fontSize < 8 ? 8 : _fontSize;
color: "white"
......
......@@ -26,27 +26,15 @@ import QGroundControl.Palette 1.0
Item {
id: instrumentPanel
height: instrumentColumn.y + instrumentColumn.height + _topBottomMargin
width: size
property alias heading: compass.heading
property alias rollAngle: attitudeWidget.rollAngle
property alias pitchAngle: attitudeWidget.pitchAngle
property real size: _defaultSize
property bool lightBorders: true
property bool active: false
property var qgcView
property real maxHeight
property Fact _emptyFact: Fact { }
property Fact groundSpeedFact: _emptyFact
property Fact airSpeedFact: _emptyFact
property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9)
width: getPreferredInstrumentWidth()
property var _qgcView: qgcView
property real _maxHeight: maxHeight
property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9)
property color _backgroundColor: qgcPal.window
property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33
property real _topBottomMargin: (size * 0.05) / 2
property real _availableValueHeight: maxHeight - (attitudeWidget.height + _spacer1.height + _spacer2.height + (_spacing * 4)) - (_showCompass ? compass.height : 0)
property real _topBottomMargin: (width * 0.05) / 2
property real _availableValueHeight: _maxHeight - (attitudeWidget.height + _spacer1.height + _spacer2.height + (_spacing * 4)) - (_showCompass ? compass.height : 0)
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
readonly property bool _showCompass: true // !ScreenTools.isShortScreen
......@@ -57,10 +45,10 @@ Item {
anchors.left: parent.left
anchors.right: parent.right
height: (_showCompass ? instrumentColumn.height : attitudeWidget.height) + (_topBottomMargin * 2)
radius: size / 2
radius: width / 2
color: _backgroundColor
border.width: 1
border.color: lightBorders ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark
border.color: _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark
}
MouseArea {
......@@ -83,7 +71,7 @@ Item {
QGCAttitudeWidget {
id: attitudeWidget
size: parent.width * 0.95
active: instrumentPanel.active
vehicle: _activeVehicle
anchors.horizontalCenter: parent.horizontalCenter
}
......@@ -131,7 +119,7 @@ Item {
anchors.margins: 1
anchors.left: parent.left
anchors.right: parent.right
qgcView: instrumentPanel.qgcView
qgcView: instrumentPanel._qgcView
textColor: qgcPal.text
backgroundColor: _backgroundColor
maxHeight: _availableValueHeight
......
......@@ -20,38 +20,24 @@ import QGroundControl.Palette 1.0
/// Instrument panel shown when virtual thumbsticks are visible
Rectangle {
id: root
width: ScreenTools.isTinyScreen ? getPreferredInstrumentWidth() * 1.5 : getPreferredInstrumentWidth()
height: _outerRadius * 2
radius: _outerRadius
color: qgcPal.window
border.width: 1
border.color: lightBorders ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark
property alias heading: compass.heading
property alias rollAngle: attitude.rollAngle
property alias pitchAngle: attitude.pitchAngle
property real size: _defaultSize
property bool active: false
property bool lightBorders: true
property var qgcView
property real maxHeight
property Fact _emptyFact: Fact { }
property Fact groundSpeedFact: _emptyFact
property Fact airSpeedFact: _emptyFact
property Fact altitudeFact: _emptyFact
property real _innerRadius: (width - (_topBottomMargin * 3)) / 4
property real _outerRadius: _innerRadius + _topBottomMargin
property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9)
property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize
property real _bigFontSize: ScreenTools.defaultFontPointSize * 2.5 * _sizeRatio
property real _normalFontSize:ScreenTools.defaultFontPointSize * 1.5 * _sizeRatio
property real _labelFontSize: ScreenTools.defaultFontPointSize * 0.75 * _sizeRatio
property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33
property real _topBottomMargin: (size * 0.05) / 2
border.color: _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark
property real _innerRadius: (width - (_topBottomMargin * 3)) / 4
property real _outerRadius: _innerRadius + _topBottomMargin
property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9)
property real _sizeRatio: ScreenTools.isTinyScreen ? (width / _defaultSize) * 0.5 : width / _defaultSize
property real _bigFontSize: ScreenTools.defaultFontPointSize * 2.5 * _sizeRatio
property real _normalFontSize: ScreenTools.defaultFontPointSize * 1.5 * _sizeRatio
property real _labelFontSize: ScreenTools.defaultFontPointSize * 0.75 * _sizeRatio
property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33
property real _topBottomMargin: (width * 0.05) / 2
property real _availableValueHeight: maxHeight - (root.height + _valuesItem.anchors.topMargin)
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
QGCPalette { id: qgcPal }
......@@ -60,7 +46,7 @@ Rectangle {
anchors.leftMargin: _topBottomMargin
anchors.left: parent.left
size: _innerRadius * 2
active: root.active
vehicle: _activeVehicle
anchors.verticalCenter: parent.verticalCenter
}
......@@ -69,7 +55,7 @@ Rectangle {
anchors.leftMargin: _spacing
anchors.left: attitude.right
size: _innerRadius * 2
vehicle: QGroundControl.multiVehicleManager.activeVehicle
vehicle: _activeVehicle
anchors.verticalCenter: parent.verticalCenter
}
......
......@@ -14,8 +14,6 @@ QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml
QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml
QGCCompassWidget 1.0 QGCCompassWidget.qml
QGCInstrumentWidget 1.0 QGCInstrumentWidget.qml
QGCInstrumentWidgetAlternate 1.0 QGCInstrumentWidgetAlternate.qml
QGCPitchIndicator 1.0 QGCPitchIndicator.qml
QGCSlider 1.0 QGCSlider.qml
ValuesWidget 1.0 ValuesWidget.qml
......
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