Merge lp:~macslow/unity/unity.fix-863246 into lp:unity

Proposed by Mirco Müller
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 1832
Proposed branch: lp:~macslow/unity/unity.fix-863246
Merge into: lp:unity
Diff against target: 503 lines (+156/-170)
4 files modified
plugins/unityshell/resources/dash-widgets.json (+2/-2)
plugins/unityshell/src/DashStyle.cpp (+151/-164)
plugins/unityshell/src/DashStyle.h (+1/-2)
plugins/unityshell/src/FilterGenreWidget.cpp (+2/-2)
To merge this branch: bzr merge lp:~macslow/unity/unity.fix-863246
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+88504@code.launchpad.net

Description of the change

Since the bug LP: #863246 states so many issues, I'm splitting up the work into a series of branches/fixes. This first part corrects pixel-grid alignment of selected/unselected button-outlines, opacity-values (outline, filling) and vertical and horizontal spacing between buttons.

Here are a few screenshots/screencast showing this first set of improvements:

 http://people.canonical.com/~mmueller/fix-863246-part-1.png
 http://people.canonical.com/~mmueller/fix-863246-part-4.png
 http://people.canonical.com/~mmueller/fix-863246-part-5.ogv

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

+1

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity failed due to conflicts:

text conflict in plugins/unityshell/resources/dash-widgets.json
text conflict in plugins/unityshell/src/FilterGenreWidget.cpp

Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/resources/dash-widgets.json'
2--- plugins/unityshell/resources/dash-widgets.json 2012-01-09 10:27:16 +0000
3+++ plugins/unityshell/resources/dash-widgets.json 2012-01-13 15:19:22 +0000
4@@ -40,14 +40,14 @@
5 "icon-gap" : 40},
6
7 "button-label": {
8- "border-opacity" : [ 1.0, 0.5, 0.5, 0.5, 0.5],
9+ "border-opacity" : [ 1.0, 0.15, 0.15, 0.15, 0.15],
10 "border-color" : ["#ffffff", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF"],
11 "border-size" : [ 2.0, 1.0, 1.0, 0.5, 0.5],
12 "text-size" : 1.0,
13 "text-color" : ["#ffffff", "#ffffff", "#ffffff", "#ffffff", "#ffffff"],
14 "text-opacity" : [ 1.0, 1.0, 1.0, 1.0, 1.0],
15 "fill-color" : ["#FFFFFF", "#000000", "#000000", "#000000", "#000000"],
16- "fill-opacity" : [ 0.25, 0.0, 0.0, 0.0, 0.0],
17+ "fill-opacity" : [ 0.15, 0.0, 0.0, 0.0, 0.0],
18 "overlay-opacity": [ 0.1, 0.1, 0.1, 0.0, 0.0],
19 "overlay-mode" : [ "normal", "normal", "normal", "normal", "normal"],
20 "blur-size" : [ 1, 1, 1, 0, 0]},
21
22=== modified file 'plugins/unityshell/src/DashStyle.cpp'
23--- plugins/unityshell/src/DashStyle.cpp 2011-10-25 16:32:49 +0000
24+++ plugins/unityshell/src/DashStyle.cpp 2012-01-13 15:19:22 +0000
25@@ -61,21 +61,26 @@
26 ::cairo_set_source_rgba(cr, color.red, color.green, color.blue, color.alpha);
27 }
28
29-inline double _align(double val)
30+inline double _align(double val, bool odd=true)
31 {
32 double fract = val - (int) val;
33
34- // for strokes with an odd line-width
35- if (fract != 0.5f)
36- return (double) ((int) val + 0.5f);
37- else
38- return val;
39-
40- // for strokes with an even line-width
41- /*if (fract != 0.0f)
42- return (double) ((int) val);
43- else
44- return val;*/
45+ if (odd)
46+ {
47+ // for strokes with an odd line-width
48+ if (fract != 0.5f)
49+ return (double) ((int) val + 0.5f);
50+ else
51+ return val;
52+ }
53+ else
54+ {
55+ // for strokes with an even line-width
56+ if (fract != 0.0f)
57+ return (double) ((int) val);
58+ else
59+ return val;
60+ }
61 }
62
63 class LazyLoadTexture
64@@ -412,108 +417,62 @@
65 double y,
66 double cornerRadius,
67 double width,
68- double height,
69- bool align)
70+ double height)
71 {
72 // sanity check
73 if (cairo_status(cr) != CAIRO_STATUS_SUCCESS &&
74 cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE)
75 return;
76
77+ bool odd = true;
78+
79+ odd = cairo_get_line_width (cr) == 2.0 ? false : true;
80+
81 double radius = cornerRadius / aspect;
82
83- if (align)
84- {
85- // top-left, right of the corner
86- cairo_move_to(cr, _align (x + radius), _align (y));
87-
88- // top-right, left of the corner
89- cairo_line_to(cr, _align(x + width - radius), _align(y));
90-
91- // top-right, below the corner
92- cairo_arc(cr,
93- _align(x + width - radius),
94- _align(y + radius),
95- radius,
96- -90.0f * G_PI / 180.0f,
97- 0.0f * G_PI / 180.0f);
98-
99- // bottom-right, above the corner
100- cairo_line_to(cr, _align(x + width), _align(y + height - radius));
101-
102- // bottom-right, left of the corner
103- cairo_arc(cr,
104- _align(x + width - radius),
105- _align(y + height - radius),
106- radius,
107- 0.0f * G_PI / 180.0f,
108- 90.0f * G_PI / 180.0f);
109-
110- // bottom-left, right of the corner
111- cairo_line_to(cr, _align(x + radius), _align(y + height));
112-
113- // bottom-left, above the corner
114- cairo_arc(cr,
115- _align(x + radius),
116- _align(y + height - radius),
117- radius,
118- 90.0f * G_PI / 180.0f,
119- 180.0f * G_PI / 180.0f);
120-
121- // top-left, right of the corner
122- cairo_arc(cr,
123- _align(x + radius),
124- _align(y + radius),
125- radius,
126- 180.0f * G_PI / 180.0f,
127- 270.0f * G_PI / 180.0f);
128- }
129- else
130- {
131- // top-left, right of the corner
132- cairo_move_to(cr, x + radius, y);
133-
134- // top-right, left of the corner
135- cairo_line_to(cr, x + width - radius, y);
136-
137- // top-right, below the corner
138- cairo_arc(cr,
139- x + width - radius,
140- y + radius,
141- radius,
142- -90.0f * G_PI / 180.0f,
143- 0.0f * G_PI / 180.0f);
144-
145- // bottom-right, above the corner
146- cairo_line_to(cr, x + width, y + height - radius);
147-
148- // bottom-right, left of the corner
149- cairo_arc(cr,
150- x + width - radius,
151- y + height - radius,
152- radius,
153- 0.0f * G_PI / 180.0f,
154- 90.0f * G_PI / 180.0f);
155-
156- // bottom-left, right of the corner
157- cairo_line_to(cr, x + radius, y + height);
158-
159- // bottom-left, above the corner
160- cairo_arc(cr,
161- x + radius,
162- y + height - radius,
163- radius,
164- 90.0f * G_PI / 180.0f,
165- 180.0f * G_PI / 180.0f);
166-
167- // top-left, right of the corner
168- cairo_arc(cr,
169- x + radius,
170- y + radius,
171- radius,
172- 180.0f * G_PI / 180.0f,
173- 270.0f * G_PI / 180.0f);
174- }
175+ // top-left, right of the corner
176+ cairo_move_to(cr, _align (x + radius, odd), _align (y, odd));
177+
178+ // top-right, left of the corner
179+ cairo_line_to(cr, _align(x + width - radius, odd), _align(y, odd));
180+
181+ // top-right, below the corner
182+ cairo_arc(cr,
183+ _align(x + width - radius, odd),
184+ _align(y + radius, odd),
185+ radius,
186+ -90.0f * G_PI / 180.0f,
187+ 0.0f * G_PI / 180.0f);
188+
189+ // bottom-right, above the corner
190+ cairo_line_to(cr, _align(x + width, odd), _align(y + height - radius, odd));
191+
192+ // bottom-right, left of the corner
193+ cairo_arc(cr,
194+ _align(x + width - radius, odd),
195+ _align(y + height - radius, odd),
196+ radius,
197+ 0.0f * G_PI / 180.0f,
198+ 90.0f * G_PI / 180.0f);
199+
200+ // bottom-left, right of the corner
201+ cairo_line_to(cr, _align(x + radius, odd), _align(y + height, odd));
202+
203+ // bottom-left, above the corner
204+ cairo_arc(cr,
205+ _align(x + radius, odd),
206+ _align(y + height - radius, odd),
207+ radius,
208+ 90.0f * G_PI / 180.0f,
209+ 180.0f * G_PI / 180.0f);
210+
211+ // top-left, right of the corner
212+ cairo_arc(cr,
213+ _align(x + radius, odd),
214+ _align(y + radius, odd),
215+ radius,
216+ 180.0f * G_PI / 180.0f,
217+ 270.0f * G_PI / 180.0f);
218 }
219
220 static inline void _blurinner(guchar* pixel,
221@@ -1007,48 +966,51 @@
222 Arrow arrow,
223 nux::ButtonVisualState state)
224 {
225- double radius = cornerRadius / aspect;
226+ double radius = cornerRadius / aspect;
227 double arrow_w = radius / 1.5;
228 double arrow_h = radius / 2.0;
229+ bool odd = true;
230+
231+ odd = cairo_get_line_width (cr) == 2.0 ? false : true;
232
233 switch (segment)
234 {
235 case Segment::LEFT:
236 // top-left, right of the corner
237- cairo_move_to(cr, x + radius, y);
238+ cairo_move_to(cr, _align(x + radius, odd), _align(y, odd));
239
240 // top-right
241- cairo_line_to(cr, x + width, y);
242+ cairo_line_to(cr, _align(x + width, odd), _align(y, odd));
243
244 if (arrow == Arrow::RIGHT && state == nux::VISUAL_STATE_PRESSED)
245 {
246- cairo_line_to(cr, x + width, y + height / 2.0 - arrow_h);
247- cairo_line_to(cr, x + width - arrow_w, y + height / 2.0);
248- cairo_line_to(cr, x + width, y + height / 2.0 + arrow_h);
249+ cairo_line_to(cr, _align(x + width, odd), _align(y + height / 2.0 - arrow_h, odd));
250+ cairo_line_to(cr, _align(x + width - arrow_w, odd), _align(y + height / 2.0, odd));
251+ cairo_line_to(cr, _align(x + width, odd), _align(y + height / 2.0 + arrow_h, odd));
252 }
253
254 // bottom-right
255- cairo_line_to(cr, x + width, y + height);
256+ cairo_line_to(cr, _align(x + width, odd), _align(y + height, odd));
257
258 // bottom-left, right of the corner
259- cairo_line_to(cr, x + radius, y + height);
260+ cairo_line_to(cr, _align(x + radius, odd), _align(y + height, odd));
261
262 // bottom-left, above the corner
263 cairo_arc(cr,
264- x + radius,
265- y + height - radius,
266- radius,
267+ _align(x, odd) + _align(radius, odd),
268+ _align(y + height, odd) - _align(radius, odd),
269+ _align(radius, odd),
270 90.0f * G_PI / 180.0f,
271 180.0f * G_PI / 180.0f);
272
273 // left, right of the corner
274- cairo_line_to(cr, x, y + radius);
275+ cairo_line_to(cr, _align(x, odd), _align(y + radius, odd));
276
277 // top-left, right of the corner
278 cairo_arc(cr,
279- x + radius,
280- y + radius,
281- radius,
282+ _align(x, odd) + _align(radius, odd),
283+ _align(y, odd) + _align(radius, odd),
284+ _align(radius, odd),
285 180.0f * G_PI / 180.0f,
286 270.0f * G_PI / 180.0f);
287
288@@ -1056,29 +1018,29 @@
289
290 case Segment::MIDDLE:
291 // top-left
292- cairo_move_to(cr, x, y);
293+ cairo_move_to(cr, _align(x, odd), _align(y, odd));
294
295 // top-right
296- cairo_line_to(cr, x + width, y);
297+ cairo_line_to(cr, _align(x + width, odd), _align(y, odd));
298
299 if ((arrow == Arrow::RIGHT || arrow == Arrow::BOTH) && state == nux::VISUAL_STATE_PRESSED)
300 {
301- cairo_line_to(cr, x + width, y + height / 2.0 - arrow_h);
302- cairo_line_to(cr, x + width - arrow_w, y + height / 2.0);
303- cairo_line_to(cr, x + width, y + height / 2.0 + arrow_h);
304+ cairo_line_to(cr, _align(x + width, odd), _align(y + height / 2.0 - arrow_h, odd));
305+ cairo_line_to(cr, _align(x + width - arrow_w, odd), _align(y + height / 2.0, odd));
306+ cairo_line_to(cr, _align(x + width, odd), _align(y + height / 2.0 + arrow_h, odd));
307 }
308
309 // bottom-right
310- cairo_line_to(cr, x + width, y + height);
311+ cairo_line_to(cr, _align(x + width, odd), _align(y + height, odd));
312
313 // bottom-left
314- cairo_line_to(cr, x, y + height);
315+ cairo_line_to(cr, _align(x, odd), _align(y + height, odd));
316
317 if ((arrow == Arrow::LEFT || arrow == Arrow::BOTH) && state == nux::VISUAL_STATE_PRESSED)
318 {
319- cairo_line_to(cr, x, y + height / 2.0 + arrow_h);
320- cairo_line_to(cr, x + arrow_w, y + height / 2.0);
321- cairo_line_to(cr, x, y + height / 2.0 - arrow_h);
322+ cairo_line_to(cr, _align(x, odd), _align(y + height / 2.0 + arrow_h, odd));
323+ cairo_line_to(cr, _align(x + arrow_w, odd), _align(y + height / 2.0, odd));
324+ cairo_line_to(cr, _align(x, odd), _align(y + height / 2.0 - arrow_h, odd));
325 }
326
327 // back to top-left
328@@ -1087,38 +1049,38 @@
329
330 case Segment::RIGHT:
331 // top-left, right of the corner
332- cairo_move_to(cr, x, y);
333+ cairo_move_to(cr, _align(x, odd), _align(y, odd));
334
335 // top-right, left of the corner
336- cairo_line_to(cr, x + width - radius, y);
337+ cairo_line_to(cr, _align(x + width - radius, odd), _align(y, odd));
338
339 // top-right, below the corner
340 cairo_arc(cr,
341- x + width - radius,
342- y + radius,
343- radius,
344+ _align(x + width, odd) - _align(radius, odd),
345+ _align(y, odd) + _align(radius, odd),
346+ _align(radius, odd),
347 -90.0f * G_PI / 180.0f,
348 0.0f * G_PI / 180.0f);
349
350 // bottom-right, above the corner
351- cairo_line_to(cr, x + width, y + height - radius);
352+ cairo_line_to(cr, _align(x + width, odd), _align(y + height - radius, odd));
353
354 // bottom-right, left of the corner
355 cairo_arc(cr,
356- x + width - radius,
357- y + height - radius,
358- radius,
359+ _align(x + width, odd) - _align(radius, odd),
360+ _align(y + height, odd) - _align(radius, odd),
361+ _align(radius, odd),
362 0.0f * G_PI / 180.0f,
363 90.0f * G_PI / 180.0f);
364
365 // bottom-left
366- cairo_line_to(cr, x, y + height);
367+ cairo_line_to(cr, _align(x, odd), _align(y + height, odd));
368
369 if (arrow == Arrow::LEFT && state == nux::VISUAL_STATE_PRESSED)
370 {
371- cairo_line_to(cr, x, y + height / 2.0 + arrow_h);
372- cairo_line_to(cr, x + arrow_w, y + height / 2.0);
373- cairo_line_to(cr, x, y + height / 2.0 - arrow_h);
374+ cairo_line_to(cr, _align(x, odd), _align(y + height / 2.0 + arrow_h, odd));
375+ cairo_line_to(cr, _align(x + arrow_w, odd), _align(y + height / 2.0, odd));
376+ cairo_line_to(cr, _align(x, odd), _align(y + height / 2.0 - arrow_h, odd));
377 }
378
379 // back to top-left
380@@ -1563,14 +1525,26 @@
381 //ButtonOutlinePath(cr, true);
382 double w = cairo_image_surface_get_width(cairo_get_target(cr));
383 double h = cairo_image_surface_get_height(cairo_get_target(cr));
384- RoundedRect(cr,
385- 1.0,
386- (double) (garnish),
387- (double) (garnish),
388- 7.0,
389- w - (double) (2 * garnish),
390- h - (double) (2 * garnish),
391- true);
392+
393+ cairo_set_line_width(cr, pimpl->button_label_border_size_[state]);
394+
395+ if (pimpl->button_label_border_size_[state] == 2.0)
396+ RoundedRect(cr,
397+ 1.0,
398+ (double) (garnish) + 1.0,
399+ (double) (garnish) + 1.0,
400+ 7.0,
401+ w - (double) (2 * garnish) - 1.0,
402+ h - (double) (2 * garnish) - 1.0);
403+ else
404+ RoundedRect(cr,
405+ 1.0,
406+ (double) (garnish),
407+ (double) (garnish),
408+ 7.0,
409+ w - (double) (2 * garnish),
410+ h - (double) (2 * garnish));
411+
412
413 if (pimpl->button_label_fill_color_[state].alpha != 0.0)
414 {
415@@ -1578,7 +1552,7 @@
416 cairo_fill_preserve(cr);
417 }
418 cairo_set_source_rgba(cr, pimpl->button_label_border_color_[state]);
419- cairo_set_line_width(cr, pimpl->button_label_border_size_[state]);
420+ //cairo_set_line_width(cr, pimpl->button_label_border_size_[state]);
421 cairo_stroke(cr);
422
423 pimpl->DrawOverlay(cr,
424@@ -1707,16 +1681,30 @@
425 w -= 2.0;
426 }
427
428- pimpl->RoundedRectSegment(cr,
429- 1.0,
430- x,
431- y,
432- h / 4.0,
433- w,
434- h,
435- segment,
436- arrow,
437- state);
438+ cairo_set_line_width(cr, pimpl->button_label_border_size_[state]);
439+
440+ if (pimpl->button_label_border_size_[state] == 2.0)
441+ pimpl->RoundedRectSegment(cr,
442+ 1.0,
443+ x+1.0,
444+ y+1.0,
445+ (h-1.0) / 4.0,
446+ w-1.0,
447+ h-1.0,
448+ segment,
449+ arrow,
450+ state);
451+ else
452+ pimpl->RoundedRectSegment(cr,
453+ 1.0,
454+ x,
455+ y,
456+ h / 4.0,
457+ w,
458+ h,
459+ segment,
460+ arrow,
461+ state);
462
463 if (pimpl->button_label_fill_color_[state].alpha != 0.0)
464 {
465@@ -1724,7 +1712,6 @@
466 cairo_fill_preserve(cr);
467 }
468 cairo_set_source_rgba(cr, pimpl->button_label_border_color_[state]);
469- cairo_set_line_width(cr, pimpl->button_label_border_size_[state]);
470 cairo_stroke(cr);
471 pimpl->Text(cr,
472 pimpl->button_label_text_color_[state],
473
474=== modified file 'plugins/unityshell/src/DashStyle.h'
475--- plugins/unityshell/src/DashStyle.h 2011-10-25 16:32:49 +0000
476+++ plugins/unityshell/src/DashStyle.h 2012-01-13 15:19:22 +0000
477@@ -125,8 +125,7 @@
478 double y,
479 double cornerRadius,
480 double width,
481- double height,
482- bool align);
483+ double height);
484
485 nux::Color const& GetTextColor() const;
486
487
488=== modified file 'plugins/unityshell/src/FilterGenreWidget.cpp'
489--- plugins/unityshell/src/FilterGenreWidget.cpp 2012-01-11 09:32:22 +0000
490+++ plugins/unityshell/src/FilterGenreWidget.cpp 2012-01-13 15:19:22 +0000
491@@ -46,10 +46,10 @@
492 genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);
493 genre_layout_->ForceChildrenSize(true);
494 genre_layout_->MatchContentSize(true);
495- genre_layout_->SetSpaceBetweenChildren(10, 12);
496+ genre_layout_->SetSpaceBetweenChildren (7, 9);
497 genre_layout_->SetTopAndBottomPadding(12);
498 genre_layout_->EnablePartialVisibility(false);
499- genre_layout_->SetChildrenSize(Style::Instance().GetTileWidth() - 12, 32);
500+ genre_layout_->SetChildrenSize(Style::Instance().GetTileWidth() - 12, 33);
501
502 SetRightHandView(all_button_);
503 SetContents(genre_layout_);