Debian Codegraph @

modules/Lomiri/Components/Extras/qml5/TabsBar/TabButton.qml

raw
1 /*
2 * Copyright (C) 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored-by: Florian Boucault <[email protected]>
17 */
18 import QtQuick 2.4
19 import Lomiri.Components 1.3
20
21 MouseArea {
22 id: tabButton
23
24 property alias iconName: icon.name
25 property alias iconSource: icon.source
26 property alias iconColor: icon.color
27 property real iconSize: units.gu(2)
28 property real leftMargin: 0
29 property real rightMargin: 0
30
31 anchors {
32 top: parent.top
33 bottom: parent.bottom
34 }
35 width: units.gu(3) + leftMargin + rightMargin
36
37 Rectangle {
38 anchors {
39 top: parent.top
40 bottom: parent.bottom
41 horizontalCenter: icon.horizontalCenter
42 }
43 width: icon.width + Math.max(leftMargin, rightMargin) * 2.0
44 color: tabsBar.highlightColor
45 visible: tabButton.pressed
46 opacity: visible ? 1.0 : 0.0
47 Behavior on opacity {
48 LomiriNumberAnimation { duration: LomiriAnimation.FastDuration }
49 }
50 }
51
52 Icon {
53 id: icon
54 width: tabButton.iconSize
55 height: tabButton.iconSize
56 anchors {
57 centerIn: parent
58 horizontalCenterOffset: (leftMargin - rightMargin) / 2.0
59 }
60 asynchronous: true
61 }
62 }