InstrumentSwipeView.qml 2.89 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
        _currentPage = pageIndex
33 34
    }

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

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

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

Don Gagne's avatar
Don Gagne committed
54 55
        Row {
            id: pageRow
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 80
            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
81 82 83
            }
        }

Don Gagne's avatar
Don Gagne committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
        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"
                }
99 100 101 102
            }
        }
    }
}