[metacity] Cut with fading the Bar title when it's longer than the decoration bar



commit a15e562ee6b3a1bd9ad69275942609e2866f2931
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date:   Fri Feb 11 16:25:25 2011 +0100

    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 eab6c17..1433efc 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -3829,6 +3829,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);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]