From 1f77b2f7113891bf395c07d410607f3068531db5 Mon Sep 17 00:00:00 2001
From: DonLakeFlyer <don@thegagnes.com>
Date: Wed, 8 Mar 2017 14:50:43 -0800
Subject: [PATCH] QGC replacement for MouseArea

Shows touch area extents when turned on
---
 qgroundcontrol.qrc                             |  1 +
 src/QmlControls/QGCMouseArea.qml               | 12 ++++++++++++
 src/QmlControls/QGroundControl.Controls.qmldir |  1 +
 src/QmlControls/ScreenTools.qml                |  6 +++++-
 4 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 src/QmlControls/QGCMouseArea.qml

diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index def0440d0b..41746308eb 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -85,6 +85,7 @@
         <file alias="QGroundControl/Controls/QGCMapLabel.qml">src/QmlControls/QGCMapLabel.qml</file>
         <file alias="QGroundControl/Controls/QGCMobileFileOpenDialog.qml">src/QmlControls/QGCMobileFileOpenDialog.qml</file>
         <file alias="QGroundControl/Controls/QGCMobileFileSaveDialog.qml">src/QmlControls/QGCMobileFileSaveDialog.qml</file>
+        <file alias="QGroundControl/Controls/QGCMouseArea.qml">src/QmlControls/QGCMouseArea.qml</file>
         <file alias="QGroundControl/Controls/QGCMovableItem.qml">src/QmlControls/QGCMovableItem.qml</file>
         <file alias="QGroundControl/Controls/QGCPipable.qml">src/QmlControls/QGCPipable.qml</file>
         <file alias="QGroundControl/Controls/QGCRadioButton.qml">src/QmlControls/QGCRadioButton.qml</file>
diff --git a/src/QmlControls/QGCMouseArea.qml b/src/QmlControls/QGCMouseArea.qml
new file mode 100644
index 0000000000..aba03c3743
--- /dev/null
+++ b/src/QmlControls/QGCMouseArea.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.3
+
+import QGroundControl 1.0
+
+MouseArea {
+    Rectangle {
+        anchors.fill:   parent
+        border.color:   "red"
+        border.width:   QGroundControl.showTouchAreas ? 1 : 0
+        color:          "transparent"
+    }
+}
diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir
index 8426dc4e0b..dd491b5f43 100644
--- a/src/QmlControls/QGroundControl.Controls.qmldir
+++ b/src/QmlControls/QGroundControl.Controls.qmldir
@@ -37,6 +37,7 @@ QGCListView             1.0 QGCListView.qml
 QGCMapLabel             1.0 QGCMapLabel.qml
 QGCMobileFileOpenDialog 1.0 QGCMobileFileOpenDialog.qml
 QGCMobileFileSaveDialog 1.0 QGCMobileFileSaveDialog.qml
+QGCMouseArea            1.0 QGCMouseArea.qml
 QGCMovableItem          1.0 QGCMovableItem.qml
 QGCPipable              1.0 QGCPipable.qml
 QGCRadioButton          1.0 QGCRadioButton.qml
diff --git a/src/QmlControls/ScreenTools.qml b/src/QmlControls/ScreenTools.qml
index 84fa4b7c20..c2085e45b7 100644
--- a/src/QmlControls/ScreenTools.qml
+++ b/src/QmlControls/ScreenTools.qml
@@ -60,6 +60,9 @@ Item {
     property bool isTinyScreen:     (Screen.width / Screen.pixelDensity) < 120 // 120mm
     property bool isShortScreen:    ScreenToolsController.isMobile && ((Screen.height / Screen.width) < 0.6) // Nexus 7 for example
 
+    readonly property real minTouchMillimeters: 10      ///< Minimum touch size in millimeters
+    property real minTouchPixels:               0       ///< Minimum touch size in pixels
+
     // The implicit heights/widths for our custom control set
     property real implicitButtonWidth:      Math.round(defaultFontPixelWidth *  (isMobile ? 7.0 : 5.0))
     property real implicitButtonHeight:     Math.round(defaultFontPixelHeight * (isMobile ? 2.0 : 1.6))
@@ -101,7 +104,8 @@ Item {
         smallFontPointSize      = defaultFontPointSize  * _screenTools.smallFontPointRatio
         mediumFontPointSize     = defaultFontPointSize  * _screenTools.mediumFontPointRatio
         largeFontPointSize      = defaultFontPointSize  * _screenTools.largeFontPointRatio
-        toolbarHeight           = defaultFontPixelHeight * 3 * QGroundControl.corePlugin.options.toolbarHeightMultiplier
+        minTouchPixels          = Math.round(minTouchMillimeters * Screen.pixelDensity)
+        toolbarHeight           = isMobile ? minTouchPixels : defaultFontPixelHeight * 3
     }
 
     Text {
-- 
GitLab