InstrumentSwipeView.qml 2.86 KB
Newer Older
1 2 3
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Layouts          1.2
4 5 6 7 8 9

import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.FlightMap     1.0

Item {
Don Gagne's avatar
Don Gagne committed
10 11 12
    id:     _root
    clip:   true
    height: column.height
13

Don Gagne's avatar
Don Gagne committed
14
    property var    qgcView         ///< QGCView to use for showing dialogs
15 16
    property color  textColor
    property color  backgroundColor
Don Gagne's avatar
Don Gagne committed
17
    property var    maxHeight       ///< Maximum height that should be taken, smaller than this is ok
18

Don Gagne's avatar
Don Gagne committed
19 20 21 22 23 24
    property real   _margins:       ScreenTools.defaultFontPixelWidth / 2
    property real   _pageWidth:     _root.width
    property int    _currentPage:   0
    property int    _maxPage:       3

    onWidthChanged: showPage(_currentPage)
25

Don Gagne's avatar
Don Gagne committed
26 27 28 29
    function showPicker() {
        valuesPage.showPicker()
    }

30
    function showPage(pageIndex) {
Don Gagne's avatar
Don Gagne committed
31
        pageRow.x = -(pageIndex * _pageWidth)
32 33
    }

Don Gagne's avatar
Don Gagne committed
34 35 36 37 38
    function showNextPage() {
        if (_currentPage == _maxPage) {
            _currentPage = 0
        } else {
            _currentPage++
39
        }
Don Gagne's avatar
Don Gagne committed
40
        showPage(_currentPage)
41 42
    }

43
    MouseArea {
Don Gagne's avatar
Don Gagne committed
44 45
        anchors.fill:   parent
        onClicked:      showNextPage()
46 47
    }

Don Gagne's avatar
Don Gagne committed
48 49 50 51
    Column {
        id:             column
        anchors.left:   parent.left
        anchors.right:  parent.right
52

Don Gagne's avatar
Don Gagne committed
53 54
        Row {
            id: pageRow
55

Don Gagne's avatar
Don Gagne committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
            ValuesWidget {
                id:         valuesPage
                width:      _pageWidth
                qgcView:    _root.qgcView
                textColor:  _root.textColor
                maxHeight:  _root.maxHeight
            }
            CameraWidget {
                width:      _pageWidth
                qgcView:    _root.qgcView
                textColor:  _root.textColor
                maxHeight:  _root.maxHeight
            }
            VehicleHealthWidget {
                width:      _pageWidth
                qgcView:    _root.qgcView
                textColor:  _root.textColor
                maxHeight:  _root.maxHeight
            }
            VibrationWidget {
                width:              _pageWidth
                textColor:          _root.textColor
                backgroundColor:    _root.backgroundColor
                maxHeight:          _root.maxHeight
80 81 82
            }
        }

Don Gagne's avatar
Don Gagne committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
        Row {
            anchors.horizontalCenter:   parent.horizontalCenter
            spacing:                    _margins

            Repeater {
                model: _maxPage + 1

                Rectangle {
                    height:         radius * 2
                    width:          radius * 2
                    radius:         ScreenTools.defaultFontPixelWidth / 3
                    border.color:   textColor
                    border.width:   1
                    color:          _currentPage == index ? textColor : "transparent"
                }
98 99 100 101
            }
        }
    }
}