Merge lp:~azzar1/unity/fix-1049601 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2876
Proposed branch: lp:~azzar1/unity/fix-1049601
Merge into: lp:unity
Diff against target: 129 lines (+31/-15)
3 files modified
launcher/Launcher.cpp (+4/-0)
unity-shared/IconRenderer.cpp (+25/-14)
unity-shared/IconRenderer.h (+2/-1)
To merge this branch: bzr merge lp:~azzar1/unity/fix-1049601
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
John Lea (community) design Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+132167@code.launchpad.net

Commit message

Update shortcut overlay visual design.

Description of the change

== Problem ==
Launcher - The shortcut overlays that are displayed on top of Launcher icons when the SUPER key is held down need to use the correct assets, and be tinted with the average background colour.

== Test ==
Not applicable: visual change.

Screenshot: https://bugs.launchpad.net/unity/+bug/1049601/+attachment/3418861/+files/launcher_shortcuts.png

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Check if you can use a map of smart pointers for the textures without being too invasive, also it would be nice if you'd use an auto const& in the foreach... Anyway overall this is already fine for me.

review: Approve
Revision history for this message
John Lea (johnlea) :
review: Approve (design)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
No commit message was specified.

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

FAILED: Autolanding.
No commit message was specified.

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.cpp'
2--- launcher/Launcher.cpp 2012-10-29 09:34:54 +0000
3+++ launcher/Launcher.cpp 2012-10-30 16:46:32 +0000
4@@ -1163,6 +1163,8 @@
5
6 void Launcher::OnBGColorChanged(GVariant *data)
7 {
8+ ui::IconRenderer::DestroyShortcutTextures();
9+
10 double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
11
12 g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
13@@ -1607,6 +1609,8 @@
14
15 void Launcher::SetIconSize(int tile_size, int icon_size)
16 {
17+ ui::IconRenderer::DestroyShortcutTextures();
18+
19 _icon_size = tile_size;
20 _icon_image_size = icon_size;
21 _icon_image_size_delta = tile_size - icon_size;
22
23=== modified file 'unity-shared/IconRenderer.cpp'
24--- unity-shared/IconRenderer.cpp 2012-10-17 22:13:25 +0000
25+++ unity-shared/IconRenderer.cpp 2012-10-30 16:46:32 +0000
26@@ -414,6 +414,8 @@
27 nux::BaseTexture* shine = local::icon_shine[size];
28 nux::BaseTexture* shadow = local::icon_shadow[size];
29
30+ nux::Color shortcut_color = arg.colorify;
31+
32 bool force_filter = icon_size != background->GetWidth();
33
34 if (backlight_intensity == 0.0f)
35@@ -632,7 +634,7 @@
36 char shortcut = (char) arg.shortcut_label;
37
38 if (local::label_map.find(shortcut) == local::label_map.end())
39- local::label_map[shortcut] = RenderCharToTexture(shortcut, icon_size, icon_size);
40+ local::label_map[shortcut] = RenderCharToTexture(shortcut, icon_size, icon_size, shortcut_color);
41
42 RenderElement(GfxContext,
43 arg,
44@@ -645,7 +647,7 @@
45 }
46 }
47
48-nux::BaseTexture* IconRenderer::RenderCharToTexture(const char label, int width, int height)
49+nux::BaseTexture* IconRenderer::RenderCharToTexture(char label, int width, int height, nux::Color const& bg_color)
50 {
51 nux::BaseTexture* texture = NULL;
52 nux::CairoGraphics* cg = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32,
53@@ -657,22 +659,26 @@
54 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
55 gchar* fontName = NULL;
56
57- double label_pos = double(icon_size / 3.0f);
58- double text_size = double(icon_size / 4.0f);
59- double label_x = label_pos;
60- double label_y = label_pos;
61- double label_w = label_pos;
62- double label_h = label_pos;
63- double label_r = 3.0f;
64+ double label_ratio = 0.44f;
65+ double label_size = icon_size * label_ratio;
66+ double label_x = (icon_size - label_size) / 2;
67+ double label_y = (icon_size - label_size) / 2;
68+ double label_w = label_size;
69+ double label_h = label_size;
70+ double label_radius = 3.0f;
71
72 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
73 cairo_paint(cr);
74 cairo_scale(cr, 1.0f, 1.0f);
75 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
76- cg->DrawRoundedRectangle(cr, 1.0f, label_x, label_y, label_r, label_w, label_h);
77- cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.65f);
78+ cg->DrawRoundedRectangle(cr, 1.0f, label_x, label_y, label_radius, label_w, label_h);
79+ cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.75f);
80+ cairo_fill_preserve(cr);
81+ cairo_set_source_rgba(cr, bg_color.red, bg_color.green, bg_color.blue, 0.20f);
82 cairo_fill(cr);
83
84+ double text_ratio = 0.75;
85+ double text_size = label_size * text_ratio;
86 layout = pango_cairo_create_layout(cr);
87 g_object_get(settings, "gtk-font-name", &fontName, NULL);
88 desc = pango_font_description_from_string(fontName);
89@@ -1049,6 +1055,13 @@
90 local::destroy_textures();
91 }
92
93+void IconRenderer::DestroyShortcutTextures()
94+{
95+ for (auto texture : local::label_map)
96+ texture.second->UnReference();
97+ local::label_map.clear();
98+}
99+
100 void IconRenderer::GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,
101 int ViewportWidth,
102 int ViewportHeight,
103@@ -1287,9 +1300,7 @@
104 squircle_shadow->UnReference();
105 squircle_shine->UnReference();
106
107- for (auto it = label_map.begin(), end = label_map.end(); it != end; ++it)
108- it->second->UnReference();
109- label_map.clear();
110+ IconRenderer::DestroyShortcutTextures();
111
112 textures_created = false;
113 }
114
115=== modified file 'unity-shared/IconRenderer.h'
116--- unity-shared/IconRenderer.h 2012-10-11 20:01:44 +0000
117+++ unity-shared/IconRenderer.h 2012-10-30 16:46:32 +0000
118@@ -46,9 +46,10 @@
119 void SetTargetSize(int tile_size, int image_size, int spacing);
120
121 static void DestroyTextures();
122+ static void DestroyShortcutTextures();
123
124 protected:
125- nux::BaseTexture* RenderCharToTexture(const char label, int width, int height);
126+ nux::BaseTexture* RenderCharToTexture(char label, int width, int height, nux::Color const& bg_color);
127
128 void RenderElement(nux::GraphicsEngine& GfxContext,
129 RenderArg const& arg,