[murrine] Added shadow_shades = { 1.0, 1.0 } to draw a gradient on the shadow and minor fixes



commit 8e8c53cec062dfd640e8d015ea6995c46e737eac
Author: Andrea Cimitan <andrea cimitan gmail com>
Date:   Tue Dec 8 04:49:59 2009 +0100

    Added shadow_shades = { 1.0, 1.0 } to draw a gradient on the shadow and minor fixes

 NEWS                   |    2 ++
 src/cairo-support.c    |   10 +++++-----
 src/murrine_rc_style.c |   13 +++++++++++++
 src/murrine_rc_style.h |    4 +++-
 src/murrine_style.c    |   10 +++++++++-
 src/murrine_style.h    |    1 +
 src/murrine_types.h    |    5 +++--
 7 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index d3b4150..cff58d0 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ Changes in this release:
 - New option: gradient_colors = { "#ffffff", "#ffffff", "#ffffff", "#ffffff" }
               to set the colors used on the gradient of many widgets.
               gradient_colors = FALSE to disable.
+- New option: shadow_shades = { 1.0, 1.0 } to draw a gradient on 
+              the shadow of some widgets.
 - New option: spinbuttonstyle = 1 to add a separator on the GtkSpinButton.
 - New option: textstyle = 1 to draw an inset on the text (use carefully).
 - New option: trough_shades = { 1.0, 1.0 } to draw a gradient on 
