[gtk-theme-engine-clearlooks] Allow filled-in focus in buttons



commit 178c4b9116401697e1f1efa52e6e61907b52590f
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 8 08:09:17 2010 -0500

    Allow filled-in focus in buttons
    
    This adds focus_fill_color and focus_fill_alpha parameters and
    uses them when drawing focus in buttons.

 src/clearlooks_draw.c     |    8 +++++++-
 src/clearlooks_rc_style.c |   16 ++++++++++++++++
 src/clearlooks_rc_style.h |    5 ++++-
 src/clearlooks_style.c    |   19 +++++++++++++++++++
 src/clearlooks_style.h    |    3 +++
 src/clearlooks_types.h    |    2 ++
 6 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/src/clearlooks_draw.c b/src/clearlooks_draw.c
index 809dbda..295e791 100644
--- a/src/clearlooks_draw.c
+++ b/src/clearlooks_draw.c
@@ -2488,7 +2488,13 @@ clearlooks_draw_focus (cairo_t *cr,
 	                 x + focus->line_width / 2.0,
 	                 y + focus->line_width / 2.0,
 	                 width - focus->line_width, height - focus->line_width);
-	cairo_stroke (cr);
+	cairo_stroke_preserve (cr);
+
+        if (focus->type == CL_FOCUS_BUTTON &&
+            focus->has_fill_color) {
+                ge_cairo_set_color (cr, &focus->fill_color);
+                cairo_fill (cr);
+        }
 }
 
 void
