Merge lp:~aacid/unity-2d/unity-2d_backport_shell_clamp into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michał Sawicz
Approved revision: 881
Merged at revision: 888
Proposed branch: lp:~aacid/unity-2d/unity-2d_backport_shell_clamp
Merge into: lp:unity-2d
Diff against target: 90 lines (+29/-9)
3 files modified
places/RatingStars.qml (+5/-8)
places/utils.js (+4/-0)
tests/manual-tests/places.txt (+20/-1)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d_backport_shell_clamp
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
Review via email: mp+91213@code.launchpad.net

Description of the change

Move clamp to utils.js

Backport from unity-2d-shell

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :

Change happened here http://bazaar.launchpad.net/~unity-2d-team/unity-2d/unity-2d-shell/revision/812 From what i can see it seems it was not MR'ed and simply commited?

Revision history for this message
Michał Sawicz (saviq) wrote :

Please add a manual test for that.

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

Manual test added

881. By Albert Astals Cid

Manual test for rating clamping

Revision history for this message
Michał Sawicz (saviq) :
review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

MR Approval awaiting lift of code freeze.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'places/RatingStars.qml'
--- places/RatingStars.qml 2011-11-14 10:45:33 +0000
+++ places/RatingStars.qml 2012-02-03 13:54:24 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19import QtQuick 1.019import QtQuick 1.0
20import "utils.js" as Utils
2021
21Item {22Item {
22 id: ratingStars23 id: ratingStars
@@ -36,16 +37,12 @@
36 width: stars.width37 width: stars.width
37 height: stars.height38 height: stars.height
3839
39 function clamp(x, min, max) {
40 return Math.max(Math.min(x, max), min)
41 }
42
43 function incrementRating() {40 function incrementRating() {
44 rating = clamp(Math.floor(rating) + 1, 1, size)41 rating = Utils.clamp(Math.floor(rating) + 1, 1, size)
45 }42 }
4643
47 function decrementRating() {44 function decrementRating() {
48 rating = clamp(Math.ceil(rating) - 1, 1, size)45 rating = Utils.clamp(Math.ceil(rating) - 1, 1, size)
49 }46 }
5047
51 Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true48 Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true
@@ -68,7 +65,7 @@
68 model: size65 model: size
69 Star {66 Star {
70 fill: if(!enabled){ /* If read-only, display any Star rating */67 fill: if(!enabled){ /* If read-only, display any Star rating */
71 return clamp(rating - index, 0, size)68 return Utils.clamp(rating - index, 0, size)
72 }69 }
73 else{ /* If user selectable, restrict to integer selections */70 else{ /* If user selectable, restrict to integer selections */
74 return (rating - index > 0) ? 1 : 071 return (rating - index > 0) ? 1 : 0
@@ -99,7 +96,7 @@
99 /* What unit is the mouse over? This is the integer part of the rating (plus one)*/96 /* What unit is the mouse over? This is the integer part of the rating (plus one)*/
100 var rating = (posX - posXOverUnit) / unitWidth + 197 var rating = (posX - posXOverUnit) / unitWidth + 1
10198
102 return clamp( rating, 0, size )99 return Utils.clamp( rating, 0, size )
103 }100 }
104101
105 anchors.fill: stars102 anchors.fill: stars
106103
=== modified file 'places/utils.js'
--- places/utils.js 2011-08-24 12:44:05 +0000
+++ places/utils.js 2012-02-03 13:54:24 +0000
@@ -27,3 +27,7 @@
27 }27 }
28 return camelName28 return camelName
29}29}
30
31function clamp(x, min, max) {
32 return Math.max(Math.min(x, max), min)
33}
3034
=== modified file 'tests/manual-tests/places.txt'
--- tests/manual-tests/places.txt 2012-01-25 17:03:58 +0000
+++ tests/manual-tests/places.txt 2012-02-03 13:54:24 +0000
@@ -36,4 +36,23 @@
36 # but it does not work realiably because of the reasons explained36 # but it does not work realiably because of the reasons explained
37 # in the places-tests.rb file37 # in the places-tests.rb file
3838
39----
40\ No newline at end of file39\ No newline at end of file
40----
41
42 # Test case objectives:
43 # * Check that filters rating is clamped
44 # Pre-conditions
45 # * Desktop with no running applications
46 # Test steps
47 # * Verify dash is not showing
48 # * Press Super
49 # * Go to the search applications lens
50 # * Make sure filtering is enabled
51 # * Go to the Rating stars with the keyboard navigation
52 # * Use Left and Right keyboard arrows to verify 1 and 5 are the maximum stars
53 # that you can get highlighted
54 # Post-conditions
55 # * None
56 # References
57 # * None
58
59----

Subscribers

People subscribed via source and target branches