Add sample qml application
[staging/HomeScreen.git] / sample-qml / imports / utils / Marker.qml
1 /* Copyright (C) 2015, Jaguar Land Rover. All Rights Reserved.
2  *
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 import QtQuick 2.0
8 import utils 1.0
9
10 Item {
11     id: root
12     width: 120
13     height: 120
14     property string text
15     signal clicked()
16     property alias pressed: area.pressed
17     property alias color: background.color
18     property alias fontSize: label.font.pixelSize
19     property bool fill: false
20
21     Rectangle {
22         id: background
23         anchors.fill: parent
24         color: Style.backgroundColor
25         opacity: root.fill ? 1.0: 0.2
26     }
27
28     Rectangle {
29         id: frame
30         anchors.fill: parent
31         color: 'transparent'
32         border.color: Qt.darker(background.color, 1.4)
33         border.width: 2
34         opacity: 1.0
35     }
36
37
38     Rectangle {
39         anchors.fill: label
40         anchors.margins: -2
41         color: Style.backgroundColor
42         opacity: root.text ? 1.0 : 0.0
43     }
44
45     Text {
46         id: label
47         anchors.centerIn: parent
48         font.pixelSize: 14
49         color: Style.greyDarkColor
50         opacity: 0.75
51         text: root.text
52     }
53     MouseArea {
54         id: area
55         anchors.fill: parent
56         onClicked: root.clicked()
57         onPressed: background.color = Qt.darker(background.color, 1.5)
58         onReleased:  background.color = Qt.lighter(background.color, 1.5)
59     }
60 }