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
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2012-10-29 09:34:54 +0000
+++ launcher/Launcher.cpp 2012-10-30 16:46:32 +0000
@@ -1163,6 +1163,8 @@
11631163
1164void Launcher::OnBGColorChanged(GVariant *data)1164void Launcher::OnBGColorChanged(GVariant *data)
1165{1165{
1166 ui::IconRenderer::DestroyShortcutTextures();
1167
1166 double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;1168 double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
11671169
1168 g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);1170 g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
@@ -1607,6 +1609,8 @@
16071609
1608void Launcher::SetIconSize(int tile_size, int icon_size)1610void Launcher::SetIconSize(int tile_size, int icon_size)
1609{1611{
1612 ui::IconRenderer::DestroyShortcutTextures();
1613
1610 _icon_size = tile_size;1614 _icon_size = tile_size;
1611 _icon_image_size = icon_size;1615 _icon_image_size = icon_size;
1612 _icon_image_size_delta = tile_size - icon_size;1616 _icon_image_size_delta = tile_size - icon_size;
16131617
=== modified file 'unity-shared/IconRenderer.cpp'
--- unity-shared/IconRenderer.cpp 2012-10-17 22:13:25 +0000
+++ unity-shared/IconRenderer.cpp 2012-10-30 16:46:32 +0000
@@ -414,6 +414,8 @@
414 nux::BaseTexture* shine = local::icon_shine[size];414 nux::BaseTexture* shine = local::icon_shine[size];
415 nux::BaseTexture* shadow = local::icon_shadow[size];415 nux::BaseTexture* shadow = local::icon_shadow[size];
416416
417 nux::Color shortcut_color = arg.colorify;
418
417 bool force_filter = icon_size != background->GetWidth();419 bool force_filter = icon_size != background->GetWidth();
418420
419 if (backlight_intensity == 0.0f)421 if (backlight_intensity == 0.0f)
@@ -632,7 +634,7 @@
632 char shortcut = (char) arg.shortcut_label;634 char shortcut = (char) arg.shortcut_label;
633635
634 if (local::label_map.find(shortcut) == local::label_map.end())636 if (local::label_map.find(shortcut) == local::label_map.end())
635 local::label_map[shortcut] = RenderCharToTexture(shortcut, icon_size, icon_size);637 local::label_map[shortcut] = RenderCharToTexture(shortcut, icon_size, icon_size, shortcut_color);
636638
637 RenderElement(GfxContext,639 RenderElement(GfxContext,
638 arg,640 arg,
@@ -645,7 +647,7 @@
645 }647 }
646}648}
647649
648nux::BaseTexture* IconRenderer::RenderCharToTexture(const char label, int width, int height)650nux::BaseTexture* IconRenderer::RenderCharToTexture(char label, int width, int height, nux::Color const& bg_color)
649{651{
650 nux::BaseTexture* texture = NULL;652 nux::BaseTexture* texture = NULL;
651 nux::CairoGraphics* cg = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32,653 nux::CairoGraphics* cg = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32,
@@ -657,22 +659,26 @@
657 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed659 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
658 gchar* fontName = NULL;660 gchar* fontName = NULL;
659661
660 double label_pos = double(icon_size / 3.0f);662 double label_ratio = 0.44f;
661 double text_size = double(icon_size / 4.0f);663 double label_size = icon_size * label_ratio;
662 double label_x = label_pos;664 double label_x = (icon_size - label_size) / 2;
663 double label_y = label_pos;665 double label_y = (icon_size - label_size) / 2;
664 double label_w = label_pos;666 double label_w = label_size;
665 double label_h = label_pos;667 double label_h = label_size;
666 double label_r = 3.0f;668 double label_radius = 3.0f;
667669
668 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);670 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
669 cairo_paint(cr);671 cairo_paint(cr);
670 cairo_scale(cr, 1.0f, 1.0f);672 cairo_scale(cr, 1.0f, 1.0f);
671 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);673 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
672 cg->DrawRoundedRectangle(cr, 1.0f, label_x, label_y, label_r, label_w, label_h);674 cg->DrawRoundedRectangle(cr, 1.0f, label_x, label_y, label_radius, label_w, label_h);
673 cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.65f);675 cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.75f);
676 cairo_fill_preserve(cr);
677 cairo_set_source_rgba(cr, bg_color.red, bg_color.green, bg_color.blue, 0.20f);
674 cairo_fill(cr);678 cairo_fill(cr);
675679
680 double text_ratio = 0.75;
681 double text_size = label_size * text_ratio;
676 layout = pango_cairo_create_layout(cr);682 layout = pango_cairo_create_layout(cr);
677 g_object_get(settings, "gtk-font-name", &fontName, NULL);683 g_object_get(settings, "gtk-font-name", &fontName, NULL);
678 desc = pango_font_description_from_string(fontName);684 desc = pango_font_description_from_string(fontName);
@@ -1049,6 +1055,13 @@
1049 local::destroy_textures();1055 local::destroy_textures();
1050}1056}
10511057
1058void IconRenderer::DestroyShortcutTextures()
1059{
1060 for (auto texture : local::label_map)
1061 texture.second->UnReference();
1062 local::label_map.clear();
1063}
1064
1052void IconRenderer::GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,1065void IconRenderer::GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,
1053 int ViewportWidth,1066 int ViewportWidth,
1054 int ViewportHeight,1067 int ViewportHeight,
@@ -1287,9 +1300,7 @@
1287 squircle_shadow->UnReference();1300 squircle_shadow->UnReference();
1288 squircle_shine->UnReference();1301 squircle_shine->UnReference();
12891302
1290 for (auto it = label_map.begin(), end = label_map.end(); it != end; ++it)1303 IconRenderer::DestroyShortcutTextures();
1291 it->second->UnReference();
1292 label_map.clear();
12931304
1294 textures_created = false;1305 textures_created = false;
1295}1306}
12961307
=== modified file 'unity-shared/IconRenderer.h'
--- unity-shared/IconRenderer.h 2012-10-11 20:01:44 +0000
+++ unity-shared/IconRenderer.h 2012-10-30 16:46:32 +0000
@@ -46,9 +46,10 @@
46 void SetTargetSize(int tile_size, int image_size, int spacing);46 void SetTargetSize(int tile_size, int image_size, int spacing);
4747
48 static void DestroyTextures();48 static void DestroyTextures();
49 static void DestroyShortcutTextures();
4950
50protected:51protected:
51 nux::BaseTexture* RenderCharToTexture(const char label, int width, int height);52 nux::BaseTexture* RenderCharToTexture(char label, int width, int height, nux::Color const& bg_color);
5253
53 void RenderElement(nux::GraphicsEngine& GfxContext,54 void RenderElement(nux::GraphicsEngine& GfxContext,
54 RenderArg const& arg,55 RenderArg const& arg,