diff --git a/src/cairo-support.c b/src/cairo-support.c
index 96460d4..bd74e04 100644
--- a/src/cairo-support.c
+++ b/src/cairo-support.c
@@ -885,19 +885,19 @@ murrine_draw_shadow (cairo_t *cr,
                      int reliefstyle,
                      MurrineGradients mrn_gradient, double alpha)
 {
-	if (mrn_gradient.border_shades[0] != 1.0 ||
-	    mrn_gradient.border_shades[1] != 1.0 ||
+	if (mrn_gradient.shadow_shades[0] != 1.0 ||
+	    mrn_gradient.shadow_shades[1] != 1.0 ||
 	    reliefstyle > 2) // improve
 	{
 		cairo_pattern_t *pat;
 		MurrineRGB shade1, shade2;
 
-		murrine_shade (color, mrn_gradient.border_shades[0], &shade1);
-		murrine_shade (color, mrn_gradient.border_shades[1], &shade2);
+		murrine_shade (color, mrn_gradient.shadow_shades[0], &shade1);
+		murrine_shade (color, mrn_gradient.shadow_shades[1], &shade2);
 
 		pat = cairo_pattern_create_linear (x, y, x, height+y);
 		murrine_pattern_add_color_stop_rgba (pat, 0.00, &shade1, reliefstyle == 3 ? 0.5*alpha : alpha);
-		murrine_pattern_add_color_stop_rgba (pat, 1.00, &shade2, reliefstyle >= 3 ? (mrn_gradient.border_shades[1] > 1.0 ? 2.5*alpha : 2.0*alpha) : alpha);
+		murrine_pattern_add_color_stop_rgba (pat, 1.00, &shade2, reliefstyle >= 3 ? 2.0*alpha : alpha);
 
 		cairo_set_source (cr, pat);
 		cairo_pattern_destroy (pat);
diff --git a/src/murrine_rc_style.c b/src/murrine_rc_style.c
index dd15121..cede05c 100644
--- a/src/murrine_rc_style.c
+++ b/src/murrine_rc_style.c
@@ -62,6 +62,7 @@ enum
 	TOKEN_RGBA,
 	TOKEN_ROUNDNESS,
 	TOKEN_SCROLLBARSTYLE,
+	TOKEN_SHADOW_SHADES,
 	TOKEN_SLIDERSTYLE,
 	TOKEN_SPINBUTTONSTYLE,
 	TOKEN_STEPPERSTYLE,
@@ -117,6 +118,7 @@ theme_symbols[] =
 	{ "rgba",                TOKEN_RGBA },
 	{ "roundness",           TOKEN_ROUNDNESS },
 	{ "scrollbarstyle",      TOKEN_SCROLLBARSTYLE },
+	{ "shadow_shades",       TOKEN_SHADOW_SHADES },
 	{ "sliderstyle",         TOKEN_SLIDERSTYLE },
 	{ "spinbuttonstyle",     TOKEN_SPINBUTTONSTYLE },
 	{ "stepperstyle",        TOKEN_STEPPERSTYLE },
@@ -181,6 +183,8 @@ murrine_rc_style_init (MurrineRcStyle *murrine_rc)
 	murrine_rc->rgba = FALSE;
 	murrine_rc->roundness = 1;
 	murrine_rc->scrollbarstyle = 0;
+	murrine_rc->shadow_shades[0] = 1.0;
+	murrine_rc->shadow_shades[1] = 1.0;
 	murrine_rc->sliderstyle = 0;
 	murrine_rc->spinbuttonstyle = 0;
 	murrine_rc->stepperstyle = 0;
@@ -701,6 +705,10 @@ murrine_rc_style_parse (GtkRcStyle *rc_style,
 				token = theme_parse_int (settings, scanner, &murrine_style->scrollbarstyle);
 				murrine_style->flags |= MRN_FLAG_SCROLLBARSTYLE;
 				break;
+			case TOKEN_SHADOW_SHADES:
+				token = theme_parse_border (settings, scanner, murrine_style->shadow_shades);
+				murrine_style->gflags |= MRN_FLAG_SHADOW_SHADES;
+				break;
 			case TOKEN_SLIDERSTYLE:
 				token = theme_parse_int (settings, scanner, &murrine_style->sliderstyle);
 				murrine_style->flags |= MRN_FLAG_SLIDERSTYLE;
@@ -887,6 +895,11 @@ murrine_rc_style_merge (GtkRcStyle *dest,
 		dest_w->gradient_shades[2] = src_w->gradient_shades[2];
 		dest_w->gradient_shades[3] = src_w->gradient_shades[3];
 	}
+	if (gflags & MRN_FLAG_SHADOW_SHADES)
+	{
+		dest_w->shadow_shades[0] = src_w->shadow_shades[0];
+		dest_w->shadow_shades[1] = src_w->shadow_shades[1];
+	}
 	if (gflags & MRN_FLAG_TROUGH_SHADES)
 	{
 		dest_w->trough_shades[0] = src_w->trough_shades[0];
diff --git a/src/murrine_rc_style.h b/src/murrine_rc_style.h
index 12b34c1..f6b6722 100644
--- a/src/murrine_rc_style.h
+++ b/src/murrine_rc_style.h
@@ -71,7 +71,8 @@ typedef enum
 	MRN_FLAG_BORDER_SHADES = 1 << 2,
 	MRN_FLAG_GRADIENT_COLORS = 1 << 3,
 	MRN_FLAG_GRADIENT_SHADES = 1 << 4,
-	MRN_FLAG_TROUGH_SHADES = 1 << 5
+	MRN_FLAG_SHADOW_SHADES = 1 << 5,
+	MRN_FLAG_TROUGH_SHADES = 1 << 6
 } MurrineRcGradientFlags;
 
 struct _MurrineRcStyle
@@ -87,6 +88,7 @@ struct _MurrineRcStyle
 	double   gradient_shades[4];
 	double   highlight_shade;
 	double   lightborder_shade;
+	double   shadow_shades[2];
 	double   trough_shades[2];
 
 	guint8   arrowstyle;
diff --git a/src/murrine_style.c b/src/murrine_style.c
index 321426d..6f46db9 100644
--- a/src/murrine_style.c
+++ b/src/murrine_style.c
@@ -191,6 +191,8 @@ murrine_set_widget_parameters (const GtkWidget  *widget,
 	else
 		mrn_gradient.has_border_colors = FALSE;
 
+	mrn_gradient.shadow_shades[0] = murrine_style->shadow_shades[0];
+	mrn_gradient.shadow_shades[1] = murrine_style->shadow_shades[1];
 	mrn_gradient.trough_shades[0] = murrine_style->trough_shades[0];
 	mrn_gradient.trough_shades[1] = murrine_style->trough_shades[1];
 
@@ -200,8 +202,10 @@ murrine_set_widget_parameters (const GtkWidget  *widget,
 	    murrine_style->gradient_shades[1] != 1.0 ||
 	    murrine_style->gradient_shades[2] != 1.0 ||
 	    murrine_style->gradient_shades[3] != 1.0 ||
+	    murrine_style->shadow_shades[0] != 1.0 ||
+	    murrine_style->shadow_shades[1] != 1.0 ||
 	    murrine_style->trough_shades[0] != 1.0 ||
-	    murrine_style->trough_shades[0] != 1.0)
+	    murrine_style->trough_shades[1] != 1.0)
 		mrn_gradient.gradients = TRUE;
 	else
 		mrn_gradient.gradients = FALSE;
@@ -2227,6 +2231,8 @@ murrine_style_init_from_rc (GtkStyle   *style,
 	/* Adjust lightborder_shade reading contrast */
 	murrine_style->lightborder_shade = murrine_get_contrast(MURRINE_RC_STYLE (rc_style)->lightborder_shade,
 	                                                        MURRINE_RC_STYLE (rc_style)->contrast);
+	murrine_style->shadow_shades[0]   = MURRINE_RC_STYLE (rc_style)->shadow_shades[0];
+	murrine_style->shadow_shades[1]   = MURRINE_RC_STYLE (rc_style)->shadow_shades[1];
 	murrine_style->trough_shades[0]   = MURRINE_RC_STYLE (rc_style)->trough_shades[0];
 	murrine_style->trough_shades[1]   = MURRINE_RC_STYLE (rc_style)->trough_shades[1];
 
@@ -2403,6 +2409,8 @@ murrine_style_copy (GtkStyle *style, GtkStyle *src)
 	mrn_style->rgba                = mrn_src->rgba;
 	mrn_style->roundness           = mrn_src->roundness;
 	mrn_style->scrollbarstyle      = mrn_src->scrollbarstyle;
+	mrn_style->shadow_shades[0]    = mrn_src->shadow_shades[0];
+	mrn_style->shadow_shades[1]    = mrn_src->shadow_shades[1];
 	mrn_style->sliderstyle 	       = mrn_src->sliderstyle;
 	mrn_style->spinbuttonstyle     = mrn_src->spinbuttonstyle;
 	mrn_style->stepperstyle        = mrn_src->stepperstyle;
diff --git a/src/murrine_style.h b/src/murrine_style.h
index baeb895..e503e6b 100644
--- a/src/murrine_style.h
+++ b/src/murrine_style.h
@@ -48,6 +48,7 @@ struct _MurrineStyle
 	double   gradient_shades[4];
 	double   highlight_shade;
 	double   lightborder_shade;
+	double   shadow_shades[2];
 	double   trough_shades[2];
 
 	guint8   arrowstyle;
diff --git a/src/murrine_types.h b/src/murrine_types.h
index 033a5b4..c9e67c1 100644
--- a/src/murrine_types.h
+++ b/src/murrine_types.h
@@ -184,10 +184,11 @@ typedef struct
 {
 	double  border_shades[2];
 	double  gradient_shades[4];
-	double  trough_shades[4];
+	double  shadow_shades[2];
+	double  trough_shades[2];
 	double  rgba_opacity;
 
-	MurrineRGB border_colors[4];
+	MurrineRGB border_colors[2];
 	MurrineRGB gradient_colors[4];
 
 	boolean has_border_colors;



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