gtk-engines r1181 - in trunk: . engines/clearlooks/src



Author: bberg
Date: Sat May 10 19:44:03 2008
New Revision: 1181
URL: http://svn.gnome.org/viewvc/gtk-engines?rev=1181&view=rev

Log:
2008-05-10  Benjamin Berg  <benjamin sipsolutions net>

	* engines/clearlooks/src/*:
	Add "style_constants" in addition to the "style_functions". And
	removed the duplication of the top_left_highlight function.


Modified:
   trunk/ChangeLog
   trunk/engines/clearlooks/src/clearlooks_draw.c
   trunk/engines/clearlooks/src/clearlooks_draw.h
   trunk/engines/clearlooks/src/clearlooks_draw_glossy.c
   trunk/engines/clearlooks/src/clearlooks_draw_gummy.c
   trunk/engines/clearlooks/src/clearlooks_draw_inverted.c
   trunk/engines/clearlooks/src/clearlooks_style.c
   trunk/engines/clearlooks/src/clearlooks_style.h
   trunk/engines/clearlooks/src/clearlooks_types.h

Modified: trunk/engines/clearlooks/src/clearlooks_draw.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_draw.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_draw.c	Sat May 10 19:44:03 2008
@@ -146,13 +146,13 @@
 	if (corners & CR_CORNER_TOPRIGHT)
 		light_right -= radius;
 
-	ge_shade_color (color, 1.3, &hilight);
+	ge_shade_color (color, params->style_constants->topleft_highlight_shade, &hilight);
 	cairo_move_to         (cr, light_left, light_bottom);
 
 	ge_cairo_rounded_corner (cr, light_left, light_top, radius, corners & CR_CORNER_TOPLEFT);
 
 	cairo_line_to         (cr, light_right, light_top);
-	cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
+	cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, params->style_constants->topleft_highlight_alpha);
 	cairo_stroke          (cr);
 
 	cairo_restore (cr);
@@ -398,9 +398,9 @@
 		cairo_stroke (cr);
 
 		/* Draw topleft shadow */
-		clearlooks_draw_top_left_highlight (cr, fill, params, xoffset + 1, yoffset + 1,
-		                                    width - 2*(xoffset + 1), height - 2*(yoffset + 1),
-		                                    MAX(radius-1, 0), params->corners);
+		params->style_functions->draw_top_left_highlight (cr, fill, params, xoffset + 1, yoffset + 1,
+		                                                  width - 2*(xoffset + 1), height - 2*(yoffset + 1),
+		                                                  MAX(radius-1, 0), params->corners);
 	}
 	cairo_restore (cr);
 }
@@ -1742,7 +1742,7 @@
 	cairo_fill (cr);
 	cairo_pattern_destroy (pattern);
 
-	clearlooks_draw_top_left_highlight (cr, &s2, widget, 1, 1, width - 2, height - 2, MAX(radius - 1, 0), corners);
+	widget->style_functions->draw_top_left_highlight (cr, &s2, widget, 1, 1, width - 2, height - 2, MAX(radius - 1, 0), corners);
 
 	ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, corners);
 	clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
@@ -2377,10 +2377,11 @@
 }
 
 void
-clearlooks_register_style_classic (ClearlooksStyleFunctions *functions)
+clearlooks_register_style_classic (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
 {
 	g_assert (functions);
 
+	functions->draw_top_left_highlight = clearlooks_draw_top_left_highlight;
 	functions->draw_button             = clearlooks_draw_button;
 	functions->draw_scale_trough       = clearlooks_draw_scale_trough;
 	functions->draw_progressbar_trough = clearlooks_draw_progressbar_trough;
@@ -2416,4 +2417,7 @@
 	functions->draw_shadow             = clearlooks_draw_shadow;
 	functions->draw_slider             = clearlooks_draw_slider;
 	functions->draw_gripdots           = clearlooks_draw_gripdots;
+
+	constants->topleft_highlight_shade = 1.3;
+	constants->topleft_highlight_alpha = 0.5;
 }

Modified: trunk/engines/clearlooks/src/clearlooks_draw.h
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_draw.h	(original)
+++ trunk/engines/clearlooks/src/clearlooks_draw.h	Sat May 10 19:44:03 2008
@@ -9,10 +9,10 @@
 
 #include <cairo.h>
 
-GE_INTERNAL void clearlooks_register_style_classic (ClearlooksStyleFunctions *functions);
-GE_INTERNAL void clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions);
-GE_INTERNAL void clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions);
-GE_INTERNAL void clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions);
+GE_INTERNAL void clearlooks_register_style_classic (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
+GE_INTERNAL void clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
+GE_INTERNAL void clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
+GE_INTERNAL void clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
 
 /* Fallback focus function */
 GE_INTERNAL void clearlooks_draw_focus (cairo_t *cr,

Modified: trunk/engines/clearlooks/src/clearlooks_draw_glossy.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_draw_glossy.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_draw_glossy.c	Sat May 10 19:44:03 2008
@@ -1443,7 +1443,7 @@
 }
 
 void
-clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions)
+clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
 {
 	functions->draw_inset              = clearlooks_glossy_draw_inset;
 	functions->draw_button             = clearlooks_glossy_draw_button;

Modified: trunk/engines/clearlooks/src/clearlooks_draw_gummy.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_draw_gummy.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_draw_gummy.c	Sat May 10 19:44:03 2008
@@ -33,10 +33,6 @@
 #define SHADE_CENTER_TOP 1.02
 #define SHADE_BOTTOM 0.94
 
-/* Topleft highlight */
-#define TOPLEFT_HIGHLIGHT_SHADE 1.3
-#define TOPLEFT_HIGHLIGHT_ALPHA 0.4
-
 /* Listview */
 #define LISTVIEW_SHADE_TOP 1.06
 #define LISTVIEW_SHADE_CENTER_TOP 1.02
@@ -141,47 +137,6 @@
 	cairo_restore (cr);
 }
 
