Merge lp:~gordallott/unity/fix-lp-878015 into lp:unity

Proposed by Gord Allott
Status: Merged
Approved by: Mirco Müller
Approved revision: no longer in the source branch.
Merged at revision: 2227
Proposed branch: lp:~gordallott/unity/fix-lp-878015
Merge into: lp:unity
Diff against target: 191 lines (+57/-24)
3 files modified
plugins/unityshell/src/ResultRendererTile.cpp (+51/-23)
plugins/unityshell/src/ResultRendererTile.h (+2/-1)
standalone-clients/CMakeLists.txt (+4/-0)
To merge this branch: bzr merge lp:~gordallott/unity/fix-lp-878015
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+100953@code.launchpad.net

Commit message

fixes widescreen icons being too small, makes them the correct aspect ratio and size

Description of the change

Small change to the dash tile visuals, fixes widescreen icons being too small, makes them the correct aspect ratio and size

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

In plugins/unityshell/src/ResultRendererTile.h:92 there a trailing double semicolon:

 int max_icon_width_;;

Also the vertical positioning is off (for the highlight) for aspect-ratios greater then 1.0... have a look at the provided screenshots:

http://people.canonical.com/~mmueller/fix-878015-issue-1.png
http://people.canonical.com/~mmueller/fix-878015-issue-2.png

review: Needs Fixing
Revision history for this message
Mirco Müller (macslow) wrote :

Check the highlighted and non-highlighted states of the file launcher_corner_h_tile_mask.png (middle PlacesGroup).

Revision history for this message
Mirco Müller (macslow) wrote :

