Merge lp:~3v1n0/unity/fading-title into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Superseded
Proposed branch: lp:~3v1n0/unity/fading-title
Merge into: lp:unity
Diff against target: 63 lines (+34/-4)
1 file modified
src/PanelMenuView.cpp (+34/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/fading-title
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+49096@code.launchpad.net

This proposal has been superseded by a proposal from 2011-02-10.

Description of the change

Adding a small fade-out effect on Menu to cut the window Title when it's longer than the panel

All this using cairo linear patterns when needed (the pattern is using non-alpha colors until the end margin is reached, then it's faded to transparent).

Example: http://go.3v1n0.net/eivzuo
The fading space can be adjusted setting the variable text_margin.

This fixes #694924.

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PanelMenuView.cpp'
2--- src/PanelMenuView.cpp 2011-02-08 14:18:09 +0000
3+++ src/PanelMenuView.cpp 2011-02-09 17:26:10 +0000
4@@ -399,9 +399,11 @@
5 PangoFontDescription *desc = NULL;
6 GtkSettings *settings = gtk_settings_get_default ();
7 cairo_t *cr;
8+ cairo_pattern_t *linpat;
9 char *font_description = NULL;
10 GdkScreen *screen = gdk_screen_get_default ();
11 int dpi = 0;
12+ const int text_margin = 20;
13
14 int x = 0;
15 int y = 0;
16@@ -456,15 +458,43 @@
17 {
18 pango_cairo_update_layout (cr, layout);
19
20+ y += (height - text_height)/2;
21+ double startalpha = 1.0 - ((double)text_margin/(double)width);
22+
23 // Once for the homies that couldn't be here
24- cairo_set_source_rgb (cr, 50/255.0f, 50/255.0f, 45/255.0f);
25- cairo_move_to (cr, x, ((height - text_height)/2)-1);
26+ if (text_width >= width)
27+ {
28+ linpat = cairo_pattern_create_linear (x, y-1, width-x, y-1+text_height);
29+ cairo_pattern_add_color_stop_rgb (linpat, 0, 50/255.0f, 50/255.0f, 45/255.0f);
30+ cairo_pattern_add_color_stop_rgb (linpat, startalpha, 50/255.0f, 50/255.0f, 45/255.0f);
31+ cairo_pattern_add_color_stop_rgba (linpat, startalpha, 0, 0.0, 0.0, 0);
32+ cairo_pattern_add_color_stop_rgba (linpat, 1, 0, 0.0, 0.0, 0);
33+ cairo_set_source(cr, linpat);
34+ cairo_pattern_destroy(linpat);
35+ }
36+ else
37+ {
38+ cairo_set_source_rgb (cr, 50/255.0f, 50/255.0f, 45/255.0f);
39+ }
40+ cairo_move_to (cr, x, y-1);
41 pango_cairo_show_layout (cr, layout);
42 cairo_stroke (cr);
43
44 // Once again for the homies that could
45- cairo_set_source_rgba (cr, 223/255.0f, 219/255.0f, 210/255.0f, 1.0f);
46- cairo_move_to (cr, x, (height - text_height)/2);
47+ if (text_width >= width)
48+ {
49+ linpat = cairo_pattern_create_linear (x, y, width-x, y+text_height);
50+ cairo_pattern_add_color_stop_rgb (linpat, 0, 223/255.0f, 219/255.0f, 210/255.0f);
51+ cairo_pattern_add_color_stop_rgb (linpat, startalpha, 223/255.0f, 219/255.0f, 210/255.0f);
52+ cairo_pattern_add_color_stop_rgba (linpat, 1, 0, 0.0, 0.0, 0);
53+ cairo_set_source(cr, linpat);
54+ cairo_pattern_destroy(linpat);
55+ }
56+ else
57+ {
58+ cairo_set_source_rgb (cr, 223/255.0f, 219/255.0f, 210/255.0f);
59+ }
60+ cairo_move_to (cr, x, y);
61 pango_cairo_show_layout (cr, layout);
62 cairo_stroke (cr);
63 }