-/* This is basically just a copy of the code from clearlooks_draw.c.
- * KEEP IN SYNC IF POSSIBLE! */
-static void
-clearlooks_gummy_draw_top_left_highlight (cairo_t *cr, const CairoColor *color,
-                                    const WidgetParameters *params,
-                                    int x, int y, int width, int height,
-                                    gdouble radius, CairoCorners corners)
-{
-	CairoColor hilight;
-
-	double line_width = cairo_get_line_width (cr);
-	double offset = line_width / 2.0;
-	double light_top, light_bottom, light_left, light_right;
-
-	cairo_save (cr);
-
-	cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
-
-	light_top = y + offset;
-	light_bottom = y + height;
-	light_left = x + offset;
-	light_right = x + width;
-	
-	if (corners & CR_CORNER_BOTTOMLEFT)
-		light_bottom -= radius;
-	if (corners & CR_CORNER_TOPRIGHT)
-		light_right -= radius;
-
-	ge_shade_color (color, TOPLEFT_HIGHLIGHT_SHADE, &hilight);
-	cairo_move_to         (cr, light_left, light_bottom);
-
-	ge_cairo_rounded_corner (cr, light_left, light_top, radius, corners & CR_CORNER_TOPLEFT);
-
-	cairo_line_to         (cr, light_right, light_top);
-	cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, TOPLEFT_HIGHLIGHT_ALPHA);
-	cairo_stroke          (cr);
-
-	cairo_restore (cr);
-}
-
-
 static void
 clearlooks_gummy_draw_button (cairo_t                *cr,
                               const ClearlooksColors *colors,
@@ -291,9 +246,9 @@
 
 	if (!params->active)
 	{
-		clearlooks_gummy_draw_top_left_highlight (cr, &fill, params, 1+xoffset, 1+xoffset,
-		                                          width-(1+xoffset)*2, height-(1+xoffset)*2,
-		                                          radius, params->corners);
+		params->style_functions->draw_top_left_highlight (cr, &fill, params, 1+xoffset, 1+xoffset,
+		                                                  width-(1+xoffset)*2, height-(1+xoffset)*2,
+		                                                  radius, params->corners);
 	}
 	cairo_restore (cr);
 }
@@ -995,7 +950,7 @@
 	}
 	cairo_stroke (cr);
 
-	clearlooks_gummy_draw_top_left_highlight (cr, &fill, params, 1, 1, width-2, height-2, 2.0, params->corners);
+	params->style_functions->draw_top_left_highlight (cr, &fill, params, 1, 1, width-2, height-2, 2.0, params->corners);
 }
 
 static void
@@ -1071,8 +1026,8 @@
 	cairo_fill (cr);
 	cairo_pattern_destroy (pattern);
 
-	clearlooks_gummy_draw_top_left_highlight (cr, &fill, widget, 1, 1, width - 2, height - 2,
-	                                          radius, corners);
+	widget->style_functions->draw_top_left_highlight (cr, &fill, widget, 1, 1, width - 2, height - 2,
+	                                                  radius, corners);
 
 	ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
 	clearlooks_set_mixed_color (cr, border, &fill, 0.2);
@@ -1144,7 +1099,7 @@
 
 	cairo_set_line_width (cr, 1);
 
-	ge_shade_color (&fill, TOPLEFT_HIGHLIGHT_SHADE, &hilight);
+	ge_shade_color (&fill, widget->style_constants->topleft_highlight_shade, &hilight);
 	ge_shade_color (&fill, SHADE_TOP, &shade1);
 	ge_shade_color (&fill, SHADE_CENTER_TOP, &shade2);
 	ge_shade_color (&fill, SHADE_BOTTOM, &shade3);
