murrine r86 - in trunk: . src



Author: acimitan
Date: Mon Sep 29 22:21:16 2008
New Revision: 86
URL: http://svn.gnome.org/viewvc/murrine?rev=86&view=rev

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

	* src/cairo-support.c (murrine_draw_glaze):
	* src/murrine_draw.c (murrine_draw_inset), (murrine_draw_button),
	(murrine_draw_menubar), (murrine_draw_toolbar),
	(murrine_get_frame_gap_clip), (murrine_draw_list_view_header),
	(murrine_draw_menuitem), (murrine_draw_scrollbar_trough),
	(murrine_draw_scrollbar_stepper), (murrine_draw_scrollbar_slider):
	* src/murrine_draw_rgba.c (murrine_draw_inset),
	(murrine_rgba_draw_button), (murrine_rgba_draw_menubar),
	(murrine_rgba_draw_toolbar), (murrine_get_frame_gap_clip),
	(murrine_rgba_draw_scrollbar_trough),
	(murrine_rgba_draw_scrollbar_stepper),
	(murrine_rgba_draw_scrollbar_slider):
	Using switch instead of "else if"


Modified:
   trunk/ChangeLog
   trunk/src/cairo-support.c
   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 22:21:16 2008
@@ -513,7 +513,6 @@
 			murrine_draw_flat_highlight (cr, x, y, width, height);
 			break;
 		case 1:
-			
 			cairo_fill (cr);
 			murrine_draw_curved_highlight (cr, x, y, width, height);
 			break;

Modified: trunk/src/murrine_draw.c
==============================================================================
--- trunk/src/murrine_draw.c	(original)
+++ trunk/src/murrine_draw.c	Mon Sep 29 22:21:16 2008
@@ -40,7 +40,7 @@
 	murrine_shade (bg_color, 1.4, &highlight);
 
 	/* highlight */
-	cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
+	cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188));
 
 	if (corners & MRN_CORNER_TOPRIGHT)
 		cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.75, M_PI * 2);
@@ -159,12 +159,15 @@
 		mrn_gradient_custom = get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
 		custom_highlight_ratio = get_decreased_ratio (widget->highlight_ratio, 2.0);
 	}
+	else
+		murrine_shade (&colors->shade[6], 0.95, &border);
 
+	/* Default button */
 	if (widget->is_default && !widget->disabled)
+	{
+		murrine_shade (&border, 0.8, &border);
 		murrine_mix_color (&fill, &colors->spot[1], 0.2, &fill);
-
-	if (!widget->disabled)
-		murrine_shade (&colors->shade[6], 0.95, &border);
+	}
 
 	if (!horizontal)
 		murrine_exchange_axis (cr, &x, &y, &width, &height);
@@ -186,10 +189,6 @@
 
 	murrine_mix_color (&border, &fill, 0.4, &border);
 
-	/* Default button */
-	if (widget->is_default && !widget->disabled)
-		murrine_shade (&border, 0.8, &border);
-
 	/* Draw the bg */
 	murrine_rounded_rectangle_closed (cr, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2, widget->roundness-1, widget->corners);
 
@@ -596,59 +595,65 @@
 	cairo_translate (cr, x, y);
 	cairo_rectangle (cr, 0, 0, width, height);
 
-	if (menubarstyle == 1) /* Glass menubar */
-	{
-		int os = (widget->glazestyle == 2) ? 1 : 0;
-		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
-		                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
-		                    widget->roundness, widget->corners, TRUE);
-	}
-	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);
-		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);
-	}
-	else if (menubarstyle == 3) /* Striped menubar */
+	switch (menubarstyle)
 	{
-		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);
+		default:
+		case 0:
+			murrine_set_color_rgb (cr, fill);
+			cairo_fill (cr);
+			break;
+		case 1:
+		{
+			int os = (widget->glazestyle == 2) ? 1 : 0;
+			murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
+			                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
+			                    widget->roundness, widget->corners, TRUE);
+			break;
+		}
+		case 2: 
+		{
+			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);
+			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);
+			break;
+		}
+		case 3:
+		{
+			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);
 
-		cairo_set_line_width  (cr, 1.0);
+			cairo_set_line_width  (cr, 1.0);
 
-		murrine_shade (&low, 0.9, &low);
-		murrine_set_color_rgb (cr, &low);
-		while (counter < width)
-		{
-			cairo_move_to (cr, counter, height);
-			cairo_line_to (cr, counter+height, 0);
-			cairo_stroke  (cr);
-			counter += 5;
+			murrine_shade (&low, 0.9, &low);
+			murrine_set_color_rgb (cr, &low);
+			while (counter < width)
+			{
+				cairo_move_to (cr, counter, height);
+				cairo_line_to (cr, counter+height, 0);
+				cairo_stroke  (cr);
+				counter += 5;
+			}
+			break;
 		}
 	}
-	else /* Flat menubar */
-	{
-		murrine_set_color_rgb (cr, fill);
-		cairo_fill (cr);
-	}
 
 	/* Draw bottom line */
 	if (menubarstyle == 1 && widget->glazestyle == 2)
@@ -681,36 +686,41 @@
 	cairo_rectangle (cr, 0, 0, width, height);
 
 	/* Glass toolbar */
-	if (toolbar->style == 1)
+	switch (toolbar->style)
 	{
-		int os = (widget->glazestyle == 2) ? 1 : 0;
-		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
-		                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
-		                    widget->roundness, widget->corners, TRUE);
-	}
-	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)
+		default:
+		case 0:
+			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);
+			}
+			break;
+		case 1:
 		{
-			cairo_move_to         (cr, 0, 0.5);
-			cairo_line_to         (cr, width, 0.5);
-			murrine_set_color_rgb (cr, top);
-			cairo_stroke          (cr);
+			int os = (widget->glazestyle == 2) ? 1 : 0;
+			murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
+			                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
+			                    widget->roundness, widget->corners, TRUE);
+			break;
+		}
+		case 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);
+			break;
 		}
 	}
 
@@ -732,33 +742,32 @@
                             MurrineRectangle      *bevel,
                             MurrineRectangle      *border)
 {
-	if (frame->gap_side == MRN_GAP_TOP)
-	{
-		MURRINE_RECTANGLE_SET ((*bevel),  1.5 + frame->gap_x,  -0.5,
-		                       frame->gap_width - 3, 2.0);
-		MURRINE_RECTANGLE_SET ((*border), 0.5 + frame->gap_x,  -0.5,
-		                       frame->gap_width - 2, 2.0);
-	}
-	else if (frame->gap_side == MRN_GAP_BOTTOM)
-	{
-		MURRINE_RECTANGLE_SET ((*bevel),  1.5 + frame->gap_x,  height - 2.5,
-		                       frame->gap_width - 3, 2.0);
-		MURRINE_RECTANGLE_SET ((*border), 0.5 + frame->gap_x,  height - 1.5,
-		                       frame->gap_width - 2, 2.0);
-	}
-	else if (frame->gap_side == MRN_GAP_LEFT)
+	switch (frame->gap_side)
 	{
-		MURRINE_RECTANGLE_SET ((*bevel),  -0.5, 1.5 + frame->gap_x,
-		                       2.0, frame->gap_width - 3);
-		MURRINE_RECTANGLE_SET ((*border), -0.5, 0.5 + frame->gap_x,
-		                       1.0, frame->gap_width - 2);
-	}
-	else if (frame->gap_side == MRN_GAP_RIGHT)
-	{
-		MURRINE_RECTANGLE_SET ((*bevel),  width - 2.5, 1.5 + frame->gap_x,
-		                       2.0, frame->gap_width - 3);
-		MURRINE_RECTANGLE_SET ((*border), width - 1.5, 0.5 + frame->gap_x,
-		                       1.0, frame->gap_width - 2);
+		case MRN_GAP_TOP:
+			MURRINE_RECTANGLE_SET ((*bevel),  1.5+frame->gap_x, -0.5,
+			                       frame->gap_width-3, 2.0);
+			MURRINE_RECTANGLE_SET ((*border), 0.5+frame->gap_x, -0.5,
+			                       frame->gap_width-2, 2.0);
+			break;
+		case MRN_GAP_BOTTOM:
+			MURRINE_RECTANGLE_SET ((*bevel),  1.5+frame->gap_x, height-2.5,
+			                       frame->gap_width-3, 2.0);
+			MURRINE_RECTANGLE_SET ((*border), 0.5+frame->gap_x, height-1.5,
+			                       frame->gap_width-2, 2.0);
+			break;
+		case MRN_GAP_LEFT:
+			MURRINE_RECTANGLE_SET ((*bevel),  -0.5, 1.5+frame->gap_x,
+			                       2.0, frame->gap_width-3);
+			MURRINE_RECTANGLE_SET ((*border), -0.5, 0.5+frame->gap_x,
+			                       1.0, frame->gap_width-2);
+			break;
+		case MRN_GAP_RIGHT:
+			MURRINE_RECTANGLE_SET ((*bevel),  width-2.5, 1.5+frame->gap_x,
+			                       2.0, frame->gap_width-3);
+			MURRINE_RECTANGLE_SET ((*border), width-1.5, 0.5+frame->gap_x,
+			                       1.0, frame->gap_width-2);
+			break;
 	}
 }
 
@@ -1130,20 +1139,16 @@
 	cairo_stroke (cr);
 
 	/* Effects */
-	if (header->style > 0)
+	switch (header->style)
 	{
-		/* Glassy header */
-		if (header->style == 1)
-		{
+		case 1:
 			cairo_rectangle (cr, 0, 0, width, height);
 
 			murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
 			                    widget->mrn_gradient, widget, 0, 0, width, height-1,
 			                    widget->roundness, widget->corners, TRUE);
-		}
-		/* Raised */
-		else if (header->style == 2)
-		{
+			break;
+		case 2:
 			border = (MurrineRGB*)&colors->shade[4];
 			MurrineRGB shadow_header;
 			murrine_shade (fill, 0.925, &shadow_header);
@@ -1164,7 +1169,7 @@
 				cairo_rectangle       (cr, 0.0, height-4.0, width, 3.0);
 			}
 			cairo_fill (cr);
-		}
+			break;
 	}
 	/* Draw bottom border */
 	murrine_set_color_rgb (cr, border);
@@ -1210,50 +1215,52 @@
 	cairo_set_line_width (cr, 1.0);
 	murrine_rounded_rectangle_closed (cr, 0, 0, width, height, widget->roundness, widget->corners);
 
-	/* Striped */
-	if (menuitemstyle == 2)
+	switch (menuitemstyle)
 	{
-		murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-		cairo_fill (cr);
-		double tile_pos = 0;
-		double stroke_width;
-		int    x_step;
-		stroke_width = height*2;
-		cairo_save (cr);
-		x_step = (((float)stroke_width/10));
-		/* Draw strokes */
-		while (tile_pos <= width+x_step-2)
-		{
-			cairo_move_to (cr, stroke_width/2-x_step, 0);
-			cairo_line_to (cr, stroke_width-x_step,   0);
-			cairo_line_to (cr, stroke_width/2-x_step, height);
-			cairo_line_to (cr, -x_step, height);
-			cairo_translate (cr, stroke_width, 0);
-			tile_pos += stroke_width;
-		}
-		murrine_set_color_rgba (cr, border, 0.15);
-		cairo_fill (cr);
-		cairo_restore (cr);
-	}
-	/* Glassy */
-	else if (menuitemstyle != 0)
-	{
-		if (widget->roundness > 1)
-			cairo_clip_preserve (cr);
+		default:
+		case 1:
+			if (widget->roundness > 1)
+				cairo_clip_preserve (cr);
 
-		murrine_draw_glaze (cr, &colors->spot[1], widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
-		                    widget->mrn_gradient, widget, 1, 1, width-2, height-2,
-		                    widget->roundness, widget->corners, TRUE);
-	}
-	else
-	{
-		murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
-		cairo_fill (cr);
+			murrine_draw_glaze (cr, &colors->spot[1], widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
+			                    widget->mrn_gradient, widget, 1, 1, width-2, height-2,
+			                    widget->roundness, widget->corners, TRUE);
+			break;
+		case 0:
+			murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
+			cairo_fill (cr);
 
-		murrine_set_color_rgba (cr, border, 0.15);
-		murrine_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, widget->roundness, widget->corners);
-		cairo_fill_preserve (cr);
+			murrine_set_color_rgba (cr, border, 0.15);
+			murrine_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, widget->roundness, widget->corners);
+			cairo_fill_preserve (cr);
+			break;
+		case 2:
+		{
+			murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
+			cairo_fill (cr);
+			double tile_pos = 0;
+			double stroke_width;
+			int    x_step;
+			stroke_width = height*2;
+			cairo_save (cr);
+			x_step = (((float)stroke_width/10));
+			/* Draw strokes */
+			while (tile_pos <= width+x_step-2)
+			{
+				cairo_move_to (cr, stroke_width/2-x_step, 0);
+				cairo_line_to (cr, stroke_width-x_step,   0);
+				cairo_line_to (cr, stroke_width/2-x_step, height);
+				cairo_line_to (cr, -x_step, height);
+				cairo_translate (cr, stroke_width, 0);
+				tile_pos += stroke_width;
+			}
+			murrine_set_color_rgba (cr, border, 0.15);
+			cairo_fill (cr);
+			cairo_restore (cr);
+			break;
+		}
 	}
+
 	murrine_set_color_rgba (cr, border, 0.8);
 	murrine_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, widget->roundness, widget->corners);
 	cairo_stroke (cr);
@@ -1273,17 +1280,17 @@
 
 	cairo_set_line_width (cr, 1.0);
 
-	if (scrollbar->horizontal)
+	if (!scrollbar->horizontal)
+	{
+		cairo_translate (cr, x, y);
+	}
+	else
 	{
 		int tmp = height;
 		rotate_mirror_translate (cr, M_PI/2, x, y, FALSE, FALSE);
 		height = width;
 		width = tmp;
 	}
-	else
-	{
-		cairo_translate (cr, x, y);
-	}
 
 	/* Draw fill */
 	murrine_set_color_rgba (cr, &fill, 0.4);
@@ -1329,7 +1336,6 @@
 	                    widget->mrn_gradient, widget, 1, 1, width-2, height-2,
 	                    widget->roundness, widget->corners, TRUE);
 
-	cairo_reset_clip (cr);
 	cairo_restore (cr);
 
 	murrine_set_color_rgb (cr, &border);
@@ -1407,36 +1413,36 @@
 	if (scrollbar->style > 0)
 		murrine_shade (&fill, 0.55, &style);
 
-	/* Draw the circles */
-	if (scrollbar->style == 1)
+	switch (scrollbar->style)
 	{
-		int circ_radius = 2;
-		int circ_space = 5;
-		int i;
-		int x1 = circ_space+circ_radius;
-		int y1 = height/2;
-		for (i = circ_space; i < width-circ_space; i += 2*circ_radius+circ_space)
+		case 1:
 		{
-			cairo_move_to (cr, i, 1);
-			cairo_arc (cr, x1, y1, circ_radius, 0, M_PI*2);
+			int circ_radius = 2;
+			int circ_space = 5;
+			int i;
+			int x1 = circ_space+circ_radius;
+			int y1 = height/2;
+			for (i = circ_space; i < width-circ_space; i += 2*circ_radius+circ_space)
+			{
+				cairo_move_to (cr, i, 1);
+				cairo_arc (cr, x1, y1, circ_radius, 0, M_PI*2);
 
-			x1 += 2*circ_radius+circ_space;
+				x1 += 2*circ_radius+circ_space;
 
-			cairo_close_path (cr);
-			murrine_set_color_rgba (cr, &style, 0.15);
-			cairo_fill (cr);
+				cairo_close_path (cr);
+				murrine_set_color_rgba (cr, &style, 0.15);
+				cairo_fill (cr);
+			}
+			break;
 		}
-	}
-	if (scrollbar->style > 2)
-	{
-		/* Draw the diagonal strokes */
-		if (scrollbar->style < 5)
+		case 3:
+		case 4:
 		{
+			int counter = -width;
 			cairo_save (cr);
 			cairo_rectangle (cr, 1, 1, width-2, height-2);
 			cairo_clip (cr);
 			cairo_new_path (cr);
-			int counter = -width;
 			cairo_set_line_width (cr, 5); /* stroke width */
 			murrine_set_color_rgba (cr, &style, 0.08);
 			while (counter < height)
@@ -1447,9 +1453,10 @@
 				counter += 12;
 			}
 			cairo_restore (cr);
+			break;
 		}
-		/* Draw the horizontal strokes */
-		if (scrollbar->style > 4)
+		case 5:
+		case 6:
 		{
 			int stroke_width = 7;
 			int stroke_space = 5;
@@ -1463,6 +1470,7 @@
 				cairo_rel_line_to (cr, 0, -(height-2));
 				cairo_fill (cr);
 			}
+			break;
 		}
 	}
 	/* Draw the handle */

Modified: trunk/src/murrine_draw_rgba.c
==============================================================================
--- trunk/src/murrine_draw_rgba.c	(original)
+++ trunk/src/murrine_draw_rgba.c	Mon Sep 29 22:21:16 2008
@@ -38,7 +38,7 @@
 	murrine_shade (bg_color, 0.4, &shadow);
 
 	/* highlight */
-	cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
+	cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188));
 
 	if (corners & MRN_CORNER_TOPRIGHT)
 		cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.75, M_PI * 2);
@@ -157,12 +157,15 @@
 		mrn_gradient_custom = get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
 		custom_highlight_ratio = get_decreased_ratio (widget->highlight_ratio, 2.0);
 	}
+	else
+		murrine_shade (&colors->shade[8], 0.95, &border);
 
-	if (widget->is_default && !widget->disabled)
+	/* Default button */
+	if (widget->is_default)
+	{
+		murrine_shade (&border, 0.8, &border);
 		murrine_mix_color (&fill, &colors->spot[1], 0.2, &fill);
-
-	if (!widget->disabled)
-		murrine_shade (&colors->shade[8], 0.95, &border);
+	}
 
 	if (!horizontal)
 		murrine_exchange_axis (cr, &x, &y, &width, &height);
@@ -184,10 +187,6 @@
 	murrine_mix_color (&border, &widget->parentbg, 0.2, &border);
 	murrine_mix_color (&border, &fill, 0.25, &border);
 
-	/* Default button */
-	if (widget->is_default)
-		murrine_shade (&border, 0.8, &border);
-
 	/* Draw the bg */
 	murrine_rounded_rectangle_closed (cr, xos+1, yos+1, width-(xos*2)-2, height-(yos*2)-2, widget->roundness-1, widget->corners);
 
@@ -523,76 +522,84 @@
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
 
 	/* Glass menubar */
-	if (menubarstyle == 1)
-	{
-		/* XXX: should use another gradient rgba_opacity */
-		int os = (widget->glazestyle == 2) ? 1 : 0;
-		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
-		                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
-		                    widget->roundness, widget->corners, TRUE);
-	}
-	else if (menubarstyle == 2) /* Gradient menubar */
-	{
-		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);
-		cairo_set_source (cr, pattern);
-		cairo_fill (cr);
-		cairo_pattern_destroy (pattern);
-
-		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-	}
-	else if (menubarstyle == 3) /* Striped menubar */
+	switch (menubarstyle)
 	{
-		cairo_pattern_t *pattern;
-		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_rgba (pattern, 0.0, top.r, top.g, top.b, MENUBAR_STRIPED_OPACITY);
-		cairo_pattern_add_color_stop_rgba (pattern, 1.0, low.r, low.g, low.b, MENUBAR_STRIPED_OPACITY);
-		cairo_set_source (cr, pattern);
-		cairo_fill (cr);
+		default:
+		case 0:
+		{
+			cairo_pattern_t *pattern;
 
-		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+			pattern = cairo_pattern_create_linear (0, 0, width, 0);
+			cairo_pattern_add_color_stop_rgba (pattern, 0.0, fill->r,
+			                                                 fill->g,
+			                                                 fill->b, MENUBAR_OPACITY);
+			cairo_pattern_add_color_stop_rgba (pattern, 0.5, fill->r,
+			                                                 fill->g,
+			                                                 fill->b, (MENUBAR_OPACITY-0.04));
+			cairo_pattern_add_color_stop_rgba (pattern, 1.0, fill->r,
+			                                                 fill->g,
+			                                                 fill->b, MENUBAR_OPACITY);
+			cairo_set_source (cr, pattern);
+			cairo_rectangle  (cr, 0, 0, width, height);
+			cairo_fill       (cr);
+			cairo_pattern_destroy (pattern);
+
+			cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+			break;
+		}
+		case 1:
+		{
+			/* XXX: should use another gradient rgba_opacity */
+			int os = (widget->glazestyle == 2) ? 1 : 0;
+			murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
+			                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
+			                    widget->roundness, widget->corners, TRUE);
+			break;
+		}
+		case 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_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);
+			cairo_set_source (cr, pattern);
+			cairo_fill (cr);
+			cairo_pattern_destroy (pattern);
 
-		cairo_pattern_destroy (pattern);
-		int counter = -height;
-		cairo_set_line_width  (cr, 1.0);
-		murrine_shade (&low, 0.9, &low);
-		murrine_set_color_rgba (cr, &low, MENUBAR_STRIPED_OPACITY);
-		while (counter < width)
-		{
-			cairo_move_to (cr, counter, height);
-			cairo_line_to (cr, counter+height, 0);
-			cairo_stroke  (cr);
-			counter += 5;
+			cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+			break;
 		}
-	}
-	else /* Flat menubar */
-	{
-		cairo_pattern_t *pattern;
+		case 3:
+		{
+			cairo_pattern_t *pattern;
+			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_rgba (pattern, 0.0, top.r, top.g, top.b, MENUBAR_STRIPED_OPACITY);
+			cairo_pattern_add_color_stop_rgba (pattern, 1.0, low.r, low.g, low.b, MENUBAR_STRIPED_OPACITY);
+			cairo_set_source (cr, pattern);
+			cairo_fill (cr);
 
-		pattern = cairo_pattern_create_linear (0, 0, width, 0);
-		cairo_pattern_add_color_stop_rgba (pattern, 0.0, fill->r,
-		                                                 fill->g,
-		                                                 fill->b, MENUBAR_OPACITY);
-		cairo_pattern_add_color_stop_rgba (pattern, 0.5, fill->r,
-		                                                 fill->g,
-		                                                 fill->b, (MENUBAR_OPACITY-0.04));
-		cairo_pattern_add_color_stop_rgba (pattern, 1.0, fill->r,
-		                                                 fill->g,
-		                                                 fill->b, MENUBAR_OPACITY);
-		cairo_set_source (cr, pattern);
-		cairo_rectangle  (cr, 0, 0, width, height);
-		cairo_fill       (cr);
-		cairo_pattern_destroy (pattern);
+			cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
-		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+			cairo_pattern_destroy (pattern);
+			int counter = -height;
+			cairo_set_line_width  (cr, 1.0);
+			murrine_shade (&low, 0.9, &low);
+			murrine_set_color_rgba (cr, &low, MENUBAR_STRIPED_OPACITY);
+			while (counter < width)
+			{
+				cairo_move_to (cr, counter, height);
+				cairo_line_to (cr, counter+height, 0);
+				cairo_stroke  (cr);
+				counter += 5;
+			}
+			break;
+		}
 	}
 
 	/* Draw bottom line */
@@ -627,43 +634,48 @@
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
 
 	/* Glass toolbar */
-	if (toolbar->style == 1)
+	switch (toolbar->style)
 	{
-		int os = (widget->glazestyle == 2) ? 1 : 0;
-		murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
-		                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
-		                    widget->roundness, widget->corners, TRUE);
-
-		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-	}
-	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_rgba (pattern, 0.0, fill->r, fill->g, fill->b, TOOLBAR_OPACITY);
-		cairo_pattern_add_color_stop_rgba (pattern, 1.0, lower.r, lower.g, lower.b, TOOLBAR_OPACITY);
-		cairo_set_source (cr, pattern);
-		cairo_fill (cr);
-		cairo_pattern_destroy (pattern);
-
-		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-	}
-	else /* Flat toolbar */
-	{
-		murrine_set_color_rgba (cr, fill, TOOLBAR_OPACITY);
-		cairo_fill (cr);
+		default:
+		case 0:
+			murrine_set_color_rgba (cr, fill, TOOLBAR_OPACITY);
+			cairo_fill (cr);
 
-		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+			cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
-		/* Draw highlight */
-		if (!toolbar->topmost)
+			/* Draw highlight */
+			if (!toolbar->topmost)
+			{
+				murrine_set_color_rgba (cr, top, 0.5);
+				cairo_move_to          (cr, 0, 0.5);
+				cairo_line_to          (cr, width, 0.5);
+				cairo_stroke           (cr);
+			}
+			break;
+		case 1:
 		{
-			murrine_set_color_rgba (cr, top, 0.5);
-			cairo_move_to          (cr, 0, 0.5);
-			cairo_line_to          (cr, width, 0.5);
-			cairo_stroke           (cr);
+			int os = (widget->glazestyle == 2) ? 1 : 0;
+			murrine_draw_glaze (cr, fill, widget->highlight_ratio, widget->glazestyle == 2 ? widget->lightborder_ratio : 1.0,
+			                    widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
+			                    widget->roundness, widget->corners, TRUE);
+
+			cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+			break;
+		}
+		case 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_rgba (pattern, 0.0, fill->r, fill->g, fill->b, TOOLBAR_OPACITY);
+			cairo_pattern_add_color_stop_rgba (pattern, 1.0, lower.r, lower.g, lower.b, TOOLBAR_OPACITY);
+			cairo_set_source (cr, pattern);
+			cairo_fill (cr);
+			cairo_pattern_destroy (pattern);
+
+			cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+			break;
 		}
 	}
 
@@ -687,33 +699,32 @@
                             MurrineRectangle      *bevel,
                             MurrineRectangle      *border)
 {
-	if (frame->gap_side == MRN_GAP_TOP)
+	switch (frame->gap_side)
 	{
-		MURRINE_RECTANGLE_SET ((*bevel),  1.5 + frame->gap_x,  -0.5,
-		                       frame->gap_width - 3, 2.0);
-		MURRINE_RECTANGLE_SET ((*border), 0.5 + frame->gap_x,  -0.5,
-		                       frame->gap_width - 2, 2.0);
-	}
-	else if (frame->gap_side == MRN_GAP_BOTTOM)
-	{
-		MURRINE_RECTANGLE_SET ((*bevel),  1.5 + frame->gap_x,  height - 2.5,
-		                       frame->gap_width - 3, 2.0);
-		MURRINE_RECTANGLE_SET ((*border), 0.5 + frame->gap_x,  height - 1.5,
-		                       frame->gap_width - 2, 2.0);
-	}
-	else if (frame->gap_side == MRN_GAP_LEFT)
-	{
-		MURRINE_RECTANGLE_SET ((*bevel),  -0.5, 1.5 + frame->gap_x,
-		                       2.0, frame->gap_width - 3);
-		MURRINE_RECTANGLE_SET ((*border), -0.5, 0.5 + frame->gap_x,
-		                       1.0, frame->gap_width - 2);
-	}
-	else if (frame->gap_side == MRN_GAP_RIGHT)
-	{
-		MURRINE_RECTANGLE_SET ((*bevel),  width - 2.5, 1.5 + frame->gap_x,
-		                       2.0, frame->gap_width - 3);
-		MURRINE_RECTANGLE_SET ((*border), width - 1.5, 0.5 + frame->gap_x,
-		                       1.0, frame->gap_width - 2);
+		case MRN_GAP_TOP:
+			MURRINE_RECTANGLE_SET ((*bevel),  1.5+frame->gap_x, -0.5,
+			                       frame->gap_width-3, 2.0);
+			MURRINE_RECTANGLE_SET ((*border), 0.5+frame->gap_x, -0.5,
+			                       frame->gap_width-2, 2.0);
+			break;
+		case MRN_GAP_BOTTOM:
+			MURRINE_RECTANGLE_SET ((*bevel),  1.5+frame->gap_x, height-2.5,
+			                       frame->gap_width-3, 2.0);
+			MURRINE_RECTANGLE_SET ((*border), 0.5+frame->gap_x, height-1.5,
+			                       frame->gap_width-2, 2.0);
+			break;
+		case MRN_GAP_LEFT:
+			MURRINE_RECTANGLE_SET ((*bevel),  -0.5, 1.5+frame->gap_x,
+			                       2.0, frame->gap_width-3);
+			MURRINE_RECTANGLE_SET ((*border), -0.5, 0.5+frame->gap_x,
+			                       1.0, frame->gap_width-2);
+			break;
+		case MRN_GAP_RIGHT:
+			MURRINE_RECTANGLE_SET ((*bevel),  width-2.5, 1.5+frame->gap_x,
+			                       2.0, frame->gap_width-3);
+			MURRINE_RECTANGLE_SET ((*border), width-1.5, 0.5+frame->gap_x,
+			                       1.0, frame->gap_width-2);
+			break;
 	}
 }
 
