Merge lp:~fboucault/ubuntu-ui-toolkit/progressbar_updated_design into lp:ubuntu-ui-toolkit

Proposed by Florian Boucault
Status: Merged
Approved by: Tim Peeters
Approved revision: 673
Merged at revision: 674
Proposed branch: lp:~fboucault/ubuntu-ui-toolkit/progressbar_updated_design
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 301 lines (+132/-85)
5 files modified
modules/Ubuntu/Components/ProgressBar.qml (+2/-76)
modules/Ubuntu/Components/Themes/Ambiance/PartialColorize.qml (+14/-7)
modules/Ubuntu/Components/Themes/Ambiance/PartialColorizeUbuntuShape.qml (+36/-0)
modules/Ubuntu/Components/Themes/Ambiance/ProgressBarStyle.qml (+78/-0)
modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml (+2/-2)
To merge this branch: bzr merge lp:~fboucault/ubuntu-ui-toolkit/progressbar_updated_design
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tim Peeters Needs Information
Review via email: mp+178075@code.launchpad.net

Commit message

ProgressBar: new visual design.
Indeterminate progress bar's design is not worked out yet. Simple placeholder animation for now.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Florian Boucault (fboucault) wrote :

Note that this implementation will be simplified when the new ubuntu shape lands.

Revision history for this message
Tim Peeters (tpeeters) wrote :

why do you need a special PartialColorize for UbuntuShape?

review: Needs Information
Revision history for this message
Tim Peeters (tpeeters) wrote :

PartialColorizeUbuntuShape fragment shader:
- why do you use color.r in the opacity calculations?
- shadow is always 0. Is this intentional? Do you need that variable?

Revision history for this message
Florian Boucault (fboucault) wrote :

> why do you need a special PartialColorize for UbuntuShape?

Well, there are very different implementations. We need to only color the inside of the UbuntuShape.

673. By Florian Boucault

Simplified shader.

Revision history for this message
Florian Boucault (fboucault) wrote :

> PartialColorizeUbuntuShape fragment shader:
> - why do you use color.r in the opacity calculations?

Since the shape is greyscale color.r is the same as color.g and color.b

> - shadow is always 0. Is this intentional? Do you need that variable?