@@ -1169,7 +1124,7 @@
 		cairo_move_to (cr, 1.5, height-1.5);
 		cairo_line_to (cr, 1.5, 1.5);
 		cairo_line_to (cr, width-1.5, 1.5);
-		cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, TOPLEFT_HIGHLIGHT_ALPHA);
+		cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, widget->style_constants->topleft_highlight_alpha);
 		cairo_stroke (cr);
 	}
 
@@ -1729,7 +1684,7 @@
 }
 
 void
-clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions)
+clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
 {
 	functions->draw_button             = clearlooks_gummy_draw_button;
 	functions->draw_entry              = clearlooks_gummy_draw_entry;
@@ -1751,4 +1706,7 @@
 	functions->draw_checkbox           = clearlooks_gummy_draw_checkbox;
 	functions->draw_radiobutton        = clearlooks_gummy_draw_radiobutton;
 	functions->draw_focus              = clearlooks_gummy_draw_focus;
+
+	constants->topleft_highlight_shade = 1.3;
+	constants->topleft_highlight_alpha = 0.4;
 }

Modified: trunk/engines/clearlooks/src/clearlooks_draw_inverted.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_draw_inverted.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_draw_inverted.c	Sat May 10 19:44:03 2008
@@ -30,29 +30,6 @@
 
 
 static void
-clearlooks_draw_top_left_highlight (cairo_t *cr,
-                                    const CairoColor *color,
-                                    const WidgetParameters *params,
-                                    int width, int height, gdouble radius)
-{
-	CairoColor hilight; 
-
-	double light_top = params->ythickness-1,
-	       light_bottom = height - params->ythickness - 1,
-	       light_left = params->xthickness-1,
-	       light_right = width - params->xthickness - 1;
-
-	ge_shade_color (color, 1.3, &hilight);
-	cairo_move_to         (cr, light_left, light_bottom - (int)radius/2);
-
-	ge_cairo_rounded_corner (cr, light_left, light_top, radius, params->corners & CR_CORNER_TOPLEFT);
-
-	cairo_line_to         (cr, light_right - (int)radius/2, light_top);
-	cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.7);
-	cairo_stroke          (cr);
-}
-
-static void
 clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height)
 {
 	cairo_pattern_t *pattern;
@@ -193,7 +170,10 @@
 		cairo_stroke (cr);
 		
 		/* Draw topleft shadow */
-		clearlooks_draw_top_left_highlight (cr, fill, params, width, height, radius);
+		params->style_functions->draw_top_left_highlight (cr, fill, params,
+		                                                  xoffset+1, yoffset+1,
+		                                                  width-2*(xoffset+1), height-2*(yoffset+1),
+		                                                  radius, params->corners);
 	}
 	cairo_restore (cr);
 }
@@ -843,7 +823,7 @@
 	cairo_fill (cr);
 	cairo_pattern_destroy (pattern);
 
-	clearlooks_draw_top_left_highlight (cr, &s1, widget, width, height, radius);
+	widget->style_functions->draw_top_left_highlight (cr, &s1, widget, 1, 1, width-2, height-2, radius, corners);
 
 	ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);	
 	clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0)); 
@@ -951,7 +931,7 @@
 		cairo_fill(cr);
 		cairo_pattern_destroy(pattern);
 		
-		clearlooks_draw_top_left_highlight (cr, &s2, widget, width, height, 0);
+		widget->style_functions->draw_top_left_highlight (cr, &s2, widget, 1, 1, width-2, height-2, 0, widget->corners);
 
 		clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
 		ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
@@ -1027,7 +1007,7 @@
 }
 
 void
-clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions)
+clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
 {
 	functions->draw_button            = clearlooks_inverted_draw_button;
 	functions->draw_slider            = clearlooks_inverted_draw_slider;
@@ -1040,5 +1020,8 @@
 	functions->draw_scrollbar_stepper = clearlooks_inverted_draw_scrollbar_stepper;	
 	functions->draw_scrollbar_slider  = clearlooks_inverted_draw_scrollbar_slider;
 	functions->draw_selected_cell     = clearlooks_inverted_draw_selected_cell;
+
+	constants->topleft_highlight_shade = 1.3;
+	constants->topleft_highlight_alpha = 0.7;
 }
 

