[murrine] New option: separatorstyle = 1 to draw smooth separators



commit 387560502b18fe94e096ff29172d30fa677bd892
Author: Andrea <andrea cimitan gmail com>
Date:   Thu Mar 18 20:32:20 2010 +0100

    New option: separatorstyle = 1 to draw smooth separators

 NEWS                     |    1 +
 schema/murrine.xml.in.in |   11 ++++
 src/murrine_draw.c       |   83 ++++++++++++++++++++++++++++++++--
 src/murrine_draw_rgba.c  |  114 ++++++++++++++++++++++++++++++++++++++--------
 src/murrine_rc_style.c   |    9 ++++
 src/murrine_rc_style.h   |   12 +++--
 src/murrine_style.c      |    4 ++
 src/murrine_style.h      |    1 +
 src/murrine_types.h      |    1 +
 9 files changed, 208 insertions(+), 28 deletions(-)
---
diff --git a/NEWS b/NEWS
index 66682d6..12bbb80 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Changes in this release:
 - New option: prelight_shade = 1.0 to select the shade level used in the
               scrollbar's slider, GtkComboBox with comboboxstyle = 1 and
               in the prelight state with gradient_colors.
+- New option: separatorstyle = 1 to draw smooth separators.              
 - 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.
diff --git a/schema/murrine.xml.in.in b/schema/murrine.xml.in.in
index 852a910..9d39429 100644
--- a/schema/murrine.xml.in.in
+++ b/schema/murrine.xml.in.in
@@ -299,6 +299,17 @@
 		</enumeration>
 	</option>
 
+	<option type="enumeration" name="separatorstyle" default="0">
+		<_long_name>Separator style</_long_name>
+		<section>General</section>
+		<enumeration value="0">
+			<label>None</label>
+		</enumeration>
+		<enumeration value="1">
+			<label>Smooth separator</label>
+		</enumeration>
+	</option>
+
 	<option type="enumeration" name="sliderstyle" default="0">
 		<_long_name>Slider style</_long_name>
 		<section>Scrolls and Lists</section>
diff --git a/src/murrine_draw.c b/src/murrine_draw.c
index d481cb5..47e2fbf 100644
--- a/src/murrine_draw.c
+++ b/src/murrine_draw.c
@@ -1392,12 +1392,50 @@ murrine_draw_separator (cairo_t *cr,
 	{
 		cairo_translate       (cr, x, y+0.5);
 
-		murrine_set_color_rgb (cr, dark);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgb (cr, dark);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, width, 0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
+		
 		cairo_move_to         (cr, 0.0,     0.0);
 		cairo_line_to         (cr, width+1, 0.0);
 		cairo_stroke          (cr);
 
-		murrine_set_color_rgb (cr, highlight);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgb (cr, highlight);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, width, 0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
+
 		cairo_move_to         (cr, 0.0,   1.0);
 		cairo_line_to         (cr, width, 1.0);
 		cairo_stroke          (cr);
@@ -1406,12 +1444,49 @@ murrine_draw_separator (cairo_t *cr,
 	{
 		cairo_translate       (cr, x+0.5, y);
 
-		murrine_set_color_rgb (cr, dark);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgb (cr, dark);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, 0, height);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
 		cairo_move_to         (cr, 0.0, 0.0);
 		cairo_line_to         (cr, 0.0, height);
 		cairo_stroke          (cr);
 
-		murrine_set_color_rgb (cr, highlight);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgb (cr, highlight);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, 0, height);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
+
 		cairo_move_to         (cr, 1.0, 0.0);
 		cairo_line_to         (cr, 1.0, height);
 		cairo_stroke          (cr);
diff --git a/src/murrine_draw_rgba.c b/src/murrine_draw_rgba.c
index 86de9b9..4816fb6 100644
--- a/src/murrine_draw_rgba.c
+++ b/src/murrine_draw_rgba.c
@@ -1011,31 +1011,107 @@ murrine_rgba_draw_separator (cairo_t *cr,
 
 	if (separator->horizontal)
 	{
-		cairo_translate       (cr, x, y+0.5);
+		cairo_translate (cr, x, y+0.5);
 
-		cairo_move_to         (cr, 0.0,     0.0);
-		cairo_line_to         (cr, width+1, 0.0);
-		murrine_set_color_rgb (cr, dark);
-		cairo_stroke          (cr);
-
-		cairo_move_to          (cr, 0.0,   1.0);
-		cairo_line_to          (cr, width, 1.0);
-		murrine_set_color_rgba (cr, highlight, 0.5);
-		cairo_stroke           (cr);
+		cairo_move_to (cr, 0.0,     0.0);
+		cairo_line_to (cr, width+1, 0.0);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgb (cr, dark);
+				cairo_stroke (cr);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, width, 0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_stroke (cr);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
+		
+		cairo_move_to (cr, 0.0,   1.0);
+		cairo_line_to (cr, width, 1.0);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgba (cr, highlight, 0.5);
+				cairo_stroke (cr);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, width, 0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_stroke (cr);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
 	}
 	else
 	{
-		cairo_translate       (cr, x+0.5, y);
+		cairo_translate (cr, x+0.5, y);
 
-		cairo_move_to         (cr, 0.0, 0.0);
-		cairo_line_to         (cr, 0.0, height);
-		murrine_set_color_rgb (cr, dark);
-		cairo_stroke          (cr);
+		cairo_move_to (cr, 0.0, 0.0);
+		cairo_line_to (cr, 0.0, height);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgb (cr, dark);
+				cairo_stroke (cr);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, width, 0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_stroke (cr);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
 
-		cairo_move_to          (cr, 1.0, 0.0);
-		cairo_line_to          (cr, 1.0, height);
-		murrine_set_color_rgba (cr, highlight, 0.5);
-		cairo_stroke           (cr);
+		cairo_move_to (cr, 1.0, 0.0);
+		cairo_line_to (cr, 1.0, height);
+		switch (separator->style)
+		{
+			default:
+			case 0:
+				murrine_set_color_rgba (cr, highlight, 0.5);
+				cairo_stroke (cr);
+				break;
+			case 1:
+			{
+				cairo_pattern_t *pat;
+				pat = cairo_pattern_create_linear (0, 0, width, 0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
+				cairo_set_source (cr, pat);
+				cairo_stroke (cr);
+				cairo_pattern_destroy (pat);
+				break;
+			}
+		}
 	}
 }
 
diff --git a/src/murrine_rc_style.c b/src/murrine_rc_style.c
index 3f4a55d..f7672e4 100644
--- a/src/murrine_rc_style.c
+++ b/src/murrine_rc_style.c
@@ -63,6 +63,7 @@ enum
 	TOKEN_RGBA,
 	TOKEN_ROUNDNESS,
 	TOKEN_SCROLLBARSTYLE,
+	TOKEN_SEPARATORSTYLE,
 	TOKEN_SHADOW_SHADES,
 	TOKEN_SLIDERSTYLE,
 	TOKEN_SPINBUTTONSTYLE,
@@ -120,6 +121,7 @@ theme_symbols[] =
 	{ "rgba",                TOKEN_RGBA },
 	{ "roundness",           TOKEN_ROUNDNESS },
 	{ "scrollbarstyle",      TOKEN_SCROLLBARSTYLE },
+	{ "separatorstyle",      TOKEN_SEPARATORSTYLE },
 	{ "shadow_shades",       TOKEN_SHADOW_SHADES },
 	{ "sliderstyle",         TOKEN_SLIDERSTYLE },
 	{ "spinbuttonstyle",     TOKEN_SPINBUTTONSTYLE },
@@ -186,6 +188,7 @@ murrine_rc_style_init (MurrineRcStyle *murrine_rc)
 	murrine_rc->rgba = FALSE;
 	murrine_rc->roundness = 1;
 	murrine_rc->scrollbarstyle = 0;
+	murrine_rc->separatorstyle = 0;
 	murrine_rc->shadow_shades[0] = 1.0;
 	murrine_rc->shadow_shades[1] = 1.0;
 	murrine_rc->sliderstyle = 0;
@@ -712,6 +715,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_SEPARATORSTYLE:
+				token = theme_parse_int (settings, scanner, &murrine_style->separatorstyle);
+				murrine_style->flags |= MRN_FLAG_SEPARATORSTYLE;
+				break;
 			case TOKEN_SHADOW_SHADES:
 				token = theme_parse_border (settings, scanner, murrine_style->shadow_shades);
 				murrine_style->gflags |= MRN_FLAG_SHADOW_SHADES;
@@ -863,6 +870,8 @@ murrine_rc_style_merge (GtkRcStyle *dest,
 		dest_w->roundness = src_w->roundness;
 	if (flags & MRN_FLAG_SCROLLBARSTYLE)
 		dest_w->scrollbarstyle = src_w->scrollbarstyle;
+	if (flags & MRN_FLAG_SEPARATORSTYLE)
+		dest_w->separatorstyle = src_w->separatorstyle;
 	if (flags & MRN_FLAG_SLIDERSTYLE)
 		dest_w->sliderstyle = src_w->sliderstyle;
 	if (flags & MRN_FLAG_SPINBUTTONSTYLE)
diff --git a/src/murrine_rc_style.h b/src/murrine_rc_style.h
index b9f16e6..4e41e1e 100644
--- a/src/murrine_rc_style.h
+++ b/src/murrine_rc_style.h
@@ -59,11 +59,12 @@ typedef enum
 	MRN_FLAG_RGBA = 1 << 21,
 	MRN_FLAG_ROUNDNESS = 1 << 22,
 	MRN_FLAG_SCROLLBARSTYLE = 1 << 23,
-	MRN_FLAG_SLIDERSTYLE = 1 << 24,
-	MRN_FLAG_SPINBUTTONSTYLE = 1 << 25,
-	MRN_FLAG_STEPPERSTYLE = 1 << 26,
-	MRN_FLAG_TEXTSTYLE = 1 << 27,
-	MRN_FLAG_TOOLBARSTYLE = 1 << 28
+	MRN_FLAG_SEPARATORSTYLE = 1 << 24,
+	MRN_FLAG_SLIDERSTYLE = 1 << 25,
+	MRN_FLAG_SPINBUTTONSTYLE = 1 << 26,
+	MRN_FLAG_STEPPERSTYLE = 1 << 27,
+	MRN_FLAG_TEXTSTYLE = 1 << 28,
+	MRN_FLAG_TOOLBARSTYLE = 1 << 29
 } MurrineRcFlags;
 
 typedef enum
@@ -107,6 +108,7 @@ struct _MurrineRcStyle
 	guint8   progressbarstyle;
 	guint8   reliefstyle;
 	guint8   roundness;
+	guint8   separatorstyle;
 	guint8   scrollbarstyle;
 	guint8   sliderstyle;
 	guint8   spinbuttonstyle;
diff --git a/src/murrine_style.c b/src/murrine_style.c
index 0738b6f..2410927 100644
--- a/src/murrine_style.c
+++ b/src/murrine_style.c
@@ -1634,6 +1634,7 @@ murrine_style_draw_vline (GtkStyle     *style,
 
 	SeparatorParameters separator;
 	separator.horizontal = FALSE;
+	separator.style = murrine_style->separatorstyle;
 
 	WidgetParameters params;
 
@@ -1678,6 +1679,7 @@ murrine_style_draw_hline (GtkStyle     *style,
 
 	SeparatorParameters separator;
 	separator.horizontal = TRUE;
+	separator.style = murrine_style->separatorstyle;
 
 	WidgetParameters params;
 
@@ -2288,6 +2290,7 @@ murrine_style_init_from_rc (GtkStyle   *style,
 	murrine_style->reliefstyle         = MURRINE_RC_STYLE (rc_style)->reliefstyle;
 	murrine_style->rgba                = MURRINE_RC_STYLE (rc_style)->rgba;
 	murrine_style->scrollbarstyle      = MURRINE_RC_STYLE (rc_style)->scrollbarstyle;
+	murrine_style->separatorstyle      = MURRINE_RC_STYLE (rc_style)->separatorstyle;	
 	murrine_style->sliderstyle         = MURRINE_RC_STYLE (rc_style)->sliderstyle;
 	murrine_style->spinbuttonstyle     = MURRINE_RC_STYLE (rc_style)->spinbuttonstyle;
 	murrine_style->stepperstyle        = MURRINE_RC_STYLE (rc_style)->stepperstyle;
@@ -2431,6 +2434,7 @@ 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->separatorstyle      = mrn_src->separatorstyle;
 	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;
diff --git a/src/murrine_style.h b/src/murrine_style.h
index 5758d1c..6b81798 100644
--- a/src/murrine_style.h
+++ b/src/murrine_style.h
@@ -66,6 +66,7 @@ struct _MurrineStyle
 	guint8   progressbarstyle;
 	guint8   reliefstyle;
 	guint8   roundness;
+	guint8   separatorstyle;
 	guint8   scrollbarstyle;
 	guint8   sliderstyle;
 	guint8   spinbuttonstyle;
diff --git a/src/murrine_types.h b/src/murrine_types.h
index 2f4ec7f..5d8c97b 100644
--- a/src/murrine_types.h
+++ b/src/murrine_types.h
@@ -303,6 +303,7 @@ typedef struct
 {
 	boolean horizontal;
 	boolean use_rgba;
+	int     style;
 } SeparatorParameters;
 
 typedef struct



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