Merge lp:~robertcarr/unity/filter-clampratings into lp:unity

Proposed by Robert Carr
Status: Merged
Merge reported by: Neil J. Patel
Merged at revision: not available
Proposed branch: lp:~robertcarr/unity/filter-clampratings
Merge into: lp:unity
Diff against target: 11 lines (+1/-0)
1 file modified
plugins/unityshell/src/FilterRatingsButton.cpp (+1/-0)
To merge this branch: bzr merge lp:~robertcarr/unity/filter-clampratings
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Needs Fixing
Andrea Cimitan (community) Approve
Review via email: mp+77356@code.launchpad.net

Description of the change

Clamp rating values to between 0 and 1

To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) wrote :

I'm missing the CLAMP macro in c++ :)

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Well, actually we can use that in unity. So go for that! ;)

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/FilterRatingsButton.cpp'
2--- plugins/unityshell/src/FilterRatingsButton.cpp 2011-09-26 14:03:42 +0000
3+++ plugins/unityshell/src/FilterRatingsButton.cpp 2011-09-28 16:01:26 +0000
4@@ -244,6 +244,7 @@
5 float new_rating = (static_cast<float>(x) / width) + 0.10f;
6
7 new_rating = ceil(10*new_rating)/10;
8+ new_rating = new_rating > 1 ? 1 : (new_rating < 0 ? 0 : new_rating);
9
10 if (filter != NULL)
11 filter->rating = new_rating;