Modified: trunk/engines/clearlooks/src/clearlooks_style.c
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_style.c	(original)
+++ trunk/engines/clearlooks/src/clearlooks_style.c	Sat May 10 19:44:03 2008
@@ -64,6 +64,7 @@
                                   WidgetParameters     *params)
 {
 	params->style_functions = &(clearlooks_style_class->style_functions[CLEARLOOKS_STYLE (style)->style]);
+	params->style_constants = &(clearlooks_style_class->style_constants[CLEARLOOKS_STYLE (style)->style]);
 
 	params->active        = (state_type == GTK_STATE_ACTIVE);
 	params->prelight      = (state_type == GTK_STATE_PRELIGHT);
@@ -1772,13 +1773,23 @@
 	style_class->draw_layout      = clearlooks_style_draw_layout;
 	style_class->render_icon      = clearlooks_style_draw_render_icon;
 
-	clearlooks_register_style_classic (&clearlooks_style_class->style_functions[CL_STYLE_CLASSIC]);
+	clearlooks_register_style_classic (&clearlooks_style_class->style_functions[CL_STYLE_CLASSIC],
+	                                   &clearlooks_style_class->style_constants[CL_STYLE_CLASSIC]);
+
 	clearlooks_style_class->style_functions[CL_STYLE_GLOSSY] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
-	clearlooks_register_style_glossy (&clearlooks_style_class->style_functions[CL_STYLE_GLOSSY]);
+	clearlooks_style_class->style_constants[CL_STYLE_GLOSSY] = clearlooks_style_class->style_constants[CL_STYLE_CLASSIC];
+	clearlooks_register_style_glossy (&clearlooks_style_class->style_functions[CL_STYLE_GLOSSY],
+	                                  &clearlooks_style_class->style_constants[CL_STYLE_GLOSSY]);
+
 	clearlooks_style_class->style_functions[CL_STYLE_INVERTED] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
-	clearlooks_register_style_inverted (&clearlooks_style_class->style_functions[CL_STYLE_INVERTED]);
+	clearlooks_style_class->style_constants[CL_STYLE_INVERTED] = clearlooks_style_class->style_constants[CL_STYLE_CLASSIC];
+	clearlooks_register_style_glossy (&clearlooks_style_class->style_functions[CL_STYLE_INVERTED],
+	                                  &clearlooks_style_class->style_constants[CL_STYLE_INVERTED]);
+
 	clearlooks_style_class->style_functions[CL_STYLE_GUMMY] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
-	clearlooks_register_style_gummy (&clearlooks_style_class->style_functions[CL_STYLE_GUMMY]);
+	clearlooks_style_class->style_constants[CL_STYLE_GUMMY] = clearlooks_style_class->style_constants[CL_STYLE_CLASSIC];
+	clearlooks_register_style_glossy (&clearlooks_style_class->style_functions[CL_STYLE_GUMMY],
+	                                  &clearlooks_style_class->style_constants[CL_STYLE_GUMMY]);
 }
 
 GType clearlooks_type_style = 0;

Modified: trunk/engines/clearlooks/src/clearlooks_style.h
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_style.h	(original)
+++ trunk/engines/clearlooks/src/clearlooks_style.h	Sat May 10 19:44:03 2008
@@ -68,6 +68,7 @@
 	GtkStyleClass parent_class;
 
 	ClearlooksStyleFunctions style_functions[CL_NUM_STYLES];
+	ClearlooksStyleConstants style_constants[CL_NUM_STYLES];
 };
 
 GE_INTERNAL void clearlooks_style_register_type (GTypeModule *module);

Modified: trunk/engines/clearlooks/src/clearlooks_types.h
==============================================================================
--- trunk/engines/clearlooks/src/clearlooks_types.h	(original)
+++ trunk/engines/clearlooks/src/clearlooks_types.h	Sat May 10 19:44:03 2008
@@ -6,6 +6,7 @@
 typedef unsigned char boolean;
 typedef unsigned char uint8;
 typedef struct _ClearlooksStyleFunctions ClearlooksStyleFunctions;
+typedef struct _ClearlooksStyleConstants ClearlooksStyleConstants;
 
 typedef enum
 {
@@ -174,6 +175,7 @@
 	CairoColor parentbg;
 
 	ClearlooksStyleFunctions *style_functions;
+	ClearlooksStyleConstants *style_constants;
 } WidgetParameters;
 
 typedef struct
@@ -287,8 +289,21 @@
 	boolean  topmost;
 } ToolbarParameters;
 
+struct _ClearlooksStyleConstants
+{
+	gdouble topleft_highlight_shade;
+	gdouble topleft_highlight_alpha;
+};
+
 struct _ClearlooksStyleFunctions
 {
+	void (*draw_top_left_highlight) (cairo_t *cr,
+	                               const CairoColor *color,
+	                               const WidgetParameters *params,
+                                       int x, int y, int width, int height,
+                                       gdouble radius,
+                                       CairoCorners corners);
+
 	void (*draw_button)           (cairo_t *cr,
 	                               const ClearlooksColors *colors,
 	                               const WidgetParameters *widget,



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