Merge lp:~3v1n0/unity/icons-emblem-scaling into lp:unity
- icons-emblem-scaling
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Christopher Townsend | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | 3861 | ||||||||
Proposed branch: | lp:~3v1n0/unity/icons-emblem-scaling | ||||||||
Merge into: | lp:unity | ||||||||
Diff against target: |
669 lines (+202/-141) 13 files modified
hud/HudIconTextureSource.cpp (+0/-5) hud/HudIconTextureSource.h (+0/-1) launcher/Launcher.cpp (+1/-1) launcher/LauncherIcon.cpp (+114/-103) launcher/LauncherIcon.h (+12/-8) launcher/MockLauncherIcon.h (+0/-5) launcher/SwitcherView.cpp (+2/-0) panel/PanelIndicatorEntryView.cpp (+1/-1) unity-shared/DecorationStyle.cpp (+2/-2) unity-shared/IconRenderer.cpp (+35/-9) unity-shared/IconTextureSource.cpp (+26/-0) unity-shared/IconTextureSource.h (+7/-3) unity-shared/TextInput.cpp (+2/-3) |
||||||||
To merge this branch: | bzr merge lp:~3v1n0/unity/icons-emblem-scaling | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Christopher Townsend | Approve | ||
Review via email: mp+229937@code.launchpad.net |
Commit message
IconRenderer: draw count texture at proper scaling, built by LauncherIcon
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3853
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Christopher Townsend (townsend) wrote : | # |
Looks pretty good. Just to note as discussed, when scaling down < 1, the text can become hard to read depending on the scaling factor, but there is not much that can be done to make it better.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3855
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3855
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3855
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3855
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3855
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'hud/HudIconTextureSource.cpp' |
2 | --- hud/HudIconTextureSource.cpp 2012-10-29 09:34:54 +0000 |
3 | +++ hud/HudIconTextureSource.cpp 2014-08-08 15:13:47 +0000 |
4 | @@ -109,11 +109,6 @@ |
5 | return nux::Color(0.0f, 0.0f, 0.0f, 0.0f); |
6 | } |
7 | |
8 | -nux::BaseTexture* HudIconTextureSource::Emblem() |
9 | -{ |
10 | - return nullptr; |
11 | -} |
12 | - |
13 | } |
14 | } |
15 | |
16 | |
17 | === modified file 'hud/HudIconTextureSource.h' |
18 | --- hud/HudIconTextureSource.h 2013-11-06 11:21:43 +0000 |
19 | +++ hud/HudIconTextureSource.h 2014-08-08 15:13:47 +0000 |
20 | @@ -37,7 +37,6 @@ |
21 | virtual nux::Color BackgroundColor() const; |
22 | virtual nux::BaseTexture* TextureForSize(int size); |
23 | virtual nux::Color GlowColor(); |
24 | - virtual nux::BaseTexture* Emblem(); |
25 | void ColorForIcon(GdkPixbuf* pixbuf); |
26 | |
27 | private: |
28 | |
29 | === modified file 'launcher/Launcher.cpp' |
30 | --- launcher/Launcher.cpp 2014-07-17 18:33:37 +0000 |
31 | +++ launcher/Launcher.cpp 2014-08-08 15:13:47 +0000 |
32 | @@ -1219,6 +1219,7 @@ |
33 | Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_height), monitor_geo.height - panel_height); |
34 | |
35 | icon_renderer_->monitor = new_monitor; |
36 | + icon_renderer_->scale = cv_->DPIScale(); |
37 | SetIconSize(options()->tile_size, options()->icon_size); |
38 | } |
39 | |
40 | @@ -1519,7 +1520,6 @@ |
41 | ui::IconRenderer::DestroyShortcutTextures(); |
42 | |
43 | icon_size_ = tile_size; |
44 | - icon_renderer_->scale = cv_->DPIScale(); |
45 | icon_renderer_->SetTargetSize(icon_size_.CP(cv_), RawPixel(icon_size).CP(cv_), SPACE_BETWEEN_ICONS.CP(cv_)); |
46 | AbstractLauncherIcon::icon_size = icon_size_; |
47 | |
48 | |
49 | === modified file 'launcher/LauncherIcon.cpp' |
50 | --- launcher/LauncherIcon.cpp 2014-05-28 12:14:44 +0000 |
51 | +++ launcher/LauncherIcon.cpp 2014-08-08 15:13:47 +0000 |
52 | @@ -59,6 +59,11 @@ |
53 | const std::string CENTER_STABILIZE_TIMEOUT = "center-stabilize-timeout"; |
54 | const std::string PRESENT_TIMEOUT = "present-timeout"; |
55 | const std::string QUIRK_DELAY_TIMEOUT = "quirk-delay-timeout"; |
56 | + |
57 | +const int COUNT_WIDTH = 32; |
58 | +const int COUNT_HEIGHT = 16; |
59 | +const int COUNT_FONT_WIDTH = COUNT_WIDTH - 4; |
60 | +const int COUNT_FONT_HEIGHT = COUNT_HEIGHT - 5; |
61 | } |
62 | |
63 | NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon); |
64 | @@ -69,7 +74,6 @@ |
65 | LauncherIcon::LauncherIcon(IconType type) |
66 | : _icon_type(type) |
67 | , _sticky(false) |
68 | - , _remote_urgent(false) |
69 | , _present_urgency(0) |
70 | , _progress(0.0f) |
71 | , _sort_priority(DefaultPriority(type)) |
72 | @@ -99,6 +103,8 @@ |
73 | mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown)); |
74 | mouse_up.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseUp)); |
75 | mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick)); |
76 | + Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &LauncherIcon::CleanCountTextures)); |
77 | + icon_size.changed.connect(sigc::hide(sigc::mem_fun(this, &LauncherIcon::CleanCountTextures))); |
78 | |
79 | for (unsigned i = 0; i < monitors::MAX; ++i) |
80 | { |
81 | @@ -966,14 +972,42 @@ |
82 | return result; |
83 | } |
84 | |
85 | -nux::BaseTexture* |
86 | -LauncherIcon::Emblem() |
87 | +nux::BaseTexture* LauncherIcon::Emblem() const |
88 | { |
89 | return _emblem.GetPointer(); |
90 | } |
91 | |
92 | -void |
93 | -LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem) |
94 | +nux::BaseTexture* LauncherIcon::CountTexture(double scale) |
95 | +{ |
96 | + int count = Count(); |
97 | + |
98 | + if (!count) |
99 | + return nullptr; |
100 | + |
101 | + auto it = _counts.find(scale); |
102 | + |
103 | + if (it != _counts.end()) |
104 | + return it->second.GetPointer(); |
105 | + |
106 | + auto const& texture = DrawCountTexture(count, scale); |
107 | + _counts[scale] = texture; |
108 | + return texture.GetPointer(); |
109 | +} |
110 | + |
111 | +unsigned LauncherIcon::Count() const |
112 | +{ |
113 | + if (!_remote_entries.empty()) |
114 | + { |
115 | + auto const& remote = _remote_entries.front(); |
116 | + |
117 | + if (remote->CountVisible()) |
118 | + return remote->Count(); |
119 | + } |
120 | + |
121 | + return 0; |
122 | +} |
123 | + |
124 | +void LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem) |
125 | { |
126 | _emblem = emblem; |
127 | EmitNeedsRedraw(); |
128 | @@ -994,60 +1028,44 @@ |
129 | emblem->UnReference(); |
130 | } |
131 | |
132 | -void |
133 | -LauncherIcon::SetEmblemText(std::string const& text) |
134 | -{ |
135 | - PangoLayout* layout = NULL; |
136 | - |
137 | - PangoContext* pangoCtx = NULL; |
138 | - PangoFontDescription* desc = NULL; |
139 | - GdkScreen* screen = gdk_screen_get_default(); // not ref'ed |
140 | - GtkSettings* settings = gtk_settings_get_default(); // not ref'ed |
141 | - gchar* fontName = NULL; |
142 | - |
143 | - int width = 32; |
144 | - int height = 8 * 2; |
145 | - int font_height = height - 5; |
146 | - |
147 | - |
148 | - nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height); |
149 | - cairo_t* cr = cg.GetInternalContext(); |
150 | - |
151 | - cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); |
152 | - cairo_paint(cr); |
153 | - |
154 | - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
155 | - |
156 | - |
157 | - layout = pango_cairo_create_layout(cr); |
158 | - |
159 | - g_object_get(settings, "gtk-font-name", &fontName, NULL); |
160 | - desc = pango_font_description_from_string(fontName); |
161 | - pango_font_description_set_absolute_size(desc, pango_units_from_double(font_height)); |
162 | - |
163 | - pango_layout_set_font_description(layout, desc); |
164 | - pango_font_description_free(desc); |
165 | - |
166 | - pango_layout_set_width(layout, pango_units_from_double(width - 4.0f)); |
167 | +void LauncherIcon::CleanCountTextures() |
168 | +{ |
169 | + _counts.clear(); |
170 | +} |
171 | + |
172 | +BaseTexturePtr LauncherIcon::DrawCountTexture(unsigned count, double scale) |
173 | +{ |
174 | + auto const& count_text = (count / 10000 != 0) ? "****" : std::to_string(count); |
175 | + |
176 | + glib::Object<PangoContext> pango_ctx(gdk_pango_context_get()); |
177 | + glib::Object<PangoLayout> layout(pango_layout_new(pango_ctx)); |
178 | + |
179 | + glib::String font_name; |
180 | + g_object_get(gtk_settings_get_default(), "gtk-font-name", &font_name, nullptr); |
181 | + std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free); |
182 | + pango_font_description_set_absolute_size(desc.get(), pango_units_from_double(COUNT_FONT_HEIGHT)); |
183 | + pango_layout_set_font_description(layout, desc.get()); |
184 | + |
185 | + pango_layout_set_width(layout, pango_units_from_double(COUNT_FONT_WIDTH)); |
186 | pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); |
187 | pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); |
188 | - pango_layout_set_markup_with_accel(layout, text.c_str(), -1, '_', NULL); |
189 | - |
190 | - pangoCtx = pango_layout_get_context(layout); // is not ref'ed |
191 | - pango_cairo_context_set_font_options(pangoCtx, |
192 | - gdk_screen_get_font_options(screen)); |
193 | - |
194 | - PangoRectangle logical_rect, ink_rect; |
195 | - pango_layout_get_extents(layout, &logical_rect, &ink_rect); |
196 | + pango_layout_set_markup_with_accel(layout, count_text.c_str(), -1, '_', nullptr); |
197 | + |
198 | + PangoRectangle ink_rect; |
199 | + pango_layout_get_pixel_extents(layout, &ink_rect, nullptr); |
200 | |
201 | /* DRAW OUTLINE */ |
202 | - float radius = height / 2.0f - 1.0f; |
203 | + float radius = COUNT_HEIGHT / 2.0f - 1.0f; |
204 | float inset = radius + 1.0f; |
205 | |
206 | - cairo_move_to(cr, inset, height - 1.0f); |
207 | + nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, std::round(COUNT_WIDTH * scale), std::round(COUNT_HEIGHT * scale)); |
208 | + cairo_surface_set_device_scale(cg.GetSurface(), scale, scale); |
209 | + cairo_t* cr = cg.GetInternalContext(); |
210 | + |
211 | + cairo_move_to(cr, inset, COUNT_HEIGHT - 1.0f); |
212 | cairo_arc(cr, inset, inset, radius, 0.5 * M_PI, 1.5 * M_PI); |
213 | - cairo_arc(cr, width - inset, inset, radius, 1.5 * M_PI, 0.5 * M_PI); |
214 | - cairo_line_to(cr, inset, height - 1.0f); |
215 | + cairo_arc(cr, COUNT_WIDTH - inset, inset, radius, 1.5 * M_PI, 0.5 * M_PI); |
216 | + cairo_line_to(cr, inset, COUNT_HEIGHT - 1.0f); |
217 | |
218 | cairo_set_source_rgba(cr, 0.35f, 0.35f, 0.35f, 1.0f); |
219 | cairo_fill_preserve(cr); |
220 | @@ -1059,16 +1077,11 @@ |
221 | cairo_set_line_width(cr, 1.0f); |
222 | |
223 | /* DRAW TEXT */ |
224 | - cairo_move_to(cr, |
225 | - (int)((width - pango_units_to_double(logical_rect.width)) / 2.0f), |
226 | - (int)((height - pango_units_to_double(logical_rect.height)) / 2.0f - pango_units_to_double(logical_rect.y))); |
227 | + cairo_move_to(cr, (COUNT_WIDTH - ink_rect.width) / 2.0 - ink_rect.x, |
228 | + (COUNT_HEIGHT - ink_rect.height) / 2.0 - ink_rect.y); |
229 | pango_cairo_show_layout(cr, layout); |
230 | |
231 | - SetEmblem(texture_ptr_from_cairo_graphics(cg)); |
232 | - |
233 | - // clean up |
234 | - g_object_unref(layout); |
235 | - g_free(fontName); |
236 | + return texture_ptr_from_cairo_graphics(cg); |
237 | } |
238 | |
239 | void |
240 | @@ -1077,26 +1090,34 @@ |
241 | SetEmblem(BaseTexturePtr()); |
242 | } |
243 | |
244 | -void |
245 | -LauncherIcon::InsertEntryRemote(LauncherEntryRemote::Ptr const& remote) |
246 | +void LauncherIcon::InsertEntryRemote(LauncherEntryRemote::Ptr const& remote) |
247 | { |
248 | - if (std::find(_entry_list.begin(), _entry_list.end(), remote) != _entry_list.end()) |
249 | + if (!remote || std::find(_remote_entries.begin(), _remote_entries.end(), remote) != _remote_entries.end()) |
250 | return; |
251 | |
252 | - _entry_list.push_front(remote); |
253 | + _remote_entries.push_back(remote); |
254 | AddChild(remote.get()); |
255 | - |
256 | - remote->emblem_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemChanged)); |
257 | - remote->count_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountChanged)); |
258 | - remote->progress_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressChanged)); |
259 | - remote->quicklist_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteQuicklistChanged)); |
260 | - |
261 | - remote->emblem_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemVisibleChanged)); |
262 | - remote->count_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountVisibleChanged)); |
263 | - remote->progress_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressVisibleChanged)); |
264 | - |
265 | - remote->urgent_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteUrgentChanged)); |
266 | - |
267 | + SelectEntryRemote(remote); |
268 | +} |
269 | + |
270 | +void LauncherIcon::SelectEntryRemote(LauncherEntryRemote::Ptr const& remote) |
271 | +{ |
272 | + if (!remote) |
273 | + return; |
274 | + |
275 | + auto& cm = _remote_connections; |
276 | + cm.Clear(); |
277 | + |
278 | + cm.Add(remote->emblem_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemChanged))); |
279 | + cm.Add(remote->count_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountChanged))); |
280 | + cm.Add(remote->progress_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressChanged))); |
281 | + cm.Add(remote->quicklist_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteQuicklistChanged))); |
282 | + |
283 | + cm.Add(remote->emblem_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemVisibleChanged))); |
284 | + cm.Add(remote->count_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountVisibleChanged))); |
285 | + cm.Add(remote->progress_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressVisibleChanged))); |
286 | + |
287 | + cm.Add(remote->urgent_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteUrgentChanged))); |
288 | |
289 | if (remote->EmblemVisible()) |
290 | OnRemoteEmblemVisibleChanged(remote.get()); |
291 | @@ -1113,28 +1134,30 @@ |
292 | OnRemoteQuicklistChanged(remote.get()); |
293 | } |
294 | |
295 | -void |
296 | -LauncherIcon::RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote) |
297 | +void LauncherIcon::RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote) |
298 | { |
299 | - if (std::find(_entry_list.begin(), _entry_list.end(), remote) == _entry_list.end()) |
300 | + auto remote_it = std::find(_remote_entries.begin(), _remote_entries.end(), remote); |
301 | + |
302 | + if (remote_it == _remote_entries.end()) |
303 | return; |
304 | |
305 | - _entry_list.remove(remote); |
306 | + SetQuirk(Quirk::PROGRESS, false); |
307 | + |
308 | + if (remote->Urgent()) |
309 | + SetQuirk(Quirk::URGENT, false); |
310 | + |
311 | + _remote_entries.erase(remote_it); |
312 | RemoveChild(remote.get()); |
313 | - |
314 | DeleteEmblem(); |
315 | - SetQuirk(Quirk::PROGRESS, false); |
316 | - |
317 | - if (_remote_urgent) |
318 | - SetQuirk(Quirk::URGENT, false); |
319 | - |
320 | _remote_menus = nullptr; |
321 | + |
322 | + if (!_remote_entries.empty()) |
323 | + SelectEntryRemote(_remote_entries.back()); |
324 | } |
325 | |
326 | void |
327 | LauncherIcon::OnRemoteUrgentChanged(LauncherEntryRemote* remote) |
328 | { |
329 | - _remote_urgent = remote->Urgent(); |
330 | SetQuirk(Quirk::URGENT, remote->Urgent()); |
331 | } |
332 | |
333 | @@ -1153,14 +1176,8 @@ |
334 | if (!remote->CountVisible()) |
335 | return; |
336 | |
337 | - if (remote->Count() / 10000 != 0) |
338 | - { |
339 | - SetEmblemText("****"); |
340 | - } |
341 | - else |
342 | - { |
343 | - SetEmblemText(std::to_string(remote->Count())); |
344 | - } |
345 | + CleanCountTextures(); |
346 | + EmitNeedsRedraw(); |
347 | } |
348 | |
349 | void |
350 | @@ -1190,14 +1207,8 @@ |
351 | void |
352 | LauncherIcon::OnRemoteCountVisibleChanged(LauncherEntryRemote* remote) |
353 | { |
354 | - if (remote->CountVisible()) |
355 | - { |
356 | - SetEmblemText(std::to_string(remote->Count())); |
357 | - } |
358 | - else |
359 | - { |
360 | - DeleteEmblem(); |
361 | - } |
362 | + CleanCountTextures(); |
363 | + EmitNeedsRedraw(); |
364 | } |
365 | |
366 | void |
367 | |
368 | === modified file 'launcher/LauncherIcon.h' |
369 | --- launcher/LauncherIcon.h 2014-05-28 09:56:00 +0000 |
370 | +++ launcher/LauncherIcon.h 2014-08-08 15:13:47 +0000 |
371 | @@ -154,14 +154,15 @@ |
372 | } |
373 | |
374 | nux::BaseTexture* TextureForSize(int size); |
375 | - |
376 | - nux::BaseTexture* Emblem(); |
377 | + nux::BaseTexture* Emblem() const override; |
378 | + nux::BaseTexture* CountTexture(double scale) override; |
379 | |
380 | MenuItemsVector Menus(); |
381 | - |
382 | - void InsertEntryRemote(LauncherEntryRemote::Ptr const& remote); |
383 | - |
384 | - void RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote); |
385 | + unsigned Count() const; |
386 | + |
387 | + void InsertEntryRemote(LauncherEntryRemote::Ptr const&); |
388 | + void SelectEntryRemote(LauncherEntryRemote::Ptr const&); |
389 | + void RemoveEntryRemote(LauncherEntryRemote::Ptr const&); |
390 | |
391 | nux::DndAction QueryAcceptDrop(DndData const& dnd_data) |
392 | { |
393 | @@ -323,9 +324,10 @@ |
394 | void LoadQuicklist(); |
395 | |
396 | void OnTooltipEnabledChanged(bool value); |
397 | + void CleanCountTextures(); |
398 | + BaseTexturePtr DrawCountTexture(unsigned count, double scale); |
399 | |
400 | bool _sticky; |
401 | - bool _remote_urgent; |
402 | float _present_urgency; |
403 | float _progress; |
404 | int _sort_priority; |
405 | @@ -346,8 +348,10 @@ |
406 | time::Spec _last_action; |
407 | |
408 | BaseTexturePtr _emblem; |
409 | + std::unordered_map<double, BaseTexturePtr> _counts; |
410 | |
411 | - std::list<LauncherEntryRemote::Ptr> _entry_list; |
412 | + std::vector<LauncherEntryRemote::Ptr> _remote_entries; |
413 | + connection::Manager _remote_connections; |
414 | glib::Object<DbusmenuClient> _remote_menus; |
415 | |
416 | static glib::Object<GtkIconTheme> _unity_theme; |
417 | |
418 | === modified file 'launcher/MockLauncherIcon.h' |
419 | --- launcher/MockLauncherIcon.h 2013-12-11 15:03:25 +0000 |
420 | +++ launcher/MockLauncherIcon.h 2014-08-08 15:13:47 +0000 |
421 | @@ -329,11 +329,6 @@ |
422 | return icon_; |
423 | } |
424 | |
425 | - nux::BaseTexture* Emblem() |
426 | - { |
427 | - return 0; |
428 | - } |
429 | - |
430 | MenuItemsVector Menus() |
431 | { |
432 | return MenuItemsVector (); |
433 | |
434 | === modified file 'launcher/SwitcherView.cpp' |
435 | --- launcher/SwitcherView.cpp 2014-07-15 16:28:45 +0000 |
436 | +++ launcher/SwitcherView.cpp 2014-08-08 15:13:47 +0000 |
437 | @@ -76,6 +76,7 @@ |
438 | icon_renderer_->pip_style = OVER_TILE; |
439 | icon_renderer_->monitor = monitors::MAX; |
440 | icon_renderer_->SetTargetSize(tile_size, icon_size, minimum_spacing); |
441 | + icon_renderer_->scale = scale(); |
442 | |
443 | text_view_->SetMaximumWidth(tile_size * TEXT_TILE_MULTIPLIER); |
444 | text_view_->SetLines(1); |
445 | @@ -196,6 +197,7 @@ |
446 | tile_size = TILE_SIZE.CP(scale); |
447 | text_size = TEXT_SIZE.CP(scale); |
448 | vertical_size = tile_size + VERTICAL_PADDING.CP(scale) * 2; |
449 | + icon_renderer_->scale = scale; |
450 | } |
451 | |
452 | void SwitcherView::StartAnimation() |
453 | |
454 | === modified file 'panel/PanelIndicatorEntryView.cpp' |
455 | --- panel/PanelIndicatorEntryView.cpp 2014-05-30 07:20:13 +0000 |
456 | +++ panel/PanelIndicatorEntryView.cpp 2014-08-08 15:13:47 +0000 |
457 | @@ -426,7 +426,7 @@ |
458 | } |
459 | } |
460 | |
461 | - glib::Object<PangoContext> context(gdk_pango_context_get_for_screen(gdk_screen_get_default())); |
462 | + glib::Object<PangoContext> context(gdk_pango_context_get()); |
463 | std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font.c_str()), pango_font_description_free); |
464 | pango_context_set_font_description(context, desc.get()); |
465 | pango_context_set_language(context, gtk_get_default_language()); |
466 | |
467 | === modified file 'unity-shared/DecorationStyle.cpp' |
468 | --- unity-shared/DecorationStyle.cpp 2014-06-13 15:22:15 +0000 |
469 | +++ unity-shared/DecorationStyle.cpp 2014-08-08 15:13:47 +0000 |
470 | @@ -147,8 +147,8 @@ |
471 | , ctx_(gtk_style_context_new()) |
472 | , settings_(g_settings_new(SETTINGS_NAME.c_str())) |
473 | , usettings_(g_settings_new(UNITY_SETTINGS_NAME.c_str())) |
474 | - , title_pango_ctx_(gdk_pango_context_get_for_screen(gdk_screen_get_default())) |
475 | - , menu_item_pango_ctx_(gdk_pango_context_get_for_screen(gdk_screen_get_default())) |
476 | + , title_pango_ctx_(gdk_pango_context_get()) |
477 | + , menu_item_pango_ctx_(gdk_pango_context_get()) |
478 | , title_alignment_(0) |
479 | , title_indent_(0) |
480 | , title_fade_(0) |
481 | |
482 | === modified file 'unity-shared/IconRenderer.cpp' |
483 | --- unity-shared/IconRenderer.cpp 2014-05-08 18:52:16 +0000 |
484 | +++ unity-shared/IconRenderer.cpp 2014-08-08 15:13:47 +0000 |
485 | @@ -199,6 +199,8 @@ |
486 | const std::array<int, IconSize::SIZE> TILE_SIZES = { 54, 150 }; |
487 | const std::array<int, IconSize::SIZE> GLOW_SIZES = { 62, 200 }; |
488 | const std::array<int, IconSize::SIZE> MARKER_SIZES = { 19, 37 }; |
489 | + |
490 | +constexpr double count_scaling(double icon_size, bool switcher) { return icon_size / (TILE_SIZES[local::IconSize::SMALL] * (switcher ? 2.0 : 1.0)); } |
491 | } // anonymous namespace |
492 | } // local namespace |
493 | |
494 | @@ -352,6 +354,7 @@ |
495 | GetInverseScreenPerspectiveMatrix(ViewMatrix, ProjectionMatrix, geo.width, geo.height, 0.1f, 1000.0f, DEGTORAD(90)); |
496 | |
497 | nux::Matrix4 const& PremultMatrix = ProjectionMatrix * ViewMatrix; |
498 | + int monitor = this->monitor(); |
499 | |
500 | std::list<RenderArg>::iterator it; |
501 | int i; |
502 | @@ -363,6 +366,7 @@ |
503 | it->logical_center == launcher_icon->LastLogicalCenter(monitor) && |
504 | it->rotation == launcher_icon->LastRotation(monitor) && |
505 | it->skip == launcher_icon->WasSkipping(monitor) && |
506 | + (launcher_icon->Count() != 0) == launcher_icon->HadCount(monitor) && |
507 | (launcher_icon->Emblem() != nullptr) == launcher_icon->HadEmblem(monitor)) |
508 | { |
509 | continue; |
510 | @@ -372,6 +376,7 @@ |
511 | launcher_icon->RememberRotation(monitor, it->rotation); |
512 | launcher_icon->RememberSkip(monitor, it->skip); |
513 | launcher_icon->RememberEmblem(monitor, launcher_icon->Emblem() != nullptr); |
514 | + launcher_icon->RememberCount(monitor, launcher_icon->Count() != 0); |
515 | |
516 | float w = icon_size; |
517 | float h = icon_size; |
518 | @@ -423,16 +428,26 @@ |
519 | |
520 | UpdateIconTransform(launcher_icon, ViewProjectionMatrix, geo, x, y, w, h, z, ui::IconTextureSource::TRANSFORM_HIT_AREA); |
521 | |
522 | - if (launcher_icon->Emblem()) |
523 | - { |
524 | - nux::BaseTexture* emblem = launcher_icon->Emblem(); |
525 | - |
526 | + float emb_w, emb_h; |
527 | + nux::BaseTexture* emblem = launcher_icon->Emblem(); |
528 | + |
529 | + if (nux::BaseTexture* count_texture = launcher_icon->CountTexture(local::count_scaling(icon_size, pip_style != OUTSIDE_TILE))) |
530 | + { |
531 | + emblem = count_texture; |
532 | + emb_w = emblem->GetWidth(); |
533 | + emb_h = emblem->GetHeight(); |
534 | + } |
535 | + else if (emblem) |
536 | + { |
537 | + emb_w = std::round(emblem->GetWidth() * scale()); |
538 | + emb_h = std::round(emblem->GetHeight() * scale()); |
539 | + } |
540 | + |
541 | + if (emblem) |
542 | + { |
543 | float w = icon_size; |
544 | float h = icon_size; |
545 | |
546 | - float emb_w = emblem->GetWidth(); |
547 | - float emb_h = emblem->GetHeight(); |
548 | - |
549 | x = it->render_center.x + (icon_size * 0.50f - emb_w - icon_size * 0.05f); // puts right edge of emblem just over the edge of the launcher icon |
550 | y = it->render_center.y - icon_size * 0.50f; // y = top left corner position of emblem |
551 | z = it->render_center.z; |
552 | @@ -718,7 +733,18 @@ |
553 | tile_transform); |
554 | } |
555 | |
556 | - if (arg.icon->Emblem()) |
557 | + if (nux::BaseTexture* count_texture = arg.icon->CountTexture(local::count_scaling(icon_size, pip_style != OUTSIDE_TILE))) |
558 | + { |
559 | + RenderElement(GfxContext, |
560 | + arg, |
561 | + count_texture->GetDeviceTexture(), |
562 | + nux::color::White, |
563 | + nux::color::White, |
564 | + arg.alpha, |
565 | + force_filter, |
566 | + arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_EMBLEM, monitor)); |
567 | + } |
568 | + else if (arg.icon->Emblem()) |
569 | { |
570 | RenderElement(GfxContext, |
571 | arg, |
572 | @@ -726,7 +752,7 @@ |
573 | nux::color::White, |
574 | nux::color::White, |
575 | arg.alpha, |
576 | - force_filter, |
577 | + force_filter || scale != 1.0, |
578 | arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_EMBLEM, monitor)); |
579 | } |
580 | |
581 | |
582 | === modified file 'unity-shared/IconTextureSource.cpp' |
583 | --- unity-shared/IconTextureSource.cpp 2013-10-04 00:46:07 +0000 |
584 | +++ unity-shared/IconTextureSource.cpp 2014-08-08 15:13:47 +0000 |
585 | @@ -34,6 +34,7 @@ |
586 | IconTextureSource::IconTextureSource() |
587 | : skip_(RENDERERS_SIZE, false) |
588 | , had_emblem_(RENDERERS_SIZE, false) |
589 | + , had_count_(RENDERERS_SIZE, false) |
590 | , last_render_center_(RENDERERS_SIZE) |
591 | , last_logical_center_(RENDERERS_SIZE) |
592 | , last_rotation_(RENDERERS_SIZE) |
593 | @@ -91,5 +92,30 @@ |
594 | return had_emblem_[monitor]; |
595 | } |
596 | |
597 | +void IconTextureSource::RememberCount(int monitor, bool has_count) |
598 | +{ |
599 | + had_count_[monitor] = has_count; |
600 | +} |
601 | + |
602 | +bool IconTextureSource::HadCount(int monitor) const |
603 | +{ |
604 | + return had_count_[monitor]; |
605 | +} |
606 | + |
607 | +unsigned IconTextureSource::Count() const |
608 | +{ |
609 | + return 0; |
610 | +} |
611 | + |
612 | +nux::BaseTexture* IconTextureSource::Emblem() const |
613 | +{ |
614 | + return nullptr; |
615 | +} |
616 | + |
617 | +nux::BaseTexture* IconTextureSource::CountTexture(double scale) |
618 | +{ |
619 | + return nullptr; |
620 | +} |
621 | + |
622 | } |
623 | } |
624 | \ No newline at end of file |
625 | |
626 | === modified file 'unity-shared/IconTextureSource.h' |
627 | --- unity-shared/IconTextureSource.h 2013-11-06 11:21:43 +0000 |
628 | +++ unity-shared/IconTextureSource.h 2014-08-08 15:13:47 +0000 |
629 | @@ -62,17 +62,21 @@ |
630 | void RememberEmblem(int monitor, bool has_emblem); |
631 | bool HadEmblem(int monitor) const; |
632 | |
633 | + void RememberCount(int monitor, bool has_count); |
634 | + bool HadCount(int monitor) const; |
635 | + |
636 | virtual nux::Color BackgroundColor() const = 0; |
637 | - |
638 | virtual nux::Color GlowColor() = 0; |
639 | - |
640 | virtual nux::BaseTexture* TextureForSize(int size) = 0; |
641 | |
642 | - virtual nux::BaseTexture* Emblem() = 0; |
643 | + virtual unsigned Count() const; |
644 | + virtual nux::BaseTexture* CountTexture(double scale); |
645 | + virtual nux::BaseTexture* Emblem() const; |
646 | |
647 | private: |
648 | std::vector<bool> skip_; |
649 | std::vector<bool> had_emblem_; |
650 | + std::vector<bool> had_count_; |
651 | std::vector<nux::Point3> last_render_center_; |
652 | std::vector<nux::Point3> last_logical_center_; |
653 | std::vector<nux::Vector3> last_rotation_; |
654 | |
655 | === modified file 'unity-shared/TextInput.cpp' |
656 | --- unity-shared/TextInput.cpp 2014-07-28 17:55:19 +0000 |
657 | +++ unity-shared/TextInput.cpp 2014-08-08 15:13:47 +0000 |
658 | @@ -234,9 +234,8 @@ |
659 | gtk_style_context_set_path(style_context, widget_path.get()); |
660 | gtk_style_context_add_class(style_context, "tooltip"); |
661 | |
662 | - glib::Object<PangoLayout> layout; |
663 | - glib::Object<PangoContext> context(gdk_pango_context_get_for_screen(gdk_screen_get_default())); |
664 | - layout = pango_layout_new(context); |
665 | + glib::Object<PangoContext> context(gdk_pango_context_get()); |
666 | + glib::Object<PangoLayout> layout(pango_layout_new(context)); |
667 | |
668 | std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free); |
669 | pango_context_set_font_description(context, desc.get()); |
PASSED: Continuous integration, rev:3852 jenkins. qa.ubuntu. com/job/ unity-ci/ 1054/ jenkins. qa.ubuntu. com/job/ unity-utopic- amd64-ci/ 141 jenkins. qa.ubuntu. com/job/ unity-utopic- armhf-ci/ 141 jenkins. qa.ubuntu. com/job/ unity-utopic- i386-ci/ 141
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/1054/ rebuild
http://