Merge lp:~unity-team/unity/unity.fix-633069 into lp:unity

Proposed by Mirco Müller
Status: Merged
Approved by: Mirco Müller
Approved revision: no longer in the source branch.
Merged at revision: 549
Proposed branch: lp:~unity-team/unity/unity.fix-633069
Merge into: lp:unity
Diff against target: 70 lines (+27/-22)
1 file modified
unity-private/launcher/scroller-view.vala (+27/-22)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix-633069
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+36535@code.launchpad.net

Description of the change

Beautified the keyboard-shortcuts. Text is crisper and centered in the box. Rounded corners are a bit smaller. Fixes most issues mentioned in LP: #633069. There's no precise visual spec yet for this.

To post a comment you must log in.
Revision history for this message
Gord Allott (gordallott) wrote :

code looks fine, approved from me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-private/launcher/scroller-view.vala'
2--- unity-private/launcher/scroller-view.vala 2010-09-22 15:35:51 +0000
3+++ unity-private/launcher/scroller-view.vala 2010-09-24 09:32:41 +0000
4@@ -592,27 +592,31 @@
5 double y = 0;
6 double w = 10;
7 double h = 10;
8- double r = Ctk.em_to_pixel (1);
9+ double r = Ctk.em_to_pixel (0.7f);
10
11+ Pango.Layout layout = Pango.cairo_create_layout (cr);
12 Gtk.Settings settings = Gtk.Settings.get_default ();
13 Pango.FontDescription desc = Pango.FontDescription.from_string (settings.gtk_font_name);
14-
15- cr.select_font_face (desc.get_family (),
16- Cairo.FontSlant.NORMAL,
17- Cairo.FontWeight.NORMAL);
18- double size;
19- size = Ctk.em_to_pixel (1) * 0.9;
20- cr.set_font_size (size);
21-
22-
23- Cairo.TextExtents extents = Cairo.TextExtents ();
24- cr.text_extents ("2", out extents);
25-
26- Cairo.TextExtents real_extents = Cairo.TextExtents ();
27- cr.text_extents (text, out extents);
28-
29- w += extents.width;
30- h += extents.height;
31+ desc.set_weight (Pango.Weight.NORMAL);
32+ layout.set_font_description (desc);
33+ layout.set_text (text, -1);
34+ Pango.Context pango_context = layout.get_context ();
35+ Gdk.Screen screen = Gdk.Screen.get_default ();
36+ Pango.cairo_context_set_font_options (pango_context,
37+ screen.get_font_options ());
38+ Pango.cairo_context_set_resolution (pango_context,
39+ (float) settings.gtk_xft_dpi /
40+ (float) Pango.SCALE);
41+ layout.context_changed ();
42+ int text_width;
43+ int text_height;
44+ Pango.Rectangle log_rect;
45+ layout.get_extents (null, out log_rect);
46+ text_width = log_rect.width / Pango.SCALE;
47+ text_height = log_rect.height / Pango.SCALE;
48+
49+ w += text_width;
50+ h += text_height;
51 cr.set_source_rgba (0.07, 0.07, 0.07, 0.8);
52
53 cr.move_to(x+r,y); // Move to A
54@@ -627,11 +631,12 @@
55
56 cr.fill ();
57
58- //x = (extents.width - real_extents.width) / 2.0;
59- y = 0;//(extents.height - real_extents.height) / 2.0;
60 cr.set_source_rgba (1, 1, 1, 1);
61- cr.move_to (x + 5 - (real_extents.width * 0.5), y+5+extents.height);
62- cr.show_text (text);
63+
64+ // draw text
65+ cr.move_to (x + (w - text_width) * 0.5,
66+ y + (h - text_height) * 0.5);
67+ Pango.cairo_show_layout (cr, layout);
68 }
69
70 /*