Merge lp:~vthompson/music-app/theme-slider into lp:music-app/remix

Proposed by Victor Thompson
Status: Merged
Approved by: Victor Thompson
Approved revision: 746
Merged at revision: 746
Proposed branch: lp:~vthompson/music-app/theme-slider
Merge into: lp:music-app/remix
Diff against target: 486 lines (+408/-4)
8 files modified
MusicNowPlaying.qml (+2/-4)
common/Themes/Ambiance/BubbleShape.qml (+172/-0)
common/Themes/Ambiance/PartialColorize.qml (+51/-0)
common/Themes/Ambiance/PartialColorizeUbuntuShape.qml (+36/-0)
common/Themes/Ambiance/UbuntuBlueSliderStyle.qml (+126/-0)
common/Themes/Ambiance/artwork/bubble_shadow@20.sci (+7/-0)
common/Themes/Ambiance/artwork/bubble_shadow@30.sci (+7/-0)
common/Themes/Ambiance/artwork/bubble_shadow@8.sci (+7/-0)
To merge this branch: bzr merge lp:~vthompson/music-app/theme-slider
Reviewer Review Type Date Requested Status
Andrew Hayzen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+242161@code.launchpad.net

Commit message

Theme the Slider component.

Description of the change

Theme the Slider component. This brings in the required Themes.Ambiance components, which are modified to have the Slider be UbuntuColors.blue. This comes from the current development SDK in vivid. As such, we'll want to keep this component in sync with any updates in the SDK.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
lp:~vthompson/music-app/theme-slider updated
746. By Victor Thompson

Add necessary artwork from the theme

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

