[murrine/menustyle-speedup] More updates, should work better



commit 83edb4a9f3b41415050d19193a696d5b15e107c2
Author: Andrea Cimitan <andrea cimitan Å?mail com>
Date:   Tue Sep 7 16:40:18 2010 +0200

    More updates, should work better

 src/murrine_draw.c      |   74 +++++++++++++--------
 src/murrine_draw_rgba.c |  166 ++++++++++-------------------------------------
 src/murrine_style.c     |    6 +-
 3 files changed, 83 insertions(+), 163 deletions(-)
---
diff --git a/src/murrine_draw.c b/src/murrine_draw.c
index 73f9db9..bd3e087 100644
--- a/src/murrine_draw.c
+++ b/src/murrine_draw.c
@@ -1562,8 +1562,9 @@ murrine_draw_separator (cairo_t *cr,
                         const SeparatorParameters *separator,
                         int x, int y, int width, int height)
 {
-	const MurrineRGB *dark = &colors->shade[3];
-	const MurrineRGB *highlight = &colors->shade[0];
+	MurrineRGB dark, highlight;
+	murrine_shade (&colors->bg[0], murrine_get_contrast(0.7, widget->contrast), &dark);
+	murrine_shade (&colors->bg[0], murrine_get_contrast(1.3, widget->contrast), &highlight);
 
 	if (separator->horizontal)
 	{
@@ -1573,16 +1574,16 @@ murrine_draw_separator (cairo_t *cr,
 		{
 			default:
 			case 0:
-				murrine_set_color_rgb (cr, dark);
+				murrine_set_color_rgba (cr, &dark, 0.5);
 				break;
 			case 1:
 			{
 				cairo_pattern_t *pat;
 				pat = cairo_pattern_create_linear (0, 0, width, 0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, &dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, &dark, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, &dark, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, &dark, 0.0);
 				cairo_set_source (cr, pat);
 				cairo_pattern_destroy (pat);
 				break;
@@ -1597,20 +1598,23 @@ murrine_draw_separator (cairo_t *cr,
 		{
 			default:
 			case 0:
-				murrine_set_color_rgb (cr, highlight);
+				murrine_set_color_rgba (cr, &highlight, 0.5);
 				break;
 			case 1:
 			{
 				cairo_pattern_t *pat;
 				pat = cairo_pattern_create_linear (0, 0, width, 0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, &highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, &highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, &highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, &highlight, 0.0);
 				cairo_set_source (cr, pat);
 				cairo_pattern_destroy (pat);
 				break;
 			}
+			case 3:
+				return;
+				break;
 		}
 
 		cairo_move_to (cr, 0.0,   1.0);
@@ -1625,16 +1629,16 @@ murrine_draw_separator (cairo_t *cr,
 		{
 			default:
 			case 0:
-				murrine_set_color_rgb (cr, dark);
+				murrine_set_color_rgba (cr, &dark, 0.5);
 				break;
 			case 1:
 			{
 				cairo_pattern_t *pat;
 				pat = cairo_pattern_create_linear (0, 0, 0, height);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, &dark, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, &dark, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, &dark, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, &dark, 0.0);
 				cairo_set_source (cr, pat);
 				cairo_pattern_destroy (pat);
 				break;
@@ -1648,20 +1652,23 @@ murrine_draw_separator (cairo_t *cr,
 		{
 			default:
 			case 0:
-				murrine_set_color_rgb (cr, highlight);
+				murrine_set_color_rgba (cr, &highlight, 0.5);
 				break;
 			case 1:
 			{
 				cairo_pattern_t *pat;
 				pat = cairo_pattern_create_linear (0, 0, 0, height);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.00, &highlight, 0.0);
+				murrine_pattern_add_color_stop_rgba (pat, 0.25, &highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 0.75, &highlight, 0.5);
+				murrine_pattern_add_color_stop_rgba (pat, 1.00, &highlight, 0.0);
 				cairo_set_source (cr, pat);
 				cairo_pattern_destroy (pat);
 				break;
 			}
+			case 3:
+				return;
+				break;
 		}
 
 		cairo_move_to (cr, 1.0, 0.0);
@@ -2352,27 +2359,36 @@ murrine_draw_menu_frame (cairo_t *cr,
 			MurrineRGB fill;
 			raico_blur_t* blur = NULL;
 			cairo_t *cr_surface; 
-			cairo_surface_t *surface; 
+			cairo_surface_t *surface;
+			cairo_pattern_t *pat;
 			int bradius = 30;
+			int bheight = MIN (height, 300);
 
 			murrine_shade (&colors->bg[0], murrine_get_contrast(1.1, widget->contrast), &border);
-			murrine_shade (&colors->bg[0], 1.9, &fill);
+			murrine_shade (&colors->bg[0], 0.96, &fill);
 
 			murrine_set_color_rgb (cr, &border);
 			cairo_rectangle       (cr, 0.5, 0.5, width-1, height-1);
 			cairo_stroke          (cr);
 
 			/* draw glow */
-			surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width+bradius*2, height+bradius*2);
+			surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, bheight);
 			cr_surface = cairo_create (surface); 
 			blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
 			raico_blur_set_radius (blur, bradius);
-			cairo_set_line_width (cr_surface, 4.0);
-			cairo_rectangle (cr_surface, bradius, bradius-5, width, height+5);
+			cairo_set_line_width (cr_surface, 1.0);
+			cairo_rectangle (cr_surface, bradius, bradius-15, width-bradius*2, bheight-bradius*2+15);
 			murrine_set_color_rgb (cr_surface, &fill);
-			cairo_stroke (cr_surface);
+			cairo_fill (cr_surface);
 			raico_blur_apply (blur, surface);
-			cairo_set_source_surface (cr, surface, -bradius, -bradius); 
+			cairo_rectangle (cr_surface, 0, -15, width, bheight+15);
+			pat = cairo_pattern_create_linear (0, -15, 0.0, bheight+15);
+			murrine_pattern_add_color_stop_rgba (pat, 0.25, &colors->bg[0], 0.0);
+			murrine_pattern_add_color_stop_rgba (pat, 1.0, &colors->bg[0], 1.0);
+			cairo_set_source (cr_surface, pat);
+			cairo_pattern_destroy (pat);
+			cairo_fill (cr_surface);
+			cairo_set_source_surface (cr, surface, 0, 0); 
 			cairo_paint (cr);
 			cairo_surface_destroy (surface); 
 			cairo_destroy (cr_surface);
diff --git a/src/murrine_draw_rgba.c b/src/murrine_draw_rgba.c
index 53d8b9b..b1797a0 100644
--- a/src/murrine_draw_rgba.c
+++ b/src/murrine_draw_rgba.c
@@ -1117,121 +1117,6 @@ murrine_rgba_draw_frame (cairo_t *cr,
 }
 
 static void
-murrine_rgba_draw_separator (cairo_t *cr,
-                             const MurrineColors       *colors,
-                             const WidgetParameters    *widget,
-                             const SeparatorParameters *separator,
-                             int x, int y, int width, int height)
-{
-	const MurrineRGB *dark      = &colors->shade[4];
-	const MurrineRGB *highlight = &colors->shade[0];
-
-	if (separator->horizontal)
-	{
-		cairo_translate (cr, x, y+0.5);
-
-		switch (separator->style)
-		{
-			default:
-			case 0:
-				murrine_set_color_rgb (cr, dark);
-				break;
-			case 1:
-			{
-				cairo_pattern_t *pat;
-				pat = cairo_pattern_create_linear (0, 0, width, 0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
-				cairo_set_source (cr, pat);
-				cairo_pattern_destroy (pat);
-				break;
-			}
-		}
-		
-		cairo_move_to (cr, 0.0,     0.0);
-		cairo_line_to (cr, width+1, 0.0);
-		cairo_stroke  (cr);
-
-		switch (separator->style)
-		{
-			default:
-			case 0:
-				murrine_set_color_rgba (cr, highlight, 0.5);
-				break;
-			case 1:
-			{
-				cairo_pattern_t *pat;
-				pat = cairo_pattern_create_linear (0, 0, width, 0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 0.5);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 0.5);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
-				cairo_set_source (cr, pat);
-				cairo_pattern_destroy (pat);
-				break;
-			}
-		}
-
-		cairo_move_to (cr, 0.0,   1.0);
-		cairo_line_to (cr, width, 1.0);
-		cairo_stroke  (cr);
-	}
-	else
-	{
-		cairo_translate (cr, x+0.5, y);
-
-		switch (separator->style)
-		{
-			default:
-			case 0:
-				murrine_set_color_rgb (cr, dark);
-				break;
-			case 1:
-			{
-				cairo_pattern_t *pat;
-				pat = cairo_pattern_create_linear (0, 0, 0, height);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, dark, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, dark, 1.0);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, dark, 0.0);
-				cairo_set_source (cr, pat);
-				cairo_pattern_destroy (pat);
-				break;
-			}
-		}
-		cairo_move_to (cr, 0.0, 0.0);
-		cairo_line_to (cr, 0.0, height);
-		cairo_stroke  (cr);
-
-		switch (separator->style)
-		{
-			default:
-			case 0:
-				murrine_set_color_rgba (cr, highlight, 0.5);
-				break;
-			case 1:
-			{
-				cairo_pattern_t *pat;
-				pat = cairo_pattern_create_linear (0, 0, 0, height);
-				murrine_pattern_add_color_stop_rgba (pat, 0.00, highlight, 0.0);
-				murrine_pattern_add_color_stop_rgba (pat, 0.25, highlight, 0.5);
-				murrine_pattern_add_color_stop_rgba (pat, 0.75, highlight, 0.5);
-				murrine_pattern_add_color_stop_rgba (pat, 1.00, highlight, 0.0);
-				cairo_set_source (cr, pat);
-				cairo_pattern_destroy (pat);
-				break;
-			}
-		}
-
-		cairo_move_to (cr, 1.0, 0.0);
-		cairo_line_to (cr, 1.0, height);
-		cairo_stroke  (cr);
-	}
-}
-
-static void
 murrine_rgba_draw_tab (cairo_t *cr,
                        const MurrineColors    *colors,
                        const WidgetParameters *widget,
@@ -2276,26 +2161,35 @@ murrine_rgba_draw_menu_frame (cairo_t *cr,
 			MurrineRGB fill;
 			raico_blur_t* blur = NULL;
 			cairo_t *cr_surface; 
-			cairo_surface_t *surface; 
+			cairo_surface_t *surface;
+			cairo_pattern_t *pat;
 			int bradius = 30;
+			int bheight = MIN (height, 300);
 
-			murrine_shade (&colors->bg[0], 0.1, &fill);
+			murrine_shade (&colors->bg[0], 1.14, &fill);
 
 			murrine_set_color_rgb (cr, border);
-			murrine_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, widget->roundness, corners);
+			cairo_rectangle       (cr, 0.5, 0.5, width-1, height-1);
 			cairo_stroke          (cr);
 
 			/* draw glow */
-			surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width+bradius*2, height+bradius*2);
+			surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, bheight);
 			cr_surface = cairo_create (surface); 
 			blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
 			raico_blur_set_radius (blur, bradius);
-			cairo_set_line_width (cr_surface, 4.0);
-			cairo_rectangle (cr_surface, bradius, bradius-5, width, height+5);
+			cairo_set_line_width (cr_surface, 1.0);
+			cairo_rectangle (cr_surface, bradius, bradius-15, width-bradius*2, bheight-bradius*2+15);
 			murrine_set_color_rgb (cr_surface, &fill);
-			cairo_stroke (cr_surface);
+			cairo_fill (cr_surface);
 			raico_blur_apply (blur, surface);
-			cairo_set_source_surface (cr, surface, -bradius, -bradius); 
+			cairo_rectangle (cr_surface, 0, -15, width, bheight+15);
+			pat = cairo_pattern_create_linear (0, -15, 0.0, bheight+15);
+			murrine_pattern_add_color_stop_rgba (pat, 0.25, &colors->bg[0], 0.0);
+			murrine_pattern_add_color_stop_rgba (pat, 1.0, &colors->bg[0], 1.0);
+			cairo_set_source (cr_surface, pat);
+			cairo_pattern_destroy (pat);
+			cairo_fill (cr_surface);
+			cairo_set_source_surface (cr, surface, 0, 0); 
 			cairo_paint (cr);
 			cairo_surface_destroy (surface); 
 			cairo_destroy (cr_surface);
@@ -2307,27 +2201,36 @@ murrine_rgba_draw_menu_frame (cairo_t *cr,
 			MurrineRGB fill;
 			raico_blur_t* blur = NULL;
 			cairo_t *cr_surface; 
-			cairo_surface_t *surface; 
+			cairo_surface_t *surface;
+			cairo_pattern_t *pat;
 			int bradius = 30;
+			int bheight = MIN (height, 300);
 
 			murrine_shade (&colors->bg[0], murrine_get_contrast(1.1, widget->contrast), &border);
-			murrine_shade (&colors->bg[0], 1.9, &fill);
+			murrine_shade (&colors->bg[0], 0.96, &fill);
 
 			murrine_set_color_rgb (cr, &border);
-			murrine_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, widget->roundness, corners);
+			cairo_rectangle       (cr, 0.5, 0.5, width-1, height-1);
 			cairo_stroke          (cr);
 
 			/* draw glow */
-			surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width+bradius*2, height+bradius*2);
+			surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, bheight);
 			cr_surface = cairo_create (surface); 
 			blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
 			raico_blur_set_radius (blur, bradius);
-			cairo_set_line_width (cr_surface, 4.0);
-			cairo_rectangle (cr_surface, bradius, bradius-5, width, height+5);
+			cairo_set_line_width (cr_surface, 1.0);
+			cairo_rectangle (cr_surface, bradius, bradius-15, width-bradius*2, bheight-bradius*2+15);
 			murrine_set_color_rgb (cr_surface, &fill);
-			cairo_stroke (cr_surface);
+			cairo_fill (cr_surface);
 			raico_blur_apply (blur, surface);
-			cairo_set_source_surface (cr, surface, -bradius, -bradius); 
+			cairo_rectangle (cr_surface, 0, -15, width, bheight+15);
+			pat = cairo_pattern_create_linear (0, -15, 0.0, bheight+15);
+			murrine_pattern_add_color_stop_rgba (pat, 0.25, &colors->bg[0], 0.0);
+			murrine_pattern_add_color_stop_rgba (pat, 1.0, &colors->bg[0], 1.0);
+			cairo_set_source (cr_surface, pat);
+			cairo_pattern_destroy (pat);
+			cairo_fill (cr_surface);
+			cairo_set_source_surface (cr, surface, 0, 0); 
 			cairo_paint (cr);
 			cairo_surface_destroy (surface); 
 			cairo_destroy (cr_surface);
@@ -2371,7 +2274,6 @@ murrine_register_style_rgba (MurrineStyleFunctions *functions)
 	functions->draw_menubar            = murrine_rgba_draw_menubar;
 	functions->draw_toolbar            = murrine_rgba_draw_toolbar;
 	functions->draw_frame              = murrine_rgba_draw_frame;
-	functions->draw_separator          = murrine_rgba_draw_separator;
 	functions->draw_tab                = murrine_rgba_draw_tab;
 	functions->draw_scrollbar_trough   = murrine_rgba_draw_scrollbar_trough;
 	functions->draw_scrollbar_stepper  = murrine_rgba_draw_scrollbar_stepper;
diff --git a/src/murrine_style.c b/src/murrine_style.c
index b756095..9133f23 100644
--- a/src/murrine_style.c
+++ b/src/murrine_style.c
@@ -1745,6 +1745,7 @@ murrine_style_draw_vline (GtkStyle     *style,
 
 	WidgetParameters params;
 
+	params.contrast = murrine_style->contrast;
 	params.style = MRN_STYLE_MURRINE;
 	if (murrine_widget_is_rgba (toplevel))
 	{
@@ -1756,7 +1757,7 @@ murrine_style_draw_vline (GtkStyle     *style,
 	    MRN_IS_TOGGLE_BUTTON (widget->parent->parent) &&
 	    MRN_IS_COMBO_BOX (widget->parent->parent->parent)))
 	{
-		STYLE_FUNCTION(draw_separator) (cr, colors, NULL, &separator, x, y1, 2, y2-y1);
+		STYLE_FUNCTION(draw_separator) (cr, colors, &params, &separator, x, y1, 2, y2-y1);
 	}
 
 	cairo_destroy (cr);
@@ -1790,13 +1791,14 @@ murrine_style_draw_hline (GtkStyle     *style,
 
 	WidgetParameters params;
 
+	params.contrast = murrine_style->contrast;
 	params.style = MRN_STYLE_MURRINE;
 	if (murrine_widget_is_rgba (toplevel))
 	{
 		params.style = MRN_STYLE_RGBA;
 	}
 
-	STYLE_FUNCTION(draw_separator) (cr, colors, NULL, &separator, x1, y, x2-x1, 2);
+	STYLE_FUNCTION(draw_separator) (cr, colors, &params, &separator, x1, y, x2-x1, 2);
 
 	cairo_destroy (cr);
 }



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