6import QGroundControl.Controls
8/// Drop panel that displays positioned next to the specified click position.
9/// By default the panel drops to the right of the click position. If there isn't
10/// enough room to the right then the panel will drop to the left.
14 leftPadding: _dropRight ? _innerMargin + _arrowPointWidth : _innerMargin
15 rightPadding: _dropRight ? _innerMargin : _innerMargin + _arrowPointWidth
18 closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
22 property var sourceComponent // Component to display within the popup
23 property var clickRect: Qt.rect(0, 0, 0, 0) // Rectangle of clicked item - used to position drop down
24 property var dropViewPort: Qt.rect(0, 0, parent.width, parent.height) // Available viewport for dropdown
26 property var _qgcPal: QGroundControl.globalPalette
27 property real _innerMargin: ScreenTools.defaultFontPixelWidth * 0.5 // Margin between content and rectanglular portion of background
28 property real _arrowPointWidth: ScreenTools.defaultFontPixelWidth * 2 // Distance from vertical side to point
29 property real _arrowPointPositionY: height / 2
30 property bool _dropRight: true
33 // Panel defaults to dropping to the right of click position
34 let xPos = clickRect.x + clickRect.width
36 // If there isn't room to the right then we switch to drop to the left
37 if (xPos + _root.width > dropViewPort.x + dropViewPort.width) {
39 xPos = clickRect.x - _root.width
42 // Default position of panel is vertically centered on click position
43 let yPos = clickRect.y + (clickRect.height / 2)
44 yPos -= _root.height / 2
46 // Make sure panel is within viewport
47 let originalYPos = yPos
48 yPos = Math.max(yPos, dropViewPort.y)
49 yPos = Math.min(yPos, dropViewPort.y + dropViewPort.height - _root.height)
54 // Adjust arrow position back to point at click position
55 _arrowPointPositionY += originalYPos - yPos
59 implicitWidth: contentItem.implicitWidth + _innerMargin * 2 + _arrowPointWidth
60 implicitHeight: contentItem.implicitHeight + _innerMargin * 2
63 x: _dropRight ? _arrowPointWidth : 0
64 radius: ScreenTools.defaultFontPixelHeight / 2
65 width: parent.implicitWidth - _arrowPointWidth
66 height: parent.implicitHeight
72 x: _dropRight ? 0 : parent.width - _arrowPointWidth
73 y: _arrowPointPositionY - _arrowPointWidth
74 width: _arrowPointWidth
75 height: _arrowPointWidth * 2
78 var context = getContext("2d")
81 context.moveTo(_dropRight ? 0 : _arrowPointWidth, _arrowPointWidth)
82 context.lineTo(_dropRight ? _arrowPointWidth : 0, 0)
83 context.lineTo(_dropRight ? _arrowPointWidth : 0, _arrowPointWidth * 2)
85 context.fillStyle = _qgcPal.window
91 contentItem: SettingsGroupLayout {
93 sourceComponent: _root.sourceComponent