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

Proposed by Gord Allott on 2012-04-05
Status: Merged
Approved by: Mirco Müller on 2012-04-05
Approved revision: 2227
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) 2012-04-05 Approve on 2012-04-05
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.
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
Mirco Müller (macslow) wrote :

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

lp:~gordallott/unity/fix-lp-878015 updated on 2012-04-05
2227. By Gord Allott on 2012-04-05

fix wrongly aligned icons

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
1=== modified file 'plugins/unityshell/src/ResultRendererTile.cpp'
2--- plugins/unityshell/src/ResultRendererTile.cpp 2012-04-03 16:14:21 +0000
3+++ plugins/unityshell/src/ResultRendererTile.cpp 2012-04-05 13:21:24 +0000
4@@ -95,7 +95,7 @@
5 int x_offset, int y_offset)
6 {
7 TextureContainer* container = row.renderer<TextureContainer*>();
8- if (container == nullptr)
9+ if (container == nullptr || container->icon == nullptr)
10 return;
11
12 dash::Style& style = dash::Style::Instance();
13@@ -103,30 +103,29 @@
14
15 // set up our texture mode
16 nux::TexCoordXForm texxform;
17-
18- int icon_left_hand_side = geometry.x + (geometry.width - tile_icon_size) / 2;
19- int icon_top_side = geometry.y + padding;
20-
21+
22+ int icon_left_hand_side = geometry.x + (geometry.width - container->icon->GetWidth()) / 2;
23+ int icon_top_side = geometry.y + padding + ((tile_icon_size - container->icon->GetHeight()) / 2);
24
25 if (container->blurred_icon && state == ResultRendererState::RESULT_RENDERER_NORMAL)
26 {
27 GfxContext.QRP_1Tex(icon_left_hand_side - 5 - x_offset,
28 icon_top_side - 5 - y_offset,
29- tile_icon_size + 10,
30- tile_icon_size + 10,
31+ container->blurred_icon->GetWidth(),
32+ container->blurred_icon->GetHeight(),
33 container->blurred_icon->GetDeviceTexture(),
34 texxform,
35 nux::Color(0.15f, 0.15f, 0.15f, 0.15f));
36 }
37
38 // render highlight if its needed
39- if (state != ResultRendererState::RESULT_RENDERER_NORMAL)
40+ if (container->prelight && state != ResultRendererState::RESULT_RENDERER_NORMAL)
41 {
42 GfxContext.QRP_1Tex(icon_left_hand_side - highlight_padding,
43 icon_top_side - highlight_padding,
44- tile_icon_size + (highlight_padding * 2),
45- tile_icon_size + (highlight_padding * 2),
46- prelight_cache_->GetDeviceTexture(),
47+ container->prelight->GetWidth(),
48+ container->prelight->GetHeight(),
49+ container->prelight->GetDeviceTexture(),
50 texxform,
51 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
52 }
53@@ -136,8 +135,8 @@
54 {
55 GfxContext.QRP_1Tex(icon_left_hand_side,
56 icon_top_side,
57- tile_icon_size,
58- tile_icon_size,
59+ container->icon->GetWidth(),
60+ container->icon->GetHeight(),
61 container->icon->GetDeviceTexture(),
62 texxform,
63 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
64@@ -241,7 +240,7 @@
65 std::string const& icon_hint = row.icon_hint;
66 #define DEFAULT_GICON ". GThemedIcon text-x-preview"
67 std::string icon_name;
68- if (neko)
69+ if (G_UNLIKELY(neko))
70 {
71 int tmp1 = style.GetTileIconSize() + (rand() % 16) - 8;
72 gsize tmp3;
73@@ -288,6 +287,13 @@
74 int pixbuf_width, pixbuf_height;
75 pixbuf_width = gdk_pixbuf_get_width(pixbuf);
76 pixbuf_height = gdk_pixbuf_get_height(pixbuf);
77+ if (G_UNLIKELY(!pixbuf_height || !pixbuf_width))
78+ {
79+ LOG_ERROR(logger) << "Pixbuf: " << texid << " has a zero height/width: "
80+ << width << "," << height;
81+ pixbuf_width = (pixbuf_width) ? pixbuf_width : 1; // no zeros please
82+ pixbuf_height = (pixbuf_height) ? pixbuf_height: 1; // no zeros please
83+ }
84
85 if (pixbuf_width == pixbuf_height)
86 {
87@@ -298,21 +304,40 @@
88 {
89 // slow path for non square icons that must be resized to fit in the square
90 // texture
91- nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height);
92+
93+ Style& style = Style::Instance();
94+ float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0
95+ if (aspect < 1.0f)
96+ {
97+ pixbuf_width = style.GetTileWidth() - (padding * 2);
98+ pixbuf_width = (max_icon_width_ > 0) ? std::min(pixbuf_width, max_icon_width_) : pixbuf_width;
99+ pixbuf_height = pixbuf_width * aspect;
100+
101+
102+ if (pixbuf_height > height)
103+ {
104+ // scaled too big, scale down
105+ pixbuf_height = height;
106+ pixbuf_width = pixbuf_height / aspect;
107+ }
108+ }
109+ else
110+ {
111+ pixbuf_height = height;
112+ pixbuf_width = pixbuf_height / aspect;
113+ }
114+
115+ nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, pixbuf_width, pixbuf_height);
116 cairo_t* cr = cairo_graphics.GetInternalContext();
117
118 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
119 cairo_paint(cr);
120
121- float scale;
122- if (pixbuf_width > pixbuf_height)
123- scale = pixbuf_height / static_cast<float>(pixbuf_width);
124- else
125- scale = pixbuf_width / static_cast<float>(pixbuf_height);
126+ float scale = gdk_pixbuf_get_height(pixbuf) / float(pixbuf_height);
127
128- cairo_translate(cr,
129- static_cast<int>((width - (pixbuf_width * scale)) * 0.5),
130- static_cast<int>((height - (pixbuf_height * scale)) * 0.5));
131+ //cairo_translate(cr,
132+ // static_cast<int>((width - (pixbuf_width * scale)) * 0.5),
133+ // static_cast<int>((height - (pixbuf_height * scale)) * 0.5));
134
135 cairo_scale(cr, scale, scale);
136
137@@ -383,8 +408,11 @@
138 BaseTexturePtr texture_blurred(cache.FindTexture(blur_texid, style.GetTileIconSize(), style.GetTileIconSize(),
139 sigc::bind(sigc::mem_fun(this, &ResultRendererTile::CreateBlurredTextureCallback), pixbuf)));
140
141+ BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", texture->GetWidth() + highlight_padding*2, texture->GetHeight() + highlight_padding*2, sigc::mem_fun(this, &ResultRendererTile::DrawHighlight)));
142+
143 container->icon = texture;
144 container->blurred_icon = texture_blurred;
145+ container->prelight = texture_prelight;
146
147 NeedsRedraw.emit();
148
149
150=== modified file 'plugins/unityshell/src/ResultRendererTile.h'
151--- plugins/unityshell/src/ResultRendererTile.h 2012-04-03 16:14:21 +0000
152+++ plugins/unityshell/src/ResultRendererTile.h 2012-04-05 13:21:24 +0000
153@@ -45,6 +45,7 @@
154 BaseTexturePtr text;
155 BaseTexturePtr icon;
156 BaseTexturePtr blurred_icon;
157+ BaseTexturePtr prelight;
158 int slot_handle;
159
160 TextureContainer()
161@@ -88,7 +89,7 @@
162 void LoadIcon(Result& row);
163 nux::ObjectPtr<nux::BaseTexture> prelight_cache_;
164 nux::ObjectPtr<nux::BaseTexture> normal_cache_;
165-
166+ int max_icon_width_;
167 private:
168 //icon loading callbacks
169 void IconLoaded(std::string const& texid,
170
171=== modified file 'standalone-clients/CMakeLists.txt'
172--- standalone-clients/CMakeLists.txt 2012-03-21 13:31:08 +0000
173+++ standalone-clients/CMakeLists.txt 2012-04-05 13:21:24 +0000
174@@ -45,6 +45,8 @@
175 standalone_dash.cpp
176 ${UNITY_SRC}/AbstractPlacesGroup.cpp
177 ${UNITY_SRC}/AbstractPlacesGroup.h
178+ ${UNITY_SRC}/AbstractSeparator.h
179+ ${UNITY_SRC}/AbstractSeparator.cpp
180 ${UNITY_SRC}/BackgroundEffectHelper.cpp
181 ${UNITY_SRC}/BackgroundEffectHelper.h
182 ${UNITY_SRC}/BGHash.cpp
183@@ -105,6 +107,8 @@
184 ${UNITY_SRC}/LensView.h
185 ${UNITY_SRC}/LensViewPrivate.cpp
186 ${UNITY_SRC}/LensViewPrivate.h
187+ ${UNITY_SRC}/LineSeparator.cpp
188+ ${UNITY_SRC}/LineSeparator.h
189 ${UNITY_SRC}/OverlayRenderer.cpp
190 ${UNITY_SRC}/PreviewApplications.cpp
191 ${UNITY_SRC}/PreviewBase.cpp