Merge lp:~macslow/unity/unity.fix-924884 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: 1989
Proposed branch: lp:~macslow/unity/unity.fix-924884
Merge into: lp:unity
Diff against target: 476 lines (+70/-239)
5 files modified
plugins/unityshell/src/DashStyle.cpp (+21/-123)
plugins/unityshell/src/DashStyle.h (+4/-6)
plugins/unityshell/src/FilterRatingsButton.cpp (+36/-92)
plugins/unityshell/src/FilterRatingsButton.h (+0/-17)
plugins/unityshell/src/FilterRatingsWidget.cpp (+9/-1)
To merge this branch: bzr merge lp:~macslow/unity/unity.fix-924884
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Andrea Cimitan (community) design Approve
Review via email: mp+93811@code.launchpad.net

Description of the change

Fixed artwork-assets to be correctly cropped to intended size. Replaced procedural vector drawing methods with newly added artwork-textures. Updated sizes and margins to adapt to new artwork. Added FIXME-hint for keyboard-navigation highlight implementation.

Also see size/gap verification in gimp for screenshot of newly implemented rating-stars:
http://people.canonical.com/~mmueller/fix-924884.png

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

The stars are correctly rendered at the moment, what is currently broken in the filter pane is a lot of padding and spacing. Might worth fixing it after those elements gets in

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

(at the moment = with this branch. thanks mirco!)

Revision history for this message
Andrea Azzarone (azzar1) wrote :

388 + // FIXME: A small hint for the keyboard-navigation highlight... you can use
389 + // the method...
390 + //
391 + // style.GetStarHighlightIcon()
392 + //
393 + // ... to get the correct texture from the style/theme and use an opacity of
394 + // .5 for blending it over the regular star-textures.
395 + //
396 + //GfxContext.QRP_1Tex(geo_star.x,
397 + // geo_star.y,
398 + // geo_star.width,
399 + // geo_star.height,
400 + // style.GetStarHighlightIcon()->GetDeviceTexture(),
401 + // texxform,
402 + // nux::Color(1.0f, 1.0f, 1.0f, 0.5f));
403 +
404 + geo_star.x += geo_star.width + star_gap;

Thanks for this :)