LGTM :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MusicNowPlaying.qml'
2--- MusicNowPlaying.qml 2014-11-16 22:07:05 +0000
3+++ MusicNowPlaying.qml 2014-11-21 00:17:49 +0000
4@@ -24,6 +24,7 @@
5 import Ubuntu.Thumbnailer 0.1
6 import "common"
7 import "common/ListItemActions"
8+import "common/Themes/Ambiance"
9 import "meta-database.js" as Library
10 import "playlists.js" as Playlists
11
12@@ -289,6 +290,7 @@
13 anchors.right: parent.right
14 maximumValue: player.duration // load value at startup
15 objectName: "progressSliderShape"
16+ style: UbuntuBlueSliderStyle {}
17 value: player.position // load value at startup
18
19 function formatValue(v) {
20@@ -308,10 +310,6 @@
21 }
22 }
23
24- Component.onCompleted: {
25- Theme.palette.selected.foreground = UbuntuColors.blue
26- }
27-
28 onPressedChanged: {
29 seeking = pressed
30
31
32=== added directory 'common/Themes'
33=== added directory 'common/Themes/Ambiance'
34=== added file 'common/Themes/Ambiance/BubbleShape.qml'
35--- common/Themes/Ambiance/BubbleShape.qml 1970-01-01 00:00:00 +0000
36+++ common/Themes/Ambiance/BubbleShape.qml 2014-11-21 00:17:49 +0000
37@@ -0,0 +1,172 @@
38+/*
39+ * Copyright 2013-2014 Canonical Ltd.
40+ *
41+ * This program is free software; you can redistribute it and/or modify
42+ * it under the terms of the GNU Lesser General Public License as published by
43+ * the Free Software Foundation; version 3.
44+ *
45+ * This program is distributed in the hope that it will be useful,
46+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
47+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+ * GNU Lesser General Public License for more details.
49+ *
50+ * You should have received a copy of the GNU Lesser General Public License
51+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
52+ */
53+
54+import QtQuick 2.0
55+import Ubuntu.Components 1.1
56+
57+Item {
58+ id: bubbleShape
59+
60+ /*!
61+ Do not use an UbuntuShape but a Rectangle as the background of the BubbleShape.
62+ */
63+ property bool square: false
64+
65+ /*!
66+ The background color of the bubble.
67+ */
68+ property color color: square ? Theme.palette.normal.background : Theme.palette.normal.overlay
69+
70+ property point target
71+ property string direction: "down"
72+ property bool clipContent: false
73+ default property alias children: content.children
74+ // FIXME: This should not be necessary. See
75+ // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1214978
76+ property alias arrowSource: arrow.source
77+
78+ implicitWidth: units.gu(10)
79+ implicitHeight: units.gu(8)
80+
81+ signal showCompleted()
82+ signal hideCompleted()
83+
84+ opacity: 0.0
85+
86+ function show() {
87+ hideAnimation.stop();
88+ showAnimation.start();
89+ }
90+
91+ function hide() {
92+ showAnimation.stop();
93+ hideAnimation.start();
94+ }
95+
96+ ParallelAnimation {
97+ id: showAnimation
98+
99+ NumberAnimation {
100+ target: bubbleShape
101+ property: "opacity"
102+ from: 0.0
103+ to: 1.0
104+ duration: UbuntuAnimation.FastDuration
105+ easing: UbuntuAnimation.StandardEasing
106+ }
107+ NumberAnimation {
108+ target: scaleTransform
109+ property: (direction === "up" || direction === "down") ? "yScale" : "xScale"
110+ from: 0.91
111+ to: 1.0
112+ duration: UbuntuAnimation.FastDuration
113+ easing: UbuntuAnimation.StandardEasing
114+ }
115+ onStopped: showCompleted()
116+ }
117+
118+ NumberAnimation {
119+ id: hideAnimation
120+ target: bubbleShape
121+ property: "opacity"
122+ from: 1.0
123+ to: 0.0
124+ duration: UbuntuAnimation.FastDuration
125+ easing: UbuntuAnimation.StandardEasing
126+ onStopped: hideCompleted()
127+ }
128+
129+ transform: Scale {
130+ id: scaleTransform
131+ origin.x: direction === "right" ? bubbleShape.width :
132+ direction === "left" ? 0 :
133+ bubbleShape.width/2.0
134+ origin.y: direction === "up" ? 0 :
135+ direction === "down" ? bubbleShape.height :
136+ bubbleShape.height/2.0
137+ }
138+
139+ BorderImage {
140+ id: shadow
141+ anchors.fill: parent
142+ anchors.margins: square ? -units.gu(1) : -units.dp(2)
143+ anchors.topMargin: square ? 0 : anchors.margins
144+ source: !square ? "artwork/bubble_shadow.sci" : "artwork/header_overflow_dropshadow.sci"
145+ opacity: 0.8
146+ }
147+
148+ UbuntuShape {
149+ anchors.fill: parent
150+ borderSource: "none"
151+ color: Theme.palette.normal.overlay
152+ image: bubbleShape.clipContent ? shapeSource : null
153+ visible: !square
154+ }
155+
156+ ShaderEffectSource {
157+ id: shapeSource
158+ visible: bubbleShape.clipContent
159+ sourceItem: bubbleShape.clipContent ? content : null
160+ hideSource: !square
161+ // FIXME: visible: false prevents rendering so make it a nearly
162+ // transparent 1x1 pixel instead
163+ opacity: 0.01
164+ width: 1
165+ height: 1
166+ }
167+
168+ Item {
169+ id: content
170+ anchors.fill: parent
171+
172+ Rectangle {
173+ id: colorRect
174+ anchors.fill: parent
175+ color: bubbleShape.color
176+ visible: bubbleShape.clipContent
177+ }
178+ }
179+
180+ Item {
181+ x: target.x
182+ y: target.y
183+
184+ Image {
185+ id: arrow
186+
187+ visible: !square && bubbleShape.direction != "none"
188+
189+ function directionToRotation(direction) {
190+ switch (direction) {
191+ case "up":
192+ return 180;
193+ case "left":
194+ return 90;
195+ case "right":
196+ return -90;
197+ default: // "down" or "none"
198+ return 0;
199+ }
200+ }
201+
202+ x: -width / 2.0
203+ y: -height
204+ transformOrigin: Item.Bottom
205+ rotation: directionToRotation(bubbleShape.direction)
206+ source: "artwork/bubble_arrow.png"
207+ }
208+ }
209+}
210
211=== added file 'common/Themes/Ambiance/PartialColorize.qml'
212--- common/Themes/Ambiance/PartialColorize.qml 1970-01-01 00:00:00 +0000
213+++ common/Themes/Ambiance/PartialColorize.qml 2014-11-21 00:17:49 +0000
214@@ -0,0 +1,51 @@
215+/*
216+ * Copyright 2013 Canonical Ltd.
217+ *
218+ * This program is free software; you can redistribute it and/or modify
219+ * it under the terms of the GNU Lesser General Public License as published by
220+ * the Free Software Foundation; version 3.
221+ *
222+ * This program is distributed in the hope that it will be useful,
223+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
224+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225+ * GNU Lesser General Public License for more details.
226+ *
227+ * You should have received a copy of the GNU Lesser General Public License
228+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
229+ */
230+
231+import QtQuick 2.0
232+
233+ShaderEffect {
234+ id: partialColorize
235+
236+ implicitWidth: source.implicitWidth
237+ implicitHeight: source.implicitHeight
238+ visible: source != null && source.visible
239+
240+ property Item sourceItem
241+ property var source: ShaderEffectSource {
242+ hideSource: true
243+ sourceItem: partialColorize.sourceItem
244+ visible: sourceItem != null
245+ }
246+ property color leftColor
247+ property color rightColor
248+ property real progress
249+ property bool mirror: false
250+ property string texCoord: mirror ? "1.0 - qt_TexCoord0.x" : "qt_TexCoord0.x"
251+
252+ fragmentShader: "
253+ varying highp vec2 qt_TexCoord0;
254+ uniform sampler2D source;
255+ uniform lowp vec4 leftColor;
256+ uniform lowp vec4 rightColor;
257+ uniform lowp float progress;
258+ uniform lowp float qt_Opacity;
259+
260+ void main() {
261+ lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
262+ lowp vec4 newColor = mix(leftColor, rightColor, step(progress, " + texCoord + "));
263+ gl_FragColor = newColor * sourceColor.a * qt_Opacity;
264+ }"
265+}
266
267=== added file 'common/Themes/Ambiance/PartialColorizeUbuntuShape.qml'
268--- common/Themes/Ambiance/PartialColorizeUbuntuShape.qml 1970-01-01 00:00:00 +0000
269+++ common/Themes/Ambiance/PartialColorizeUbuntuShape.qml 2014-11-21 00:17:49 +0000
270@@ -0,0 +1,36 @@
271+/*
272+ * Copyright 2013 Canonical Ltd.
273+ *
274+ * This program is free software; you can redistribute it and/or modify
275+ * it under the terms of the GNU Lesser General Public License as published by
276+ * the Free Software Foundation; version 3.
277+ *
278+ * This program is distributed in the hope that it will be useful,
279+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
280+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
281+ * GNU Lesser General Public License for more details.
282+ *
283+ * You should have received a copy of the GNU Lesser General Public License
284+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
285+ */
286+
287+import QtQuick 2.0
288+
289+PartialColorize {
290+ fragmentShader: "
291+ varying highp vec2 qt_TexCoord0;
292+ uniform sampler2D source;
293+ uniform highp vec4 leftColor;
294+ uniform highp vec4 rightColor;
295+ uniform lowp float progress;
296+ uniform lowp float qt_Opacity;
297+
298+ void main() {
299+ lowp vec4 color = texture2D(source, qt_TexCoord0);
300+ lowp vec4 newColor = mix(leftColor, rightColor, step(progress, " + texCoord + "));
301+ highp float opacity = (1.0 - color.r / max(1.0/256.0, color.a));
302+ lowp vec4 result = opacity * vec4(0.0, 0.0, 0.0, 1.0) + vec4(1.0 - opacity) * newColor;
303+ gl_FragColor = vec4(result.rgb * result.a, result.a) * color.a * qt_Opacity;
304+ }
305+ "
306+}
307
308=== added file 'common/Themes/Ambiance/UbuntuBlueSliderStyle.qml'
309--- common/Themes/Ambiance/UbuntuBlueSliderStyle.qml 1970-01-01 00:00:00 +0000
310+++ common/Themes/Ambiance/UbuntuBlueSliderStyle.qml 2014-11-21 00:17:49 +0000
311@@ -0,0 +1,126 @@
312+/*
313+ * Copyright 2013 Canonical Ltd.
314+ *
315+ * This program is free software; you can redistribute it and/or modify
316+ * it under the terms of the GNU Lesser General Public License as published by
317+ * the Free Software Foundation; version 3.
318+ *
319+ * This program is distributed in the hope that it will be useful,
320+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
321+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
322+ * GNU Lesser General Public License for more details.
323+ *
324+ * You should have received a copy of the GNU Lesser General Public License
325+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
326+ */
327+
328+import QtQuick 2.0
329+import Ubuntu.Components 1.1
330+
331+/*
332+ The default slider style consists of a bar and a thumb shape.
333+
334+ This style is themed using the following properties:
335+ - thumbSpacing: spacing between the thumb and the bar
336+*/
337+Item {
338+ id: sliderStyle
339+
340+ property color foregroundColor: UbuntuColors.blue // CUSTOM
341+ property color backgroundColor: Theme.palette.normal.base
342+
343+ property real thumbSpacing: units.gu(0)
344+ property Item bar: background
345+ property Item thumb: thumb
346+
347+ implicitWidth: units.gu(38)
348+ implicitHeight: units.gu(5)
349+
350+ UbuntuShape {
351+ id: background
352+ anchors {
353+ verticalCenter: parent.verticalCenter
354+ right: parent.right
355+ left: parent.left
356+ }
357+ height: units.dp(4)
358+
359+ color: "white"
360+ }
361+
362+ PartialColorizeUbuntuShape {
363+ anchors.fill: background
364+ sourceItem: background
365+ progress: thumb.x / thumb.barMinusThumbWidth
366+ leftColor: foregroundColor
367+ rightColor: backgroundColor
368+ mirror: Qt.application.layoutDirection == Qt.RightToLeft
369+ }
370+
371+ UbuntuShape {
372+ id: thumb
373+
374+ anchors {
375+ verticalCenter: parent.verticalCenter
376+ topMargin: thumbSpacing
377+ bottomMargin: thumbSpacing
378+ }
379+
380+ property real barMinusThumbWidth: background.width - (thumb.width + 2.0*thumbSpacing)
381+ property real position: thumbSpacing + SliderUtils.normalizedValue(styledItem) * barMinusThumbWidth
382+ property bool pressed: SliderUtils.isPressed(styledItem)
383+ property bool positionReached: x == position
384+ x: position
385+
386+ /* Enable the animation on x when pressing the slider.
387+ Disable it when x has reached the target position.
388+ */
389+ onPressedChanged: if (pressed) xBehavior.enabled = true;
390+ onPositionReachedChanged: if (positionReached) xBehavior.enabled = false;
391+
392+ Behavior on x {
393+ id: xBehavior
394+ SmoothedAnimation {
395+ duration: UbuntuAnimation.FastDuration
396+ }
397+ }
398+ width: units.gu(2)
399+ height: units.gu(2)
400+ opacity: 0.97
401+ color: Theme.palette.normal.overlay
402+ }
403+
404+ BubbleShape {
405+ id: bubbleShape
406+
407+ width: units.gu(8)
408+ height: units.gu(6)
409+
410+ // FIXME: very temporary implementation
411+ property real minX: 0.0
412+ property real maxX: background.width - width
413+ property real pointerSize: units.dp(6)
414+ property real targetMargin: units.gu(1)
415+ property point globalTarget: Qt.point(thumb.x + thumb.width / 2.0, thumb.y - targetMargin)
416+
417+ x: MathUtils.clamp(globalTarget.x - width / 2.0, minX, maxX)
418+ y: globalTarget.y - height - pointerSize
419+ target: Qt.point(globalTarget.x - x, globalTarget.y - y)
420+
421+ property bool pressed: SliderUtils.isPressed(styledItem)
422+ property bool shouldShow: pressed && label.text != ""
423+ onShouldShowChanged: if (shouldShow) {
424+ show();
425+ } else {
426+ hide();
427+ }
428+
429+ Label {
430+ id: label
431+ anchors.centerIn: parent
432+ text: styledItem.formatValue(SliderUtils.liveValue(styledItem))
433+ fontSize: "large"
434+ color: Theme.palette.normal.overlayText
435+ }
436+ }
437+}
438
439=== added directory 'common/Themes/Ambiance/artwork'
440=== added file 'common/Themes/Ambiance/artwork/bubble_arrow@20.png'
441Binary files common/Themes/Ambiance/artwork/bubble_arrow@20.png 1970-01-01 00:00:00 +0000 and common/Themes/Ambiance/artwork/bubble_arrow@20.png 2014-11-21 00:17:49 +0000 differ
442=== added file 'common/Themes/Ambiance/artwork/bubble_arrow@30.png'
443Binary files common/Themes/Ambiance/artwork/bubble_arrow@30.png 1970-01-01 00:00:00 +0000 and common/Themes/Ambiance/artwork/bubble_arrow@30.png 2014-11-21 00:17:49 +0000 differ
444=== added file 'common/Themes/Ambiance/artwork/bubble_arrow@8.png'
445Binary files common/Themes/Ambiance/artwork/bubble_arrow@8.png 1970-01-01 00:00:00 +0000 and common/Themes/Ambiance/artwork/bubble_arrow@8.png 2014-11-21 00:17:49 +0000 differ
446=== added file 'common/Themes/Ambiance/artwork/bubble_shadow@20.png'
447Binary files common/Themes/Ambiance/artwork/bubble_shadow@20.png 1970-01-01 00:00:00 +0000 and common/Themes/Ambiance/artwork/bubble_shadow@20.png 2014-11-21 00:17:49 +0000 differ
448=== added file 'common/Themes/Ambiance/artwork/bubble_shadow@20.sci'
449--- common/Themes/Ambiance/artwork/bubble_shadow@20.sci 1970-01-01 00:00:00 +0000
450+++ common/Themes/Ambiance/artwork/bubble_shadow@20.sci 2014-11-21 00:17:49 +0000
451@@ -0,0 +1,7 @@
452+border.top: 21
453+border.bottom: 26
454+border.left: 27
455+border.right: 27
456+horizontalTileMode: BorderImage.Stretch
457+verticalTileMode: BorderImage.Stretch
458+source: bubble_shadow@20.png
459
460=== added file 'common/Themes/Ambiance/artwork/bubble_shadow@30.png'
461Binary files common/Themes/Ambiance/artwork/bubble_shadow@30.png 1970-01-01 00:00:00 +0000 and common/Themes/Ambiance/artwork/bubble_shadow@30.png 2014-11-21 00:17:49 +0000 differ
462=== added file 'common/Themes/Ambiance/artwork/bubble_shadow@30.sci'
463--- common/Themes/Ambiance/artwork/bubble_shadow@30.sci 1970-01-01 00:00:00 +0000
464+++ common/Themes/Ambiance/artwork/bubble_shadow@30.sci 2014-11-21 00:17:49 +0000
465@@ -0,0 +1,7 @@
466+border.top: 31
467+border.bottom: 37
468+border.left: 38
469+border.right: 38
470+horizontalTileMode: BorderImage.Stretch
471+verticalTileMode: BorderImage.Stretch
472+source: bubble_shadow@30.png
473
474=== added file 'common/Themes/Ambiance/artwork/bubble_shadow@8.png'
475Binary files common/Themes/Ambiance/artwork/bubble_shadow@8.png 1970-01-01 00:00:00 +0000 and common/Themes/Ambiance/artwork/bubble_shadow@8.png 2014-11-21 00:17:49 +0000 differ
476=== added file 'common/Themes/Ambiance/artwork/bubble_shadow@8.sci'
477--- common/Themes/Ambiance/artwork/bubble_shadow@8.sci 1970-01-01 00:00:00 +0000
478+++ common/Themes/Ambiance/artwork/bubble_shadow@8.sci 2014-11-21 00:17:49 +0000
479@@ -0,0 +1,7 @@
480+border.top: 10
481+border.bottom: 11
482+border.left: 12
483+border.right: 11
484+horizontalTileMode: BorderImage.Stretch
485+verticalTileMode: BorderImage.Stretch
486+source: bubble_shadow@8.png

Subscribers

People subscribed via source and target branches