Merge lp:~nick-dedekind/unity/dash-results.focus+size into lp:unity

Proposed by Nick Dedekind
Status: Merged
Approved by: Michal Hruby
Approved revision: no longer in the source branch.
Merged at revision: 2687
Proposed branch: lp:~nick-dedekind/unity/dash-results.focus+size
Merge into: lp:unity
Diff against target: 356 lines (+56/-128)
4 files modified
dash/ResultRendererTile.cpp (+34/-120)
dash/ResultRendererTile.h (+0/-4)
unity-shared/DashStyle.cpp (+18/-3)
unity-shared/DashStyle.h (+4/-1)
To merge this branch: bzr merge lp:~nick-dedekind/unity/dash-results.focus+size
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Needs Fixing
John Lea (community) design Approve
Michal Hruby (community) Approve
Review via email: mp+123747@code.launchpad.net

Commit message

Updated dash result highlight focus to 106x106 pixels with 20% white opacity. Increased dash result file image size to 96x96.

Description of the change

Updated dash result highlight focus to 106x106 pixels with 20% white opacity. Increased dash result file image size to 96x96.

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

45 - if (container->blurred_icon && state == ResultRendererState::RESULT_RENDERER_NORMAL)
46 - {
47 - GfxContext.QRP_1Tex(icon_left_hand_side - 5 - x_offset,
48 - icon_top_side - 5 - y_offset,
49 - container->blurred_icon->GetWidth(),
50 - container->blurred_icon->GetHeight(),
51 - container->blurred_icon->GetDeviceTexture(),
52 - texxform,
53 - nux::Color(0.15f, 0.15f, 0.15f, 0.15f));
54 - }

Why have you removed this code?

g_str_has_prefix(icon_name.c_str(), "/") ? style.GetTileImageSize() : style.GetTileGIconSize()

g_str_has_prefix returns a gboolean. Maybe I'm wrong but with a gboolean it is preferable to check if value is == FALSE or != FALSE.

gboolean var;
...
if (var != FALSE)
{
 /* 1 */
}
else
{
 /* 2 */
}

or

if (!var)
{
  /* 2 */
}
else
{
 /* 1 */
}

Also provide screenshot for the design review.

review: Needs Information
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Re the removal of code; design don't want the blur on the icon any more.

As to the gboolean==TRUE/FALSE, Technically I don't think it matters unless someday glib decides to change it's #defs.
But I can change it for readabilities sake.

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

> Re the removal of code; design don't want the blur on the icon any more.

We no longer need container->blurred_icon right? Can you remove the defination too?

>
> As to the gboolean==TRUE/FALSE, Technically I don't think it matters unless
> someday glib decides to change it's #defs.
> But I can change it for readabilities sake.

I was partially wrong. You should not do == TRUE but == true is fine.

Revision history for this message
Michal Hruby (mhr3) wrote :

> > As to the gboolean==TRUE/FALSE, Technically I don't think it matters unless
> > someday glib decides to change it's #defs.
> > But I can change it for readabilities sake.
>
> I was partially wrong. You should not do == TRUE but == true is fine.

FALSE equals 0, so using ternary operator is fine. The only dangerous op is `gboolean_var == true ?`, which is never true.

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

> > > As to the gboolean==TRUE/FALSE, Technically I don't think it matters
> unless
> > > someday glib decides to change it's #defs.
> > > But I can change it for readabilities sake.
> >
> > I was partially wrong. You should not do == TRUE but == true is fine.
>
> FALSE equals 0, so using ternary operator is fine. The only dangerous op is
> `gboolean_var == true ?`, which is never true.

From https://lists.launchpad.net/unity-dev/msg00231.html

«bool bool_test = 42;
gboolean g_test = 42;

bool_test == true -> true // 42 is converted to true at assignment time
g_test == TRUE -> false
g_test == FALSE -> false
bool(g_test) -> true

if statements and assignment to bool will implicitly cast the gboolean to a bool. This uses the standard definition for true and false, and as such, a value like 42 is considered true.

If you feel like you really must check for a value, please check for FALSE, or != FALSE. This is the only true safe way to check an integral value for "true".»

Btw in this case the function returns a gboolean so there is no problem at all.

Revision history for this message
Michal Hruby (mhr3) wrote :

FWIW the gboolean issue is solved by my branch that deps on this (and removes the call completely). Approving.

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

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1278/console reported an error when processing this lp:~nick-dedekind/unity/dash-results.focus+size branch.
Not merging it.

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

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1279/console reported an error when processing this lp:~nick-dedekind/unity/dash-results.focus+size branch.
Not merging it.

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

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1281/console reported an error when processing this lp:~nick-dedekind/unity/dash-results.focus+size branch.
Not merging it.

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

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1283/console reported an error when processing this lp:~nick-dedekind/unity/dash-results.focus+size branch.
Not merging it.

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

