Merge lp:~aacid/unity8/obeyArtShapeFixedSize into lp:unity8

Proposed by Albert Astals Cid
Status: Superseded
Proposed branch: lp:~aacid/unity8/obeyArtShapeFixedSize
Merge into: lp:unity8
Diff against target: 219 lines (+72/-43)
5 files modified
plugins/Dash/CardCreator.js (+11/-6)
tests/plugins/Dash/cardcreator/1.res (+13/-8)
tests/plugins/Dash/cardcreator/3.res (+19/-14)
tests/plugins/Dash/cardcreator/5.res (+20/-15)
tests/qmltests/Dash/tst_Card.qml (+9/-0)
To merge this branch: bzr merge lp:~aacid/unity8/obeyArtShapeFixedSize
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+222294@code.launchpad.net

This proposal has been superseded by a proposal from 2014-06-23.

Commit message

Make so that fixedArtShapeSize actually fixes artShapeSize

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) wrote :

can we test this?

Revision history for this message
Albert Astals Cid (aacid) wrote :

tests/plugins/Dash/cardcreator/3.res are tests, no?

What other test do you want?

Revision history for this message
Andrea Cimitan (cimi) wrote :

> tests/plugins/Dash/cardcreator/3.res are tests, no?
>
> What other test do you want?
Do you remember the condition when the image was bigger than the shape? What is supposedly fixed by this branch... I'd add a qml test for it, comparing the dimension of the icon and the art shape to be the same... (should fail before your branch, not failing after)

949. By Albert Astals Cid

Add test for fixedArtShapeSize

950. By Albert Astals Cid

c&p mistake found by Cimi

951. By Albert Astals Cid

!= -1 → > 0

952. By Albert Astals Cid

and the tests

953. By Albert Astals Cid

Check fixedArtShapeSizeAspect

Revision history for this message
Andrea Cimitan (cimi) wrote :

waiting CI

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes.

 * Did CI run pass? If not, please explain why.
Oh, yes!

