QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCFlickableScrollIndicator.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4import QGroundControl.Controls
5
6Rectangle {
7 id: control
8 z: 10
9 color: _flickable.indicatorColor
10 opacity: _opacity
11 visible: showIndicator
12 state: orientation == QGCFlickableScrollIndicator.Vertical ? "vertical" : "horizontal"
13
14 property bool showIndicator: false
15 property int orientation: QGCFlickableScrollIndicator.Vertical
16
17 enum Orientation {
18 Vertical,
19 Horizontal
20 }
21
22 property real _opacity: 0.5
23 property var _flickable: parent
24
25 states: [
26 State {
27 name: "vertical"
28 AnchorChanges {
29 target: control
30 anchors.right: _flickable.right
31 }
32
33 PropertyChanges {
34 target: control
35 y: _flickable.height * (_flickable.contentY / _flickable.contentHeight)
36 width: ScreenTools.defaultFontPixelWidth / 2
37 height: _flickable.height * (_flickable.height / _flickable.contentHeight)
38 showIndicator: (_flickable.flickableDirection === Flickable.AutoFlickDirection ||
39 _flickable.flickableDirection === Flickable.VerticalFlick ||
40 _flickable.flickableDirection === Flickable.HorizontalAndVerticalFlick) &&
41 (_flickable.contentHeight > _flickable.height)
42 }
43 },
44
45 State {
46 name: "horizontal"
47 AnchorChanges {
48 target: control
49 anchors.bottom: _flickable.bottom
50 }
51
52 PropertyChanges {
53 target: control
54 x: _flickable.width * (_flickable.contentX / _flickable.contentWidth)
55 height: ScreenTools.defaultFontPixelWidth / 2
56 width: _flickable.width * (_flickable.width / _flickable.contentWidth)
57 showIndicator: (_flickable.flickableDirection === Flickable.AutoFlickDirection ||
58 _flickable.flickableDirection === Flickable.HorizontalFlick ||
59 _flickable.flickableDirection === Flickable.HorizontalAndVerticalFlick) &&
60 (_flickable.contentWidth > _flickable.width)
61 }
62 }
63 ]
64
65 Component.onCompleted: { if (animateOpacity) animateOpacity.restart() }
66 onVisibleChanged: { if (animateOpacity) animateOpacity.restart() }
67 onHeightChanged: { if (animateOpacity) animateOpacity.restart() }
68 onWidthChanged: { if (animateOpacity) animateOpacity.restart() }
69
70 Connections {
71 target: control._flickable
72 function onMovementStarted() { control.opacity = control._opacity }
73 function onMovementEnded() { animateOpacity.restart() }
74 function onContentHeightChanged() { animateOpacity.restart() }
75 }
76
77 NumberAnimation {
78 id: animateOpacity
79 target: control
80 properties: "opacity"
81 from: control._opacity
82 to: 0.0
83 duration: 2000
84 easing.type: Easing.InQuint
85 }
86}