[murrine/dec09-new-features] Fixed button, progressbar_fill, menuitem, scrollbar_slider with gradient_colors



commit 0092d21fb97afffd1d7bbad58af52da0a3bd89f3
Author: Andrea Cimitan <andrea cimitan gmail com>
Date:   Tue Dec 8 00:46:23 2009 +0100

    Fixed button, progressbar_fill, menuitem, scrollbar_slider with gradient_colors

 src/cairo-support.c     |   12 ++++++++++++
 src/cairo-support.h     |    3 +++
 src/murrine_draw.c      |   43 ++++++++++++++++++++++++-------------------
 src/murrine_draw_rgba.c |   24 +++++++++++++-----------
 4 files changed, 52 insertions(+), 30 deletions(-)
---
diff --git a/src/cairo-support.c b/src/cairo-support.c
index ab86acf..2c85952 100644
--- a/src/cairo-support.c
+++ b/src/cairo-support.c
@@ -1017,6 +1017,18 @@ murrine_exchange_axis (cairo_t  *cr,
 	*height = tmp;
 }
 
+void
+get_fill_color (MurrineRGB *color,
+                MurrineGradients *mrn_gradient)
+{
+	if (mrn_gradient->has_gradient_colors)
+	{
+		murrine_mix_color (&mrn_gradient->gradient_colors[1],
+		                   &mrn_gradient->gradient_colors[2],
+		                   0.5, color);
+	}
+}
+
 double
 get_decreased_shade (double old, double factor)
 {
diff --git a/src/cairo-support.h b/src/cairo-support.h
index 7e78531..c6b59bf 100644
--- a/src/cairo-support.h
+++ b/src/cairo-support.h
@@ -51,6 +51,9 @@ G_GNUC_INTERNAL void rotate_mirror_translate (cairo_t *cr,
                                               double radius, double x, double y,
                                               boolean mirror_horizontally, boolean mirror_vertically);
 
+G_GNUC_INTERNAL void murrine_get_fill_color (MurrineRGB *color,
+                                             MurrineGradients *mrn_gradient);
+
 G_GNUC_INTERNAL double get_decreased_shade (double old, double factor);
 
 G_GNUC_INTERNAL double get_increased_shade (double old, double factor);
diff --git a/src/murrine_draw.c b/src/murrine_draw.c
index 3227135..5b9b225 100644
--- a/src/murrine_draw.c
+++ b/src/murrine_draw.c
@@ -154,10 +154,7 @@ murrine_draw_button (cairo_t *cr,
 	MurrineGradients mrn_gradient_new = widget->mrn_gradient;
 	MurrineRGB border = colors->shade[!widget->disabled ? 6 : 5];
 	MurrineRGB fill = colors->bg[widget->state_type];
-	if (mrn_gradient_new.has_gradient_colors)
-    	murrine_mix_color (&mrn_gradient_new.gradient_colors[0],
-		                   &mrn_gradient_new.gradient_colors[3],
-		                   0.5, &fill);
+	get_fill_color (&fill, &mrn_gradient_new);
 
 	if (widget->disabled)
 	{
@@ -674,8 +671,11 @@ murrine_draw_progressbar_fill (cairo_t *cr,
 	double     stroke_width;
 	int        x_step;
 	int        roundness;
-	const      MurrineRGB *fill = &colors->spot[1];
 	MurrineRGB border = colors->spot[2];
+	MurrineRGB fill = colors->spot[1];
+	get_fill_color (&fill, &widget->mrn_gradient);
+
+	murrine_shade (&fill, get_contrast(0.65, widget->contrast), &border);
 
 	/* progressbar->orientation < 2 == boolean is_horizontal */
 	if (progressbar->orientation < 2)
@@ -712,7 +712,7 @@ murrine_draw_progressbar_fill (cairo_t *cr,
 
 	cairo_rectangle (cr, 2, 1, width-4, height-2);
 
-	murrine_draw_glaze (cr, fill,
+	murrine_draw_glaze (cr, &fill,
 	                    widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
 	                    widget->mrn_gradient, widget, 2, 1, width-4, height-2,
 	                    roundness, widget->corners, TRUE);
@@ -736,7 +736,7 @@ murrine_draw_progressbar_fill (cairo_t *cr,
 				tile_pos += stroke_width;
 			}
 
-			murrine_set_color_rgba (cr, &colors->spot[2], 0.15);
+			murrine_set_color_rgba (cr, &border, 0.15);
 			cairo_fill (cr);
 			break;
 		}
@@ -746,7 +746,7 @@ murrine_draw_progressbar_fill (cairo_t *cr,
 			int step = 18;
 			int i;
 
-			murrine_shade (fill, widget->lightborder_shade*widget->highlight_shade, &highlight);
+			murrine_shade (&fill, widget->lightborder_shade*widget->highlight_shade, &highlight);
 
 			for (i=step; i<width-3; i+=step)
 			{
@@ -757,7 +757,7 @@ murrine_draw_progressbar_fill (cairo_t *cr,
 
 				cairo_move_to (cr, i+0.5, 1);
 				cairo_line_to (cr, i+0.5, height-1);
-				murrine_set_color_rgba (cr, &colors->spot[2], 0.25);
+				murrine_set_color_rgba (cr, &border, 0.25);
 				cairo_stroke (cr);
 			}
 			break;
@@ -776,7 +776,7 @@ murrine_draw_progressbar_fill (cairo_t *cr,
 	cairo_clip (cr);
 
 	/* Draw border */
-	murrine_mix_color (&border, fill, 0.28, &border);
+	murrine_mix_color (&border, &fill, 0.28, &border);
 	murrine_draw_border (cr, &border,
 	                     1.5, 0.5, width-3, height-1,
 	                     roundness, widget->corners,
@@ -1515,8 +1515,11 @@ murrine_draw_menuitem (cairo_t *cr,
                        int x, int y, int width, int height,
                        int menuitemstyle)
 {
-	const MurrineRGB *fill   = &colors->spot[1];
-	const MurrineRGB *border = &colors->spot[2];
+	MurrineRGB border = colors->spot[2];
+	MurrineRGB fill = colors->spot[1];
+	get_fill_color (&fill, &widget->mrn_gradient);
+
+	murrine_shade (&fill, get_contrast(0.65, widget->contrast), &border);
 
 	cairo_translate (cr, x, y);
 	murrine_rounded_rectangle_closed (cr, 0, 0, width, height, widget->roundness, widget->corners);
@@ -1524,10 +1527,10 @@ murrine_draw_menuitem (cairo_t *cr,
 	switch (menuitemstyle)
 	{
 		case 0:
-			murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
+			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_set_color_rgba (cr, &border, 0.15);
 			murrine_rounded_rectangle_closed (cr, 0.5, 0.5, width-1, height-1, widget->roundness, widget->corners);
 			cairo_fill_preserve (cr);
 			break;
@@ -1535,14 +1538,14 @@ murrine_draw_menuitem (cairo_t *cr,
 		case 1:
 			cairo_clip_preserve (cr);
 
-			murrine_draw_glaze (cr, &colors->spot[1],
+			murrine_draw_glaze (cr, &fill,
 			                    widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
 			                    widget->mrn_gradient, widget, 1, 1, width-2, height-2,
 			                    widget->roundness, widget->corners, TRUE);
 			break;
 		case 2:
 		{
-			murrine_set_gradient (cr, fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
+			murrine_set_gradient (cr, &fill, widget->mrn_gradient, 0, 0, 0, height, widget->mrn_gradient.gradients, FALSE);
 			cairo_fill (cr);
 
 			double tile_pos = 0;
@@ -1563,14 +1566,14 @@ murrine_draw_menuitem (cairo_t *cr,
 				cairo_translate (cr, stroke_width, 0);
 				tile_pos += stroke_width;
 			}
-			murrine_set_color_rgba (cr, border, 0.15);
+			murrine_set_color_rgba (cr, &border, 0.15);
 			cairo_fill (cr);
 			cairo_restore (cr);
 			break;
 		}
 	}
 
-	murrine_draw_border (cr, border,
+	murrine_draw_border (cr, &border,
 	                     0.5, 0.5, width-1, height-1,
 	                     widget->roundness, widget->corners,
 	                     widget->mrn_gradient, 0.8);
@@ -1679,11 +1682,13 @@ murrine_draw_scrollbar_slider (cairo_t *cr,
 {
 	MurrineGradients mrn_gradient_new = widget->mrn_gradient;
 	double border_stop_mid = ((mrn_gradient_new.border_shades[0])+
-		                      (mrn_gradient_new.border_shades[1]))/2.0;
+	                          (mrn_gradient_new.border_shades[1]))/2.0;
 	MurrineRGB fill = scrollbar->has_color ? scrollbar->color : colors->bg[0];
 	MurrineRGB border;
 	uint8 corners = widget->corners;
 
+	get_fill_color (&fill, &mrn_gradient_new);
+
 	if (scrollbar->stepperstyle != 1)
 	{
 		if (scrollbar->junction & MRN_JUNCTION_BEGIN)
diff --git a/src/murrine_draw_rgba.c b/src/murrine_draw_rgba.c
index 8bfff13..f4d420a 100644
--- a/src/murrine_draw_rgba.c
+++ b/src/murrine_draw_rgba.c
@@ -154,10 +154,7 @@ murrine_rgba_draw_button (cairo_t *cr,
 	MurrineGradients mrn_gradient_new = widget->mrn_gradient;
 	MurrineRGB border = colors->shade[!widget->disabled ? 8 : 6];
 	MurrineRGB fill = colors->bg[widget->state_type];
-	if (mrn_gradient_new.has_gradient_colors)
-    	murrine_mix_color (&mrn_gradient_new.gradient_colors[0], 
-		                   &mrn_gradient_new.gradient_colors[3],
-		                   0.5, &fill);
+	get_fill_color (&fill, &mrn_gradient_new);
 
 	if (widget->disabled)
 	{
@@ -558,8 +555,11 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
 	double     stroke_width;
 	int        x_step;
 	int        roundness;
-	const      MurrineRGB *fill = &colors->spot[1];
 	MurrineRGB border = colors->spot[2];
+	MurrineRGB fill = colors->spot[1];
+	get_fill_color (&fill, &widget->mrn_gradient);
+
+	murrine_shade (&fill, get_contrast(0.65, widget->contrast), &border);
 
 	/* progressbar->orientation < 2 == boolean is_horizontal */
 	if (progressbar->orientation < 2)
@@ -598,7 +598,7 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
 
 	cairo_rectangle (cr, 2, 1, width-4, height-2);
 
-	murrine_draw_glaze (cr, fill,
+	murrine_draw_glaze (cr, &fill,
 	                    widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
 	                    widget->mrn_gradient, widget, 2, 1, width-4, height-2,
 	                    roundness, widget->corners, TRUE);
@@ -626,7 +626,7 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
 				tile_pos += stroke_width;
 			}
 
-			murrine_set_color_rgba (cr, &colors->spot[2], 0.15);
+			murrine_set_color_rgba (cr, &border, 0.15);
 			cairo_fill (cr);
 			break;
 		}
@@ -636,7 +636,7 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
 			int step = 18;
 			int i;
 
-			murrine_shade (fill, widget->lightborder_shade*widget->highlight_shade, &highlight);
+			murrine_shade (&fill, widget->lightborder_shade*widget->highlight_shade, &highlight);
 
 			for (i=step; i<width-3; i+=step)
 			{
@@ -647,7 +647,7 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
 
 				cairo_move_to (cr, i+0.5, 1);
 				cairo_line_to (cr, i+0.5, height-1);
-				murrine_set_color_rgba (cr, &colors->spot[2], 0.25);
+				murrine_set_color_rgba (cr, &border, 0.25);
 				cairo_stroke (cr);
 			}
 			break;
@@ -666,7 +666,7 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
 	cairo_clip (cr);
 
 	/* Draw border */
-	murrine_mix_color (&border, fill, 0.28, &border);
+	murrine_mix_color (&border, &fill, 0.28, &border);
 	murrine_draw_border (cr, &border,
 	                     1.5, 0.5, width-3, height-1,
 	                     roundness, widget->corners,
@@ -1321,11 +1321,13 @@ murrine_rgba_draw_scrollbar_slider (cairo_t *cr,
 {
 	MurrineGradients mrn_gradient_new = widget->mrn_gradient;
 	double border_stop_mid = ((mrn_gradient_new.border_shades[0])+
-		                      (mrn_gradient_new.border_shades[1]))/2.0;
+	                          (mrn_gradient_new.border_shades[1]))/2.0;
 	MurrineRGB fill = scrollbar->has_color ? scrollbar->color : colors->bg[0];
 	MurrineRGB border;
 	uint8 corners = widget->corners;
 
+	get_fill_color (&fill, &mrn_gradient_new);
+
 	if (scrollbar->stepperstyle < 1)
 	{
 		if (scrollbar->junction & MRN_JUNCTION_BEGIN)



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