QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCMouseArea.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4import QGroundControl.Controls
5
6/// Works just like a regular MouseArea except:
7/// 1) It supports the ability to show touch extents based on QGroundControl.showTouchAreas
8/// 2) You can specify fillItem and it will automatically fill to the size and adjust touch areas on mobile
9MouseArea {
10 anchors.leftMargin: fillItem ? -_touchMarginHorizontal : 0
11 anchors.rightMargin: fillItem ? -_touchMarginHorizontal : 0
12 anchors.topMargin: fillItem ? -_touchMarginVertical : 0
13 anchors.bottomMargin: fillItem ? -_touchMarginVertical : 0
14 anchors.fill: fillItem ? fillItem : undefined
15
16 property var fillItem
17 property bool debugMobile: false ///< Allows you to debug mobile sizing on desktop builds
18
19 property real _itemWidth: fillItem ? fillItem.width : width
20 property real _itemHeight: fillItem ? fillItem.height : height
21 property real _touchWidth: Math.max(_itemWidth, ScreenTools.minTouchPixels)
22 property real _touchHeight: Math.max(_itemHeight, ScreenTools.minTouchPixels)
23 property real _touchMarginHorizontal: debugMobile || ScreenTools.isMobile ? (_touchWidth - _itemWidth) / 2 : 0
24 property real _touchMarginVertical: debugMobile || ScreenTools.isMobile ? (_touchHeight - _itemHeight) / 2 : 0
25
26 Rectangle {
27 anchors.fill: parent
28 border.color: "red"
29 border.width: QGroundControl.corePlugin.showTouchAreas ? 3 : 0
30 color: "transparent"
31 }
32}