@@ -1063,17 +1074,17 @@
 
 	cairo_set_line_width (cr, 1.0);
 
-	if (scrollbar->horizontal)
+	if (!scrollbar->horizontal)
+	{
+		cairo_translate (cr, x, y);
+	}
+	else
 	{
 		int tmp = height;
 		rotate_mirror_translate (cr, M_PI/2, x, y, FALSE, FALSE);
 		height = width;
 		width = tmp;
 	}
-	else
-	{
-		cairo_translate (cr, x, y);
-	}
 
 	/* Draw fill */
 	murrine_set_color_rgba (cr, &fill, 0.4);
@@ -1119,7 +1130,6 @@
 	                    widget->mrn_gradient, widget, 1, 1, width-2, height-2,
 	                    widget->roundness, widget->corners, TRUE);
 
-	cairo_reset_clip (cr);
 	cairo_restore (cr);
 
 	murrine_set_color_rgb (cr, &border_normal);
@@ -1198,36 +1208,36 @@
 	if (scrollbar->style > 0)
 		murrine_shade (&fill, 0.55, &style);
 
-	/* Draw the circles */
-	if (scrollbar->style == 1)
+	switch (scrollbar->style)
 	{
-		int circ_radius = 2;
-		int circ_space = 5;
-		int i;
-		int x1 = circ_space+circ_radius;
-		int y1 = height/2;
-		for (i = circ_space; i < width-circ_space; i += 2*circ_radius+circ_space)
+		case 1:
 		{
-			cairo_move_to (cr, i, 1);
-			cairo_arc (cr, x1, y1, circ_radius, 0, M_PI*2);
+			int circ_radius = 2;
+			int circ_space = 5;
+			int i;
+			int x1 = circ_space+circ_radius;
+			int y1 = height/2;
+			for (i = circ_space; i < width-circ_space; i += 2*circ_radius+circ_space)
+			{
+				cairo_move_to (cr, i, 1);
+				cairo_arc (cr, x1, y1, circ_radius, 0, M_PI*2);
 
-			x1 += 2*circ_radius+circ_space;
+				x1 += 2*circ_radius+circ_space;
 
-			cairo_close_path (cr);
-			murrine_set_color_rgba (cr, &style, 0.15);
-			cairo_fill (cr);
+				cairo_close_path (cr);
+				murrine_set_color_rgba (cr, &style, 0.15);
+				cairo_fill (cr);
+			}
+			break;
 		}
-	}
-	if (scrollbar->style > 2)
-	{
-		/* Draw the diagonal strokes */
-		if (scrollbar->style < 5)
+		case 3:
+		case 4:
 		{
+			int counter = -width;
 			cairo_save (cr);
 			cairo_rectangle (cr, 1, 1, width-2, height-2);
 			cairo_clip (cr);
 			cairo_new_path (cr);
-			int counter = -width;
 			cairo_set_line_width (cr, 5); /* stroke width */
 			murrine_set_color_rgba (cr, &style, 0.08);
 			while (counter < height)
@@ -1238,9 +1248,10 @@
 				counter += 12;
 			}
 			cairo_restore (cr);
+			break;
 		}
-		/* Draw the horizontal strokes */
-		if (scrollbar->style > 4)
+		case 5:
+		case 6:
 		{
 			int stroke_width = 7;
 			int stroke_space = 5;
@@ -1254,6 +1265,7 @@
 				cairo_rel_line_to (cr, 0, -(height-2));
 				cairo_fill (cr);
 			}
+			break;
 		}
 	}
 	/* Draw the handle */



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