-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathColors.qml
224 lines (206 loc) · 8.49 KB
/
Colors.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import QtQml.Models 2.1
Template {
id: colorsTemplate
objectName: "colorsTemplate"
TemplateSection {
id: paletteSection
title: "Palette"
className: "Palette"
documentation: "Ubuntu.Components.Themes/%1.html".arg(className)
property var palettes: ["normal", "disabled", "selected", "selectedDisabled", "highlighted", "focused"]
property var paletteValues: [["background", ["backgroundText", "backgroundSecondaryText", "backgroundTertiaryText"]],
["base", ["baseText"]],
["foreground", ["foregroundText"]],
["field", ["fieldText"]],
["focus", ["focusText"]],
["activity", ["activityText"]],
["negative", ["negativeText"]],
["overlay", ["overlayText", "overlaySecondaryText"]],
["positive", ["positiveText"]],
["raised", ["raisedText", "raisedSecondaryText"]],
["selection", ["selectionText"]],
["position", ["positionText"]],
]
Flow {
id: paletteFlow
anchors {
left: parent.left
right: parent.right
}
spacing: units.gu(2)
property var previewed
Repeater {
model: paletteSection.palettes
Column {
spacing: units.gu(1)
width: paletteColorGrid.width
property var palette: theme.palette[modelData]
Label {
text: "theme.palette." + modelData
textSize: Label.Small
}
Grid {
id: paletteColorGrid
spacing: units.gu(0)
Repeater {
model: paletteSection.paletteValues
Item {
id: paletteColor
property string mainColor: modelData[0]
property var textColors: modelData[1]
property bool previewed: paletteFlow.previewed == paletteColor
width: units.gu(8)
height: units.gu(5)
z: previewed ? 10 : 0
MouseArea {
id: colorHoverArea
anchors.fill: parent
hoverEnabled: true
onClicked: paletteFlow.previewed = paletteColor
onContainsMouseChanged: {
if (containsMouse) {
paletteFlow.previewed = paletteColor;
} else {
if (paletteFlow.previewed == paletteColor) {
paletteFlow.previewed = null;
}
}
}
}
Rectangle {
width: paletteColor.width + (previewed ? units.gu(26) : 0)
height: paletteColor.height + (previewed ? units.gu(2.5) : 0)
Behavior on height { UbuntuNumberAnimation {duration: UbuntuAnimation.SnapDuration} }
color: theme.palette.normal.background
parent: previewed ? colorsTemplate : paletteColor
x: Math.max(0, paletteColor.mapToItem(parent, 0, 0).x + (previewed ? (paletteColor.width-width)/2 : 0))
y: paletteColor.mapToItem(parent, 0, 0).y + (previewed ? (paletteColor.height-height)/2 : 0)
Rectangle {
anchors.fill: parent
color: palette ? palette[mainColor] : "transparent"
border.width: color == theme.palette.normal.background ? units.dp(1) : 0
border.color: theme.palette.normal.backgroundText
}
Column {
anchors {
left: parent.left
leftMargin: units.gu(0.5)
right: parent.right
top: parent.top
topMargin: units.gu(0.5)
}
Repeater {
model: textColors
Label {
width: previewed ? implicitWidth : parent.width
text: previewed ? modelData : modelData.slice(0, 10)
color: palette ? palette[modelData] : "transparent"
textSize: previewed ? Label.Medium : Label.XSmall
elide: Text.ElideRight
}
}
}
}
}
}
}
}
}
}
}
TemplateSection {
title: "UbuntuColors"
className: "UbuntuColors"
// Except orange, none of the colors from UbuntuComponents 1.0
// are included because they may be deprecated soon.
TemplateRow {
title: i18n.tr("Orange")
UbuntuShape {
backgroundColor: UbuntuColors.orange
}
}
TemplateRow {
title: i18n.tr("Porcelain")
UbuntuShape {
backgroundColor: UbuntuColors.porcelain
}
}
TemplateRow {
title: i18n.tr("Silk")
UbuntuShape {
backgroundColor: UbuntuColors.silk
}
}
TemplateRow {
title: i18n.tr("Ash")
UbuntuShape {
backgroundColor: UbuntuColors.ash
}
}
TemplateRow {
title: i18n.tr("Graphite")
UbuntuShape {
backgroundColor: UbuntuColors.graphite
}
}
TemplateRow {
title: i18n.tr("Slate")
UbuntuShape {
backgroundColor: UbuntuColors.slate
}
}
TemplateRow {
title: i18n.tr("Inkstone")
UbuntuShape {
backgroundColor: UbuntuColors.inkstone
}
}
TemplateRow {
title: i18n.tr("Jet")
UbuntuShape {
backgroundColor: UbuntuColors.jet
}
}
TemplateRow {
title: i18n.tr("Red")
UbuntuShape {
backgroundColor: UbuntuColors.red
}
}
TemplateRow {
title: i18n.tr("Green")
UbuntuShape {
backgroundColor: UbuntuColors.green
}
}
TemplateRow {
title: i18n.tr("Blue")
UbuntuShape {
backgroundColor: UbuntuColors.blue
}
}
TemplateRow {
title: i18n.tr("Purple")
UbuntuShape {
backgroundColor: UbuntuColors.purple
}
}
}
}