From a656c2467c93eeac9cad81598dde280d2742036c Mon Sep 17 00:00:00 2001
From: dogmaphobic <mavlink@grubba.com>
Date: Fri, 14 Aug 2015 09:19:40 -0400
Subject: [PATCH] Enabling the option of using Compass and Attitude Widgets or
 HUD.

---
 qgroundcontrol.qrc                         |   8 +-
 src/ui/flightdisplay/FlightDisplay.qml     | 166 +++++++++++++++++------------
 src/ui/qmlcommon/QGCAttitudeHUD.qml        |  81 ++++++++++++++
 src/ui/qmlcommon/QGCAttitudeInstrument.qml | 103 ------------------
 src/ui/qmlcommon/QGCAttitudeWidget.qml     |  75 +++++++++----
 src/ui/qmlcommon/QGCCompass.qml            |  74 -------------
 src/ui/qmlcommon/QGCCompassHUD.qml         |  72 +++++++++++++
 src/ui/qmlcommon/QGCCompassInstrument.qml  |  82 --------------
 src/ui/qmlcommon/QGCCompassWidget.qml      |  82 ++++++++++++++
 src/ui/qmlcommon/QGCPitchIndicator.qml     | 103 ++++++++++++++++++
 src/ui/qmlcommon/QGCPitchWidget.qml        | 103 ------------------
 src/ui/qmlcommon/qmldir                    |  20 ++--
 12 files changed, 501 insertions(+), 468 deletions(-)
 create mode 100644 src/ui/qmlcommon/QGCAttitudeHUD.qml
 delete mode 100644 src/ui/qmlcommon/QGCAttitudeInstrument.qml
 delete mode 100644 src/ui/qmlcommon/QGCCompass.qml
 create mode 100644 src/ui/qmlcommon/QGCCompassHUD.qml
 delete mode 100644 src/ui/qmlcommon/QGCCompassInstrument.qml
 create mode 100644 src/ui/qmlcommon/QGCCompassWidget.qml
 create mode 100644 src/ui/qmlcommon/QGCPitchIndicator.qml
 delete mode 100644 src/ui/qmlcommon/QGCPitchWidget.qml

diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index c9b1729..a5ec028 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -120,16 +120,16 @@
         <file alias="MapDisplay.qml">src/ui/mapdisplay/MapDisplay.qml</file>
         <file alias="QGroundControl/FlightControls/QGCAltitudeWidget.qml">src/ui/qmlcommon/QGCAltitudeWidget.qml</file>
         <file alias="QGroundControl/FlightControls/QGCArtificialHorizon.qml">src/ui/qmlcommon/QGCArtificialHorizon.qml</file>
-        <file alias="QGroundControl/FlightControls/QGCAttitudeInstrument.qml">src/ui/qmlcommon/QGCAttitudeInstrument.qml</file>
         <file alias="QGroundControl/FlightControls/QGCAttitudeWidget.qml">src/ui/qmlcommon/QGCAttitudeWidget.qml</file>
-        <file alias="QGroundControl/FlightControls/QGCCompass.qml">src/ui/qmlcommon/QGCCompass.qml</file>
-        <file alias="QGroundControl/FlightControls/QGCCompassInstrument.qml">src/ui/qmlcommon/QGCCompassInstrument.qml</file>
+        <file alias="QGroundControl/FlightControls/QGCAttitudeHUD.qml">src/ui/qmlcommon/QGCAttitudeHUD.qml</file>
+        <file alias="QGroundControl/FlightControls/QGCCompassWidget.qml">src/ui/qmlcommon/QGCCompassWidget.qml</file>
+        <file alias="QGroundControl/FlightControls/QGCCompassHUD.qml">src/ui/qmlcommon/QGCCompassHUD.qml</file>
         <file alias="QGroundControl/FlightControls/QGCCurrentAltitude.qml">src/ui/qmlcommon/QGCCurrentAltitude.qml</file>
         <file alias="QGroundControl/FlightControls/QGCCurrentSpeed.qml">src/ui/qmlcommon/QGCCurrentSpeed.qml</file>
         <file alias="QGroundControl/FlightControls/QGCHudMessage.qml">src/ui/qmlcommon/QGCHudMessage.qml</file>
         <file alias="QGroundControl/FlightControls/QGCMapBackground.qml">src/ui/qmlcommon/QGCMapBackground.qml</file>
         <file alias="QGroundControl/FlightControls/QGCMapToolButton.qml">src/ui/qmlcommon/QGCMapToolButton.qml</file>
-        <file alias="QGroundControl/FlightControls/QGCPitchWidget.qml">src/ui/qmlcommon/QGCPitchWidget.qml</file>
+        <file alias="QGroundControl/FlightControls/QGCPitchIndicator.qml">src/ui/qmlcommon/QGCPitchIndicator.qml</file>
         <file alias="QGroundControl/FlightControls/QGCSlider.qml">src/ui/qmlcommon/QGCSlider.qml</file>
         <file alias="QGroundControl/FlightControls/QGCSpeedWidget.qml">src/ui/qmlcommon/QGCSpeedWidget.qml</file>
         <file alias="QGroundControl/FlightControls/QGCVideoBackground.qml">src/ui/qmlcommon/QGCVideoBackground.qml</file>
