From 876f409477f3953da7918bb1061841512a8a7aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20(Trevi=C3=B1o)?= Date: Fri, 11 Feb 2011 16:25:25 +0100 Subject: [PATCH] Cut with fading the Bar title when it's longer than the decoration bar With this patch, when an application title is longer than the decorator available space for title, the text is colored using a cairo linear pattern which is divided into two parts: * The first pixels - apha_margin are colored with the defined opaque color * The pixels from alpha_margin until the string end are colored using a cairo pattern going from the opaque color to the transparent one. --- src/ui/theme.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/src/ui/theme.c b/src/ui/theme.c index 84b57a0..48cfe89 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -3807,6 +3807,33 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op, rx = parse_x_position_unchecked (op->data.title.x, env); ry = parse_y_position_unchecked (op->data.title.y, env); + if (rx - env->rect.x + env->title_width >= env->rect.width) + { + const double alpha_margin = 30.0; + int text_space = env->rect.x + env->rect.width - + (rx - env->rect.x) - env->right_width; + + double startalpha = 1.0 - (alpha_margin/((double)text_space)); + + cairo_pattern_t *linpat; + linpat = cairo_pattern_create_linear (rx, ry, text_space, + env->title_height); + cairo_pattern_add_color_stop_rgb (linpat, 0, color.red/65535.0, + color.green/65535.0, + color.blue/65535.0); + cairo_pattern_add_color_stop_rgb (linpat, startalpha, + color.red/65535.0, + color.green/65535.0, + color.blue/65535.0); + cairo_pattern_add_color_stop_rgba (linpat, 1, color.red/65535.0, + color.green/65535.0, + color.blue/65535.0, 0); + cairo_set_source(cr, linpat); + cairo_pattern_destroy(linpat); + } else { + gdk_cairo_set_source_color (cr, &color); + } + cairo_move_to (cr, rx, ry); pango_cairo_show_layout (cr, info->title_layout); } -- 1.7.2.3