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
=== modified file 'hud/HudIconTextureSource.cpp'
--- hud/HudIconTextureSource.cpp 2012-10-29 09:34:54 +0000
+++ hud/HudIconTextureSource.cpp 2014-08-25 23:14:36 +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-25 23:14:36 +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-25 23:14:36 +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-25 23:14:36 +0000
@@ -59,6 +59,9 @@
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_FONT_SIZE = 11;
64const int COUNT_PADDING = 2;
62}65}
6366
64NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon);67NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon);
@@ -69,7 +72,6 @@
69LauncherIcon::LauncherIcon(IconType type)72LauncherIcon::LauncherIcon(IconType type)
70 : _icon_type(type)73 : _icon_type(type)
71 , _sticky(false)74 , _sticky(false)
72 , _remote_urgent(false)
73 , _present_urgency(0)75 , _present_urgency(0)
74 , _progress(0.0f)76 , _progress(0.0f)
75 , _sort_priority(DefaultPriority(type))77 , _sort_priority(DefaultPriority(type))
@@ -99,6 +101,8 @@
99 mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));101 mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));
100 mouse_up.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseUp));102 mouse_up.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseUp));
101 mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick));103 mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick));
104 Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &LauncherIcon::CleanCountTextures));
105 icon_size.changed.connect(sigc::hide(sigc::mem_fun(this, &LauncherIcon::CleanCountTextures)));
102106
103 for (unsigned i = 0; i < monitors::MAX; ++i)107 for (unsigned i = 0; i < monitors::MAX; ++i)
104 {108 {
@@ -966,14 +970,42 @@
966 return result;970 return result;
967}971}
968972
969nux::BaseTexture*973nux::BaseTexture* LauncherIcon::Emblem() const
970LauncherIcon::Emblem()
971{974{
972 return _emblem.GetPointer();975 return _emblem.GetPointer();
973}976}
974977
975void978nux::BaseTexture* LauncherIcon::CountTexture(double scale)
976LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem)979{
980 int count = Count();
981
982 if (!count)
983 return nullptr;
984
985 auto it = _counts.find(scale);
986
987 if (it != _counts.end())
988 return it->second.GetPointer();
989
990 auto const& texture = DrawCountTexture(count, scale);
991 _counts[scale] = texture;
992 return texture.GetPointer();
993}
994
995unsigned LauncherIcon::Count() const
996{
997 if (!_remote_entries.empty())
998 {
999 auto const& remote = _remote_entries.front();
1000
1001 if (remote->CountVisible())
1002 return remote->Count();
1003 }
1004
1005 return 0;
1006}
1007
1008void LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem)
977{1009{
978 _emblem = emblem;1010 _emblem = emblem;
979 EmitNeedsRedraw();1011 EmitNeedsRedraw();
@@ -994,56 +1026,41 @@
994 emblem->UnReference();1026 emblem->UnReference();
995}1027}
9961028
997void1029void LauncherIcon::CleanCountTextures()
998LauncherIcon::SetEmblemText(std::string const& text)1030{
999{1031 _counts.clear();
1000 PangoLayout* layout = NULL;1032}
10011033
1002 PangoContext* pangoCtx = NULL;1034BaseTexturePtr LauncherIcon::DrawCountTexture(unsigned count, double scale)
1003 PangoFontDescription* desc = NULL;1035{
1004 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed1036 glib::Object<PangoContext> pango_ctx(gdk_pango_context_get());
1005 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed1037 glib::Object<PangoLayout> layout(pango_layout_new(pango_ctx));
1006 gchar* fontName = NULL;1038
10071039 glib::String font_name;
1008 int width = 32;1040 g_object_get(gtk_settings_get_default(), "gtk-font-name", &font_name, nullptr);
1009 int height = 8 * 2;1041 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);
1010 int font_height = height - 5;1042 pango_font_description_set_absolute_size(desc.get(), pango_units_from_double(COUNT_FONT_SIZE));
10111043 pango_layout_set_font_description(layout, desc.get());
10121044
1013 nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height);1045 pango_layout_set_width(layout, pango_units_from_double(icon_size() * 0.75));
1046 pango_layout_set_height(layout, -1);
1047 pango_layout_set_wrap(layout, PANGO_WRAP_CHAR);
1048 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_MIDDLE);
1049 pango_layout_set_markup_with_accel(layout, std::to_string(count).c_str(), -1, '_', nullptr);
1050
1051 PangoRectangle ink_rect;
1052 pango_layout_get_pixel_extents(layout, &ink_rect, nullptr);
1053
1054 /* DRAW OUTLINE */
1055 const float height = ink_rect.height + COUNT_PADDING * 4;
1056 const float inset = height / 2.0;
1057 const float radius = inset - 1.0f;
1058 const float width = ink_rect.width + inset + COUNT_PADDING * 2;
1059
1060 nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, std::round(width * scale), std::round(height * scale));
1061 cairo_surface_set_device_scale(cg.GetSurface(), scale, scale);
1014 cairo_t* cr = cg.GetInternalContext();1062 cairo_t* cr = cg.GetInternalContext();
10151063
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);
1033 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
1034 pango_layout_set_markup_with_accel(layout, text.c_str(), -1, '_', NULL);
1035
1036 pangoCtx = pango_layout_get_context(layout); // is not ref'ed
1037 pango_cairo_context_set_font_options(pangoCtx,
1038 gdk_screen_get_font_options(screen));
1039
1040 PangoRectangle logical_rect, ink_rect;
1041 pango_layout_get_extents(layout, &logical_rect, &ink_rect);
1042
1043 /* DRAW OUTLINE */
1044 float radius = height / 2.0f - 1.0f;
1045 float inset = radius + 1.0f;
1046
1047 cairo_move_to(cr, inset, height - 1.0f);1064 cairo_move_to(cr, inset, height - 1.0f);
1048 cairo_arc(cr, inset, inset, radius, 0.5 * M_PI, 1.5 * M_PI);1065 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);1066 cairo_arc(cr, width - inset, inset, radius, 1.5 * M_PI, 0.5 * M_PI);
@@ -1059,16 +1076,11 @@
1059 cairo_set_line_width(cr, 1.0f);1076 cairo_set_line_width(cr, 1.0f);
10601077
1061 /* DRAW TEXT */1078 /* DRAW TEXT */
1062 cairo_move_to(cr,1079 cairo_move_to(cr, (width - ink_rect.width) / 2.0 - ink_rect.x,
1063 (int)((width - pango_units_to_double(logical_rect.width)) / 2.0f),1080 (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);1081 pango_cairo_show_layout(cr, layout);
10661082
1067 SetEmblem(texture_ptr_from_cairo_graphics(cg));1083 return texture_ptr_from_cairo_graphics(cg);
1068
1069 // clean up
1070 g_object_unref(layout);
1071 g_free(fontName);
1072}1084}
10731085
1074void1086void
@@ -1077,26 +1089,34 @@
1077 SetEmblem(BaseTexturePtr());1089 SetEmblem(BaseTexturePtr());
1078}1090}
10791091
1080void1092void LauncherIcon::InsertEntryRemote(LauncherEntryRemote::Ptr const& remote)
1081LauncherIcon::InsertEntryRemote(LauncherEntryRemote::Ptr const& remote)
1082{1093{
1083 if (std::find(_entry_list.begin(), _entry_list.end(), remote) != _entry_list.end())1094 if (!remote || std::find(_remote_entries.begin(), _remote_entries.end(), remote) != _remote_entries.end())
1084 return;1095 return;
10851096
1086 _entry_list.push_front(remote);1097 _remote_entries.push_back(remote);
1087 AddChild(remote.get());1098 AddChild(remote.get());
10881099 SelectEntryRemote(remote);
1089 remote->emblem_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemChanged));1100}
1090 remote->count_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountChanged));1101
1091 remote->progress_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressChanged));1102void LauncherIcon::SelectEntryRemote(LauncherEntryRemote::Ptr const& remote)
1092 remote->quicklist_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteQuicklistChanged));1103{
10931104 if (!remote)
1094 remote->emblem_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemVisibleChanged));1105 return;
1095 remote->count_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountVisibleChanged));1106
1096 remote->progress_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressVisibleChanged));1107 auto& cm = _remote_connections;
10971108 cm.Clear();
1098 remote->urgent_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteUrgentChanged));1109
10991110 cm.Add(remote->emblem_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemChanged)));
1111 cm.Add(remote->count_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountChanged)));
1112 cm.Add(remote->progress_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressChanged)));
1113 cm.Add(remote->quicklist_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteQuicklistChanged)));
1114
1115 cm.Add(remote->emblem_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteEmblemVisibleChanged)));
1116 cm.Add(remote->count_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteCountVisibleChanged)));
1117 cm.Add(remote->progress_visible_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteProgressVisibleChanged)));
1118
1119 cm.Add(remote->urgent_changed.connect(sigc::mem_fun(this, &LauncherIcon::OnRemoteUrgentChanged)));
11001120
1101 if (remote->EmblemVisible())1121 if (remote->EmblemVisible())
1102 OnRemoteEmblemVisibleChanged(remote.get());1122 OnRemoteEmblemVisibleChanged(remote.get());
@@ -1113,28 +1133,30 @@
1113 OnRemoteQuicklistChanged(remote.get());1133 OnRemoteQuicklistChanged(remote.get());
1114}1134}
11151135
1116void1136void LauncherIcon::RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote)
1117LauncherIcon::RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote)
1118{1137{
1119 if (std::find(_entry_list.begin(), _entry_list.end(), remote) == _entry_list.end())1138 auto remote_it = std::find(_remote_entries.begin(), _remote_entries.end(), remote);
1139
1140 if (remote_it == _remote_entries.end())
1120 return;1141 return;
11211142
1122 _entry_list.remove(remote);1143 SetQuirk(Quirk::PROGRESS, false);
1144
1145 if (remote->Urgent())
1146 SetQuirk(Quirk::URGENT, false);
1147
1148 _remote_entries.erase(remote_it);
1123 RemoveChild(remote.get());1149 RemoveChild(remote.get());
1124
1125 DeleteEmblem();1150 DeleteEmblem();
1126 SetQuirk(Quirk::PROGRESS, false);
1127
1128 if (_remote_urgent)
1129 SetQuirk(Quirk::URGENT, false);
1130
1131 _remote_menus = nullptr;1151 _remote_menus = nullptr;
1152
1153 if (!_remote_entries.empty())
1154 SelectEntryRemote(_remote_entries.back());
1132}1155}
11331156
1134void1157void
1135LauncherIcon::OnRemoteUrgentChanged(LauncherEntryRemote* remote)1158LauncherIcon::OnRemoteUrgentChanged(LauncherEntryRemote* remote)
1136{1159{
1137 _remote_urgent = remote->Urgent();
1138 SetQuirk(Quirk::URGENT, remote->Urgent());1160 SetQuirk(Quirk::URGENT, remote->Urgent());
1139}1161}
11401162
@@ -1153,14 +1175,8 @@
1153 if (!remote->CountVisible())1175 if (!remote->CountVisible())
1154 return;1176 return;
11551177
1156 if (remote->Count() / 10000 != 0)1178 CleanCountTextures();
1157 {1179 EmitNeedsRedraw();
1158 SetEmblemText("****");
1159 }
1160 else
1161 {
1162 SetEmblemText(std::to_string(remote->Count()));
1163 }
1164}1180}
11651181
1166void1182void
@@ -1190,14 +1206,8 @@
1190void1206void
1191LauncherIcon::OnRemoteCountVisibleChanged(LauncherEntryRemote* remote)1207LauncherIcon::OnRemoteCountVisibleChanged(LauncherEntryRemote* remote)
1192{1208{
1193 if (remote->CountVisible())1209 CleanCountTextures();
1194 {1210 EmitNeedsRedraw();
1195 SetEmblemText(std::to_string(remote->Count()));
1196 }
1197 else
1198 {
1199 DeleteEmblem();
1200 }
1201}1211}
12021212
1203void1213void
12041214
=== modified file 'launcher/LauncherIcon.h'
--- launcher/LauncherIcon.h 2014-05-28 09:56:00 +0000
+++ launcher/LauncherIcon.h 2014-08-25 23:14:36 +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-25 23:14:36 +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-25 23:14:36 +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-25 23:14:36 +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-25 23:14:36 +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-25 23:14:36 +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() == launcher_icon->LastCount(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());
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-25 23:14:36 +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 , last_count_(RENDERERS_SIZE, 0)
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, unsigned count)
96{
97 last_count_[monitor] = count;
98}
99
100unsigned IconTextureSource::LastCount(int monitor) const
101{
102 return last_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-25 23:14:36 +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, unsigned count);
66 unsigned LastCount(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<unsigned> last_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-08-11 12:30:29 +0000
+++ unity-shared/TextInput.cpp 2014-08-25 23:14:36 +0000
@@ -262,9 +262,8 @@
262 gtk_style_context_set_path(style_context, widget_path.get());262 gtk_style_context_set_path(style_context, widget_path.get());
263 gtk_style_context_add_class(style_context, "tooltip");263 gtk_style_context_add_class(style_context, "tooltip");
264264
265 glib::Object<PangoLayout> layout;265 glib::Object<PangoContext> context(gdk_pango_context_get());
266 glib::Object<PangoContext> context(gdk_pango_context_get_for_screen(gdk_screen_get_default()));266 glib::Object<PangoLayout> layout(pango_layout_new(context));
267 layout = pango_layout_new(context);
268267
269 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);268 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);
270 pango_context_set_font_description(context, desc.get());269 pango_context_set_font_description(context, desc.get());