diff --git a/src/ui/flightdisplay/FlightDisplay.qml b/src/ui/flightdisplay/FlightDisplay.qml
index e075a52..0d4a7dd 100644
--- a/src/ui/flightdisplay/FlightDisplay.qml
+++ b/src/ui/flightdisplay/FlightDisplay.qml
@@ -47,8 +47,6 @@ Item {
     property real pitch:   isNaN(MavManager.pitch)   ? 0 : MavManager.pitch
 
     property bool showPitchIndicator:       true
-    property bool showAttitudeIndicator:    true
-    property bool showCompass:              true
 
     function getBool(value) {
         return value === '0' ? false : true;
@@ -58,8 +56,11 @@ Item {
         return value ? "1" : "0";
     }
 
-    function showHudInstruments() {
-        return videoBackground.visible || mapBackground.visible;
+    function enforceExclusiveOption(setWidget, alternateWidget, defaultSetting, alternateSetting) {
+        setWidget.visible = !setWidget.visible;
+        flightDisplay.saveSetting(defaultSetting, setBool(setWidget.visible));
+        alternateWidget.visible = setWidget.visible ? false : alternateWidget.visible;
+        flightDisplay.saveSetting(alternateSetting, setBool(alternateWidget.visible));
     }
 
     Connections {
@@ -75,9 +76,11 @@ Item {
         mapBackground.showWaypoints         = getBool(flightDisplay.loadSetting("mapShowWaypoints",         "0"));
         mapBackground.alwaysNorth           = getBool(flightDisplay.loadSetting("mapAlwaysPointsNorth",     "0"));
         videoBackground.visible             = getBool(flightDisplay.loadSetting("showVideoBackground",      "0"));
-        showAttitudeIndicator               = getBool(flightDisplay.loadSetting("showAttitudeIndicator",    "1"));
         showPitchIndicator                  = getBool(flightDisplay.loadSetting("showPitchIndicator",       "1"));
-        showCompass                         = getBool(flightDisplay.loadSetting("showCompass",              "1"));
+        compassWidget.visible               = getBool(flightDisplay.loadSetting("showCompassWidget",        "0"));
+        compassHUD.visible                  = getBool(flightDisplay.loadSetting("showCompassHUD",           "1"));
+        attitudeWidget.visible              = getBool(flightDisplay.loadSetting("showAttitudeWidget",       "0"));
+        attitudeHUD.visible                 = getBool(flightDisplay.loadSetting("showAttitudeHUD",          "1"));
         altitudeWidget.visible              = getBool(flightDisplay.loadSetting("showAltitudeWidget",       "1"));
         speedWidget.visible                 = getBool(flightDisplay.loadSetting("showSpeedWidget",          "1"));
         currentSpeed.showAirSpeed           = getBool(flightDisplay.loadSetting("showCurrentAirSpeed",      "1"));
@@ -91,6 +94,16 @@ Item {
             videoBackground.visible = false;
             flightDisplay.saveSetting("showVideoBackground", setBool(videoBackground.visible));
         }
+        // Compass HUD or Widget. Not both:
+        if(compassWidget.visible && compassHUD.visible) {
+            compassWidget.visible = false;
+            flightDisplay.saveSetting("showCompassWidget", setBool(compassWidget.visible));
+        }
+        // Attitude HUD or Widget. Not both:
+        if(attitudeWidget.visible && attitudeHUD.visible) {
+            attitudeWidget.visible = false;
+            flightDisplay.saveSetting("showAttitudeWidget", setBool(attitudeWidget.visible));
+        }
         // Disable video if we don't have support for it
         if(!flightDisplay.hasVideo) {
             videoBackground.visible = false;
@@ -103,19 +116,13 @@ Item {
     Menu {
         id: contextMenu
 
-        ExclusiveGroup { id: backgroundDisplay }
-
         MenuItem {
             text: "Map Background"
             checkable: true
             checked: mapBackground.visible
-            exclusiveGroup: backgroundDisplay
             onTriggered:
             {
-                mapBackground.visible = !mapBackground.visible;
-                flightDisplay.saveSetting("showMapBackground", setBool(mapBackground.visible));
-                videoBackground.visible = mapBackground.visible ? false : videoBackground.visible;
-                flightDisplay.saveSetting("showVideoBackground", setBool(videoBackground.visible));
+                enforceExclusiveOption(mapBackground, videoBackground, "showMapBackground", "showVideoBackground");
             }
         }
 
@@ -152,22 +159,39 @@ Item {
             text: "Video Background"
             checkable: true
             checked: videoBackground.visible
-            exclusiveGroup: backgroundDisplay
             onTriggered:
             {
-                videoBackground.visible = !videoBackground.visible;
-                flightDisplay.saveSetting("showVideoBackground", setBool(videoBackground.visible));
-                mapBackground.visible = videoBackground.visible ? false : mapBackground.visible;
-                flightDisplay.saveSetting("showMapBackground", setBool(mapBackground.visible));
+                enforceExclusiveOption(videoBackground, mapBackground, "showVideoBackground", "showMapBackground");
             }
         }
 
         MenuSeparator {}
 
         MenuItem {
+            text: "Attitude Widget"
+            checkable:  true
+            checked:    attitudeWidget.visible
+            onTriggered:
+            {
+                enforceExclusiveOption(attitudeWidget, attitudeHUD, "showAttitudeWidget", "showAttitudeHUD");
+            }
+        }
+
+        MenuItem {
+            text: "Attitude HUD"
+            checkable:  true
+            checked:    attitudeHUD.visible
+            onTriggered:
+            {
+                enforceExclusiveOption(attitudeHUD, attitudeWidget, "showAttitudeHUD", "showAttitudeWidget");
+            }
+        }
+
+        MenuItem {
             text: "Pitch Indicator"
             checkable:  true
             checked:    showPitchIndicator
+            enabled:    attitudeHUD.visible || attitudeWidget.visible
             onTriggered:
             {
                 showPitchIndicator = !showPitchIndicator;
@@ -176,24 +200,22 @@ Item {
         }
 
         MenuItem {
-            text: "Attitude Indicator"
-            checkable:  true
-            checked:    showAttitudeIndicator
+            text: "Compass Widget"
+            checkable: true
+            checked: compassWidget.visible
             onTriggered:
             {
-                showAttitudeIndicator = !showAttitudeIndicator;
-                flightDisplay.saveSetting("showAttitudeIndicator", setBool(showAttitudeIndicator));
+                enforceExclusiveOption(compassWidget, compassHUD, "showCompassWidget", "showCompassHUD");
             }
         }
 
         MenuItem {
-            text: "Compass"
+            text: "Compass HUD"
             checkable: true
-            checked: showCompass
+            checked: compassHUD.visible
             onTriggered:
             {
-                showCompass = !showCompass;
-                flightDisplay.saveSetting("showCompass", setBool(showCompass));
+                enforceExclusiveOption(compassHUD, compassWidget, "showCompassHUD", "showCompassWidget");
             }
         }
 
@@ -271,10 +293,14 @@ Item {
             {
                 showPitchIndicator = true;
                 flightDisplay.saveSetting("showPitchIndicator", setBool(showPitchIndicator));
-                showAttitudeIndicator = true;
-                flightDisplay.saveSetting("showAttitudeIndicator", setBool(showAttitudeIndicator));
-                showCompass = true;
-                flightDisplay.saveSetting("showCompass", setBool(showCompass));
+                attitudeWidget.visible = false;
+                flightDisplay.saveSetting("showAttitudeWidget", setBool(attitudeWidget.visible));
+                attitudeHUD.visible = true;
+                flightDisplay.saveSetting("showAttitudeHUD", setBool(attitudeHUD.visible));
+                compassWidget.visible = false
+                flightDisplay.saveSetting("showCompassWidget", setBool(compassWidget.visible));
+                compassHUD.visible = true
+                flightDisplay.saveSetting("showCompassHUD", setBool(compassHUD.visible));
                 altitudeWidget.visible = true;
                 flightDisplay.saveSetting("showAltitudeWidget", setBool(altitudeWidget.visible));
                 currentAltitude.showAltitude = true;
@@ -300,6 +326,8 @@ Item {
 
     }
 
+    // Video and Map backgrounds are exclusive. If one is enabled the other is disabled.
+
     QGCVideoBackground {
         id:                 videoBackground
         anchors.fill:       parent
@@ -329,13 +357,14 @@ Item {
         z:                  mapBackground.z + 1
     }
 
-    QGCCompassInstrument {
-        id:                 compassInstrument
+    // Floating (Top Left) Compass Widget
+
+    QGCCompassWidget {
+        id:                 compassWidget
         y:                  ScreenTools.defaultFontPixelSize * (0.42)
         x:                  ScreenTools.defaultFontPixelSize * (7.1)
         size:               ScreenTools.defaultFontPixelSize * (13.3)
         heading:            isNaN(MavManager.heading) ? 0 : MavManager.heading
-        visible:            showHudInstruments() && showCompass
         z:                  mapBackground.z + 2
         onResetRequested: {
             y               = ScreenTools.defaultFontPixelSize * (0.42)
@@ -346,14 +375,37 @@ Item {
         }
     }
 
-    QGCAttitudeInstrument {
-        id:                 attitudeInstrument
+    // HUD (lower middle) Compass
+
+    QGCCompassHUD {
+        id:                 compassHUD
+        y:                  root.height * 0.7
+        x:                  root.width  * 0.5 - ScreenTools.defaultFontPixelSize * (5)
+        width:              ScreenTools.defaultFontPixelSize * (10)
+        height:             ScreenTools.defaultFontPixelSize * (10)
+        heading:            isNaN(MavManager.heading) ? 0 : MavManager.heading
+        z:                  70
+    }
+
+    // Sky/Ground background (visible when no Map or Video is enabled)
+
+    QGCArtificialHorizon {
+        id:                 artificialHoriz
+        anchors.fill:       parent
+        rollAngle:          roll
+        pitchAngle:         pitch
+        visible:            !videoBackground.visible && !mapBackground.visible
+    }
+
+    // Floating (Top Right) Attitude Widget
+
+    QGCAttitudeWidget {
+        id:                 attitudeWidget
         y:                  ScreenTools.defaultFontPixelSize * (0.42)
         size:               ScreenTools.defaultFontPixelSize * (13.3)
         rollAngle:          roll
         pitchAngle:         pitch
         showPitch:          showPitchIndicator
-        visible:            showHudInstruments() && showAttitudeIndicator
         anchors.right:      root.right
         anchors.rightMargin: ScreenTools.defaultFontPixelSize * (7.1)
         z:                  mapBackground.z + 2
@@ -367,35 +419,18 @@ Item {
         }
     }
 
-    QGCArtificialHorizon {
-        id:                 artificialHoriz
-        anchors.fill:       parent
-        rollAngle:          roll
-        pitchAngle:         pitch
-        visible:            !showHudInstruments()
-    }
+    // HUD (center) Attitude Indicator
 
-    QGCAttitudeWidget {
-        id:                 attitudeWidget
+    QGCAttitudeHUD {
+        id:                 attitudeHUD
         rollAngle:          roll
         pitchAngle:         pitch
-        visible:            !showHudInstruments() && showAttitudeIndicator
-        width:              ScreenTools.defaultFontPixelSize * (21.7)
-        height:             ScreenTools.defaultFontPixelSize * (21.7)
+        showPitch:          showPitchIndicator
+        width:              ScreenTools.defaultFontPixelSize * (30)
+        height:             ScreenTools.defaultFontPixelSize * (30)
         z:                  20
     }
 
-    QGCPitchWidget {
-        id:                 pitchWidget
-        visible:            showPitchIndicator && !showHudInstruments()
-        anchors.verticalCenter: parent.verticalCenter
-        pitchAngle:         pitch
-        rollAngle:          roll
-        color:              Qt.rgba(0,0,0,0)
-        size:               ScreenTools.defaultFontPixelSize * (10)
-        z:                  30
-    }
-
     QGCAltitudeWidget {
         id:                 altitudeWidget
         anchors.right:      parent.right
@@ -438,17 +473,6 @@ Item {
         z:                  60
     }
 
-    QGCCompass {
-        id:                 compassIndicator
-        y:                  root.height * 0.7
-        x:                  root.width  * 0.5 - ScreenTools.defaultFontPixelSize * (5)
-        width:              ScreenTools.defaultFontPixelSize * (10)
-        height:             ScreenTools.defaultFontPixelSize * (10)
-        heading:            isNaN(MavManager.heading) ? 0 : MavManager.heading
-        visible:            !showHudInstruments() && showCompass
-        z:                  70
-    }
-
     //- Context Menu
     MouseArea {
         anchors.fill: parent
diff --git a/src/ui/qmlcommon/QGCAttitudeHUD.qml b/src/ui/qmlcommon/QGCAttitudeHUD.qml
new file mode 100644
index 0000000..2456a47
--- /dev/null
+++ b/src/ui/qmlcommon/QGCAttitudeHUD.qml
@@ -0,0 +1,81 @@
+/*=====================================================================
+
+QGroundControl Open Source Ground Control Station
+
+(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
+
+This file is part of the QGROUNDCONTROL project
+
+    QGROUNDCONTROL is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    QGROUNDCONTROL is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
+
+======================================================================*/
+
+/**
+ * @file
+ *   @brief QGC Attitude Widget
+ *   @author Gus Grubba <mavlink@grubba.com>
+ */
+
+import QtQuick 2.4
+import QGroundControl.ScreenTools 1.0
+
+Item {
+    id: root
+    anchors.centerIn: parent
+    property real rollAngle :   0
+    property real pitchAngle:   0
+    property bool showPitch:    true
+
+    Image {
+        id: rollDial
+        anchors     { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter}
+        source:     "/qmlimages/rollDialWhite.svg"
+        mipmap:     true
+        width:      parent.width
+        fillMode:   Image.PreserveAspectFit
+        transform: Rotation {
+            origin.x: rollDial.width / 2
+            origin.y: rollDial.height
+            angle:   -rollAngle
+        }
+    }
+
+    Image {
+        id: pointer
+        anchors     { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter}
+        source:     "/qmlimages/rollPointerWhite.svg"
+        mipmap:     true
+        width:      rollDial.width
+        fillMode:   Image.PreserveAspectFit
+    }
+
+    Image {
+        id:                 crossHair
+        anchors.centerIn:   parent
+        source:             "/qmlimages/crossHair.svg"
+        mipmap:             true
+        width:              parent.width
+        fillMode:           Image.PreserveAspectFit
+    }
+
+    QGCPitchIndicator {
+        id:                 pitchIndicator
+        anchors.verticalCenter: parent.verticalCenter
+        visible:            root.showPitch
+        pitchAngle:         root.pitchAngle
+        rollAngle:          root.rollAngle
+        color:              Qt.rgba(0,0,0,0)
+        size:               ScreenTools.defaultFontPixelSize * (10)
+    }
+}
diff --git a/src/ui/qmlcommon/QGCAttitudeInstrument.qml b/src/ui/qmlcommon/QGCAttitudeInstrument.qml
deleted file mode 100644
index df060bc..0000000
--- a/src/ui/qmlcommon/QGCAttitudeInstrument.qml
+++ /dev/null
@@ -1,103 +0,0 @@
-/*=====================================================================
-
-QGroundControl Open Source Ground Control Station
-
-(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
-
-This file is part of the QGROUNDCONTROL project
-
-    QGROUNDCONTROL is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    QGROUNDCONTROL is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
-
-======================================================================*/
-
-/**
- * @file
- *   @brief QGC Attitude Instrument
- *   @author Gus Grubba <mavlink@grubba.com>
- */
-
-import QtQuick 2.4
-import QGroundControl.Controls 1.0
-
-QGCMovableItem {
-    id: root
-    property real rollAngle:    0
-    property real pitchAngle:   0
-    property bool showPitch:    true
-    property real size
-
-    width:  size
-    height: size
-
-    //----------------------------------------------------
-    //-- Artificial Horizon
-    QGCArtificialHorizon {
-        rollAngle:      root.rollAngle
-        pitchAngle:     root.pitchAngle
-        anchors.fill:   parent
-    }
-    //----------------------------------------------------
-    //-- Pointer
-    Image {
-        id:         pointer
-        source:     "/qmlimages/attitudePointer.svg"
-        mipmap:     true
-        fillMode:   Image.PreserveAspectFit
-        anchors.fill: parent
-    }
-    //----------------------------------------------------
-    //-- Instrument Dial
-    Image {
-        id:         instrumentDial
-        source:     "/qmlimages/attitudeDial.svg"
-        mipmap:     true
-        fillMode:   Image.PreserveAspectFit
-        anchors.fill: parent
-        transform: Rotation {
-            origin.x: root.width  / 2
-            origin.y: root.height / 2
-            angle: -rollAngle
-        }
-    }
-    //----------------------------------------------------
-    //-- Pitch
-    QGCPitchWidget {
-        id:                 pitchWidget
-        visible:            root.showPitch
-        size:               root.size * 0.65
-        anchors.verticalCenter: parent.verticalCenter
-        pitchAngle:         root.pitchAngle
-        rollAngle:          root.rollAngle
-        color:              Qt.rgba(0,0,0,0)
-    }
-    //----------------------------------------------------
-    //-- Cross Hair
-    Image {
-        id:                 crossHair
-        anchors.centerIn:   parent
-        source:             "/qmlimages/crossHair.svg"
-        mipmap:             true
-        width:              size * 0.75
-        fillMode:           Image.PreserveAspectFit
-    }
-    //----------------------------------------------------
-    //-- Instrument Pannel
-    Image {
-        id:             pannel
-        source:         "/qmlimages/attitudeInstrument.svg"
-        mipmap:         true
-        fillMode:       Image.PreserveAspectFit
-        anchors.fill:   parent
-    }
-}
diff --git a/src/ui/qmlcommon/QGCAttitudeWidget.qml b/src/ui/qmlcommon/QGCAttitudeWidget.qml
index 40e8062..f0095fd 100644
--- a/src/ui/qmlcommon/QGCAttitudeWidget.qml
+++ b/src/ui/qmlcommon/QGCAttitudeWidget.qml
@@ -23,48 +23,81 @@ This file is part of the QGROUNDCONTROL project
 
 /**
  * @file
- *   @brief QGC Attitude Widget
+ *   @brief QGC Attitude Instrument
  *   @author Gus Grubba <mavlink@grubba.com>
  */
 
 import QtQuick 2.4
-import QGroundControl.ScreenTools 1.0
+import QGroundControl.Controls 1.0
 
-Item {
+QGCMovableItem {
     id: root
-    anchors.centerIn: parent
-    property real rollAngle :   0
+    property real rollAngle:    0
     property real pitchAngle:   0
+    property bool showPitch:    true
+    property real size
 
+    width:  size
+    height: size
+
+    //----------------------------------------------------
+    //-- Artificial Horizon
+    QGCArtificialHorizon {
+        rollAngle:      root.rollAngle
+        pitchAngle:     root.pitchAngle
+        anchors.fill:   parent
+    }
+    //----------------------------------------------------
+    //-- Pointer
     Image {
-        id: rollDial
-        anchors     { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter}
-        source:     "/qmlimages/rollDialWhite.svg"
+        id:         pointer
+        source:     "/qmlimages/attitudePointer.svg"
         mipmap:     true
-        width:      parent.width
         fillMode:   Image.PreserveAspectFit
-        transform: Rotation {
-            origin.x: rollDial.width / 2
-            origin.y: rollDial.height
-            angle:   -rollAngle
-        }
+        anchors.fill: parent
     }
-
+    //----------------------------------------------------
+    //-- Instrument Dial
     Image {
-        id: pointer
-        anchors     { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter}
-        source:     "/qmlimages/rollPointerWhite.svg"
+        id:         instrumentDial
+        source:     "/qmlimages/attitudeDial.svg"
         mipmap:     true
-        width:      rollDial.width
         fillMode:   Image.PreserveAspectFit
+        anchors.fill: parent
+        transform: Rotation {
+            origin.x: root.width  / 2
+            origin.y: root.height / 2
+            angle: -rollAngle
+        }
     }
-
+    //----------------------------------------------------
+    //-- Pitch
+    QGCPitchIndicator {
+        id:                 pitchWidget
+        visible:            root.showPitch
+        size:               root.size * 0.65
+        anchors.verticalCenter: parent.verticalCenter
+        pitchAngle:         root.pitchAngle
+        rollAngle:          root.rollAngle
+        color:              Qt.rgba(0,0,0,0)
+    }
+    //----------------------------------------------------
+    //-- Cross Hair
     Image {
         id:                 crossHair
         anchors.centerIn:   parent
         source:             "/qmlimages/crossHair.svg"
         mipmap:             true
-        width:              parent.width
+        width:              size * 0.75
         fillMode:           Image.PreserveAspectFit
     }
+    //----------------------------------------------------
+    //-- Instrument Pannel
+    Image {
+        id:             pannel
+        source:         "/qmlimages/attitudeInstrument.svg"
+        mipmap:         true
+        fillMode:       Image.PreserveAspectFit
+        anchors.fill:   parent
+    }
 }
diff --git a/src/ui/qmlcommon/QGCCompass.qml b/src/ui/qmlcommon/QGCCompass.qml
deleted file mode 100644
index 2d8e2af..0000000
--- a/src/ui/qmlcommon/QGCCompass.qml
+++ /dev/null
@@ -1,74 +0,0 @@
-/*=====================================================================
-
-QGroundControl Open Source Ground Control Station
-
-(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
-
-This file is part of the QGROUNDCONTROL project
-
-    QGROUNDCONTROL is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    QGROUNDCONTROL is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
-
-======================================================================*/
-
-/**
- * @file
- *   @brief QGC Compass
- *   @author Gus Grubba <mavlink@grubba.com>
- */
-
-import QtQuick 2.4
-import QGroundControl.Controls 1.0
-import QGroundControl.ScreenTools 1.0
-
-Item {
-    id:    root
-    property real heading : 0
-    Image {
-        id: compass
-        anchors.centerIn: parent
-        source: "/qmlimages/compass.svg"
-        mipmap: true
-        width: root.width
-        fillMode: Image.PreserveAspectFit
-        transform: Rotation {
-            origin.x: compass.width  / 2
-            origin.y: compass.height / 2
-            angle: -heading
-        }
-    }
-    Image {
-        id: pointer
-        anchors.bottom: compass.top
-        anchors.horizontalCenter: root.horizontalCenter
-        source: "/qmlimages/compassNeedle.svg"
-        smooth:   true
-        width:    compass.width * 0.1
-        fillMode: Image.PreserveAspectFit
-    }
-    Rectangle {
-        anchors.centerIn: compass
-        width:  ScreenTools.defaultFontPixelSize * (3.33)
-        height: ScreenTools.defaultFontPixelSize * (2.08)
-        border.color: Qt.rgba(1,1,1,0.15)
-        color: Qt.rgba(0,0,0,0.25)
-        QGCLabel {
-            text: heading.toFixed(0)
-            font.weight: Font.DemiBold
-            color: "white"
-            anchors.centerIn: parent
-        }
-    }
-}
-
-
diff --git a/src/ui/qmlcommon/QGCCompassHUD.qml b/src/ui/qmlcommon/QGCCompassHUD.qml
new file mode 100644
index 0000000..6a39a35
--- /dev/null
+++ b/src/ui/qmlcommon/QGCCompassHUD.qml
@@ -0,0 +1,72 @@
+/*=====================================================================
+
+QGroundControl Open Source Ground Control Station
+
+(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
+
+This file is part of the QGROUNDCONTROL project
+
+    QGROUNDCONTROL is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    QGROUNDCONTROL is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
+
+======================================================================*/
+
+/**
+ * @file
+ *   @brief QGC Compass HUD
+ *   @author Gus Grubba <mavlink@grubba.com>
+ */
+
+import QtQuick 2.4
+import QGroundControl.Controls 1.0
+import QGroundControl.ScreenTools 1.0
+
+Item {
+    id:    root
+    property real heading : 0
+    Image {
+        id: compass
+        anchors.centerIn: parent
+        source: "/qmlimages/compass.svg"
+        mipmap: true
+        width: root.width
+        fillMode: Image.PreserveAspectFit
+        transform: Rotation {
+            origin.x: compass.width  / 2
+            origin.y: compass.height / 2
+            angle: -heading
+        }
+    }
+    Image {
+        id: pointer
+        anchors.bottom: compass.top
+        anchors.horizontalCenter: root.horizontalCenter
+        source: "/qmlimages/compassNeedle.svg"
+        smooth:   true
+        width:    compass.width * 0.1
+        fillMode: Image.PreserveAspectFit
+    }
+    Rectangle {
+        anchors.centerIn: compass
+        width:  ScreenTools.defaultFontPixelSize * (3.33)
+        height: ScreenTools.defaultFontPixelSize * (2.08)
+        border.color: Qt.rgba(1,1,1,0.15)
+        color: Qt.rgba(0,0,0,0.25)
+        QGCLabel {
+            text: heading.toFixed(0)
+            font.weight: Font.DemiBold
+            color: "white"
+            anchors.centerIn: parent
+        }
+    }
+}
diff --git a/src/ui/qmlcommon/QGCCompassInstrument.qml b/src/ui/qmlcommon/QGCCompassInstrument.qml
deleted file mode 100644
index adbde3b..0000000
--- a/src/ui/qmlcommon/QGCCompassInstrument.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/*=====================================================================
-
-QGroundControl Open Source Ground Control Station
-
-(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
-
-This file is part of the QGROUNDCONTROL project
-
-    QGROUNDCONTROL is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    QGROUNDCONTROL is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
-
-======================================================================*/
-
-/**
- * @file
- *   @brief QGC Compass
- *   @author Gus Grubba <mavlink@grubba.com>
- */
-
-import QtQuick 2.4
-import QGroundControl.Controls 1.0
-import QGroundControl.ScreenTools 1.0
-
-QGCMovableItem {
-    id:                     root
-    property real heading:  0
-    property real size:     ScreenTools.defaultFontPixelSize * (10)
-    property int _fontSize: ScreenTools.defaultFontPixelSize
-    width:                  size
-    height:                 size
-    Rectangle {
-        id:                 compassBack
-        anchors.fill:       parent
-        color:              "#212121"
-    }
-    Image {
-        id:                 pointer
-        source:             "/qmlimages/compassInstrumentAirplane.svg"
-        mipmap:             true
-        width:              size * 0.75
-        fillMode:           Image.PreserveAspectFit
-        anchors.centerIn:   parent
-        transform: Rotation {
-            origin.x:   pointer.width  / 2
-            origin.y:   pointer.height / 2
-            angle:      heading
-        }
-    }
-    Image {
-        id:                 compassDial
-        source:             "/qmlimages/compassInstrumentDial.svg"
-        mipmap:             true
-        fillMode:           Image.PreserveAspectFit
-        anchors.fill:       parent
-    }
-    Rectangle {
-        anchors.centerIn:   root
-        width:              size * 0.35
-        height:             size * 0.2
-        border.color:       Qt.rgba(1,1,1,0.15)
-        color:              Qt.rgba(0,0,0,0.65)
-        QGCLabel {
-            text:           heading.toFixed(0)
-            font.weight:    Font.DemiBold
-            font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
-            color: "white"
-            anchors.centerIn: parent
-        }
-    }
-}
-
-
diff --git a/src/ui/qmlcommon/QGCCompassWidget.qml b/src/ui/qmlcommon/QGCCompassWidget.qml
new file mode 100644
index 0000000..d4ca061
--- /dev/null
+++ b/src/ui/qmlcommon/QGCCompassWidget.qml
@@ -0,0 +1,82 @@
+/*=====================================================================
+
+QGroundControl Open Source Ground Control Station
+
+(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
+
+This file is part of the QGROUNDCONTROL project
+
+    QGROUNDCONTROL is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    QGROUNDCONTROL is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
+
+======================================================================*/
+
+/**
+ * @file
+ *   @brief QGC Compass Widget
+ *   @author Gus Grubba <mavlink@grubba.com>
+ */
+
+import QtQuick 2.4
+import QGroundControl.Controls 1.0
+import QGroundControl.ScreenTools 1.0
+
+QGCMovableItem {
+    id:                     root
+    property real heading:  0
+    property real size:     ScreenTools.defaultFontPixelSize * (10)
+    property int _fontSize: ScreenTools.defaultFontPixelSize
+    width:                  size
+    height:                 size
+    Rectangle {
+        id:                 compassBack
+        anchors.fill:       parent
+        color:              "#212121"
+    }
+    Image {
+        id:                 pointer
+        source:             "/qmlimages/compassInstrumentAirplane.svg"
+        mipmap:             true
+        width:              size * 0.75
+        fillMode:           Image.PreserveAspectFit
+        anchors.centerIn:   parent
+        transform: Rotation {
+            origin.x:   pointer.width  / 2
+            origin.y:   pointer.height / 2
+            angle:      heading
+        }
+    }
+    Image {
+        id:                 compassDial
+        source:             "/qmlimages/compassInstrumentDial.svg"
+        mipmap:             true
+        fillMode:           Image.PreserveAspectFit
+        anchors.fill:       parent
+    }
+    Rectangle {
+        anchors.centerIn:   root
+        width:              size * 0.35
+        height:             size * 0.2
+        border.color:       Qt.rgba(1,1,1,0.15)
+        color:              Qt.rgba(0,0,0,0.65)
+        QGCLabel {
+            text:           heading.toFixed(0)
+            font.weight:    Font.DemiBold
+            font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
+            color: "white"
+            anchors.centerIn: parent
+        }
+    }
+}
+
+
diff --git a/src/ui/qmlcommon/QGCPitchIndicator.qml b/src/ui/qmlcommon/QGCPitchIndicator.qml
new file mode 100644
index 0000000..3e7c938
--- /dev/null
+++ b/src/ui/qmlcommon/QGCPitchIndicator.qml
@@ -0,0 +1,103 @@
+/*=====================================================================
+
+QGroundControl Open Source Ground Control Station
+
+(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
+
+This file is part of the QGROUNDCONTROL project
+
+    QGROUNDCONTROL is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    QGROUNDCONTROL is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
+
+======================================================================*/
+
+/**
+ * @file
+ *   @brief QGC Pitch Indicator
+ *   @author Gus Grubba <mavlink@grubba.com>
+ */
+
+import QtQuick 2.1
+import QGroundControl.ScreenTools 1.0
+import QGroundControl.Controls 1.0
+
+Rectangle {
+    property real pitchAngle:       0
+    property real rollAngle:        0
+    property real size:             120
+    property real _reticleHeight:   1
+    property real _reticleSpacing:  size * 0.15
+    property real _reticleSlot:     _reticleSpacing + _reticleHeight
+    property real _longDash:        size * 0.40
+    property real _shortDash:       size * 0.25
+    property real _fontSize:        ScreenTools.defaultFontPixelSize
+    height: size * 0.9
+    width:  size
+    radius: ScreenTools.defaultFontPixelSize * (0.66)
+    anchors.horizontalCenter: parent.horizontalCenter
+    anchors.verticalCenter:   parent.verticalCenter
+    clip: true
+    Item {
+        height: parent.height
+        width:  parent.width
+        Column{
+            anchors.horizontalCenter: parent.horizontalCenter
+            anchors.verticalCenter:   parent.verticalCenter
+            spacing: _reticleSpacing
+            Repeater {
+                model: 36
+                Rectangle {
+                    property int _pitch: -(modelData * 5 - 90)
+                    anchors.horizontalCenter: parent.horizontalCenter
+                    width: (_pitch % 10) === 0 ? _longDash : _shortDash
+                    height: _reticleHeight
+                    color: "white"
+                    antialiasing: true
+                    smooth: true
+                    QGCLabel {
+                        anchors.horizontalCenter: parent.horizontalCenter
+                        anchors.horizontalCenterOffset: -(_longDash * 0.8)
+                        anchors.verticalCenter: parent.verticalCenter
+                        smooth: true
+                        font.weight: Font.DemiBold
+                        font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
+                        text: _pitch
+                        color: "white"
+                        visible: (_pitch != 0) && ((_pitch % 10) === 0)
+                    }
+                    QGCLabel {
+                        anchors.horizontalCenter: parent.horizontalCenter
+                        anchors.horizontalCenterOffset: (_longDash * 0.8)
+                        anchors.verticalCenter: parent.verticalCenter
+                        smooth: true
+                        font.weight: Font.DemiBold
+                        font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
+                        text: _pitch
+                        color: "white"
+                        visible: (_pitch != 0) && ((_pitch % 10) === 0)
+                    }
+                }
+            }
+        }
+        transform: [ Translate {
+                y: (pitchAngle * _reticleSlot / 5) - (_reticleSlot / 2)
+                }]
+    }
+    transform: [
+        Rotation {
+            origin.x: width  / 2
+            origin.y: height / 2
+            angle:    -rollAngle
+            }
+    ]
+}
diff --git a/src/ui/qmlcommon/QGCPitchWidget.qml b/src/ui/qmlcommon/QGCPitchWidget.qml
deleted file mode 100644
index 3e7c938..0000000
--- a/src/ui/qmlcommon/QGCPitchWidget.qml
+++ /dev/null
@@ -1,103 +0,0 @@
-/*=====================================================================
-
-QGroundControl Open Source Ground Control Station
-
-(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
-
-This file is part of the QGROUNDCONTROL project
-
-    QGROUNDCONTROL is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    QGROUNDCONTROL is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
-
-======================================================================*/
-
-/**
- * @file
- *   @brief QGC Pitch Indicator
- *   @author Gus Grubba <mavlink@grubba.com>
- */
-
-import QtQuick 2.1
-import QGroundControl.ScreenTools 1.0
-import QGroundControl.Controls 1.0
-
-Rectangle {
-    property real pitchAngle:       0
-    property real rollAngle:        0
-    property real size:             120
-    property real _reticleHeight:   1
-    property real _reticleSpacing:  size * 0.15
-    property real _reticleSlot:     _reticleSpacing + _reticleHeight
-    property real _longDash:        size * 0.40
-    property real _shortDash:       size * 0.25
-    property real _fontSize:        ScreenTools.defaultFontPixelSize
-    height: size * 0.9
-    width:  size
-    radius: ScreenTools.defaultFontPixelSize * (0.66)
-    anchors.horizontalCenter: parent.horizontalCenter
-    anchors.verticalCenter:   parent.verticalCenter
-    clip: true
-    Item {
-        height: parent.height
-        width:  parent.width
-        Column{
-            anchors.horizontalCenter: parent.horizontalCenter
-            anchors.verticalCenter:   parent.verticalCenter
-            spacing: _reticleSpacing
-            Repeater {
-                model: 36
-                Rectangle {
-                    property int _pitch: -(modelData * 5 - 90)
-                    anchors.horizontalCenter: parent.horizontalCenter
-                    width: (_pitch % 10) === 0 ? _longDash : _shortDash
-                    height: _reticleHeight
-                    color: "white"
-                    antialiasing: true
-                    smooth: true
-                    QGCLabel {
-                        anchors.horizontalCenter: parent.horizontalCenter
-                        anchors.horizontalCenterOffset: -(_longDash * 0.8)
-                        anchors.verticalCenter: parent.verticalCenter
-                        smooth: true
-                        font.weight: Font.DemiBold
-                        font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
-                        text: _pitch
-                        color: "white"
-                        visible: (_pitch != 0) && ((_pitch % 10) === 0)
-                    }
-                    QGCLabel {
-                        anchors.horizontalCenter: parent.horizontalCenter
-                        anchors.horizontalCenterOffset: (_longDash * 0.8)
-                        anchors.verticalCenter: parent.verticalCenter
-                        smooth: true
-                        font.weight: Font.DemiBold
-                        font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
-                        text: _pitch
-                        color: "white"
-                        visible: (_pitch != 0) && ((_pitch % 10) === 0)
-                    }
-                }
-            }
-        }
-        transform: [ Translate {
-                y: (pitchAngle * _reticleSlot / 5) - (_reticleSlot / 2)
-                }]
-    }
-    transform: [
-        Rotation {
-            origin.x: width  / 2
-            origin.y: height / 2
-            angle:    -rollAngle
-            }
-    ]
-}
diff --git a/src/ui/qmlcommon/qmldir b/src/ui/qmlcommon/qmldir
index dfaeec2..7bd0f90 100644
--- a/src/ui/qmlcommon/qmldir
+++ b/src/ui/qmlcommon/qmldir
@@ -1,19 +1,19 @@
 Module QGroundControl.FlightControls
 
 QGCAltitudeWidget       1.0 QGCAltitudeWidget.qml
+QGCArtificialHorizon    1.0 QGCArtificialHorizon.qml
+QGCAttitudeHUD          1.0 QGCAttitudeHUD.qml
 QGCAttitudeWidget       1.0 QGCAttitudeWidget.qml
-QGCCompass              1.0 QGCCompass.qml
+QGCCompassHUD           1.0 QGCCompassHUD.qml
+QGCCompassWidget        1.0 QGCCompassWidget.qml
 QGCCurrentAltitude      1.0 QGCCurrentAltitude.qml
 QGCCurrentSpeed         1.0 QGCCurrentSpeed.qml
+QGCHudMessage           1.0 QGCHudMessage.qml
 QGCMapBackground        1.0 QGCMapBackground.qml
-QGCPitchWidget          1.0 QGCPitchWidget.qml
-QGCSpeedWidget          1.0 QGCSpeedWidget.qml
-QGCSlider               1.0 QGCSlider.qml
-QGCWaypointEditor       1.0 QGCWaypointEditor.qml
 QGCMapToolButton        1.0 QGCMapToolButton.qml
-QGCAttitudeInstrument   1.0 QGCAttitudeInstrument.qml
-QGCCompassInstrument    1.0 QGCCompassInstrument.qml
-QGCArtificialHorizon    1.0 QGCArtificialHorizon.qml
-QGCWaypoint             1.0 QGCWaypoint.qml
-QGCHudMessage           1.0 QGCHudMessage.qml
+QGCPitchIndicator       1.0 QGCPitchIndicator.qml
+QGCSlider               1.0 QGCSlider.qml
+QGCSpeedWidget          1.0 QGCSpeedWidget.qml
 QGCVideoBackground      1.0 QGCVideoBackground.qml
+QGCWaypoint             1.0 QGCWaypoint.qml
+QGCWaypointEditor       1.0 QGCWaypointEditor.qml