Debian Codegraph @

src/imports/Components/Themes/Ambiance/1.3/BottomEdgeHintStyle.qml

raw
1 /*
2 * Copyright 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 Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.4
18 import Lomiri.Components 1.3
19 import Lomiri.Components.ListItems 1.3
20
21 Item {
22 id: bottomEdgeHintStyle
23 implicitWidth: styledItem.parent.width
24 implicitHeight: units.gu(4)
25
26 readonly property BottomEdgeHint hint: styledItem
27
28 property color backgroundColor: styledItem.enabled
29 ? theme.palette.normal.overlay
30 : theme.palette.disabled.overlay
31
32 property color foregroundColor: styledItem.enabled
33 ? theme.palette.normal.overlayText
34 : theme.palette.disabled.overlayText
35
36 // translate hint status into state
37 state: {
38 switch (hint.status) {
39 case BottomEdgeHint.Hidden: return "Hidden";
40 case BottomEdgeHint.Inactive: return "Inactive"
41 case BottomEdgeHint.Active: return "Active"
42 case BottomEdgeHint.Locked: return "Locked"
43 }
44 }
45
46 states: [
47 State {
48 name: "Inactive"
49 extend: ""
50 },
51 State {
52 name: "Active"
53 PropertyChanges {
54 target: h1
55 anchors.verticalCenterOffset: styledItem.height / 2
56 }
57 PropertyChanges {
58 target: h2
59 anchors.topMargin: 0
60 }
61 },
62 State {
63 name: "Hidden"
64 PropertyChanges {
65 target: styledItem
66 opacity: 0.0
67 }
68 },
69 State {
70 name: "Locked"
71 PropertyChanges {
72 target: h1
73 anchors.verticalCenterOffset: styledItem.height / 2
74 }
75 PropertyChanges {
76 target: h2
77 anchors.topMargin: 0
78 }
79 }
80 ]
81 transitions: [
82 Transition {
83 from: "*"
84 to: "Active"
85 reversible: true
86 LomiriNumberAnimation {
87 targets: [h1, h2]
88 properties: "anchors.verticalCenterOffset, anchors.topMargin"
89 }
90 },
91 Transition {
92 from: "*"
93 to: "Hidden"
94 reversible: true
95 LomiriNumberAnimation {
96 target: styledItem
97 property: "opacity"
98 duration: LomiriAnimation.SlowDuration
99 }
100 }
101 ]
102
103 clip: true
104
105 Icon {
106 id: h1
107 width: units.gu(3)
108 height: units.gu(1.5)
109 anchors {
110 centerIn: parent
111 topMargin: styledItem.height
112 }
113 name: "toolkit_bottom-edge-hint"
114 color: foregroundColor
115
116 FocusShape {
117 }
118 }
119
120 Rectangle {
121 id: h2
122 anchors {
123 top: parent.top
124 left: parent.left
125 right: parent.right
126 topMargin: styledItem.height
127 }
128 height: styledItem.height
129 color: backgroundColor
130 ThinDivider {
131 anchors.top: parent.top
132 }
133
134 FocusShape {
135 anchors {
136 fill: undefined
137 margins: 0
138 top: parent.top
139 bottom: parent.bottom
140 horizontalCenter: parent.horizontalCenter
141 }
142 // icon, spacing, label, margin on either side
143 width: icon.width + units.gu(1) + label.width + units.gu(0.46) * 2
144 }
145 Row {
146 anchors {
147 top: parent.top
148 bottom: parent.bottom
149 horizontalCenter: parent.horizontalCenter
150 }
151 spacing: units.gu(1)
152 Icon {
153 id: icon
154 name: styledItem.iconName
155 source: styledItem.iconSource
156 width: height
157 height: units.gu(2)
158 anchors.verticalCenter: parent.verticalCenter
159 color: foregroundColor
160 }
161 Label {
162 id: label
163 text: styledItem.text
164 textSize: Label.Medium
165 color: foregroundColor
166 height: styledItem.height
167 anchors.verticalCenter: parent.verticalCenter
168 verticalAlignment: Text.AlignVCenter
169 }
170 }
171 }
172 }