Removed it.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/ProgressBar.qml'
2--- modules/Ubuntu/Components/ProgressBar.qml 2012-10-19 01:09:07 +0000
3+++ modules/Ubuntu/Components/ProgressBar.qml 2013-08-02 12:15:38 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2012 Canonical Ltd.
7+ * Copyright 2013 Canonical Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11@@ -44,9 +44,6 @@
12 AnimatedItem {
13 id: progressBar
14
15- width: units.gu(25)
16- height: units.gu(1.5)
17-
18 /*!
19 \preliminary
20 Specifies whether the progress interval is unknown. When set, altering
21@@ -73,76 +70,5 @@
22 */
23 property real value: 0.5
24
25- // TODO: use proper images/styling
26- BorderImage {
27- id: frame
28- anchors.fill: parent
29- source: internals.barSource
30- border {
31- left: units.dp(2)
32- top: units.dp(2)
33- right: units.dp(2)
34- bottom: units.dp(2)
35- }
36-
37- smooth: true
38- clip: true
39- Image {
40- id: trackerIndeterminate
41- visible: progressBar.indeterminate
42- width: progressBar.width - 2 * internals.trackerOffset + 4 * sourceSize.width
43- y: internals.trackerOffset
44- height: progressBar.height - 2 * internals.trackerOffset
45-
46- source: internals.unknownTrackerSource
47- smooth: true
48- fillMode: Image.TileHorizontally
49-
50- property real animatedX
51- x: internals.trackerOffset + Math.round(trackerIndeterminate.animatedX)
52- NumberAnimation on animatedX {
53- running: progressBar.indeterminate && progressBar.visible && progressBar.onScreen
54- loops: Animation.Infinite
55- from: -trackerIndeterminate.sourceSize.width
56- to: 0
57- duration: (300 * trackerIndeterminate.sourceSize.width / 10)
58- }
59- }
60-
61- BorderImage {
62- id: tracker
63- visible: !progressBar.indeterminate
64-
65- source: internals.knownTrackerSource
66- anchors {
67- fill: frame
68- leftMargin: internals.trackerOffset
69- topMargin: internals.trackerOffset
70- bottomMargin: internals.trackerOffset
71- rightMargin: internals.trackerOffset + internals.progress()
72- }
73- smooth: true
74- }
75- }
76-
77- QtObject {
78- id: internals
79- // style properties, preparation for theming
80- property url barSource: Qt.resolvedUrl("artwork/ProgressBarBackground.png")
81- property url knownTrackerSource: Qt.resolvedUrl("artwork/ProgressBarTracker.png")
82- property url unknownTrackerSource: Qt.resolvedUrl("artwork/ProgressBarTrackerIndeterminate.png")
83- property int trackerOffset: units.dp(1)
84-
85- function progress()
86- {
87- if (progressBar.indeterminate)
88- return 0
89- var normalValue = Math.max(progressBar.value, progressBar.minimumValue)
90- normalValue = Math.min(normalValue, progressBar.maximumValue)
91- var area = Math.abs(progressBar.maximumValue - progressBar.minimumValue)
92- var progress = Math.abs((normalValue + Math.abs(progressBar.minimumValue)) / area)
93- var trackerW = progressBar.width - 2 * trackerOffset
94- return trackerW - trackerW * progress
95- }
96- }
97+ style: Theme.createStyleComponent("ProgressBarStyle.qml", progressBar)
98 }
99
100=== renamed file 'modules/Ubuntu/Components/Themes/Ambiance/PartialColorizeImage.qml' => 'modules/Ubuntu/Components/Themes/Ambiance/PartialColorize.qml'
101--- modules/Ubuntu/Components/Themes/Ambiance/PartialColorizeImage.qml 2013-07-08 21:13:19 +0000
102+++ modules/Ubuntu/Components/Themes/Ambiance/PartialColorize.qml 2013-08-02 12:15:38 +0000
103@@ -1,31 +1,38 @@
104 /*
105- * Copyright (C) 2013 Canonical, Ltd.
106+ * Copyright 2013 Canonical Ltd.
107 *
108 * This program is free software; you can redistribute it and/or modify
109- * it under the terms of the GNU General Public License as published by
110+ * it under the terms of the GNU Lesser General Public License as published by
111 * the Free Software Foundation; version 3.
112 *
113 * This program is distributed in the hope that it will be useful,
114 * but WITHOUT ANY WARRANTY; without even the implied warranty of
115 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
116- * GNU General Public License for more details.
117+ * GNU Lesser General Public License for more details.
118 *
119- * You should have received a copy of the GNU General Public License
120+ * You should have received a copy of the GNU Lesser General Public License
121 * along with this program. If not, see <http://www.gnu.org/licenses/>.
122 */
123
124 import QtQuick 2.0
125
126 ShaderEffect {
127+ id: partialColorize
128+
129 implicitWidth: source.implicitWidth
130 implicitHeight: source.implicitHeight
131+ visible: source != null && source.visible
132
133- property Image source
134+ property Item sourceItem
135+ property var source: ShaderEffectSource {
136+ hideSource: true
137+ sourceItem: partialColorize.sourceItem
138+ visible: sourceItem != null
139+ }
140 property color leftColor
141 property color rightColor
142 property real progress
143- visible: source.status == Image.Ready
144-
145+
146 fragmentShader: "
147 varying highp vec2 qt_TexCoord0;
148 uniform sampler2D source;
149
150=== added file 'modules/Ubuntu/Components/Themes/Ambiance/PartialColorizeUbuntuShape.qml'
151--- modules/Ubuntu/Components/Themes/Ambiance/PartialColorizeUbuntuShape.qml 1970-01-01 00:00:00 +0000
152+++ modules/Ubuntu/Components/Themes/Ambiance/PartialColorizeUbuntuShape.qml 2013-08-02 12:15:38 +0000
153@@ -0,0 +1,36 @@
154+/*
155+ * Copyright 2013 Canonical Ltd.
156+ *
157+ * This program is free software; you can redistribute it and/or modify
158+ * it under the terms of the GNU Lesser General Public License as published by
159+ * the Free Software Foundation; version 3.
160+ *
161+ * This program is distributed in the hope that it will be useful,
162+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
163+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
164+ * GNU Lesser General Public License for more details.
165+ *
166+ * You should have received a copy of the GNU Lesser General Public License
167+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
168+ */
169+
170+import QtQuick 2.0
171+
172+PartialColorize {
173+ fragmentShader: "
174+ varying highp vec2 qt_TexCoord0;
175+ uniform sampler2D source;
176+ uniform highp vec4 leftColor;
177+ uniform highp vec4 rightColor;
178+ uniform lowp float progress;
179+ uniform lowp float qt_Opacity;
180+
181+ void main() {
182+ lowp vec4 color = texture2D(source, qt_TexCoord0);
183+ lowp vec4 newColor = mix(leftColor, rightColor, step(progress, qt_TexCoord0.x));
184+ highp float opacity = (1.0 - color.r / max(1.0/256.0, color.a));
185+ lowp vec4 result = opacity * vec4(0.0, 0.0, 0.0, 1.0) + vec4(1.0 - opacity) * newColor;
186+ gl_FragColor = vec4(result.rgb * result.a, result.a) * color.a * qt_Opacity;
187+ }
188+ "
189+}
190
191=== added file 'modules/Ubuntu/Components/Themes/Ambiance/ProgressBarStyle.qml'
192--- modules/Ubuntu/Components/Themes/Ambiance/ProgressBarStyle.qml 1970-01-01 00:00:00 +0000
193+++ modules/Ubuntu/Components/Themes/Ambiance/ProgressBarStyle.qml 2013-08-02 12:15:38 +0000
194@@ -0,0 +1,78 @@
195+/*
196+ * Copyright 2013 Canonical Ltd.
197+ *
198+ * This program is free software; you can redistribute it and/or modify
199+ * it under the terms of the GNU Lesser General Public License as published by
200+ * the Free Software Foundation; version 3.
201+ *
202+ * This program is distributed in the hope that it will be useful,
203+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
204+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
205+ * GNU Lesser General Public License for more details.
206+ *
207+ * You should have received a copy of the GNU Lesser General Public License
208+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
209+ */
210+
211+import QtQuick 2.0
212+import Ubuntu.Components 0.1
213+
214+Item {
215+ id: progressBarStyle
216+
217+ property ProgressBar progressBar: styledItem
218+
219+ implicitWidth: units.gu(38)
220+ implicitHeight: units.gu(5)
221+
222+ UbuntuShape {
223+ id: background
224+ anchors.fill: parent
225+ /* The color must be white for PartialColorizeUbuntuShape to accurately
226+ replace the white with leftColor and rightColor
227+ */
228+ color: progressBar.indeterminate ? Theme.palette.normal.base : "white"
229+ }
230+
231+ property real progress: progressBar.indeterminate ? 0.0
232+ : progressBar.value / (progressBar.maximumValue - progressBar.minimumValue)
233+
234+ /* Colorize the background with rightColor and progressively fill it
235+ with leftColor proportionally to progress
236+ */
237+ PartialColorizeUbuntuShape {
238+ anchors.fill: background
239+ sourceItem: progressBar.indeterminate ? null : background
240+ progress: progressBarStyle.progress
241+ leftColor: Theme.palette.selected.foreground
242+ rightColor: Theme.palette.normal.base
243+ }
244+
245+ Label {
246+ id: valueLabel
247+ anchors.centerIn: background
248+ fontSize: "medium"
249+ color: Theme.palette.normal.baseText
250+ text: progressBar.indeterminate ? i18n.tr("In Progress...")
251+ : "%1%".arg(Number(progressBarStyle.progress * 100.0).toFixed(0))
252+
253+ SequentialAnimation on opacity {
254+ loops: Animation.Infinite
255+ running: progressBar.indeterminate
256+ UbuntuNumberAnimation {
257+ to: 0.5; duration: UbuntuAnimation.SleepyDuration
258+ }
259+ UbuntuNumberAnimation {
260+ to: 1.0; duration: UbuntuAnimation.SleepyDuration
261+ }
262+ }
263+ }
264+
265+ PartialColorize {
266+ anchors.fill: valueLabel
267+ sourceItem: progressBar.indeterminate ? null : valueLabel
268+ leftColor: Theme.palette.selected.foregroundText
269+ rightColor: Theme.palette.normal.baseText
270+ progress: (progressBarStyle.progress * background.width - valueLabel.x) / valueLabel.width
271+ }
272+}
273
274=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml'
275--- modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml 2013-07-10 17:34:20 +0000
276+++ modules/Ubuntu/Components/Themes/Ambiance/SwitchStyle.qml 2013-08-02 12:15:38 +0000
277@@ -83,7 +83,7 @@
278 height: thumb.height
279 width: thumb.width
280
281- PartialColorizeImage {
282+ PartialColorize {
283 anchors.centerIn: parent
284 source: Image {
285 source: "artwork/cross.png"
286@@ -105,7 +105,7 @@
287 height: thumb.height
288 width: thumb.width
289
290- PartialColorizeImage {
291+ PartialColorize {
292 anchors.centerIn: parent
293 source: Image {
294 source: "artwork/tick.png"
295
296=== removed file 'modules/Ubuntu/Components/artwork/ProgressBarBackground@8.png'
297Binary files modules/Ubuntu/Components/artwork/ProgressBarBackground@8.png 2012-11-21 12:07:16 +0000 and modules/Ubuntu/Components/artwork/ProgressBarBackground@8.png 1970-01-01 00:00:00 +0000 differ
298=== removed file 'modules/Ubuntu/Components/artwork/ProgressBarTracker@8.png'
299Binary files modules/Ubuntu/Components/artwork/ProgressBarTracker@8.png 2012-11-21 12:07:16 +0000 and modules/Ubuntu/Components/artwork/ProgressBarTracker@8.png 1970-01-01 00:00:00 +0000 differ
300=== removed file 'modules/Ubuntu/Components/artwork/ProgressBarTrackerIndeterminate@8.png'
301Binary files modules/Ubuntu/Components/artwork/ProgressBarTrackerIndeterminate@8.png 2012-11-21 12:07:16 +0000 and modules/Ubuntu/Components/artwork/ProgressBarTrackerIndeterminate@8.png 1970-01-01 00:00:00 +0000 differ

Subscribers

People subscribed via source and target branches

to status/vote changes: