murrine r80 - in trunk: . src



Author: acimitan
Date: Mon Sep 29 00:25:50 2008
New Revision: 80
URL: http://svn.gnome.org/viewvc/murrine?rev=80&view=rev

Log:
2008-09-29  Andrea Cimitan  <andrea cimitan gmail com>

	* src/cairo-support.c (murrine_draw_curved_highlight),
	(murrine_draw_curved_highlight_top),
	(murrine_draw_curved_highlight_bottom), (murrine_draw_glaze):
	* src/cairo-support.h:
	* src/murrine_draw.c (murrine_draw_button),
	(murrine_draw_progressbar_fill), (murrine_draw_menubar),
	(murrine_draw_toolbar), (murrine_draw_list_view_header),
	(murrine_draw_menuitem), (murrine_draw_scrollbar_stepper),
	(murrine_draw_scrollbar_slider), (murrine_draw_selected_cell),
	(murrine_draw_statusbar):
	* src/murrine_draw_rgba.c (murrine_rgba_draw_button),
	(murrine_rgba_draw_entry), (murrine_rgba_draw_progressbar_fill),
	(murrine_rgba_draw_menubar), (murrine_rgba_draw_toolbar),
	(murrine_rgba_draw_tab), (murrine_rgba_draw_scrollbar_stepper),
	(murrine_rgba_draw_scrollbar_slider),
	(murrine_rgba_draw_statusbar):
	TOTAL rewrite of the glaze functions, removed 500 lines of code ;)
	Please TEST! Comparing before/after.



Modified:
   trunk/ChangeLog
   trunk/src/cairo-support.c
   trunk/src/cairo-support.h
   trunk/src/murrine_draw.c
   trunk/src/murrine_draw_rgba.c

Modified: trunk/src/cairo-support.c
==============================================================================
--- trunk/src/cairo-support.c	(original)
+++ trunk/src/cairo-support.c	Mon Sep 29 00:25:50 2008
@@ -448,40 +448,134 @@
 
 void
 murrine_draw_curved_highlight (cairo_t *cr,
-                               double curve_pos, int width, int height)
+                               int x, int y, int width, int height)
 {
-	cairo_move_to (cr, curve_pos, height-curve_pos);
-	cairo_curve_to (cr, curve_pos, height/2+height/5, height/5, height/2, height/2, height/2);
-	cairo_line_to (cr, width-height/2, height/2);
-	cairo_curve_to (cr, width-curve_pos-height/5, height/2, width-curve_pos-0.5, height/2-height/5, width-curve_pos, curve_pos);
-	cairo_line_to (cr, curve_pos, curve_pos);
-	cairo_line_to (cr, curve_pos, height-curve_pos);
+	int w = width+x*2;
+	int h = height+y*2;
+
+	cairo_move_to (cr, x, h-y);
+	cairo_curve_to (cr, x, h/2+h/5, h/5, h/2, h/2, h/2);
+	cairo_line_to (cr, w-h/2, h/2);
+	cairo_curve_to (cr, w-x-h/5, h/2, w-x-0.5, h/2-h/5, w-x, y);
+	cairo_line_to (cr, x, y);
+	cairo_line_to (cr, x, h-y);
 	cairo_close_path (cr);
 }
 
 void
 murrine_draw_curved_highlight_top (cairo_t *cr,
-                                   double curve_pos, int width, int height)
+                                   int x, int y, int width, int height)
 {
-	cairo_move_to (cr, curve_pos, curve_pos);
-	cairo_curve_to (cr, curve_pos, height/2-height/5, height/5, height/2, height/2, height/2);
-	cairo_line_to (cr, width-height/2, height/2);
-	cairo_curve_to (cr, width-curve_pos-height/5, height/2, width-curve_pos-0.5, height/2-height/5, width-curve_pos, curve_pos);
+	int w = width+x*2;
+	int h = height+y*2;
+
+	cairo_move_to (cr, x, y);
+	cairo_curve_to (cr, x, h/2-h/5, h/5, h/2, h/2, h/2);
+	cairo_line_to (cr, w-h/2, h/2);
+	cairo_curve_to (cr, w-x-h/5, h/2, w-x-0.5, h/2-h/5, w-x, y);
 	cairo_close_path (cr);
 }
 
 void
 murrine_draw_curved_highlight_bottom (cairo_t *cr,
-                                      double curve_pos, int width, int height)
+                                      int x, int y, int width, int height)
 {
-	cairo_move_to (cr, curve_pos, height-curve_pos);
-	cairo_curve_to (cr, curve_pos, height/2+height/5, height/5, height/2, height/2, height/2);
-	cairo_line_to (cr, width-height/2, height/2);
-	cairo_curve_to (cr, width-curve_pos-height/5, height/2, width-curve_pos-0.5, height/2+height/5, width-curve_pos, height-curve_pos);
+	int w = width+x*2;
+	int h = height+y*2;
+
+	cairo_move_to (cr, x, h-y);
+	cairo_curve_to (cr, x, h/2+h/5, h/5, h/2, h/2, h/2);
+	cairo_line_to (cr, w-h/2, h/2);
+	cairo_curve_to (cr, w-x-h/5, h/2, w-x-0.5, h/2+h/5, w-x, h-y);
 	cairo_close_path (cr);
 }
 
 void
+murrine_draw_glaze (cairo_t *cr,
+                    const MurrineRGB *fill,
+                    double highlight_ratio,
+                    MurrineGradients mrn_gradient,
+                    const WidgetParameters *widget,
+                    int x, int y, int width, int height)
+{
+	MurrineRGB highlight;
+	murrine_shade (fill, highlight_ratio, &highlight);
+
+	murrine_set_gradient (cr, fill, mrn_gradient, x, y, 0, height, mrn_gradient.gradients, FALSE);
+	switch (widget->glazestyle)
+	{
+		default:
+		case 0:
+			cairo_fill (cr);
+			murrine_draw_flat_highlight (cr, x, y, width, height);
+			break;
+		case 1:
+			cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+			cairo_fill (cr);
+			murrine_draw_curved_highlight (cr, x, y, width, height);
+			break;
+		case 2:
+			cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+			cairo_fill_preserve (cr);
+			murrine_draw_curved_highlight (cr, x, y, width, height);
+			break;
+		case 3:
+		case 4:
+			cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+			cairo_fill (cr);
+			murrine_draw_curved_highlight_top (cr, x, y, width, height);
+			break;
+	}
+
+	murrine_set_gradient (cr, &highlight, mrn_gradient, x, y, 0, height, mrn_gradient.gradients, TRUE);
+	cairo_fill (cr);
+
+	if (widget->glazestyle == 4)
+	{
+		MurrineRGB shadow;
+		murrine_shade (fill, 1.0/highlight_ratio, &shadow);
+
+		murrine_draw_curved_highlight_bottom (cr, x, y, width, height);
+		murrine_set_gradient (cr, &shadow, mrn_gradient, x, y, 0, height, mrn_gradient.gradients, TRUE);
+		cairo_fill (cr);
+	}
+}
+
+/* Old one */
+/*
+static void
+murrine_draw_glaze (cairo_t *cr,
+                    const WidgetParameters *widget,
+                    int x, int y, int width, int height)
+{
+	switch (widget->glazestyle)
+	{
+		default:
+		case 0:
+			cairo_fill (cr);
+			murrine_draw_flat_highlight (cr, x, y, width, height);
+			break;
+		case 1:
+			cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+			cairo_fill (cr);
+			murrine_draw_curved_highlight (cr, x, y, width, height);
+			break;
+		case 2:
+			cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+			cairo_fill_preserve (cr);
+			murrine_draw_curved_highlight (cr, x, y, width, height);
+			break;
+		case 3:
+		case 4:
+			cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+			cairo_fill (cr);
+			murrine_draw_curved_highlight_top (cr, x, y, width, height);
+			break;
+	}
+}
+*/
+
+void
 murrine_draw_lightborder (cairo_t *cr,
                           const MurrineRGB *highlight_color,
                           const MurrineRGB *fill,

Modified: trunk/src/cairo-support.h
==============================================================================
--- trunk/src/cairo-support.h	(original)
+++ trunk/src/cairo-support.h	Mon Sep 29 00:25:50 2008
@@ -94,17 +94,21 @@
                                            boolean gradients, boolean alpha);
 
 G_GNUC_INTERNAL void murrine_draw_flat_highlight (cairo_t *cr,
-                                                int x, int y, int width, int height);
+                                                  int x, int y, int width, int height);
 
 G_GNUC_INTERNAL void murrine_draw_curved_highlight (cairo_t *cr,
-                                                  double curve_pos,
-                                                  int width, int height);
+                                                    int x, int y, int width, int height);
 
 G_GNUC_INTERNAL void murrine_draw_curved_highlight_top (cairo_t *cr,
-                                                      double curve_pos,
-                                                      int width, int height);
+                                                        int x, int y, int width, int height);
 
 G_GNUC_INTERNAL void murrine_draw_curved_highlight_bottom (cairo_t *cr,
-                                                         double curve_pos,
-                                                         int width, int height);
+                                                           int x, int y, int width, int height);
+
+G_GNUC_INTERNAL void murrine_draw_glaze (cairo_t *cr,
+                                         const MurrineRGB *fill,
+                                         double highlight_ratio,
+                                         MurrineGradients mrn_gradient,
+                                         const WidgetParameters *widget,
+                                         int x, int y, int width, int height);
 

Modified: trunk/src/murrine_draw.c
==============================================================================
--- trunk/src/murrine_draw.c	(original)
+++ trunk/src/murrine_draw.c	Mon Sep 29 00:25:50 2008
@@ -152,7 +152,7 @@
 	MurrineRGB fill = colors->bg[widget->state_type];
 	MurrineRGB border_disabled = colors->shade[5];
 	MurrineRGB border_normal;
-	MurrineRGB highlight;
+
 	double custom_highlight_ratio = widget->highlight_ratio;
 	MurrineGradients mrn_gradient_custom = widget->mrn_gradient;
 
@@ -166,7 +166,6 @@
 		murrine_mix_color (&fill, &colors->spot[1], 0.2, &fill);
 
 	murrine_shade (&colors->shade[6], 0.95, &border_normal);
-	murrine_shade (&fill, custom_highlight_ratio, &highlight);
 
 	if (!horizontal)
 		murrine_exchange_axis (cr, &x, &y, &width, &height);
@@ -195,48 +194,21 @@
 
 	/* Draw the bg */
 	murrine_rounded_rectangle_closed (cr, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2, widget->roundness, widget->corners);
-	murrine_set_gradient (cr, &fill, mrn_gradient_custom, xos+1, yos+1, 0, height-(yos*2)-2, widget->mrn_gradient.gradients, FALSE);
 
 	cairo_save (cr);
 	if (widget->roundness > 1)
 		cairo_clip_preserve (cr);
 
-	int curve_pos = 1;
-	if (widget->glazestyle != 4)
-		curve_pos = 2;
-
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, curve_pos, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, curve_pos, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2);
-	}
-
-	murrine_set_gradient (cr, &highlight, mrn_gradient_custom, xos+1, yos+1, 0, height-(yos*2)-2, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, curve_pos, width, height);
-		MurrineRGB shadow;
-		murrine_shade (&fill, 1.0/custom_highlight_ratio, &shadow);
-		murrine_set_gradient (cr, &shadow, mrn_gradient_custom, xos+1, yos+1, 0, height-(yos*2)-2, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, &fill, custom_highlight_ratio, mrn_gradient_custom, widget, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2);
 
 	/* Draw the white inner border */
 	if (widget->glazestyle != 4 && !widget->active)
 	{
+		MurrineRGB highlight;
+
+		murrine_shade (&fill, custom_highlight_ratio, &highlight);
 		murrine_shade (&fill, widget->lightborder_ratio*custom_highlight_ratio, &highlight);
+
 		if (horizontal)
 		{
 			murrine_draw_lightborder (cr, &highlight, &fill, mrn_gradient_custom,
@@ -552,9 +524,6 @@
 	int        x_step;
 	const      MurrineRGB *fill = &colors->spot[1];
 	MurrineRGB border = colors->spot[2];
-	MurrineRGB highlight;
-
-	murrine_shade (fill, widget->highlight_ratio, &highlight);
 
 	cairo_rectangle (cr, x, y, width, height);
 
@@ -569,10 +538,7 @@
 	{
 		int tmp = height; height = width; width = tmp;
 
-		x = x + 1;
-		y = y - 1;
-		width = width + 2;
-		height = height - 2;
+		x = x + 1; y = y - 1; width = width + 2; height = height - 2;
 
 		if (progressbar->orientation == MRN_ORIENTATION_TOP_TO_BOTTOM)
 			rotate_mirror_translate (cr, M_PI/2, x, y, FALSE, FALSE);
@@ -589,39 +555,15 @@
 	cairo_save (cr);
 	cairo_rectangle (cr, 1, 0, width-2, height);
 
-	/* Draw fill */
-	murrine_set_gradient (cr, fill, widget->mrn_gradient, 1, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, 1, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, 1, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, 1, 0, width-2, height);
-	}
-
-	murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 1, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, 1, width, height);
-		MurrineRGB shadow;
-		murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-		murrine_set_gradient (cr, &shadow, widget->mrn_gradient, 1, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 1, 0, width-2, height);
 
 	if (widget->glazestyle != 4)
 	{
+		MurrineRGB highlight;
+
+		murrine_shade (fill, widget->highlight_ratio, &highlight);
 		murrine_shade (fill, widget->highlight_ratio*widget->lightborder_ratio, &highlight);
+
 		murrine_draw_lightborder (cr, &highlight, fill, widget->mrn_gradient,
 		                          2.5, 1.5, width-5, height-3,
 		                          widget->mrn_gradient.gradients, TRUE,
@@ -691,40 +633,13 @@
 
 	if (menubarstyle == 1) /* Glass menubar */
 	{
-		MurrineRGB highlight;
-
-		murrine_shade (fill, widget->highlight_ratio, &highlight);
-
-		murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-		/* The glass effect */
-		if (widget->glazestyle > 0)
-		{
-			widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-			if (widget->glazestyle < 3)
-				murrine_draw_curved_highlight (cr, 0, width, height);
-			else
-				murrine_draw_curved_highlight_top (cr, 0, width, height);
-		}
-		else
-		{
-			cairo_fill (cr);
-			murrine_draw_flat_highlight (cr, 0, 0, width, height);
-		}
-
-		murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-
-		if (widget->glazestyle == 4)
-		{
-			murrine_draw_curved_highlight_bottom (cr, 0, width, height);
-			MurrineRGB shadow;
-			murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-			murrine_set_color_rgb (cr, &shadow);
-			cairo_fill (cr);
-		}
+		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 0, 0, width, height);
 
 		if (widget->glazestyle == 2)
 		{
+			MurrineRGB highlight;
+			murrine_shade (fill, widget->highlight_ratio, &highlight);
+
 			murrine_draw_lightborder (cr, &highlight, fill, widget->mrn_gradient,
 			                          1.5, 1.5, width-3, height-3,
 			                          widget->mrn_gradient.gradients, TRUE,
@@ -735,19 +650,13 @@
 	else if (menubarstyle == 2) /* Gradient menubar */
 	{
 		cairo_pattern_t *pattern;
+		double alpha = !widget->mrn_gradient.use_rgba ? 1.0 : 0.7;
 		MurrineRGB lower;
 		murrine_shade (fill, 0.95, &lower);
+
 		pattern = cairo_pattern_create_linear (0, 0, 0, height);
-		if (!widget->mrn_gradient.use_rgba)
-		{
-			cairo_pattern_add_color_stop_rgb (pattern, 0.0, fill->r, fill->g, fill->b);
-			cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower.r, lower.g, lower.b);
-		}
-		else
-		{
-			cairo_pattern_add_color_stop_rgba (pattern, 0.0, fill->r, fill->g, fill->b, 0.7);
-			cairo_pattern_add_color_stop_rgba (pattern, 1.0, lower.r, lower.g, lower.b, 0.7);
-		}
+		cairo_pattern_add_color_stop_rgba (pattern, 0.0, fill->r, fill->g, fill->b, alpha);
+		cairo_pattern_add_color_stop_rgba (pattern, 1.0, lower.r, lower.g, lower.b, alpha);
 		cairo_set_source (cr, pattern);
 		cairo_fill (cr);
 		cairo_pattern_destroy (pattern);
@@ -755,17 +664,20 @@
 	else if (menubarstyle == 3) /* Striped menubar */
 	{
 		cairo_pattern_t *pattern;
+		int counter = -height;
 		MurrineRGB low, top;
 		murrine_shade (fill, 0.9, &top);
 		murrine_shade (fill, 1.1, &low);
+
 		pattern = cairo_pattern_create_linear (0, 0, 0, height);
 		cairo_pattern_add_color_stop_rgb (pattern, 0.0, top.r, top.g, top.b);
 		cairo_pattern_add_color_stop_rgb (pattern, 1.0, low.r, low.g, low.b);
 		cairo_set_source (cr, pattern);
 		cairo_fill (cr);
 		cairo_pattern_destroy (pattern);
-		int counter = -height;
+
 		cairo_set_line_width  (cr, 1.0);
+
 		murrine_shade (&low, 0.9, &low);
 		murrine_set_color_rgb (cr, &low);
 		while (counter < width)
@@ -797,6 +709,66 @@
 #endif
 }
 
+/* We can't draw transparent things here, since it will be called on the same
+ * surface multiple times, when placed on a handlebox_bin or dockitem_bin */
+static void
+murrine_draw_toolbar (cairo_t *cr,
+                      const MurrineColors    *colors,
+                      const WidgetParameters *widget,
+                      const ToolbarParameters *toolbar,
+                      int x, int y, int width, int height)
+{
+	const MurrineRGB *dark = &colors->shade[3];
+	const MurrineRGB *fill = &colors->bg[0];
+	const MurrineRGB *top  = &colors->shade[0];
+
+	cairo_set_line_width (cr, 1.0);
+	cairo_translate      (cr, x, y);
+	cairo_rectangle (cr, 0, 0, width, height);
+
+#ifdef HAVE_MACMENU
+	murrine_set_color_rgb (cr, fill);
+	cairo_fill (cr);
+#else
+	/* Glass toolbar */
+	if (toolbar->style == 1)
+	{
+		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 0, 0, width, height);
+	}
+	else if (toolbar->style == 2)
+	{
+		cairo_pattern_t *pattern;
+		MurrineRGB lower;
+		murrine_shade (fill, 0.95, &lower);
+		pattern = cairo_pattern_create_linear (0, 0, 0, height);
+		cairo_pattern_add_color_stop_rgb (pattern, 0.0, fill->r, fill->g, fill->b);
+		cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower.r, lower.g, lower.b);
+		cairo_set_source (cr, pattern);
+		cairo_fill (cr);
+		cairo_pattern_destroy (pattern);
+	}
+	else /* Flat toolbar */
+	{
+		murrine_set_color_rgb (cr, fill);
+		cairo_fill (cr);
+		/* Draw highlight */
+		if (!toolbar->topmost)
+		{
+			cairo_move_to         (cr, 0, 0.5);
+			cairo_line_to         (cr, width, 0.5);
+			murrine_set_color_rgb (cr, top);
+			cairo_stroke          (cr);
+		}
+	}
+#endif
+
+	/* Draw shadow */
+	murrine_set_color_rgb (cr, dark);
+	cairo_move_to         (cr, 0, height-0.5);
+	cairo_line_to         (cr, width, height-0.5);
+	cairo_stroke          (cr);
+}
+
 static void
 murrine_get_frame_gap_clip (int x, int y, int width, int height,
                             const FrameParameters *frame,
@@ -1207,40 +1179,12 @@
 	/* Effects */
 	if (header->style > 0)
 	{
-		MurrineRGB highlight_header;
-
-		murrine_shade (fill, widget->highlight_ratio, &highlight_header);
 		/* Glassy header */
 		if (header->style == 1)
 		{
 			cairo_rectangle (cr, 0, 0, width, height);
-			murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height-1, widget->mrn_gradient.gradients, FALSE);
-			/* Glass effect */
-			if (widget->glazestyle > 0)
-			{
-				widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-				if (widget->glazestyle < 3)
-					murrine_draw_curved_highlight (cr, 0, width, height);
-				else
-					murrine_draw_curved_highlight_top (cr, 0, width, height);
-			}
-			else
-			{
-				cairo_fill (cr);
-				murrine_draw_flat_highlight (cr, 0 , 0 , width, height);
-			}
-
-			murrine_set_gradient (cr, &highlight_header, widget->mrn_gradient, 0, 0, 0, height-1, widget->mrn_gradient.gradients, TRUE);
-			cairo_fill (cr);
 
-			if (widget->glazestyle == 4)
-			{
-				murrine_draw_curved_highlight_bottom (cr, 0, width, height);
-				MurrineRGB shadow;
-				murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-				murrine_set_gradient (cr, &shadow, widget->mrn_gradient, 0, 0, 0, height-1, widget->mrn_gradient.gradients, TRUE);
-				cairo_fill (cr);
-			}
+			murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 0, 0, width, height-1);
 
 			if (widget->glazestyle == 2)
 			{
@@ -1306,96 +1250,6 @@
 	}
 }
 
-/* We can't draw transparent things here, since it will be called on the same
- * surface multiple times, when placed on a handlebox_bin or dockitem_bin */
-static void
-murrine_draw_toolbar (cairo_t *cr,
-                      const MurrineColors    *colors,
-                      const WidgetParameters *widget,
-                      const ToolbarParameters *toolbar,
-                      int x, int y, int width, int height)
-{
-	const MurrineRGB *dark = &colors->shade[3];
-	const MurrineRGB *fill = &colors->bg[0];
-	const MurrineRGB *top  = &colors->shade[0];
-
-	cairo_set_line_width (cr, 1.0);
-	cairo_translate      (cr, x, y);
-	cairo_rectangle (cr, 0, 0, width, height);
-
-#ifdef HAVE_MACMENU
-	murrine_set_color_rgb (cr, fill);
-	cairo_fill (cr);
-#else
-	/* Glass toolbar */
-	if (toolbar->style == 1)
-	{
-		MurrineRGB highlight;
-
-		murrine_shade (fill, widget->highlight_ratio, &highlight);
-
-		murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-		/* Glass effect */
-		if (widget->glazestyle > 0)
-		{
-			widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-			if (widget->glazestyle < 3)
-				murrine_draw_curved_highlight (cr, 0, width, height);
-			else
-				murrine_draw_curved_highlight_top (cr, 0, width, height);
-		}
-		else
-		{
-			cairo_fill (cr);
-			murrine_draw_flat_highlight (cr, 0, 0, width, height);
-		}
-
-		murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-
-		if (widget->glazestyle == 4)
-		{
-			murrine_draw_curved_highlight_bottom (cr, 0, width, height);
-			MurrineRGB shadow;
-			murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-			murrine_set_color_rgb (cr, &shadow);
-			cairo_fill (cr);
-		}
-	}
-	else if (toolbar->style == 2)
-	{
-		cairo_pattern_t *pattern;
-		MurrineRGB lower;
-		murrine_shade (fill, 0.95, &lower);
-		pattern = cairo_pattern_create_linear (0, 0, 0, height);
-		cairo_pattern_add_color_stop_rgb (pattern, 0.0, fill->r, fill->g, fill->b);
-		cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower.r, lower.g, lower.b);
-		cairo_set_source (cr, pattern);
-		cairo_fill (cr);
-		cairo_pattern_destroy (pattern);
-	}
-	else /* Flat toolbar */
-	{
-		murrine_set_color_rgb (cr, fill);
-		cairo_fill (cr);
-		/* Draw highlight */
-		if (!toolbar->topmost)
-		{
-			cairo_move_to         (cr, 0, 0.5);
-			cairo_line_to         (cr, width, 0.5);
-			murrine_set_color_rgb (cr, top);
-			cairo_stroke          (cr);
-		}
-	}
-#endif
-
-	/* Draw shadow */
-	murrine_set_color_rgb (cr, dark);
-	cairo_move_to         (cr, 0, height-0.5);
-	cairo_line_to         (cr, width, height-0.5);
-	cairo_stroke          (cr);
-}
-
 static void
 murrine_draw_menuitem (cairo_t *cr,
                        const MurrineColors    *colors,
@@ -1405,8 +1259,6 @@
 {
 	const MurrineRGB *fill   = &colors->spot[1];
 	const MurrineRGB *border = &colors->spot[2];
-	MurrineRGB highlight;
-	murrine_shade (fill, widget->highlight_ratio, &highlight);
 
 	cairo_translate      (cr, x, y);
 	cairo_set_line_width (cr, 1.0);
@@ -1442,34 +1294,15 @@
 	{
 		if (widget->roundness > 1)
 			cairo_clip_preserve (cr);
-		/* Glass effect */
-		if (widget->glazestyle > 0)
-		{
-			widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-			if (widget->glazestyle < 3)
-				murrine_draw_curved_highlight (cr, 0, width, height);
-			else
-				murrine_draw_curved_highlight_top (cr, 0, width, height);
-		}
-		else
-		{
-			cairo_fill (cr);
-			murrine_draw_flat_highlight (cr, 0, 0, width, height);
-		}
-		murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
 
-		if (widget->glazestyle == 4)
-		{
-			murrine_draw_curved_highlight_bottom (cr, 0, width, height);
-			MurrineRGB shadow;
-			murrine_shade (&colors->spot[1], 1.0/widget->highlight_ratio, &shadow);
-			murrine_set_gradient (cr, &shadow, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-			cairo_fill (cr);
-		}
+		murrine_draw_glaze (cr, &colors->spot[1], widget->highlight_ratio, widget->mrn_gradient, widget, 0, 0, width, height);
 
 		if (widget->glazestyle == 2)
 		{
+			MurrineRGB highlight;
+
+			murrine_shade (fill, widget->highlight_ratio, &highlight);
+
 			murrine_draw_lightborder (cr, &highlight, fill, widget->mrn_gradient,
 			                          1.5, 1.5, width-3, height-3,
 			                          widget->mrn_gradient.gradients, TRUE,
@@ -1536,10 +1369,9 @@
 {
 	const MurrineRGB *fill  = &colors->bg[widget->state_type];
 	MurrineRGB border_normal;
-	MurrineRGB highlight;
+
 
 	murrine_shade (&colors->shade[6], 0.95, &border_normal);
-	murrine_shade (fill, widget->highlight_ratio, &highlight);
 
 	if (!scrollbar->horizontal)
 		murrine_exchange_axis (cr, &x, &y, &width, &height);
@@ -1552,45 +1384,19 @@
 
 	/* Draw the bg */
 	murrine_rounded_rectangle_closed (cr, 1, 1, width-2, height-2, widget->roundness, widget->corners);
-	murrine_set_gradient (cr, fill, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, FALSE);
 
 	cairo_save (cr);
 
-	int curve_pos = 1;
-	if (widget->glazestyle != 4)
-		curve_pos = 2;
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, curve_pos, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, curve_pos, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, 1, 1, width-2, height-2);
-	}
-
-	murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, curve_pos, width, height);
-		MurrineRGB shadow;
-		murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-		murrine_set_gradient (cr, &shadow, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 1, 1, width-2, height-2);
 
 	/* Draw the white inner border */
 	if (widget->glazestyle != 4)
 	{
+		MurrineRGB highlight;
+
+		murrine_shade (fill, widget->highlight_ratio, &highlight);
 		murrine_shade (fill, widget->lightborder_ratio*widget->highlight_ratio, &highlight);
+
 		murrine_draw_lightborder (cr, &highlight, fill, widget->mrn_gradient,
 		                          1.5, 1.5, width-3, height-3,
 		                          widget->mrn_gradient.gradients, scrollbar->horizontal,
@@ -1640,14 +1446,13 @@
 	/* Set colors */
 	MurrineRGB fill = scrollbar->has_color ? scrollbar->color : colors->bg[0];
 	MurrineRGB border;
-	MurrineRGB highlight;
+
 
 	murrine_shade (&colors->shade[6], 0.95, &border);
 
 	if (widget->prelight)
 		murrine_shade (&fill, 1.06, &fill);
 
-	murrine_shade (&fill, widget->highlight_ratio, &highlight);
 	/* Draw the border */
 	murrine_mix_color (&border, &fill, 0.4, &border);
 
@@ -1668,38 +1473,16 @@
 	cairo_stroke (cr);
 
 	cairo_rectangle (cr, 1, 1, width-2, height-2);
-	murrine_set_gradient (cr, &fill, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, FALSE);
 
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, 1, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, 1, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, 1, 1, width-2, height-2);
-	}
-
-	murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, 1, width, height);
-		MurrineRGB shadow;
-		murrine_shade (&fill, 1.0/widget->highlight_ratio, &shadow);
-		murrine_set_color_rgb (cr, &shadow);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, &fill, widget->highlight_ratio, widget->mrn_gradient, widget, 1, 1, width-2, height-2);
 
 	if (widget->glazestyle != 4)
 	{
+		MurrineRGB highlight;
+
+		murrine_shade (&fill, widget->highlight_ratio, &highlight);
 		murrine_shade (&fill, widget->lightborder_ratio*widget->highlight_ratio, &highlight);
+
 		murrine_draw_lightborder (cr, &highlight, &fill, widget->mrn_gradient,
 		                          1.5, 1.5, width-3, height-3,
 		                          widget->mrn_gradient.gradients, TRUE,
@@ -1801,7 +1584,6 @@
 	MurrineRGB border;
 
 	cairo_save (cr);
-
 	cairo_translate (cr, x, y);
 
 	murrine_set_gradient (cr, &fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
@@ -1810,12 +1592,11 @@
 
 	murrine_shade (&fill, (!widget->mrn_gradient.gradients ? 0.9 : 0.95), &border);
 
+	murrine_set_color_rgb (cr, &border);
 	cairo_move_to  (cr, 0, 0.5);
 	cairo_rel_line_to (cr, width, 0);
 	cairo_move_to (cr, 0, height-0.5);
 	cairo_rel_line_to (cr, width, 0);
-
-	murrine_set_color_rgb (cr, &border);
 	cairo_stroke (cr);
 
 	cairo_restore (cr);
@@ -1832,15 +1613,15 @@
 
 	cairo_set_line_width  (cr, 1);
 	cairo_translate       (cr, x, y+0.5);
+
+	murrine_set_color_rgb (cr, dark);
 	cairo_move_to         (cr, 0, 0);
 	cairo_line_to         (cr, width, 0);
-	murrine_set_color_rgb (cr, dark);
 	cairo_stroke          (cr);
 
-	cairo_translate       (cr, 0, 1);
-	cairo_move_to         (cr, 0, 0);
-	cairo_line_to         (cr, width, 0);
 	murrine_set_color_rgb (cr, highlight);
+	cairo_move_to         (cr, 0, 1);
+	cairo_line_to         (cr, width, 1);
 	cairo_stroke          (cr);
 }
 

Modified: trunk/src/murrine_draw_rgba.c
==============================================================================
--- trunk/src/murrine_draw_rgba.c	(original)
+++ trunk/src/murrine_draw_rgba.c	Mon Sep 29 00:25:50 2008
@@ -195,7 +195,6 @@
 
 	/* Draw the bg */
 	murrine_rounded_rectangle_closed (cr, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2, widget->roundness, widget->corners);
-	murrine_set_gradient (cr, &fill, mrn_gradient_custom, xos+1, yos+1, 0, height-(yos*2)-2, widget->mrn_gradient.gradients, FALSE);
 
 	cairo_save (cr);
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
@@ -203,37 +202,7 @@
 	if (widget->roundness > 1)
 		cairo_clip_preserve (cr);
 
-	int curve_pos = 1;
-	if (widget->glazestyle != 4)
-		curve_pos = 2;
-
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, curve_pos, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, curve_pos, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2);
-	}
-
-	murrine_set_gradient (cr, &highlight, mrn_gradient_custom, xos+1, yos+1, 0, height-(yos*2)-2, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, curve_pos, width, height);
-		MurrineRGB shadow;
-		murrine_shade (&fill, 1.0/custom_highlight_ratio, &shadow);
-		murrine_set_gradient (cr, &shadow, mrn_gradient_custom, xos+1, yos+1, 0, height-(yos*2)-2, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, &fill, custom_highlight_ratio, mrn_gradient_custom, widget, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2);
 
 	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
@@ -320,14 +289,9 @@
 	cairo_translate (cr, x+0.5, y+0.5);
 	cairo_set_line_width (cr, 1.0);
 
-	/* Draw (erase) the background */
-	/* // CLEARING should be useless... testing
-	cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
-	cairo_paint (cr);
-	*/
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
 
-	/* Fill the entry's base color (why isn't is large enough by default?) */
+	/* Fill the entry's base color */
 	cairo_rectangle (cr, 1.5, 1.5, width-4, height-4);
 	murrine_set_color_rgba (cr, base, ENTRY_OPACITY);
 	cairo_fill (cr);
@@ -510,9 +474,6 @@
 	int        x_step;
 	const      MurrineRGB *fill = &colors->spot[1];
 	MurrineRGB border = colors->spot[2];
-	MurrineRGB highlight;
-
-	murrine_shade (fill, widget->highlight_ratio, &highlight);
 
 	cairo_rectangle (cr, x, y, width, height);
 
@@ -527,10 +488,7 @@
 	{
 		int tmp = height; height = width; width = tmp;
 
-		x = x + 1;
-		y = y - 1;
-		width = width + 2;
-		height = height - 2;
+		x = x + 1; y = y - 1; width = width + 2; height = height - 2;
 
 		if (progressbar->orientation == MRN_ORIENTATION_TOP_TO_BOTTOM)
 			rotate_mirror_translate (cr, M_PI/2, x, y, FALSE, FALSE);
@@ -550,41 +508,17 @@
 
 	cairo_rectangle (cr, 1, 0, width-2, height);
 
-	/* Draw fill */
-	murrine_set_gradient (cr, fill, widget->mrn_gradient, 1, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, 1, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, 1, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, 1, 0, width-2, height);
-	}
-
-	murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 1, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, 1, width, height);
-		MurrineRGB shadow;
-		murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-		murrine_set_gradient (cr, &shadow, widget->mrn_gradient, 1, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 1, 0, width-2, height);
 
 	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
 	if (widget->glazestyle != 4)
 	{
+		MurrineRGB highlight;
+
+		murrine_shade (fill, widget->highlight_ratio, &highlight);
 		murrine_shade (fill, widget->highlight_ratio*widget->lightborder_ratio, &highlight);
+
 		murrine_draw_lightborder (cr, &highlight, fill, widget->mrn_gradient,
 		                          2.5, 1.5, width-5, height-3,
 		                          widget->mrn_gradient.gradients, TRUE,
@@ -632,41 +566,15 @@
 	if (menubarstyle == 1)
 	{
 		/* XXX: should use another gradient rgba_opacity */
-		MurrineRGB highlight;
-
-		murrine_shade (fill, widget->highlight_ratio, &highlight);
-
-		murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-		if (widget->glazestyle > 0)
-		{
-			widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-			if (widget->glazestyle < 3)
-				murrine_draw_curved_highlight (cr, 0, width, height);
-			else
-				murrine_draw_curved_highlight_top (cr, 0, width, height);
-		}
-		else
-		{
-			cairo_fill (cr);
-			murrine_draw_flat_highlight (cr, 0, 0, width, height);
-		}
-
-		murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-
-		if (widget->glazestyle == 4)
-		{
-			murrine_draw_curved_highlight_bottom (cr, 0, width, height);
-			MurrineRGB shadow;
-			murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-			murrine_set_color_rgb (cr, &shadow);
-			cairo_fill (cr);
-		}
+		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 0, 0, width, height);
 
 		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
 		if (widget->glazestyle == 2)
 		{
+			MurrineRGB highlight;
+			murrine_shade (fill, widget->highlight_ratio, &highlight);
+
 			murrine_draw_lightborder (cr, &highlight, fill, widget->mrn_gradient,
 			                          1.5, 1.5, width-3, height-3,
 			                          widget->mrn_gradient.gradients, TRUE,
@@ -679,6 +587,7 @@
 		cairo_pattern_t *pattern;
 		MurrineRGB lower;
 		murrine_shade (fill, 0.95, &lower);
+
 		pattern = cairo_pattern_create_linear (0, 0, 0, height);
 		cairo_pattern_add_color_stop_rgba (pattern, 0.0, fill->r, fill->g, fill->b, MENUBAR_OPACITY);
 		cairo_pattern_add_color_stop_rgba (pattern, 1.0, lower.r, lower.g, lower.b, MENUBAR_OPACITY);
@@ -779,37 +688,7 @@
 	if (toolbar->style == 1)
 	{
 		/* XXX: should use another gradient rgba_opacity */
-		MurrineRGB highlight;
-
-		murrine_shade (fill, widget->highlight_ratio, &highlight);
-
-		murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-		/* Glass effect */
-		if (widget->glazestyle > 0)
-		{
-			widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-			if (widget->glazestyle < 3)
-				murrine_draw_curved_highlight (cr, 0, width, height);
-			else
-				murrine_draw_curved_highlight_top (cr, 0, width, height);
-		}
-		else
-		{
-			cairo_fill (cr);
-			murrine_draw_flat_highlight (cr, 0, 0, width, height);
-		}
-
-		murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-
-		if (widget->glazestyle == 4)
-		{
-			murrine_draw_curved_highlight_bottom (cr, 0, width, height);
-			MurrineRGB shadow;
-			murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-			murrine_set_color_rgb (cr, &shadow);
-			cairo_fill (cr);
-		}
+		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 0, 0, width, height);
 
 		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 	}
@@ -1063,11 +942,6 @@
 			cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
 	}
 
-/*	murrine_set_color_rgba (cr, &colors->bg[0], 0.0); */
-/*	/* Draw (erase) the background */
-/*	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-	cairo_paint (cr); */
-
 	/* Set tab shape */
 	murrine_rounded_rectangle_closed (cr, 0, 0, width-1, height-1, widget->roundness, widget->corners);
 
@@ -1275,10 +1149,8 @@
 {
 	const MurrineRGB *fill  = &colors->bg[widget->state_type];
 	MurrineRGB border_normal;
-	MurrineRGB highlight;
 
 	murrine_shade (&colors->shade[7], 0.95, &border_normal);
-	murrine_shade (fill, widget->highlight_ratio, &highlight);
 
 	if (!scrollbar->horizontal)
 		murrine_exchange_axis (cr, &x, &y, &width, &height);
@@ -1292,47 +1164,21 @@
 
 	/* Draw the bg */
 	murrine_rounded_rectangle_closed (cr, 1, 1, width-2, height-2, widget->roundness, widget->corners);
-	murrine_set_gradient (cr, fill, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, FALSE);
 
 	cairo_save (cr);
 
-	int curve_pos = 1;
-	if (widget->glazestyle != 4)
-		curve_pos = 2;
-
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, curve_pos, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, curve_pos, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, 1, 1, width-2, height-2);
-	}
-
-	murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, curve_pos, width, height);
-		MurrineRGB shadow;
-		murrine_shade (fill, 1.0/widget->highlight_ratio, &shadow);
-		murrine_set_gradient (cr, &shadow, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, TRUE);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->mrn_gradient, widget, 1, 1, width-2, height-2);
 
 	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
 	/* Draw the white inner border */
 	if (widget->glazestyle != 4)
 	{
+		MurrineRGB highlight;
+
+		murrine_shade (fill, widget->highlight_ratio, &highlight);
+		murrine_shade (fill, widget->lightborder_ratio*widget->highlight_ratio, &highlight);
+
 		murrine_shade (fill, widget->lightborder_ratio*widget->highlight_ratio, &highlight);
 		murrine_draw_lightborder (cr, &highlight, fill, widget->mrn_gradient,
 		                          1.5, 1.5, width-3, height-3,
@@ -1383,14 +1229,12 @@
 	/* Set colors */
 	MurrineRGB fill = scrollbar->has_color ? scrollbar->color : colors->bg[0];
 	MurrineRGB border;
-	MurrineRGB highlight;
 
 	murrine_shade (&colors->shade[7], 0.95, &border);
 
 	if (widget->prelight)
 		murrine_shade (&fill, 1.06, &fill);
 
-	murrine_shade (&fill, widget->highlight_ratio, &highlight);
 	/* Draw the border */
 	murrine_mix_color (&border, &fill, 0.5, &border);
 
@@ -1412,40 +1256,18 @@
 	cairo_stroke (cr);
 
 	cairo_rectangle (cr, 1, 1, width-2, height-2);
-	murrine_set_gradient (cr, &fill, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, FALSE);
 
-	/* Draw the glass effect */
-	if (widget->glazestyle > 0)
-	{
-		widget->glazestyle == 2 ? cairo_fill_preserve (cr) : cairo_fill (cr);
-		if (widget->glazestyle < 3)
-			murrine_draw_curved_highlight (cr, 1, width, height);
-		else
-			murrine_draw_curved_highlight_top (cr, 1, width, height);
-	}
-	else
-	{
-		cairo_fill (cr);
-		murrine_draw_flat_highlight (cr, 1, 1, width-2, height-2);
-	}
-
-	murrine_set_gradient (cr, &highlight, widget->mrn_gradient, 1, 1, 0, height-2, widget->mrn_gradient.gradients, TRUE);
-	cairo_fill (cr);
-
-	if (widget->glazestyle == 4)
-	{
-		murrine_draw_curved_highlight_bottom (cr, 1, width, height);
-		MurrineRGB shadow;
-		murrine_shade (&fill, 1.0/widget->highlight_ratio, &shadow);
-		murrine_set_color_rgb (cr, &shadow);
-		cairo_fill (cr);
-	}
+	murrine_draw_glaze (cr, &fill, widget->highlight_ratio, widget->mrn_gradient, widget, 1, 1, width-2, height-2);
 
 	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
 	if (widget->glazestyle != 4)
 	{
+		MurrineRGB highlight;
+
+		murrine_shade (&fill, widget->highlight_ratio, &highlight);
 		murrine_shade (&fill, widget->lightborder_ratio*widget->highlight_ratio, &highlight);
+
 		murrine_draw_lightborder (cr, &highlight, &fill, widget->mrn_gradient,
 		                          1.5, 1.5, width-3, height-3,
 		                          widget->mrn_gradient.gradients, TRUE,
@@ -1902,15 +1724,15 @@
 
 	cairo_set_line_width  (cr, 1);
 	cairo_translate       (cr, x, y+0.5);
+
+	murrine_set_color_rgb (cr, dark);
 	cairo_move_to         (cr, 0, 0);
 	cairo_line_to         (cr, width, 0);
-	murrine_set_color_rgb (cr, dark);
 	cairo_stroke          (cr);
 
-	cairo_translate        (cr, 0, 1);
-	cairo_move_to          (cr, 0, 0);
-	cairo_line_to          (cr, width, 0);
 	murrine_set_color_rgba (cr, highlight, 0.5);
+	cairo_move_to          (cr, 0, 1);
+	cairo_line_to          (cr, width, 1);
 	cairo_stroke           (cr);
 }
 



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