Merge lp:~3v1n0/unity/adaptive-icon-count into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Superseded
Proposed branch: lp:~3v1n0/unity/adaptive-icon-count
Merge into: lp:unity
Diff against target: 665 lines (+202/-142)
13 files modified
hud/HudIconTextureSource.cpp (+0/-5)
hud/HudIconTextureSource.h (+0/-1)
launcher/Launcher.cpp (+1/-1)
launcher/LauncherIcon.cpp (+114/-104)
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/adaptive-icon-count
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+232143@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-25.

Commit message

LauncherIcon: make the Icon count width depending on the text value width

Description of the change

LauncherIcon: make the Icon count width depending on the text value width

To post a comment you must log in.

Preview Diff

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