diff --git a/src/clearlooks_rc_style.c b/src/clearlooks_rc_style.c
index 2355d62..767d47b 100644
--- a/src/clearlooks_rc_style.c
+++ b/src/clearlooks_rc_style.c
@@ -48,6 +48,8 @@ static void      clearlooks_rc_style_merge        (GtkRcStyle             *dest,
 enum
 {
 	TOKEN_FOCUSCOLOR = G_TOKEN_LAST + 1,
+	TOKEN_FOCUSFILLCOLOR,
+	TOKEN_FOCUSFILLALPHA,
 	TOKEN_SCROLLBARCOLOR,
 	TOKEN_COLORIZESCROLLBAR,
 	TOKEN_CONTRAST,
@@ -83,6 +85,8 @@ enum
 
 static gchar* clearlooks_rc_symbols =
 	"focus_color\0"
+	"focus_fill_color\0"
+	"focus_fill_alpha\0"
 	"scrollbar_color\0"
 	"colorize_scrollbar\0"
 	"contrast\0"
@@ -436,6 +440,14 @@ clearlooks_rc_style_parse (GtkRcStyle *rc_style,
 				token = clearlooks_gtk2_rc_parse_color (settings, scanner, rc_style, &clearlooks_style->focus_color);
 				clearlooks_style->flags |= CL_FLAG_FOCUS_COLOR;
 				break;
+			case TOKEN_FOCUSFILLCOLOR:
+				token = clearlooks_gtk2_rc_parse_color (settings, scanner, rc_style, &clearlooks_style->focus_fill_color);
+				clearlooks_style->flags |= CL_FLAG_FOCUS_FILL_COLOR;
+				break;
+			case TOKEN_FOCUSFILLALPHA:
+				token = clearlooks_gtk2_rc_parse_double (settings, scanner, &clearlooks_style->focus_fill_alpha);
+				clearlooks_style->flags |= CL_FLAG_FOCUS_FILL_COLOR;
+                                break;
 			case TOKEN_SCROLLBARCOLOR:
 				token = clearlooks_gtk2_rc_parse_color (settings, scanner, rc_style, &clearlooks_style->scrollbar_color);
 				clearlooks_style->flags |= CL_FLAG_SCROLLBAR_COLOR;
@@ -553,6 +565,10 @@ clearlooks_rc_style_merge (GtkRcStyle *dest,
 		dest_w->toolbarstyle = src_w->toolbarstyle;
 	if (flags & CL_FLAG_FOCUS_COLOR)
 		dest_w->focus_color = src_w->focus_color;
+	if (flags & CL_FLAG_FOCUS_FILL_COLOR)
+		dest_w->focus_fill_color = src_w->focus_fill_color;
+	if (flags & CL_FLAG_FOCUS_FILL_COLOR)
+		dest_w->focus_fill_alpha = src_w->focus_fill_alpha;
 	if (flags & CL_FLAG_SCROLLBAR_COLOR)
 		dest_w->scrollbar_color = src_w->scrollbar_color;
 	if (flags & CL_FLAG_COLORIZE_SCROLLBAR)
diff --git a/src/clearlooks_rc_style.h b/src/clearlooks_rc_style.h
index 5e1c3b1..dda4195 100644
--- a/src/clearlooks_rc_style.h
+++ b/src/clearlooks_rc_style.h
@@ -57,7 +57,8 @@ typedef enum {
 	CL_FLAG_HINT               = 1 <<  10,
 	CL_FLAG_DISABLE_FOCUS      = 1 <<  11,
 	CL_FLAG_ACCEL_LABEL_SHADE  = 1 <<  12,
-	CL_FLAG_GRADIENT           = 1 <<  13
+	CL_FLAG_GRADIENT           = 1 <<  13,
+	CL_FLAG_FOCUS_FILL_COLOR   = 1 <<  14
 } ClearlooksRcFlags;
 
 struct _ClearlooksRcStyle
@@ -69,6 +70,8 @@ struct _ClearlooksRcStyle
 	ClearlooksStyles style;
 
 	GdkColor focus_color;
+	GdkColor focus_fill_color;
+        double focus_fill_alpha;
 	GdkColor scrollbar_color;
 	gboolean colorize_scrollbar;
 	double contrast;
diff --git a/src/clearlooks_style.c b/src/clearlooks_style.c
index d796102..e55d3f1 100644
--- a/src/clearlooks_style.c
+++ b/src/clearlooks_style.c
@@ -1355,6 +1355,7 @@ clearlooks_style_init_from_rc (GtkStyle * style,
 	clearlooks_style->menubarstyle        = CLEARLOOKS_RC_STYLE (rc_style)->menubarstyle;
 	clearlooks_style->toolbarstyle        = CLEARLOOKS_RC_STYLE (rc_style)->toolbarstyle;
 	clearlooks_style->has_focus_color     = CLEARLOOKS_RC_STYLE (rc_style)->flags & CL_FLAG_FOCUS_COLOR;
+	clearlooks_style->has_focus_fill_color     = CLEARLOOKS_RC_STYLE (rc_style)->flags & CL_FLAG_FOCUS_FILL_COLOR;
 	clearlooks_style->has_scrollbar_color = CLEARLOOKS_RC_STYLE (rc_style)->flags & CL_FLAG_SCROLLBAR_COLOR;
 	clearlooks_style->colorize_scrollbar  = CLEARLOOKS_RC_STYLE (rc_style)->colorize_scrollbar;
 	clearlooks_style->animation           = CLEARLOOKS_RC_STYLE (rc_style)->animation;
@@ -1364,6 +1365,11 @@ clearlooks_style_init_from_rc (GtkStyle * style,
 
 	if (clearlooks_style->has_focus_color)
 		clearlooks_style->focus_color     = CLEARLOOKS_RC_STYLE (rc_style)->focus_color;
+	if (clearlooks_style->has_focus_fill_color) {
+		clearlooks_style->focus_fill_color = CLEARLOOKS_RC_STYLE (rc_style)->focus_fill_color;
+		clearlooks_style->focus_fill_alpha = CLEARLOOKS_RC_STYLE (rc_style)->focus_fill_alpha;
+        }
+
 	if (clearlooks_style->has_scrollbar_color)
 		clearlooks_style->scrollbar_color = CLEARLOOKS_RC_STYLE (rc_style)->scrollbar_color;
 }
@@ -1573,6 +1579,17 @@ clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_ty
 	}
 	else
 		focus.color = colors->bg[GTK_STATE_SELECTED];
+	if (clearlooks_style->has_focus_fill_color)
+	{
+		ge_gdk_color_to_cairo (&clearlooks_style->focus_fill_color, &focus.fill_color);
+                focus.fill_color.a = clearlooks_style->focus_fill_alpha;
+                focus.has_fill_color = TRUE;
+	}
+	else {
+		focus.fill_color = colors->bg[GTK_STATE_SELECTED];
+                focus.fill_color.a = 1.0;
+        }
+
 
 	STYLE_FUNCTION(draw_focus) (cr, colors, &params, &focus, x, y, width, height);
 
@@ -1591,6 +1608,8 @@ clearlooks_style_copy (GtkStyle * style, GtkStyle * src)
 	cl_style->toolbarstyle        = cl_src->toolbarstyle;
 	cl_style->focus_color         = cl_src->focus_color;
 	cl_style->has_focus_color     = cl_src->has_focus_color;
+	cl_style->focus_fill_color    = cl_src->focus_fill_color;
+	cl_style->has_focus_fill_color = cl_src->has_focus_fill_color;
 	cl_style->scrollbar_color     = cl_src->scrollbar_color;
 	cl_style->has_scrollbar_color = cl_src->has_scrollbar_color;
 	cl_style->colorize_scrollbar  = cl_src->colorize_scrollbar;
diff --git a/src/clearlooks_style.h b/src/clearlooks_style.h
index 61a9a84..3dcdc9b 100644
--- a/src/clearlooks_style.h
+++ b/src/clearlooks_style.h
@@ -57,6 +57,9 @@ struct _ClearlooksStyle
 	guint8   toolbarstyle;
 	GdkColor focus_color;
 	gboolean has_focus_color;
+	GdkColor focus_fill_color;
+        gdouble  focus_fill_alpha;
+	gboolean has_focus_fill_color;
 	GdkColor scrollbar_color;
 	gboolean colorize_scrollbar;
 	gboolean has_scrollbar_color;
diff --git a/src/clearlooks_types.h b/src/clearlooks_types.h
index c97ca44..e7091d0 100644
--- a/src/clearlooks_types.h
+++ b/src/clearlooks_types.h
@@ -209,6 +209,8 @@ typedef struct
 	ClearlooksContinue  continue_side;
 	CairoColor          color;
 	boolean             has_color;
+	CairoColor          fill_color;
+	boolean             has_fill_color;
 	gint                line_width;
 	gint                padding;
 	guint8*             dash_list;



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