InstrumentSwipeView.qml 2.75 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 14 15

    property color  textColor
    property color  backgroundColor
Don Gagne's avatar
Don Gagne committed
16
    property var    maxHeight       ///< Maximum height that should be taken, smaller than this is ok
17

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

    onWidthChanged: showPage(_currentPage)
24

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

29
    function showPage(pageIndex) {
Don Gagne's avatar
Don Gagne committed
30
        pageRow.x = -(pageIndex * _pageWidth)
31
        _currentPage = pageIndex
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 44 45 46
    function currentPage() {
        return _currentPage
    }

47
    MouseArea {
Don Gagne's avatar
Don Gagne committed
48 49
        anchors.fill:   parent
        onClicked:      showNextPage()
50 51
    }

Don Gagne's avatar
Don Gagne committed
52 53 54 55
    Column {
        id:             column
        anchors.left:   parent.left
        anchors.right:  parent.right
56

Don Gagne's avatar
Don Gagne committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
        Row {
            id: pageRow
            ValuesWidget {
                id:         valuesPage
                width:      _pageWidth
                textColor:  _root.textColor
                maxHeight:  _root.maxHeight
            }
            CameraWidget {
                width:      _pageWidth
                textColor:  _root.textColor
                maxHeight:  _root.maxHeight
            }
            VehicleHealthWidget {
                width:      _pageWidth
                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
            }
        }
    }
}