review: Approve

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Dash/CardCreator.js'
2--- plugins/Dash/CardCreator.js 2014-05-19 15:53:16 +0000
3+++ plugins/Dash/CardCreator.js 2014-06-13 10:43:41 +0000
4@@ -55,8 +55,8 @@
5 // %3 is used as image height
6 var kArtShapeHolderCode = 'Item { \n\
7 id: artShapeHolder; \n\
8- height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
9- width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
10+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
11+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
12 anchors { %1 } \n\
13 Loader { \n\
14 id: artShapeLoader; \n\
15@@ -68,13 +68,18 @@
16 id: artShape; \n\
17 objectName: "artShape"; \n\
18 radius: "medium"; \n\
19- readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
20+ visible: image.status == Image.Ready; \n\
21+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
22+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
23 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \n\
24 Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
25 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); \n\
26- visible: image.status == Image.Ready; \n\
27+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
28 function updateWidthHeightBindings() { \n\
29- if (aspectSmallerThanImageAspect) { \n\
30+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
31+ width = root.fixedArtShapeSize.width; \n\
32+ height = root.fixedArtShapeSize.height; \n\
33+ } else if (aspectSmallerThanImageAspect) { \n\
34 width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
35 height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect }); \n\
36 } else { \n\
37@@ -108,7 +113,7 @@
38 visible: showHeader && status == Loader.Ready; \n\
39 sourceComponent: ShaderEffect { \n\
40 id: overlay; \n\
41- height: fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight; \n\
42+ height: fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight; \n\
43 opacity: 0.6; \n\
44 property var source: ShaderEffectSource { \n\
45 id: shaderSource; \n\
46
47=== modified file 'tests/plugins/Dash/cardcreator/1.res'
48--- tests/plugins/Dash/cardcreator/1.res 2014-05-19 15:53:16 +0000
49+++ tests/plugins/Dash/cardcreator/1.res 2014-06-13 10:43:41 +0000
50@@ -16,8 +16,8 @@
51 readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
52 Item {
53 id: artShapeHolder;
54- height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height;
55- width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width;
56+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
57+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
58 anchors { horizontalCenter: parent.horizontalCenter; }
59 Loader {
60 id: artShapeLoader;
61@@ -28,14 +28,19 @@
62 sourceComponent: UbuntuShape {
63 id: artShape;
64 objectName: "artShape";
65- radius: "medium";
66- readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
67- readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
68- Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
69- onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
70+ radius: "medium";
71 visible: image.status == Image.Ready;
72+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
73+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
74+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
75+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
76+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
77+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
78 function updateWidthHeightBindings() {
79- if (aspectSmallerThanImageAspect) {
80+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
81+ width = root.fixedArtShapeSize.width;
82+ height = root.fixedArtShapeSize.height;
83+ } else if (aspectSmallerThanImageAspect) {
84 width = Qt.binding(function() { return !visible ? 0 : image.width });
85 height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
86 } else {
87
88=== modified file 'tests/plugins/Dash/cardcreator/3.res'
89--- tests/plugins/Dash/cardcreator/3.res 2014-05-19 15:53:16 +0000
90+++ tests/plugins/Dash/cardcreator/3.res 2014-06-13 10:43:41 +0000
91@@ -16,8 +16,8 @@
92 readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
93 Item {
94 id: artShapeHolder;
95- height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height;
96- width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width;
97+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
98+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
99 anchors { horizontalCenter: parent.horizontalCenter; }
100 Loader {
101 id: artShapeLoader;
102@@ -29,19 +29,24 @@
103 id: artShape;
104 objectName: "artShape";
105 radius: "medium";
106- readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
107- readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
108- Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
109- onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
110 visible: image.status == Image.Ready;
111- function updateWidthHeightBindings() {
112- if (aspectSmallerThanImageAspect) {
113- width = Qt.binding(function() { return !visible ? 0 : image.width });
114- height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
115- } else {
116- width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
117- height = Qt.binding(function() { return !visible ? 0 : image.height });
118- }
119+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
120+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
121+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
122+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
123+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
124+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
125+ function updateWidthHeightBindings() {
126+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
127+ width = root.fixedArtShapeSize.width;
128+ height = root.fixedArtShapeSize.height;
129+ } else if (aspectSmallerThanImageAspect) {
130+ width = Qt.binding(function() { return !visible ? 0 : image.width });
131+ height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
132+ } else {
133+ width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
134+ height = Qt.binding(function() { return !visible ? 0 : image.height });
135+ }
136 }
137 image: Image {
138 objectName: "artImage";
139
140=== modified file 'tests/plugins/Dash/cardcreator/5.res'
141--- tests/plugins/Dash/cardcreator/5.res 2014-05-19 15:53:16 +0000
142+++ tests/plugins/Dash/cardcreator/5.res 2014-06-13 10:43:41 +0000
143@@ -16,8 +16,8 @@
144 readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
145 Item {
146 id: artShapeHolder;
147- height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height;
148- width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width;
149+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
150+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
151 anchors { horizontalCenter: parent.horizontalCenter; }
152 Loader {
153 id: artShapeLoader;
154@@ -29,19 +29,24 @@
155 id: artShape;
156 objectName: "artShape";
157 radius: "medium";
158- readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
159- readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
160- Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
161- onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
162 visible: image.status == Image.Ready;
163- function updateWidthHeightBindings() {
164- if (aspectSmallerThanImageAspect) {
165- width = Qt.binding(function() { return !visible ? 0 : image.width });
166- height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
167- } else {
168- width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
169- height = Qt.binding(function() { return !visible ? 0 : image.height });
170- }
171+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
172+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
173+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
174+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
175+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
176+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
177+ function updateWidthHeightBindings() {
178+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
179+ width = root.fixedArtShapeSize.width;
180+ height = root.fixedArtShapeSize.height;
181+ } else if (aspectSmallerThanImageAspect) {
182+ width = Qt.binding(function() { return !visible ? 0 : image.width });
183+ height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
184+ } else {
185+ width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
186+ height = Qt.binding(function() { return !visible ? 0 : image.height });
187+ }
188 }
189 image: Image {
190 objectName: "artImage";
191@@ -68,7 +73,7 @@
192 visible: showHeader && status == Loader.Ready;
193 sourceComponent: ShaderEffect {
194 id: overlay;
195- height: fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight;
196+ height: fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight;
197 opacity: 0.6;
198 property var source: ShaderEffectSource {
199 id: shaderSource;
200
201=== modified file 'tests/qmltests/Dash/tst_Card.qml'
202--- tests/qmltests/Dash/tst_Card.qml 2014-05-05 14:47:06 +0000
203+++ tests/qmltests/Dash/tst_Card.qml 2014-06-13 10:43:41 +0000
204@@ -305,6 +305,15 @@
205 }
206 }
207
208+ function test_art_shape_fixed_size() {
209+ selector.selectedIndex = 6;
210+ card.fixedArtShapeSize = Qt.size( units.gu(8), units.gu(4) );
211+ waitForRendering(card);
212+ tryCompare(art, "width", units.gu(8));
213+ tryCompare(art, "height", units.gu(4));
214+ tryCompare(art, "fixedArtShapeSizeAspect", 2);
215+ }
216+
217 function test_art_layout_data() {
218 return [
219 { tag: "Vertical", left: function() { return units.gu(1); }, index: 0},

Subscribers

People subscribed via source and target branches