All good now... approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/ResultRendererTile.cpp'
--- plugins/unityshell/src/ResultRendererTile.cpp 2012-04-03 16:14:21 +0000
+++ plugins/unityshell/src/ResultRendererTile.cpp 2012-04-05 13:21:24 +0000
@@ -95,7 +95,7 @@
95 int x_offset, int y_offset)95 int x_offset, int y_offset)
96{96{
97 TextureContainer* container = row.renderer<TextureContainer*>();97 TextureContainer* container = row.renderer<TextureContainer*>();
98 if (container == nullptr)98 if (container == nullptr || container->icon == nullptr)
99 return;99 return;
100100
101 dash::Style& style = dash::Style::Instance();101 dash::Style& style = dash::Style::Instance();
@@ -103,30 +103,29 @@
103103
104 // set up our texture mode104 // set up our texture mode
105 nux::TexCoordXForm texxform;105 nux::TexCoordXForm texxform;
106106
107 int icon_left_hand_side = geometry.x + (geometry.width - tile_icon_size) / 2;107 int icon_left_hand_side = geometry.x + (geometry.width - container->icon->GetWidth()) / 2;
108 int icon_top_side = geometry.y + padding;108 int icon_top_side = geometry.y + padding + ((tile_icon_size - container->icon->GetHeight()) / 2);
109
110109
111 if (container->blurred_icon && state == ResultRendererState::RESULT_RENDERER_NORMAL)110 if (container->blurred_icon && state == ResultRendererState::RESULT_RENDERER_NORMAL)
112 {111 {
113 GfxContext.QRP_1Tex(icon_left_hand_side - 5 - x_offset,112 GfxContext.QRP_1Tex(icon_left_hand_side - 5 - x_offset,
114 icon_top_side - 5 - y_offset,113 icon_top_side - 5 - y_offset,
115 tile_icon_size + 10,114 container->blurred_icon->GetWidth(),
116 tile_icon_size + 10,115 container->blurred_icon->GetHeight(),
117 container->blurred_icon->GetDeviceTexture(),116 container->blurred_icon->GetDeviceTexture(),
118 texxform,117 texxform,
119 nux::Color(0.15f, 0.15f, 0.15f, 0.15f));118 nux::Color(0.15f, 0.15f, 0.15f, 0.15f));
120 }119 }
121120
122 // render highlight if its needed121 // render highlight if its needed
123 if (state != ResultRendererState::RESULT_RENDERER_NORMAL)122 if (container->prelight && state != ResultRendererState::RESULT_RENDERER_NORMAL)
124 {123 {
125 GfxContext.QRP_1Tex(icon_left_hand_side - highlight_padding,124 GfxContext.QRP_1Tex(icon_left_hand_side - highlight_padding,
126 icon_top_side - highlight_padding,125 icon_top_side - highlight_padding,
127 tile_icon_size + (highlight_padding * 2),126 container->prelight->GetWidth(),
128 tile_icon_size + (highlight_padding * 2),127 container->prelight->GetHeight(),
129 prelight_cache_->GetDeviceTexture(),128 container->prelight->GetDeviceTexture(),
130 texxform,129 texxform,
131 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));130 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
132 }131 }
@@ -136,8 +135,8 @@
136 {135 {
137 GfxContext.QRP_1Tex(icon_left_hand_side,136 GfxContext.QRP_1Tex(icon_left_hand_side,
138 icon_top_side,137 icon_top_side,
139 tile_icon_size,138 container->icon->GetWidth(),
140 tile_icon_size,139 container->icon->GetHeight(),
141 container->icon->GetDeviceTexture(),140 container->icon->GetDeviceTexture(),
142 texxform,141 texxform,
143 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));142 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
@@ -241,7 +240,7 @@
241 std::string const& icon_hint = row.icon_hint;240 std::string const& icon_hint = row.icon_hint;
242#define DEFAULT_GICON ". GThemedIcon text-x-preview"241#define DEFAULT_GICON ". GThemedIcon text-x-preview"
243 std::string icon_name;242 std::string icon_name;
244 if (neko)243 if (G_UNLIKELY(neko))
245 {244 {
246 int tmp1 = style.GetTileIconSize() + (rand() % 16) - 8;245 int tmp1 = style.GetTileIconSize() + (rand() % 16) - 8;
247 gsize tmp3;246 gsize tmp3;
@@ -288,6 +287,13 @@
288 int pixbuf_width, pixbuf_height;287 int pixbuf_width, pixbuf_height;
289 pixbuf_width = gdk_pixbuf_get_width(pixbuf);288 pixbuf_width = gdk_pixbuf_get_width(pixbuf);
290 pixbuf_height = gdk_pixbuf_get_height(pixbuf);289 pixbuf_height = gdk_pixbuf_get_height(pixbuf);
290 if (G_UNLIKELY(!pixbuf_height || !pixbuf_width))
291 {
292 LOG_ERROR(logger) << "Pixbuf: " << texid << " has a zero height/width: "
293 << width << "," << height;
294 pixbuf_width = (pixbuf_width) ? pixbuf_width : 1; // no zeros please
295 pixbuf_height = (pixbuf_height) ? pixbuf_height: 1; // no zeros please
296 }
291297
292 if (pixbuf_width == pixbuf_height)298 if (pixbuf_width == pixbuf_height)
293 {299 {
@@ -298,21 +304,40 @@
298 {304 {
299 // slow path for non square icons that must be resized to fit in the square305 // slow path for non square icons that must be resized to fit in the square
300 // texture306 // texture
301 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height);307
308 Style& style = Style::Instance();
309 float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0
310 if (aspect < 1.0f)
311 {
312 pixbuf_width = style.GetTileWidth() - (padding * 2);
313 pixbuf_width = (max_icon_width_ > 0) ? std::min(pixbuf_width, max_icon_width_) : pixbuf_width;
314 pixbuf_height = pixbuf_width * aspect;
315
316
317 if (pixbuf_height > height)
318 {
319 // scaled too big, scale down
320 pixbuf_height = height;
321 pixbuf_width = pixbuf_height / aspect;
322 }
323 }
324 else
325 {
326 pixbuf_height = height;
327 pixbuf_width = pixbuf_height / aspect;
328 }
329
330 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, pixbuf_width, pixbuf_height);
302 cairo_t* cr = cairo_graphics.GetInternalContext();331 cairo_t* cr = cairo_graphics.GetInternalContext();
303332
304 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);333 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
305 cairo_paint(cr);334 cairo_paint(cr);
306335
307 float scale;336 float scale = gdk_pixbuf_get_height(pixbuf) / float(pixbuf_height);
308 if (pixbuf_width > pixbuf_height)
309 scale = pixbuf_height / static_cast<float>(pixbuf_width);
310 else
311 scale = pixbuf_width / static_cast<float>(pixbuf_height);
312337
313 cairo_translate(cr,338 //cairo_translate(cr,
314 static_cast<int>((width - (pixbuf_width * scale)) * 0.5),339 // static_cast<int>((width - (pixbuf_width * scale)) * 0.5),
315 static_cast<int>((height - (pixbuf_height * scale)) * 0.5));340 // static_cast<int>((height - (pixbuf_height * scale)) * 0.5));
316341
317 cairo_scale(cr, scale, scale);342 cairo_scale(cr, scale, scale);
318343
@@ -383,8 +408,11 @@
383 BaseTexturePtr texture_blurred(cache.FindTexture(blur_texid, style.GetTileIconSize(), style.GetTileIconSize(),408 BaseTexturePtr texture_blurred(cache.FindTexture(blur_texid, style.GetTileIconSize(), style.GetTileIconSize(),
384 sigc::bind(sigc::mem_fun(this, &ResultRendererTile::CreateBlurredTextureCallback), pixbuf)));409 sigc::bind(sigc::mem_fun(this, &ResultRendererTile::CreateBlurredTextureCallback), pixbuf)));
385410
411 BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", texture->GetWidth() + highlight_padding*2, texture->GetHeight() + highlight_padding*2, sigc::mem_fun(this, &ResultRendererTile::DrawHighlight)));
412
386 container->icon = texture;413 container->icon = texture;
387 container->blurred_icon = texture_blurred;414 container->blurred_icon = texture_blurred;
415 container->prelight = texture_prelight;
388416
389 NeedsRedraw.emit();417 NeedsRedraw.emit();
390418
391419
=== modified file 'plugins/unityshell/src/ResultRendererTile.h'
--- plugins/unityshell/src/ResultRendererTile.h 2012-04-03 16:14:21 +0000
+++ plugins/unityshell/src/ResultRendererTile.h 2012-04-05 13:21:24 +0000
@@ -45,6 +45,7 @@
45 BaseTexturePtr text;45 BaseTexturePtr text;
46 BaseTexturePtr icon;46 BaseTexturePtr icon;
47 BaseTexturePtr blurred_icon;47 BaseTexturePtr blurred_icon;
48 BaseTexturePtr prelight;
48 int slot_handle;49 int slot_handle;
4950
50 TextureContainer()51 TextureContainer()
@@ -88,7 +89,7 @@
88 void LoadIcon(Result& row);89 void LoadIcon(Result& row);
89 nux::ObjectPtr<nux::BaseTexture> prelight_cache_;90 nux::ObjectPtr<nux::BaseTexture> prelight_cache_;
90 nux::ObjectPtr<nux::BaseTexture> normal_cache_;91 nux::ObjectPtr<nux::BaseTexture> normal_cache_;
9192 int max_icon_width_;
92private:93private:
93 //icon loading callbacks94 //icon loading callbacks
94 void IconLoaded(std::string const& texid,95 void IconLoaded(std::string const& texid,
9596
=== modified file 'standalone-clients/CMakeLists.txt'
--- standalone-clients/CMakeLists.txt 2012-03-21 13:31:08 +0000
+++ standalone-clients/CMakeLists.txt 2012-04-05 13:21:24 +0000
@@ -45,6 +45,8 @@
45 standalone_dash.cpp45 standalone_dash.cpp
46 ${UNITY_SRC}/AbstractPlacesGroup.cpp46 ${UNITY_SRC}/AbstractPlacesGroup.cpp
47 ${UNITY_SRC}/AbstractPlacesGroup.h47 ${UNITY_SRC}/AbstractPlacesGroup.h
48 ${UNITY_SRC}/AbstractSeparator.h
49 ${UNITY_SRC}/AbstractSeparator.cpp
48 ${UNITY_SRC}/BackgroundEffectHelper.cpp50 ${UNITY_SRC}/BackgroundEffectHelper.cpp
49 ${UNITY_SRC}/BackgroundEffectHelper.h51 ${UNITY_SRC}/BackgroundEffectHelper.h
50 ${UNITY_SRC}/BGHash.cpp52 ${UNITY_SRC}/BGHash.cpp
@@ -105,6 +107,8 @@
105 ${UNITY_SRC}/LensView.h107 ${UNITY_SRC}/LensView.h
106 ${UNITY_SRC}/LensViewPrivate.cpp108 ${UNITY_SRC}/LensViewPrivate.cpp
107 ${UNITY_SRC}/LensViewPrivate.h109 ${UNITY_SRC}/LensViewPrivate.h
110 ${UNITY_SRC}/LineSeparator.cpp
111 ${UNITY_SRC}/LineSeparator.h
108 ${UNITY_SRC}/OverlayRenderer.cpp112 ${UNITY_SRC}/OverlayRenderer.cpp
109 ${UNITY_SRC}/PreviewApplications.cpp113 ${UNITY_SRC}/PreviewApplications.cpp
110 ${UNITY_SRC}/PreviewBase.cpp114 ${UNITY_SRC}/PreviewBase.cpp