Please remove BaseTexturePtr blurred_icon declaration.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/ResultRendererTile.cpp'
2--- dash/ResultRendererTile.cpp 2012-06-18 02:57:23 +0000
3+++ dash/ResultRendererTile.cpp 2012-09-11 13:54:58 +0000
4@@ -53,6 +53,8 @@
5 nux::logging::Logger logger("unity.dash.results");
6
7 const int FONT_SIZE = 10;
8+
9+const float CORNER_HIGHTLIGHT_RADIUS = 2.0f;
10 }
11
12 namespace dash
13@@ -62,7 +64,6 @@
14
15 ResultRendererTile::ResultRendererTile(NUX_FILE_LINE_DECL)
16 : ResultRenderer(NUX_FILE_LINE_PARAM)
17- , highlight_padding(6)
18 , spacing(10)
19 , padding(6)
20 {
21@@ -78,9 +79,8 @@
22 // pre-load the highlight texture
23 // try and get a texture from the texture cache
24 TextureCache& cache = TextureCache::GetDefault();
25- int prelight_texture_size = style.GetTileIconSize() + (highlight_padding * 2);
26 prelight_cache_ = cache.FindTexture("ResultRendererTile.PreLightTexture",
27- prelight_texture_size, prelight_texture_size,
28+ style.GetTileIconHightlightWidth(), style.GetTileIconHightlightHeight(),
29 sigc::mem_fun(this, &ResultRendererTile::DrawHighlight));
30 }
31
32@@ -99,7 +99,7 @@
33 return;
34
35 dash::Style& style = dash::Style::Instance();
36- int tile_icon_size = style.GetTileIconSize();
37+ int tile_icon_size = style.GetTileImageSize();
38
39 // set up our texture mode
40 nux::TexCoordXForm texxform;
41@@ -118,22 +118,14 @@
42 int icon_left_hand_side = geometry.x + (geometry.width - icon_width) / 2;
43 int icon_top_side = geometry.y + padding + (tile_icon_size - icon_height) / 2;
44
45- if (container->blurred_icon && state == ResultRendererState::RESULT_RENDERER_NORMAL)
46- {
47- GfxContext.QRP_1Tex(icon_left_hand_side - 5 - x_offset,
48- icon_top_side - 5 - y_offset,
49- container->blurred_icon->GetWidth(),
50- container->blurred_icon->GetHeight(),
51- container->blurred_icon->GetDeviceTexture(),
52- texxform,
53- nux::Color(0.15f, 0.15f, 0.15f, 0.15f));
54- }
55-
56 // render highlight if its needed
57 if (container->prelight && state != ResultRendererState::RESULT_RENDERER_NORMAL)
58 {
59- GfxContext.QRP_1Tex(icon_left_hand_side - highlight_padding,
60- icon_top_side - highlight_padding,
61+ int highlight_x = (geometry.x + geometry.width/2) - style.GetTileIconHightlightWidth()/2;
62+ int highlight_y = (geometry.y + padding + tile_icon_size / 2) - style.GetTileIconHightlightHeight()/2;
63+
64+ GfxContext.QRP_1Tex(highlight_x,
65+ highlight_y,
66 container->prelight->GetWidth(),
67 container->prelight->GetHeight(),
68 container->prelight->GetDeviceTexture(),
69@@ -168,63 +160,27 @@
70 nux::BaseTexture* ResultRendererTile::DrawHighlight(std::string const& texid, int width, int height)
71 {
72 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height);
73- cairo_t* cr = cairo_graphics.GetContext();
74-
75+ cairo_t* cr = cairo_graphics.GetInternalContext();
76+
77+ cairo_scale(cr, 1.0f, 1.0f);
78+
79+ cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.0);
80 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
81 cairo_paint(cr);
82
83- int PADDING = 4;
84- int BLUR_SIZE = 5;
85-
86- int bg_width = width - PADDING - BLUR_SIZE;
87- int bg_height = height - PADDING - BLUR_SIZE;
88- int bg_x = BLUR_SIZE - 1;
89- int bg_y = BLUR_SIZE - 1;
90-
91- // draw the glow
92+ // draw the highlight
93 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
94- cairo_set_line_width(cr, 1.0f);
95- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 0.75f);
96+ cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 0.2f);
97 cairo_graphics.DrawRoundedRectangle(cr,
98- 1.0f,
99- bg_x,
100- bg_y,
101- 5.0,
102- bg_width,
103- bg_height,
104- true);
105+ 1.0f,
106+ 0.0f,
107+ 0.0f,
108+ CORNER_HIGHTLIGHT_RADIUS,
109+ width,
110+ height,
111+ false);
112 cairo_fill(cr);
113
114- cairo_graphics.BlurSurface(BLUR_SIZE - 2);
115-
116- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
117- cairo_graphics.DrawRoundedRectangle(cr,
118- 1.0,
119- bg_x,
120- bg_y,
121- 5.0,
122- bg_width,
123- bg_height,
124- true);
125- cairo_clip(cr);
126- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
127-
128- cairo_graphics.DrawRoundedRectangle(cr,
129- 1.0,
130- bg_x,
131- bg_y,
132- 5.0,
133- bg_width,
134- bg_height,
135- true);
136- cairo_set_source_rgba(cr, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f, 1.0f);
137- cairo_fill_preserve(cr);
138-
139- cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0);
140- cairo_stroke(cr);
141-
142- cairo_destroy(cr);
143-
144 return texture_from_cairo_graphics(cairo_graphics);
145 }
146
147@@ -253,7 +209,7 @@
148 std::string icon_name;
149 if (G_UNLIKELY(neko))
150 {
151- int tmp1 = style.GetTileIconSize() + (rand() % 16) - 8;
152+ int tmp1 = style.GetTileGIconSize() + (rand() % 16) - 8;
153 gsize tmp3;
154 gchar* tmp2 = (gchar*)g_base64_decode("aHR0cDovL3BsYWNla2l0dGVuLmNvbS8laS8laS8=", &tmp3);
155 gchar* tmp4 = g_strdup_printf(tmp2, tmp1, tmp1);
156@@ -273,15 +229,15 @@
157
158 if (g_strrstr(icon_name.c_str(), "://"))
159 {
160- container->slot_handle = IconLoader::GetDefault().LoadFromURI(icon_name, style.GetTileIconSize(), slot);
161+ container->slot_handle = IconLoader::GetDefault().LoadFromURI(icon_name, style.GetTileImageSize(), slot);
162 }
163 else if (G_IS_ICON(icon))
164 {
165- container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, style.GetTileIconSize(), slot);
166+ container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, g_str_has_prefix(icon_name.c_str(), "/") ? style.GetTileImageSize() : style.GetTileGIconSize(), slot);
167 }
168 else
169 {
170- container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, style.GetTileIconSize(), slot);
171+ container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, style.GetTileGIconSize(), slot);
172 }
173
174 if (icon != NULL)
175@@ -318,7 +274,7 @@
176 float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0
177 if (aspect < 1.0f)
178 {
179- pixbuf_width = style.GetTileWidth() - (padding * 2);
180+ pixbuf_width = style.GetTileImageSize();
181 pixbuf_height = pixbuf_width * aspect;
182
183 if (pixbuf_height > height)
184@@ -363,44 +319,6 @@
185
186 }
187
188-nux::BaseTexture* ResultRendererTile::CreateBlurredTextureCallback(std::string const& texid,
189- int width,
190- int height,
191- glib::Object<GdkPixbuf> const& pixbuf)
192-{
193- int pixbuf_width, pixbuf_height;
194- pixbuf_width = gdk_pixbuf_get_width(pixbuf);
195- pixbuf_height = gdk_pixbuf_get_height(pixbuf);
196-
197- nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width + 10, height + 10);
198- cairo_t* cr = cairo_graphics.GetInternalContext();
199-
200- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
201- cairo_translate(cr, 5, 5);
202- cairo_paint(cr);
203-
204- float scale;
205- if (pixbuf_width > pixbuf_height)
206- scale = pixbuf_height / static_cast<float>(pixbuf_width);
207- else
208- scale = pixbuf_width / static_cast<float>(pixbuf_height);
209-
210- cairo_translate(cr,
211- static_cast<int>((width - (pixbuf_width * scale)) * 0.5),
212- static_cast<int>((height - (pixbuf_height * scale)) * 0.5));
213-
214- cairo_scale(cr, scale, scale);
215-
216- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
217- gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
218-
219- cairo_paint(cr);
220-
221- cairo_graphics.BlurSurface(4);
222-
223- return texture_from_cairo_graphics(cairo_graphics);
224-}
225-
226
227 void ResultRendererTile::IconLoaded(std::string const& texid,
228 unsigned size,
229@@ -409,22 +327,18 @@
230 Result& row)
231 {
232 TextureContainer *container = row.renderer<TextureContainer*>();
233- Style& style = Style::Instance();
234+
235+ dash::Style& style = dash::Style::Instance();
236
237 if (pixbuf && container)
238 {
239 TextureCache& cache = TextureCache::GetDefault();
240- BaseTexturePtr texture(cache.FindTexture(icon_name, style.GetTileIconSize(), style.GetTileIconSize(),
241+ BaseTexturePtr texture(cache.FindTexture(icon_name, size, size,
242 sigc::bind(sigc::mem_fun(this, &ResultRendererTile::CreateTextureCallback), pixbuf)));
243
244- std::string blur_texid = icon_name + "_blurred";
245- BaseTexturePtr texture_blurred(cache.FindTexture(blur_texid, style.GetTileIconSize(), style.GetTileIconSize(),
246- sigc::bind(sigc::mem_fun(this, &ResultRendererTile::CreateBlurredTextureCallback), pixbuf)));
247-
248- BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", texture->GetWidth() + highlight_padding*2, texture->GetHeight() + highlight_padding*2, sigc::mem_fun(this, &ResultRendererTile::DrawHighlight)));
249+ BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", style.GetTileIconHightlightWidth(), style.GetTileIconHightlightHeight(), sigc::mem_fun(this, &ResultRendererTile::DrawHighlight)));
250
251 container->icon = texture;
252- container->blurred_icon = texture_blurred;
253 container->prelight = texture_prelight;
254
255 NeedsRedraw.emit();
256@@ -436,7 +350,7 @@
257 {
258 // we need to load a missing icon
259 IconLoader::IconLoaderCallback slot = sigc::bind(sigc::mem_fun(this, &ResultRendererTile::IconLoaded), icon_name, row);
260- container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(". GThemedIcon text-x-preview", style.GetTileIconSize(), slot);
261+ container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(". GThemedIcon text-x-preview", size, slot);
262 }
263
264 }
265@@ -447,7 +361,7 @@
266 Style& style = Style::Instance();
267 nux::CairoGraphics _cairoGraphics(CAIRO_FORMAT_ARGB32,
268 style.GetTileWidth() - (padding * 2),
269- style.GetTileHeight() - style.GetTileIconSize() - spacing);
270+ style.GetTileHeight() - style.GetTileImageSize() - spacing);
271
272 cairo_t* cr = _cairoGraphics.GetContext();
273
274
275=== modified file 'dash/ResultRendererTile.h'
276--- dash/ResultRendererTile.h 2012-07-04 02:37:23 +0000
277+++ dash/ResultRendererTile.h 2012-09-11 13:54:58 +0000
278@@ -80,7 +80,6 @@
279 // unload any previous grabbed images
280 virtual void Unload(Result& row);
281
282- int highlight_padding;
283 int spacing;
284 int padding;
285
286@@ -97,9 +96,6 @@
287 nux::BaseTexture* CreateTextureCallback(std::string const& texid,
288 int width, int height,
289 glib::Object<GdkPixbuf> const& pixbuf);
290- nux::BaseTexture* CreateBlurredTextureCallback(std::string const& texid,
291- int width, int height,
292- glib::Object<GdkPixbuf> const& pixbuf);
293 nux::BaseTexture* DrawHighlight(std::string const& texid,
294 int width, int height);
295 };
296
297=== modified file 'unity-shared/DashStyle.cpp'
298--- unity-shared/DashStyle.cpp 2012-08-20 19:59:54 +0000
299+++ unity-shared/DashStyle.cpp 2012-09-11 13:54:58 +0000
300@@ -2044,11 +2044,16 @@
301 columns_changed.emit();
302 }
303
304-int Style::GetTileIconSize() const
305+int Style::GetTileGIconSize() const
306 {
307 return 64;
308 }
309
310+int Style::GetTileImageSize() const
311+{
312+ return 96;
313+}
314+
315 int Style::GetTileWidth() const
316 {
317 return std::max(pimpl->text_width_, 150);
318@@ -2056,8 +2061,18 @@
319
320 int Style::GetTileHeight() const
321 {
322- return std::max(GetTileIconSize() + (pimpl->text_height_ * 2) + 10,
323- GetTileIconSize() + 50 + 18); // magic design numbers.
324+ return std::max(GetTileImageSize() + (pimpl->text_height_ * 2) + 10,
325+ GetTileImageSize() + 50 + 18); // magic design numbers.
326+}
327+
328+int Style::GetTileIconHightlightHeight() const
329+{
330+ return 106;
331+}
332+
333+int Style::GetTileIconHightlightWidth() const
334+{
335+ return 106;
336 }
337
338 int Style::GetHomeTileIconSize() const
339
340=== modified file 'unity-shared/DashStyle.h'
341--- unity-shared/DashStyle.h 2012-08-20 19:59:54 +0000
342+++ unity-shared/DashStyle.h 2012-09-11 13:54:58 +0000
343@@ -155,9 +155,12 @@
344 void SetDefaultNColumns(int n_cols);
345 sigc::signal<void> columns_changed;
346
347- int GetTileIconSize() const;
348+ int GetTileGIconSize() const;
349+ int GetTileImageSize() const;
350 int GetTileWidth() const;
351 int GetTileHeight() const;
352+ int GetTileIconHightlightHeight() const;
353+ int GetTileIconHightlightWidth() const;
354
355 int GetHomeTileIconSize() const;
356 int GetHomeTileWidth() const;