[murrine/border-shade] More work on shadows, reliefstyle=3 adds more shadows to widgets



commit 5eb72f918dc4dfa12782187295276bbff701be3c
Author: Andrea Cimitan <andrea cimitan gmail com>
Date:   Tue Sep 15 17:41:51 2009 +0200

    	More work on shadows, reliefstyle=3 adds more shadows to widgets

 src/cairo-support.c |   34 ++++++++++++++++++++++++++++++++++
 src/cairo-support.h |    8 ++++++++
 src/murrine_draw.c  |   20 +++++++++++++-------
 3 files changed, 55 insertions(+), 7 deletions(-)
---
diff --git a/src/cairo-support.c b/src/cairo-support.c
index 98be961..aac4ae8 100644
--- a/src/cairo-support.c
+++ b/src/cairo-support.c
@@ -836,6 +836,40 @@ murrine_draw_border (cairo_t *cr,
 }
 
 void
+murrine_draw_shadow (cairo_t *cr,
+                     const MurrineRGB  *color,
+                     double x, double y, double width, double height,
+                     int roundness, uint8 corners,
+                     int reliefstyle,
+                     double highlight_shade, double alpha)
+{
+	if (highlight_shade != 1.0 || reliefstyle > 2)
+	{
+		cairo_pattern_t *pat;
+		MurrineRGB shade1, shade2;
+
+		//warning, only accepts hightlight_shade < 2
+		murrine_shade (color, 2.0-highlight_shade, &shade1);
+		murrine_shade (color, highlight_shade, &shade2);
+
+		pat = cairo_pattern_create_linear (x, y, x, height+y);
+		murrine_pattern_add_color_stop_rgba (pat, 0.00, &shade1, alpha);
+		murrine_pattern_add_color_stop_rgba (pat, 1.00, &shade2,
+		                                     alpha*(reliefstyle > 2 ?
+		                                            (highlight_shade > 1.0 ?
+		                                             2.5 : 2.0) : 1.0));
+
+		cairo_set_source (cr, pat);
+		cairo_pattern_destroy (pat);
+	}
+	else
+		murrine_set_color_rgba (cr, color, alpha);
+
+	murrine_rounded_rectangle (cr, x, y, width, height, roundness, corners);
+	cairo_stroke (cr);
+}
+
+void
 rotate_mirror_translate (cairo_t *cr,
                          double radius, double x, double y,
                          boolean mirror_horizontally, boolean mirror_vertically)
diff --git a/src/cairo-support.h b/src/cairo-support.h
index f1333c4..860e216 100644
--- a/src/cairo-support.h
+++ b/src/cairo-support.h
@@ -97,6 +97,14 @@ G_GNUC_INTERNAL void murrine_draw_border (cairo_t *cr,
                                           int roundness, uint8 corners,
                                           double highlight_shade, double alpha);
 
+G_GNUC_INTERNAL void murrine_draw_shadow (cairo_t *cr,
+                                          const MurrineRGB  *color,
+                                          double x, double y, double width, double height,
+                                          int roundness, uint8 corners,
+                                          int reliefstyle,
+                                          double highlight_shade, double alpha);
+
+
 G_GNUC_INTERNAL void murrine_draw_glaze (cairo_t *cr,
                                          const MurrineRGB *fill,
                                          double glow_shade,
diff --git a/src/murrine_draw.c b/src/murrine_draw.c
index 014def3..eece9a6 100644
--- a/src/murrine_draw.c
+++ b/src/murrine_draw.c
@@ -182,9 +182,10 @@ murrine_draw_button (cairo_t *cr,
 
 	if (!widget->active && !widget->disabled && widget->reliefstyle > 1 && xos >= 0.5 && yos >= 0.5)
 	{
-		murrine_draw_border (cr, &border,
+		murrine_draw_shadow (cr, &border,
 		                     xos-0.5, yos-0.5, width-(xos*2)+1, height-(yos*2)+1,
 		                     widget->roundness+1, widget->corners,
+		                     widget->reliefstyle,
 		                     border_shade_custom, 0.08);
 	}
 	else if (widget->reliefstyle != 0 && xos >= 0.5 && yos >= 0.5)
@@ -1981,9 +1982,10 @@ murrine_draw_radiobutton (cairo_t *cr,
 			MurrineRGB shadow;
 			murrine_shade (border, 0.9, &shadow);
 
-			murrine_draw_border (cr, &shadow,
+			murrine_draw_shadow (cr, &shadow,
 			                     0.5, 0.5, width-1, height-1,
 			                     roundness+1, widget->corners,
+			                     widget->reliefstyle,
 			                     widget->border_shade, 0.08);
 		}
 		else if (widget->reliefstyle != 0)
@@ -2013,7 +2015,8 @@ murrine_draw_radiobutton (cairo_t *cr,
 	murrine_draw_border (cr, border,
 	                     1.5, 1.5, width-3, height-3,
 	                     roundness, widget->corners,
-	                     draw_bullet ? widget->border_shade : 1.0+fabs(1.0-widget->border_shade), 1.0);
+	                     checkbox->in_menu || checkbox->in_cell ? 1.0 : draw_bullet ?
+	                     widget->border_shade : 1.0+fabs(1.0-widget->border_shade), 1.0);
 
 	if (draw_bullet)
 	{
@@ -2091,9 +2094,11 @@ murrine_draw_checkbox (cairo_t *cr,
 			MurrineRGB shadow;
 			murrine_shade (border, 0.9, &shadow);
 
-			murrine_set_color_rgba (cr, &shadow, 0.08);
-			murrine_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, roundness+1, widget->corners);
-			cairo_stroke (cr);
+			murrine_draw_shadow (cr, &shadow,
+			                     0.5, 0.5, width-1, height-1,
+			                     roundness+1, widget->corners,
+			                     widget->reliefstyle,
+			                     widget->border_shade, 0.08);
 		}
 		else if (widget->reliefstyle != 0)
 			murrine_draw_inset (cr, &widget->parentbg, 0.5, 0.5, width-1, height-1, roundness+1, widget->corners);
@@ -2122,7 +2127,8 @@ murrine_draw_checkbox (cairo_t *cr,
 	murrine_draw_border (cr, border,
 	                     1.5, 1.5, width-3, height-3,
 	                     roundness, widget->corners,
-	                     draw_bullet ? widget->border_shade : 1.0+fabs(1.0-widget->border_shade), 1.0);
+	                     checkbox->in_menu || checkbox->in_cell ? 1.0 : draw_bullet ?
+	                     widget->border_shade : 1.0+fabs(1.0-widget->border_shade), 1.0);
 
 	if (draw_bullet)
 	{



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