QGCToolBarButton.qml 2.1 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10 11


import QtQuick          2.4
12 13
import QtQuick.Controls 1.2

14 15 16
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0
17

dogmaphobic's avatar
dogmaphobic committed
18
Item {
19 20 21
    id:     _root
    state:  "HelpShown"
    clip:   true
dogmaphobic's avatar
dogmaphobic committed
22

23 24 25
    property alias          source:         icon.source
    property bool           checked:        false
    property bool           logo:           false
dogmaphobic's avatar
dogmaphobic committed
26 27
    property ExclusiveGroup exclusiveGroup:  null

28 29
    readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight / 2

Don Gagne's avatar
Don Gagne committed
30
    signal clicked()
31

dogmaphobic's avatar
dogmaphobic committed
32 33 34 35 36 37
    onExclusiveGroupChanged: {
        if (exclusiveGroup) {
            exclusiveGroup.bindCheckable(_root)
        }
    }

38 39 40 41 42 43 44 45
    QGCPalette { id: qgcPal }

    Rectangle {
        anchors.fill:   parent
        visible:        logo
        color:          "#4A2C6D"
    }

46 47 48 49 50 51
    QGCColoredImage {
        id:                     icon
        anchors.left:           parent.left
        anchors.right:          parent.right
        anchors.topMargin:      _topBottomMargins
        anchors.top:            parent.top
Don Gagne's avatar
Don Gagne committed
52 53
        anchors.bottomMargin:   _topBottomMargins
        anchors.bottom:         parent.bottom
dogmaphobic's avatar
dogmaphobic committed
54
        sourceSize.height:      parent.height
55
        fillMode:               Image.PreserveAspectFit
56
        color:                  logo ? "white" : (checked ? qgcPal.buttonHighlight : qgcPal.buttonText)
57 58
    }

59
    Rectangle {
60 61 62
        anchors.left:   parent.left
        anchors.right:  parent.right
        anchors.bottom: parent.bottom
dogmaphobic's avatar
dogmaphobic committed
63
        height:         _topBottomMargins * 0.25
64 65
        color:          qgcPal.buttonHighlight
        visible:        checked
dogmaphobic's avatar
dogmaphobic committed
66 67 68 69 70 71 72 73 74 75
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            checked = true
            _root.clicked()
        }
    }
}