Code looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'plugins/unityshell/resources/star_deselected.png'
2Binary files plugins/unityshell/resources/star_deselected.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/star_deselected.png 2012-02-20 12:18:30 +0000 differ
3=== added file 'plugins/unityshell/resources/star_highlight.png'
4Binary files plugins/unityshell/resources/star_highlight.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/star_highlight.png 2012-02-20 12:18:30 +0000 differ
5=== added file 'plugins/unityshell/resources/star_selected.png'
6Binary files plugins/unityshell/resources/star_selected.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/star_selected.png 2012-02-20 12:18:30 +0000 differ
7=== modified file 'plugins/unityshell/src/DashStyle.cpp'
8--- plugins/unityshell/src/DashStyle.cpp 2012-02-07 20:46:22 +0000
9+++ plugins/unityshell/src/DashStyle.cpp 2012-02-20 12:18:30 +0000
10@@ -110,8 +110,6 @@
11
12 void SetDefaultValues();
13
14- void Star(cairo_t* cr, double size);
15-
16 void GetTextExtents(int& width,
17 int& height,
18 int maxWidth,
19@@ -215,6 +213,9 @@
20 LazyLoadTexture group_unexpand_texture_;
21 LazyLoadTexture group_expand_texture_;
22
23+ LazyLoadTexture star_deselected_texture_;
24+ LazyLoadTexture star_selected_texture_;
25+ LazyLoadTexture star_highlight_texture_;
26 };
27
28 Style::Impl::Impl(Style* owner)
29@@ -247,6 +248,9 @@
30 , search_spin_glow_texture_("/search_spin_glow.png")
31 , group_unexpand_texture_("/dash_group_unexpand.png")
32 , group_expand_texture_("/dash_group_expand.png")
33+ , star_deselected_texture_("/star_deselected.png")
34+ , star_selected_texture_("/star_selected.png")
35+ , star_highlight_texture_("/star_highlight.png")
36 {
37 signal_manager_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>
38 (gtk_settings_get_default(),
39@@ -669,43 +673,6 @@
40 cairo_surface_mark_dirty(surface);
41 }
42
43-void Style::Impl::Star(cairo_t* cr, double size)
44-{
45- double outter[5][2] = {{0.0, 0.0},
46- {0.0, 0.0},
47- {0.0, 0.0},
48- {0.0, 0.0},
49- {0.0, 0.0}};
50- double inner[5][2] = {{0.0, 0.0},
51- {0.0, 0.0},
52- {0.0, 0.0},
53- {0.0, 0.0},
54- {0.0, 0.0}};
55- double angle[5] = {-90.0, -18.0, 54.0, 126.0, 198.0};
56- double outterRadius = size;
57- double innerRadius = size/1.75;
58-
59- for (int i = 0; i < 5; i++)
60- {
61- outter[i][0] = outterRadius * cos(angle[i] * M_PI / 180.0);
62- outter[i][1] = outterRadius * sin(angle[i] * M_PI / 180.0);
63- inner[i][0] = innerRadius * cos((angle[i] + 36.0) * M_PI / 180.0);
64- inner[i][1] = innerRadius * sin((angle[i] + 36.0) * M_PI / 180.0);
65- }
66-
67- cairo_move_to(cr, outter[0][0], outter[0][1]);
68- cairo_line_to(cr, inner[0][0], inner[0][1]);
69- cairo_line_to(cr, outter[1][0], outter[1][1]);
70- cairo_line_to(cr, inner[1][0], inner[1][1]);
71- cairo_line_to(cr, outter[2][0], outter[2][1]);
72- cairo_line_to(cr, inner[2][0], inner[2][1]);
73- cairo_line_to(cr, outter[3][0], outter[3][1]);
74- cairo_line_to(cr, inner[3][0], inner[3][1]);
75- cairo_line_to(cr, outter[4][0], outter[4][1]);
76- cairo_line_to(cr, inner[4][0], inner[4][1]);
77- cairo_close_path(cr);
78-}
79-
80 void Style::Impl::SetDefaultValues()
81 {
82 // button-label
83@@ -1786,90 +1753,6 @@
84 return true;
85 }
86
87-bool Style::StarEmpty(cairo_t* cr, nux::ButtonVisualState state)
88-{
89- // sanity checks
90- if (cairo_status(cr) != CAIRO_STATUS_SUCCESS)
91- return false;
92-
93- if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE)
94- return false;
95-
96- double w = cairo_image_surface_get_width(cairo_get_target(cr));
97- double h = cairo_image_surface_get_height(cairo_get_target(cr));
98- double radius = .85 * h / 2.0;
99-
100- cairo_save(cr);
101- cairo_translate(cr, w / 2.0, h / 2.0);
102- pimpl->Star(cr, radius);
103- cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.2);
104- cairo_fill_preserve(cr);
105- cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5);
106- cairo_set_line_width(cr, 0.75);
107- cairo_stroke(cr);
108- cairo_restore(cr);
109-
110- return true;
111-}
112-
113-bool Style::StarHalf(cairo_t* cr, nux::ButtonVisualState state)
114-{
115- // sanity checks
116- if (cairo_status(cr) != CAIRO_STATUS_SUCCESS)
117- return false;
118-
119- if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE)
120- return false;
121-
122- double w = cairo_image_surface_get_width(cairo_get_target(cr));
123- double h = cairo_image_surface_get_height(cairo_get_target(cr));
124- double radius = .85 * h / 2.0;
125-
126- cairo_pattern_t* pattern = NULL;
127- pattern = cairo_pattern_create_linear(0.0, 0.0, w, 0.0);
128- cairo_pattern_add_color_stop_rgba(pattern, 0.0, 1.0, 1.0, 1.0, 1.0);
129- cairo_pattern_add_color_stop_rgba(pattern, .5, 1.0, 1.0, 1.0, 1.0);
130- cairo_pattern_add_color_stop_rgba(pattern, .5 + 0.01, 1.0, 1.0, 1.0, 0.2);
131- cairo_pattern_add_color_stop_rgba(pattern, 1.0, 1.0, 1.0, 1.0, 0.2);
132- cairo_set_source(cr, pattern);
133-
134- cairo_save(cr);
135- cairo_translate(cr, w / 2.0, h / 2.0);
136- pimpl->Star(cr, radius);
137- cairo_fill_preserve(cr);
138- cairo_pattern_destroy(pattern);
139- cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5);
140- cairo_set_line_width(cr, 0.75);
141- cairo_stroke(cr);
142- cairo_restore(cr);
143-
144- return true;
145-}
146-
147-bool Style::StarFull(cairo_t* cr, nux::ButtonVisualState state)
148-{
149- // sanity checks
150- if (cairo_status(cr) != CAIRO_STATUS_SUCCESS)
151- return false;
152-
153- if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE)
154- return false;
155-
156- double w = cairo_image_surface_get_width(cairo_get_target(cr));
157- double h = cairo_image_surface_get_height(cairo_get_target(cr));
158- double radius = .85 * h / 2.0;
159-
160- cairo_save(cr);
161- cairo_translate(cr, w / 2.0, h / 2.0);
162- pimpl->Star(cr, radius);
163- cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0);
164- cairo_fill_preserve(cr);
165- cairo_stroke(cr); // to make sure it's as "large" as the empty and half ones
166- cairo_restore(cr);
167-
168- return true;
169-}
170-
171 bool Style::MultiRangeSegment(cairo_t* cr,
172 nux::ButtonVisualState state,
173 std::string const& label,
174@@ -2256,6 +2139,21 @@
175 return pimpl->group_expand_texture_.texture();
176 }
177
178+nux::BaseTexture* Style::GetStarDeselectedIcon()
179+{
180+ return pimpl->star_deselected_texture_.texture();
181+}
182+
183+nux::BaseTexture* Style::GetStarSelectedIcon()
184+{
185+ return pimpl->star_selected_texture_.texture();
186+}
187+
188+nux::BaseTexture* Style::GetStarHighlightIcon()
189+{
190+ return pimpl->star_highlight_texture_.texture();
191+}
192+
193 nux::BaseTexture* Style::GetDashShine()
194 {
195 return pimpl->dash_shine_.texture();
196
197=== modified file 'plugins/unityshell/src/DashStyle.h'
198--- plugins/unityshell/src/DashStyle.h 2012-02-10 12:12:45 +0000
199+++ plugins/unityshell/src/DashStyle.h 2012-02-20 12:18:30 +0000
200@@ -106,12 +106,6 @@
201
202 virtual bool ButtonFocusOverlay(cairo_t* cr);
203
204- virtual bool StarEmpty(cairo_t* cr, nux::ButtonVisualState state);
205-
206- virtual bool StarHalf(cairo_t* cr, nux::ButtonVisualState state);
207-
208- virtual bool StarFull(cairo_t* cr, nux::ButtonVisualState state);
209-
210 virtual bool MultiRangeSegment(cairo_t* cr,
211 nux::ButtonVisualState state,
212 std::string const& label,
213@@ -192,6 +186,10 @@
214 nux::BaseTexture* GetGroupUnexpandIcon();
215 nux::BaseTexture* GetGroupExpandIcon();
216
217+ nux::BaseTexture* GetStarDeselectedIcon();
218+ nux::BaseTexture* GetStarSelectedIcon();
219+ nux::BaseTexture* GetStarHighlightIcon();
220+
221 sigc::signal<void> changed;
222
223 private:
224
225=== modified file 'plugins/unityshell/src/FilterRatingsButton.cpp'
226--- plugins/unityshell/src/FilterRatingsButton.cpp 2012-02-04 05:28:23 +0000
227+++ plugins/unityshell/src/FilterRatingsButton.cpp 2012-02-20 12:18:30 +0000
228@@ -27,15 +27,19 @@
229 #include "DashStyle.h"
230 #include "FilterRatingsButton.h"
231
232+namespace
233+{
234+const int star_size = 28;
235+const int star_gap = 10;
236+}
237+
238 namespace unity
239 {
240 namespace dash
241 {
242-
243 FilterRatingsButton::FilterRatingsButton(NUX_FILE_LINE_DECL)
244 : nux::ToggleButton(NUX_FILE_LINE_PARAM)
245 {
246- InitTheme();
247 SetAcceptKeyNavFocusOnMouseDown(false);
248
249 mouse_up.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseUp));
250@@ -58,73 +62,6 @@
251 return "FilterRatingsButton";
252 }
253
254-void FilterRatingsButton::InitTheme()
255-{
256- if (!active_empty_)
257- {
258- nux::Geometry geometry(GetGeometry());
259- geometry.width /= 5;
260-
261- active_empty_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 0, nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
262- normal_empty_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 0, nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
263- prelight_empty_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 0, nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
264-
265- active_half_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 1, nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
266- normal_half_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 1, nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
267- prelight_half_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 1, nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
268-
269- active_full_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 2, nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
270- normal_full_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 2, nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
271- prelight_full_.reset(new nux::CairoWrapper(geometry, sigc::bind(sigc::mem_fun(this, &FilterRatingsButton::RedrawTheme), 2, nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
272- }
273-}
274-
275-void FilterRatingsButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, int type, nux::ButtonVisualState faked_state)
276-{
277- Style& dash_style = Style::Instance();
278- if (type == 0)
279- {
280- // empty
281- dash_style.StarEmpty(cr, faked_state);
282- }
283- else if (type == 1)
284- {
285- // half
286- dash_style.StarHalf(cr, faked_state);
287- }
288- else
289- {
290- // full
291- dash_style.StarFull(cr, faked_state);
292- }
293-}
294-
295-long FilterRatingsButton::ComputeContentSize()
296-{
297- long ret = nux::Button::ComputeContentSize();
298- nux::Geometry geo(GetGeometry());
299-
300- if (cached_geometry_ != geo)
301- {
302- geo.width = 27;
303- active_empty_->Invalidate(geo);
304- normal_empty_->Invalidate(geo);
305- prelight_empty_->Invalidate(geo);
306-
307- active_half_->Invalidate(geo);
308- normal_half_->Invalidate(geo);
309- prelight_half_->Invalidate(geo);
310-
311- active_full_->Invalidate(geo);
312- normal_full_->Invalidate(geo);
313- prelight_full_->Invalidate(geo);
314-
315- cached_geometry_ = geo;
316- }
317-
318- return ret;
319-}
320-
321 void FilterRatingsButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
322 {
323 int rating = 0;
324@@ -138,12 +75,11 @@
325 // int total_half_stars = rating % 2;
326 // int total_full_stars = rating / 2;
327 int total_full_stars = rating;
328- int total_half_stars = 0;
329
330 nux::Geometry const& geo = GetGeometry();
331 nux::Geometry geo_star(geo);
332- geo_star.width = 27;
333-
334+ geo_star.width = star_size;
335+
336 gPainter.PaintBackground(GfxContext, geo);
337 // set up our texture mode
338 nux::TexCoordXForm texxform;
339@@ -166,33 +102,25 @@
340
341 for (int index = 0; index < 5; index++)
342 {
343- nux::BaseTexture* texture = normal_empty_->GetTexture();
344+ Style& style = Style::Instance();
345+ nux::BaseTexture* texture = style.GetStarSelectedIcon();
346 if (index < total_full_stars)
347 {
348 if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL)
349- texture = normal_full_->GetTexture();
350- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
351- texture = prelight_full_->GetTexture();
352- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
353- texture = active_full_->GetTexture();
354- }
355- else if (index < total_full_stars + total_half_stars)
356- {
357- if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL)
358- texture = normal_half_->GetTexture();
359- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
360- texture = prelight_half_->GetTexture();
361- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
362- texture = active_half_->GetTexture();
363+ texture = style.GetStarSelectedIcon();
364+ else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
365+ texture = style.GetStarSelectedIcon();
366+ else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
367+ texture = style.GetStarSelectedIcon();
368 }
369 else
370 {
371 if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL)
372- texture = normal_empty_->GetTexture();
373+ texture = style.GetStarDeselectedIcon();
374 else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
375- texture = prelight_empty_->GetTexture();
376+ texture = style.GetStarDeselectedIcon();
377 else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
378- texture = active_empty_->GetTexture();
379+ texture = style.GetStarDeselectedIcon();
380 }
381
382 GfxContext.QRP_1Tex(geo_star.x,
383@@ -203,7 +131,23 @@
384 texxform,
385 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
386
387- geo_star.x += geo_star.width + 10;
388+ // FIXME: A small hint for the keyboard-navigation highlight... you can use
389+ // the method...
390+ //
391+ // style.GetStarHighlightIcon()
392+ //
393+ // ... to get the correct texture from the style/theme and use an opacity of
394+ // .5 for blending it over the regular star-textures.
395+ //
396+ //GfxContext.QRP_1Tex(geo_star.x,
397+ // geo_star.y,
398+ // geo_star.width,
399+ // geo_star.height,
400+ // style.GetStarHighlightIcon()->GetDeviceTexture(),
401+ // texxform,
402+ // nux::Color(1.0f, 1.0f, 1.0f, 0.5f));
403+
404+ geo_star.x += geo_star.width + star_gap;
405
406 }
407
408@@ -242,4 +186,4 @@
409 }
410
411 } // namespace dash
412-} // namespace unity
413+} // namespace unity
414\ No newline at end of file
415
416=== modified file 'plugins/unityshell/src/FilterRatingsButton.h'
417--- plugins/unityshell/src/FilterRatingsButton.h 2012-02-04 05:28:23 +0000
418+++ plugins/unityshell/src/FilterRatingsButton.h 2012-02-20 12:18:30 +0000
419@@ -45,29 +45,12 @@
420 std::string GetFilterType();
421
422 protected:
423- virtual long ComputeContentSize();
424 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
425
426- void InitTheme();
427- void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, int type, nux::ButtonVisualState faked_state);
428-
429 void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
430 void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
431 void OnRatingsChanged(int rating);
432
433- typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
434-
435- NuxCairoPtr active_empty_;
436- NuxCairoPtr normal_empty_;
437- NuxCairoPtr prelight_empty_;
438- NuxCairoPtr active_half_;
439- NuxCairoPtr normal_half_;
440- NuxCairoPtr prelight_half_;
441- NuxCairoPtr active_full_;
442- NuxCairoPtr normal_full_;
443- NuxCairoPtr prelight_full_;
444- nux::Geometry cached_geometry_;
445-
446 dash::RatingsFilter::Ptr filter_;
447
448 };
449
450=== modified file 'plugins/unityshell/src/FilterRatingsWidget.cpp'
451--- plugins/unityshell/src/FilterRatingsWidget.cpp 2012-02-09 20:19:30 +0000
452+++ plugins/unityshell/src/FilterRatingsWidget.cpp 2012-02-20 12:18:30 +0000
453@@ -30,6 +30,13 @@
454 #include "FilterRatingsButton.h"
455 #include "FilterRatingsWidget.h"
456
457+namespace
458+{
459+const int top_padding = 11;
460+const int bottom_padding = 12;
461+const int star_size = 28;
462+}
463+
464 namespace unity
465 {
466 namespace dash
467@@ -43,8 +50,9 @@
468 all_button_ = new FilterAllButton(NUX_TRACKER_LOCATION);
469
470 nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
471- layout->SetTopAndBottomPadding(11, 12);
472+ layout->SetTopAndBottomPadding(top_padding, bottom_padding);
473 ratings_ = new FilterRatingsButton(NUX_TRACKER_LOCATION);
474+ ratings_->SetMinimumHeight(star_size);
475
476 layout->AddView(ratings_);
477