Merge lp:~3v1n0/unity/icons-emblem-scaling into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: 3856
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
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

To post a comment you must log in.
lp:~3v1n0/unity/icons-emblem-scaling updated
3853. By Marco Trevisan (Treviño)

LauncherIcon: just use pixel ink size to position the count number

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~3v1n0/unity/icons-emblem-scaling updated
3854. By Marco Trevisan (Treviño)

LauncherIcon: set the scaling based on the icon size as well

3855. By Marco Trevisan (Treviño)

LauncherIcon: build scaled icon texture on IconRenderer request

In this way we can scale also switcher icons with a different scale value than the one used
by the launcher.

3856. By Marco Trevisan (Treviño)

IconRenderer: Use smaller sized emblem for Switcher icons

Revision history for this message
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.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hud/HudIconTextureSource.cpp'
--- hud/HudIconTextureSource.cpp 2012-10-29 09:34:54 +0000
+++ hud/HudIconTextureSource.cpp 2014-08-08 15:13:47 +0000
@@ -109,11 +109,6 @@
109 return nux::Color(0.0f, 0.0f, 0.0f, 0.0f); 109 return nux::Color(0.0f, 0.0f, 0.0f, 0.0f);
110}110}
111111
112nux::BaseTexture* HudIconTextureSource::Emblem()
113{
114 return nullptr;
115}
116
117}112}
118}113}
119114
120115
=== modified file 'hud/HudIconTextureSource.h'
--- hud/HudIconTextureSource.h 2013-11-06 11:21:43 +0000
+++ hud/HudIconTextureSource.h 2014-08-08 15:13:47 +0000
@@ -37,7 +37,6 @@
37 virtual nux::Color BackgroundColor() const;37 virtual nux::Color BackgroundColor() const;
38 virtual nux::BaseTexture* TextureForSize(int size);38 virtual nux::BaseTexture* TextureForSize(int size);
39 virtual nux::Color GlowColor();39 virtual nux::Color GlowColor();
40 virtual nux::BaseTexture* Emblem();
41 void ColorForIcon(GdkPixbuf* pixbuf);40 void ColorForIcon(GdkPixbuf* pixbuf);
42 41
43private:42private:
4443
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2014-07-17 18:33:37 +0000
+++ launcher/Launcher.cpp 2014-08-08 15:13:47 +0000
@@ -1219,6 +1219,7 @@
1219 Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_height), monitor_geo.height - panel_height);1219 Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_height), monitor_geo.height - panel_height);
12201220
1221 icon_renderer_->monitor = new_monitor;1221 icon_renderer_->monitor = new_monitor;
1222 icon_renderer_->scale = cv_->DPIScale();
1222 SetIconSize(options()->tile_size, options()->icon_size);1223 SetIconSize(options()->tile_size, options()->icon_size);
1223}1224}
12241225
@@ -1519,7 +1520,6 @@
1519 ui::IconRenderer::DestroyShortcutTextures();1520 ui::IconRenderer::DestroyShortcutTextures();
15201521
1521 icon_size_ = tile_size;1522 icon_size_ = tile_size;
1522 icon_renderer_->scale = cv_->DPIScale();
1523 icon_renderer_->SetTargetSize(icon_size_.CP(cv_), RawPixel(icon_size).CP(cv_), SPACE_BETWEEN_ICONS.CP(cv_));1523 icon_renderer_->SetTargetSize(icon_size_.CP(cv_), RawPixel(icon_size).CP(cv_), SPACE_BETWEEN_ICONS.CP(cv_));
1524 AbstractLauncherIcon::icon_size = icon_size_;1524 AbstractLauncherIcon::icon_size = icon_size_;
15251525
15261526
=== modified file 'launcher/LauncherIcon.cpp'
--- launcher/LauncherIcon.cpp 2014-05-28 12:14:44 +0000
+++ launcher/LauncherIcon.cpp 2014-08-08 15:13:47 +0000
@@ -59,6 +59,11 @@
59const std::string CENTER_STABILIZE_TIMEOUT = "center-stabilize-timeout";59const std::string CENTER_STABILIZE_TIMEOUT = "center-stabilize-timeout";
60const std::string PRESENT_TIMEOUT = "present-timeout";60const std::string PRESENT_TIMEOUT = "present-timeout";
61const std::string QUIRK_DELAY_TIMEOUT = "quirk-delay-timeout";61const std::string QUIRK_DELAY_TIMEOUT = "quirk-delay-timeout";
62
63const int COUNT_WIDTH = 32;
64const int COUNT_HEIGHT = 16;
65const int COUNT_FONT_WIDTH = COUNT_WIDTH - 4;
66const int COUNT_FONT_HEIGHT = COUNT_HEIGHT - 5;
62}67}
6368
64NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon);69NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon);
@@ -69,7 +74,6 @@
69LauncherIcon::LauncherIcon(IconType type)74LauncherIcon::LauncherIcon(IconType type)
70 : _icon_type(type)75 : _icon_type(type)
71 , _sticky(false)76 , _sticky(false)
72 , _remote_urgent(false)
73 , _present_urgency(0)77 , _present_urgency(0)
74 , _progress(0.0f)78 , _progress(0.0f)
75 , _sort_priority(DefaultPriority(type))79 , _sort_priority(DefaultPriority(type))
@@ -99,6 +103,8 @@
99 mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));103 mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));
100 mouse_up.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseUp));104 mouse_up.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseUp));
101 mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick));105 mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick));
106 Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &LauncherIcon::CleanCountTextures));
107 icon_size.changed.connect(sigc::hide(sigc::mem_fun(this, &LauncherIcon::CleanCountTextures)));
102108
103 for (unsigned i = 0; i < monitors::MAX; ++i)109 for (unsigned i = 0; i < monitors::MAX; ++i)
104 {110 {
@@ -966,14 +972,42 @@
966 return result;972 return result;
967}973}
968974
969nux::BaseTexture*975nux::BaseTexture* LauncherIcon::Emblem() const
970LauncherIcon::Emblem()
971{976{
972 return _emblem.GetPointer();977 return _emblem.GetPointer();
973}978}
974979
975void980nux::BaseTexture* LauncherIcon::CountTexture(double scale)
976LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem)981{
982 int count = Count();
983
984 if (!count)
985 return nullptr;
986
987 auto it = _counts.find(scale);
988
989 if (it != _counts.end())
990 return it->second.GetPointer();
991
992 auto const& texture = DrawCountTexture(count, scale);
993 _counts[scale] = texture;
994 return texture.GetPointer();
995}
996
997unsigned LauncherIcon::Count() const
998{
999 if (!_remote_entries.empty())
1000 {
1001 auto const& remote = _remote_entries.front();
1002
1003 if (remote->CountVisible())
1004 return remote->Count();
1005 }
1006
1007 return 0;
1008}
1009
1010void LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem)
977{1011{
978 _emblem = emblem;1012 _emblem = emblem;
979 EmitNeedsRedraw();1013 EmitNeedsRedraw();
@@ -994,60 +1028,44 @@
994 emblem->UnReference();1028 emblem->UnReference();
995}1029}
9961030
997void1031void LauncherIcon::CleanCountTextures()
998LauncherIcon::SetEmblemText(std::string const& text)1032{
999{1033 _counts.clear();
1000 PangoLayout* layout = NULL;1034}
10011035
1002 PangoContext* pangoCtx = NULL;1036BaseTexturePtr LauncherIcon::DrawCountTexture(unsigned count, double scale)
1003 PangoFontDescription* desc = NULL;1037{
1004 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed1038 auto const& count_text = (count / 10000 != 0) ? "****" : std::to_string(count);
1005 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed1039
1006 gchar* fontName = NULL;1040 glib::Object<PangoContext> pango_ctx(gdk_pango_context_get());
10071041 glib::Object<PangoLayout> layout(pango_layout_new(pango_ctx));
1008 int width = 32;1042
1009 int height = 8 * 2;1043 glib::String font_name;
1010 int font_height = height - 5;1044 g_object_get(gtk_settings_get_default(), "gtk-font-name", &font_name, nullptr);
10111045 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);
10121046 pango_font_description_set_absolute_size(desc.get(), pango_units_from_double(COUNT_FONT_HEIGHT));
1013 nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height);1047 pango_layout_set_font_description(layout, desc.get());
1014 cairo_t* cr = cg.GetInternalContext();1048
10151049 pango_layout_set_width(layout, pango_units_from_double(COUNT_FONT_WIDTH));
1016 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
1017 cairo_paint(cr);
1018
1019 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
1020
1021
1022 layout = pango_cairo_create_layout(cr);
1023
1024 g_object_get(settings, "gtk-font-name", &fontName, NULL);
1025 desc = pango_font_description_from_string(fontName);
1026 pango_font_description_set_absolute_size(desc, pango_units_from_double(font_height));
1027
1028 pango_layout_set_font_description(layout, desc);
1029 pango_font_description_free(desc);
1030
1031 pango_layout_set_width(layout, pango_units_from_double(width - 4.0f));
1032 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);1050 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
1033 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);1051 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
1034 pango_layout_set_markup_with_accel(layout, text.c_str(), -1, '_', NULL);1052 pango_layout_set_markup_with_accel(layout, count_text.c_str(), -1, '_', nullptr);
10351053
1036 pangoCtx = pango_layout_get_context(layout); // is not ref'ed1054 PangoRectangle ink_rect;
1037 pango_cairo_context_set_font_options(pangoCtx,1055 pango_layout_get_pixel_extents(layout, &ink_rect, nullptr);
1038 gdk_screen_get_font_options(screen));
1039
1040 PangoRectangle logical_rect, ink_rect;
1041 pango_layout_get_extents(layout, &logical_rect, &ink_rect);
10421056
1043 /* DRAW OUTLINE */1057 /* DRAW OUTLINE */
1044 float radius = height / 2.0f - 1.0f;1058 float radius = COUNT_HEIGHT / 2.0f - 1.0f;
1045 float inset = radius + 1.0f;1059 float inset = radius + 1.0f;
10461060
1047 cairo_move_to(cr, inset, height - 1.0f);1061 nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, std::round(COUNT_WIDTH * scale), std::round(COUNT_HEIGHT * scale));
1062 cairo_surface_set_device_scale(cg.GetSurface(), scale, scale);
1063 cairo_t* cr = cg.GetInternalContext();
1064
1065 cairo_move_to(cr, inset, COUNT_HEIGHT - 1.0f);
1048 cairo_arc(cr, inset, inset, radius, 0.5 * M_PI, 1.5 * M_PI);1066 cairo_arc(cr, inset, inset, radius, 0.5 * M_PI, 1.5 * M_PI);
1049 cairo_arc(cr, width - inset, inset, radius, 1.5 * M_PI, 0.5 * M_PI);1067 cairo_arc(cr, COUNT_WIDTH - inset, inset, radius, 1.5 * M_PI, 0.5 * M_PI);
1050 cairo_line_to(cr, inset, height - 1.0f);1068 cairo_line_to(cr, inset, COUNT_HEIGHT - 1.0f);
10511069
1052 cairo_set_source_rgba(cr, 0.35f, 0.35f, 0.35f, 1.0f);1070 cairo_set_source_rgba(cr, 0.35f, 0.35f, 0.35f, 1.0f);
1053 cairo_fill_preserve(cr);1071 cairo_fill_preserve(cr);
@@ -1059,16 +1077,11 @@
1059 cairo_set_line_width(cr, 1.0f);1077 cairo_set_line_width(cr, 1.0f);
10601078
1061 /* DRAW TEXT */1079 /* DRAW TEXT */
1062 cairo_move_to(cr,1080 cairo_move_to(cr, (COUNT_WIDTH - ink_rect.width) / 2.0 - ink_rect.x,
1063 (int)((width - pango_units_to_double(logical_rect.width)) / 2.0f),1081 (COUNT_HEIGHT - ink_rect.height) / 2.0 - ink_rect.y);
1064 (int)((height - pango_units_to_double(logical_rect.height)) / 2.0f - pango_units_to_double(logical_rect.y)));
1065 pango_cairo_show_layout(cr, layout);1082 pango_cairo_show_layout(cr, layout);
10661083
1067 SetEmblem(texture_ptr_from_cairo_graphics(cg));1084 return texture_ptr_from_cairo_graphics(cg);
1068
1069 // clean up
1070 g_object_unref(layout);
1071 g_free(fontName);
1072}1085}
10731086
1074void1087void
@@ -1077,26 +1090,34 @@
1077 SetEmblem(BaseTexturePtr());1090 SetEmblem(BaseTexturePtr());
1078}1091}
10791092
1080void1093void LauncherIcon::InsertEntryRemote(LauncherEntryRemote::Ptr const& remote)
1081LauncherIcon::InsertEntryRemote(LauncherEntryRemote::Ptr const& remote)
1082{1094{
1083 if (std::find(_entry_list.begin(), _entry_list.end(), remote) != _entry_list.end())1095 if (!remote || std::find(_remote_entries.begin(), _remote_entries.end(), remote) != _remote_entries.end())
1084 return;1096 return;
10851097
1086 _entry_list.push_front(remote);1098 _remote_entries.push_back(remote);
1087 AddChild(remote.get());1099 AddChild(remote.get());
10881100 SelectEntryRemote(remote);
1089 remote->emblem_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemChanged));1101}
1090 remote->count_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountChanged));1102
1091 remote->progress_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressChanged));1103void LauncherIcon::SelectEntryRemote(LauncherEntryRemote::Ptr const& remote)
1092 remote->quicklist_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteQuicklistChanged));1104{
10931105 if (!remote)
1094 remote->emblem_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemVisibleChanged));1106 return;
1095 remote->count_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountVisibleChanged));1107
1096 remote->progress_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressVisibleChanged));1108 auto& cm = _remote_connections;
10971109 cm.Clear();
1098 remote->urgent_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteUrgentChanged));1110
10991111 cm.Add(remote->emblem_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemChanged)));
1112 cm.Add(remote->count_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountChanged)));
1113 cm.Add(remote->progress_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressChanged)));
1114 cm.Add(remote->quicklist_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteQuicklistChanged)));
1115
1116 cm.Add(remote->emblem_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemVisibleChanged)));
1117 cm.Add(remote->count_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountVisibleChanged)));
1118 cm.Add(remote->progress_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressVisibleChanged)));
1119
1120 cm.Add(remote->urgent_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteUrgentChanged)));
11001121
1101 if (remote->EmblemVisible())1122 if (remote->EmblemVisible())
1102 OnRemoteEmblemVisibleChanged(remote.get());1123 OnRemoteEmblemVisibleChanged(remote.get());
@@ -1113,28 +1134,30 @@
1113 OnRemoteQuicklistChanged(remote.get());1134 OnRemoteQuicklistChanged(remote.get());
1114}1135}
11151136
1116void1137void LauncherIcon::RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote)
1117LauncherIcon::RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote)
1118{1138{
1119 if (std::find(_entry_list.begin(), _entry_list.end(), remote) == _entry_list.end())1139 auto remote_it = std::find(_remote_entries.begin(), _remote_entries.end(), remote);
1140
1141 if (remote_it == _remote_entries.end())
1120 return;1142 return;
11211143
1122 _entry_list.remove(remote);1144 SetQuirk(Quirk::PROGRESS, false);
1145
1146 if (remote->Urgent())
1147 SetQuirk(Quirk::URGENT, false);
1148
1149 _remote_entries.erase(remote_it);
1123 RemoveChild(remote.get());1150 RemoveChild(remote.get());
1124
1125 DeleteEmblem();1151 DeleteEmblem();
1126 SetQuirk(Quirk::PROGRESS, false);
1127
1128 if (_remote_urgent)
1129 SetQuirk(Quirk::URGENT, false);
1130
1131 _remote_menus = nullptr;1152 _remote_menus = nullptr;
1153
1154 if (!_remote_entries.empty())
1155 SelectEntryRemote(_remote_entries.back());
1132}1156}
11331157
1134void1158void
1135LauncherIcon::OnRemoteUrgentChanged(LauncherEntryRemote* remote)1159LauncherIcon::OnRemoteUrgentChanged(LauncherEntryRemote* remote)
1136{1160{
1137 _remote_urgent = remote->Urgent();
1138 SetQuirk(Quirk::URGENT, remote->Urgent());1161 SetQuirk(Quirk::URGENT, remote->Urgent());
1139}1162}
11401163
@@ -1153,14 +1176,8 @@
1153 if (!remote->CountVisible())1176 if (!remote->CountVisible())
1154 return;1177 return;
11551178
1156 if (remote->Count() / 10000 != 0)1179 CleanCountTextures();
1157 {1180 EmitNeedsRedraw();
1158 SetEmblemText("****");
1159 }
1160 else
1161 {
1162 SetEmblemText(std::to_string(remote->Count()));
1163 }
1164}1181}
11651182
1166void1183void
@@ -1190,14 +1207,8 @@
1190void1207void
1191LauncherIcon::OnRemoteCountVisibleChanged(LauncherEntryRemote* remote)1208LauncherIcon::OnRemoteCountVisibleChanged(LauncherEntryRemote* remote)
1192{1209{
1193 if (remote->CountVisible())1210 CleanCountTextures();
1194 {1211 EmitNeedsRedraw();
1195 SetEmblemText(std::to_string(remote->Count()));
1196 }
1197 else
1198 {
1199 DeleteEmblem();
1200 }
1201}1212}
12021213
1203void1214void
12041215
=== modified file 'launcher/LauncherIcon.h'
--- launcher/LauncherIcon.h 2014-05-28 09:56:00 +0000
+++ launcher/LauncherIcon.h 2014-08-08 15:13:47 +0000
@@ -154,14 +154,15 @@
154 }154 }
155155
156 nux::BaseTexture* TextureForSize(int size);156 nux::BaseTexture* TextureForSize(int size);
157157 nux::BaseTexture* Emblem() const override;
158 nux::BaseTexture* Emblem();158 nux::BaseTexture* CountTexture(double scale) override;
159159
160 MenuItemsVector Menus();160 MenuItemsVector Menus();
161161 unsigned Count() const;
162 void InsertEntryRemote(LauncherEntryRemote::Ptr const& remote);162
163163 void InsertEntryRemote(LauncherEntryRemote::Ptr const&);
164 void RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote);164 void SelectEntryRemote(LauncherEntryRemote::Ptr const&);
165 void RemoveEntryRemote(LauncherEntryRemote::Ptr const&);
165166
166 nux::DndAction QueryAcceptDrop(DndData const& dnd_data)167 nux::DndAction QueryAcceptDrop(DndData const& dnd_data)
167 {168 {
@@ -323,9 +324,10 @@
323 void LoadQuicklist();324 void LoadQuicklist();
324325
325 void OnTooltipEnabledChanged(bool value);326 void OnTooltipEnabledChanged(bool value);
327 void CleanCountTextures();
328 BaseTexturePtr DrawCountTexture(unsigned count, double scale);
326329
327 bool _sticky;330 bool _sticky;
328 bool _remote_urgent;
329 float _present_urgency;331 float _present_urgency;
330 float _progress;332 float _progress;
331 int _sort_priority;333 int _sort_priority;
@@ -346,8 +348,10 @@
346 time::Spec _last_action;348 time::Spec _last_action;
347349
348 BaseTexturePtr _emblem;350 BaseTexturePtr _emblem;
351 std::unordered_map<double, BaseTexturePtr> _counts;
349352
350 std::list<LauncherEntryRemote::Ptr> _entry_list;353 std::vector<LauncherEntryRemote::Ptr> _remote_entries;
354 connection::Manager _remote_connections;
351 glib::Object<DbusmenuClient> _remote_menus;355 glib::Object<DbusmenuClient> _remote_menus;
352356
353 static glib::Object<GtkIconTheme> _unity_theme;357 static glib::Object<GtkIconTheme> _unity_theme;
354358
=== modified file 'launcher/MockLauncherIcon.h'
--- launcher/MockLauncherIcon.h 2013-12-11 15:03:25 +0000
+++ launcher/MockLauncherIcon.h 2014-08-08 15:13:47 +0000
@@ -329,11 +329,6 @@
329 return icon_;329 return icon_;
330 }330 }
331331
332 nux::BaseTexture* Emblem()
333 {
334 return 0;
335 }
336
337 MenuItemsVector Menus()332 MenuItemsVector Menus()
338 {333 {
339 return MenuItemsVector ();334 return MenuItemsVector ();
340335
=== modified file 'launcher/SwitcherView.cpp'
--- launcher/SwitcherView.cpp 2014-07-15 16:28:45 +0000
+++ launcher/SwitcherView.cpp 2014-08-08 15:13:47 +0000
@@ -76,6 +76,7 @@
76 icon_renderer_->pip_style = OVER_TILE;76 icon_renderer_->pip_style = OVER_TILE;
77 icon_renderer_->monitor = monitors::MAX;77 icon_renderer_->monitor = monitors::MAX;
78 icon_renderer_->SetTargetSize(tile_size, icon_size, minimum_spacing);78 icon_renderer_->SetTargetSize(tile_size, icon_size, minimum_spacing);
79 icon_renderer_->scale = scale();
7980
80 text_view_->SetMaximumWidth(tile_size * TEXT_TILE_MULTIPLIER);81 text_view_->SetMaximumWidth(tile_size * TEXT_TILE_MULTIPLIER);
81 text_view_->SetLines(1);82 text_view_->SetLines(1);
@@ -196,6 +197,7 @@
196 tile_size = TILE_SIZE.CP(scale);197 tile_size = TILE_SIZE.CP(scale);
197 text_size = TEXT_SIZE.CP(scale);198 text_size = TEXT_SIZE.CP(scale);
198 vertical_size = tile_size + VERTICAL_PADDING.CP(scale) * 2;199 vertical_size = tile_size + VERTICAL_PADDING.CP(scale) * 2;
200 icon_renderer_->scale = scale;
199}201}
200202
201void SwitcherView::StartAnimation()203void SwitcherView::StartAnimation()
202204
=== modified file 'panel/PanelIndicatorEntryView.cpp'
--- panel/PanelIndicatorEntryView.cpp 2014-05-30 07:20:13 +0000
+++ panel/PanelIndicatorEntryView.cpp 2014-08-08 15:13:47 +0000
@@ -426,7 +426,7 @@
426 }426 }
427 }427 }
428428
429 glib::Object<PangoContext> context(gdk_pango_context_get_for_screen(gdk_screen_get_default()));429 glib::Object<PangoContext> context(gdk_pango_context_get());
430 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font.c_str()), pango_font_description_free);430 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font.c_str()), pango_font_description_free);
431 pango_context_set_font_description(context, desc.get());431 pango_context_set_font_description(context, desc.get());
432 pango_context_set_language(context, gtk_get_default_language());432 pango_context_set_language(context, gtk_get_default_language());
433433
=== modified file 'unity-shared/DecorationStyle.cpp'
--- unity-shared/DecorationStyle.cpp 2014-06-13 15:22:15 +0000
+++ unity-shared/DecorationStyle.cpp 2014-08-08 15:13:47 +0000
@@ -147,8 +147,8 @@
147 , ctx_(gtk_style_context_new())147 , ctx_(gtk_style_context_new())
148 , settings_(g_settings_new(SETTINGS_NAME.c_str()))148 , settings_(g_settings_new(SETTINGS_NAME.c_str()))
149 , usettings_(g_settings_new(UNITY_SETTINGS_NAME.c_str()))149 , usettings_(g_settings_new(UNITY_SETTINGS_NAME.c_str()))
150 , title_pango_ctx_(gdk_pango_context_get_for_screen(gdk_screen_get_default()))150 , title_pango_ctx_(gdk_pango_context_get())
151 , menu_item_pango_ctx_(gdk_pango_context_get_for_screen(gdk_screen_get_default()))151 , menu_item_pango_ctx_(gdk_pango_context_get())
152 , title_alignment_(0)152 , title_alignment_(0)
153 , title_indent_(0)153 , title_indent_(0)
154 , title_fade_(0)154 , title_fade_(0)
155155
=== modified file 'unity-shared/IconRenderer.cpp'
--- unity-shared/IconRenderer.cpp 2014-05-08 18:52:16 +0000
+++ unity-shared/IconRenderer.cpp 2014-08-08 15:13:47 +0000
@@ -199,6 +199,8 @@
199const std::array<int, IconSize::SIZE> TILE_SIZES = { 54, 150 };199const std::array<int, IconSize::SIZE> TILE_SIZES = { 54, 150 };
200const std::array<int, IconSize::SIZE> GLOW_SIZES = { 62, 200 };200const std::array<int, IconSize::SIZE> GLOW_SIZES = { 62, 200 };
201const std::array<int, IconSize::SIZE> MARKER_SIZES = { 19, 37 };201const std::array<int, IconSize::SIZE> MARKER_SIZES = { 19, 37 };
202
203constexpr double count_scaling(double icon_size, bool switcher) { return icon_size / (TILE_SIZES[local::IconSize::SMALL] * (switcher ? 2.0 : 1.0)); }
202} // anonymous namespace204} // anonymous namespace
203} // local namespace205} // local namespace
204206
@@ -352,6 +354,7 @@
352 GetInverseScreenPerspectiveMatrix(ViewMatrix, ProjectionMatrix, geo.width, geo.height, 0.1f, 1000.0f, DEGTORAD(90));354 GetInverseScreenPerspectiveMatrix(ViewMatrix, ProjectionMatrix, geo.width, geo.height, 0.1f, 1000.0f, DEGTORAD(90));
353355
354 nux::Matrix4 const& PremultMatrix = ProjectionMatrix * ViewMatrix;356 nux::Matrix4 const& PremultMatrix = ProjectionMatrix * ViewMatrix;
357 int monitor = this->monitor();
355358
356 std::list<RenderArg>::iterator it;359 std::list<RenderArg>::iterator it;
357 int i;360 int i;
@@ -363,6 +366,7 @@
363 it->logical_center == launcher_icon->LastLogicalCenter(monitor) &&366 it->logical_center == launcher_icon->LastLogicalCenter(monitor) &&
364 it->rotation == launcher_icon->LastRotation(monitor) &&367 it->rotation == launcher_icon->LastRotation(monitor) &&
365 it->skip == launcher_icon->WasSkipping(monitor) &&368 it->skip == launcher_icon->WasSkipping(monitor) &&
369 (launcher_icon->Count() != 0) == launcher_icon->HadCount(monitor) &&
366 (launcher_icon->Emblem() != nullptr) == launcher_icon->HadEmblem(monitor))370 (launcher_icon->Emblem() != nullptr) == launcher_icon->HadEmblem(monitor))
367 {371 {
368 continue;372 continue;
@@ -372,6 +376,7 @@
372 launcher_icon->RememberRotation(monitor, it->rotation);376 launcher_icon->RememberRotation(monitor, it->rotation);
373 launcher_icon->RememberSkip(monitor, it->skip);377 launcher_icon->RememberSkip(monitor, it->skip);
374 launcher_icon->RememberEmblem(monitor, launcher_icon->Emblem() != nullptr);378 launcher_icon->RememberEmblem(monitor, launcher_icon->Emblem() != nullptr);
379 launcher_icon->RememberCount(monitor, launcher_icon->Count() != 0);
375380
376 float w = icon_size;381 float w = icon_size;
377 float h = icon_size;382 float h = icon_size;
@@ -423,16 +428,26 @@
423428
424 UpdateIconTransform(launcher_icon, ViewProjectionMatrix, geo, x, y, w, h, z, ui::IconTextureSource::TRANSFORM_HIT_AREA);429 UpdateIconTransform(launcher_icon, ViewProjectionMatrix, geo, x, y, w, h, z, ui::IconTextureSource::TRANSFORM_HIT_AREA);
425430
426 if (launcher_icon->Emblem())431 float emb_w, emb_h;
427 {432 nux::BaseTexture* emblem = launcher_icon->Emblem();
428 nux::BaseTexture* emblem = launcher_icon->Emblem();433
429434 if (nux::BaseTexture* count_texture = launcher_icon->CountTexture(local::count_scaling(icon_size, pip_style != OUTSIDE_TILE)))
435 {
436 emblem = count_texture;
437 emb_w = emblem->GetWidth();
438 emb_h = emblem->GetHeight();
439 }
440 else if (emblem)
441 {
442 emb_w = std::round(emblem->GetWidth() * scale());
443 emb_h = std::round(emblem->GetHeight() * scale());
444 }
445
446 if (emblem)
447 {
430 float w = icon_size;448 float w = icon_size;
431 float h = icon_size;449 float h = icon_size;
432450
433 float emb_w = emblem->GetWidth();
434 float emb_h = emblem->GetHeight();
435
436 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 icon451 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
437 y = it->render_center.y - icon_size * 0.50f; // y = top left corner position of emblem452 y = it->render_center.y - icon_size * 0.50f; // y = top left corner position of emblem
438 z = it->render_center.z;453 z = it->render_center.z;
@@ -718,7 +733,18 @@
718 tile_transform);733 tile_transform);
719 }734 }
720735
721 if (arg.icon->Emblem())736 if (nux::BaseTexture* count_texture = arg.icon->CountTexture(local::count_scaling(icon_size, pip_style != OUTSIDE_TILE)))
737 {
738 RenderElement(GfxContext,
739 arg,
740 count_texture->GetDeviceTexture(),
741 nux::color::White,
742 nux::color::White,
743 arg.alpha,
744 force_filter,
745 arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_EMBLEM, monitor));
746 }
747 else if (arg.icon->Emblem())
722 {748 {
723 RenderElement(GfxContext,749 RenderElement(GfxContext,
724 arg,750 arg,
@@ -726,7 +752,7 @@
726 nux::color::White,752 nux::color::White,
727 nux::color::White,753 nux::color::White,
728 arg.alpha,754 arg.alpha,
729 force_filter,755 force_filter || scale != 1.0,
730 arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_EMBLEM, monitor));756 arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_EMBLEM, monitor));
731 }757 }
732758
733759
=== modified file 'unity-shared/IconTextureSource.cpp'
--- unity-shared/IconTextureSource.cpp 2013-10-04 00:46:07 +0000
+++ unity-shared/IconTextureSource.cpp 2014-08-08 15:13:47 +0000
@@ -34,6 +34,7 @@
34IconTextureSource::IconTextureSource()34IconTextureSource::IconTextureSource()
35 : skip_(RENDERERS_SIZE, false)35 : skip_(RENDERERS_SIZE, false)
36 , had_emblem_(RENDERERS_SIZE, false)36 , had_emblem_(RENDERERS_SIZE, false)
37 , had_count_(RENDERERS_SIZE, false)
37 , last_render_center_(RENDERERS_SIZE)38 , last_render_center_(RENDERERS_SIZE)
38 , last_logical_center_(RENDERERS_SIZE)39 , last_logical_center_(RENDERERS_SIZE)
39 , last_rotation_(RENDERERS_SIZE)40 , last_rotation_(RENDERERS_SIZE)
@@ -91,5 +92,30 @@
91 return had_emblem_[monitor];92 return had_emblem_[monitor];
92}93}
9394
95void IconTextureSource::RememberCount(int monitor, bool has_count)
96{
97 had_count_[monitor] = has_count;
98}
99
100bool IconTextureSource::HadCount(int monitor) const
101{
102 return had_count_[monitor];
103}
104
105unsigned IconTextureSource::Count() const
106{
107 return 0;
108}
109
110nux::BaseTexture* IconTextureSource::Emblem() const
111{
112 return nullptr;
113}
114
115nux::BaseTexture* IconTextureSource::CountTexture(double scale)
116{
117 return nullptr;
118}
119
94}120}
95}121}
96\ No newline at end of file122\ No newline at end of file
97123
=== modified file 'unity-shared/IconTextureSource.h'
--- unity-shared/IconTextureSource.h 2013-11-06 11:21:43 +0000
+++ unity-shared/IconTextureSource.h 2014-08-08 15:13:47 +0000
@@ -62,17 +62,21 @@
62 void RememberEmblem(int monitor, bool has_emblem);62 void RememberEmblem(int monitor, bool has_emblem);
63 bool HadEmblem(int monitor) const;63 bool HadEmblem(int monitor) const;
6464
65 void RememberCount(int monitor, bool has_count);
66 bool HadCount(int monitor) const;
67
65 virtual nux::Color BackgroundColor() const = 0;68 virtual nux::Color BackgroundColor() const = 0;
66
67 virtual nux::Color GlowColor() = 0;69 virtual nux::Color GlowColor() = 0;
68
69 virtual nux::BaseTexture* TextureForSize(int size) = 0;70 virtual nux::BaseTexture* TextureForSize(int size) = 0;
7071
71 virtual nux::BaseTexture* Emblem() = 0;72 virtual unsigned Count() const;
73 virtual nux::BaseTexture* CountTexture(double scale);
74 virtual nux::BaseTexture* Emblem() const;
7275
73private:76private:
74 std::vector<bool> skip_;77 std::vector<bool> skip_;
75 std::vector<bool> had_emblem_;78 std::vector<bool> had_emblem_;
79 std::vector<bool> had_count_;
76 std::vector<nux::Point3> last_render_center_;80 std::vector<nux::Point3> last_render_center_;
77 std::vector<nux::Point3> last_logical_center_;81 std::vector<nux::Point3> last_logical_center_;
78 std::vector<nux::Vector3> last_rotation_;82 std::vector<nux::Vector3> last_rotation_;
7983
=== modified file 'unity-shared/TextInput.cpp'
--- unity-shared/TextInput.cpp 2014-07-28 17:55:19 +0000
+++ unity-shared/TextInput.cpp 2014-08-08 15:13:47 +0000
@@ -234,9 +234,8 @@
234 gtk_style_context_set_path(style_context, widget_path.get());234 gtk_style_context_set_path(style_context, widget_path.get());
235 gtk_style_context_add_class(style_context, "tooltip");235 gtk_style_context_add_class(style_context, "tooltip");
236236
237 glib::Object<PangoLayout> layout;237 glib::Object<PangoContext> context(gdk_pango_context_get());
238 glib::Object<PangoContext> context(gdk_pango_context_get_for_screen(gdk_screen_get_default()));238 glib::Object<PangoLayout> layout(pango_layout_new(context));
239 layout = pango_layout_new(context);
240239
241 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);240 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);
242 pango_context_set_font_description(context, desc.get());241 pango_context_set_font_description(context, desc.get());