win32-theme: Make syntax for mixing theme parts more regular

This lets us extend the argument list better
This commit is contained in:
Alexander Larsson 2011-11-28 08:39:15 +01:00
parent 6898ba4f76
commit 7c092be0ce
2 changed files with 61 additions and 59 deletions

View File

@ -97,15 +97,15 @@
}
.radio:inconsistent {
background-image: -gtk-win32-theme-part(button, 2 1, mix 2 5);
background-image: -gtk-win32-theme-part(button, 2 1, over (2 5, 0.3));
}
.radio:inconsistent:insensitive {
background-image: -gtk-win32-theme-part(button, 2 4, mix 2 8);
background-image: -gtk-win32-theme-part(button, 2 4, over (2 8, 0.3));
}
.radio:inconsistent:prelight {
background-image: -gtk-win32-theme-part(button, 2 4 , mix 2 6);
background-image: -gtk-win32-theme-part(button, 2 4, over(2 6, 0.3));
}
/* Scrollbars */
@ -194,29 +194,29 @@
.scrollbar.trough {
border-width: 0;
background-image: -gtk-win32-theme-part(scrollbar, 2 1, 4 1);
background-image: -gtk-win32-theme-part(scrollbar, 2 1, over (4 1));
}
.scrollbar.trough.vertical {
border-width: 0;
background-image: -gtk-win32-theme-part(scrollbar, 2 1, 6 1);
background-image: -gtk-win32-theme-part(scrollbar, 2 1, over (6 1));
}
.scrollbar.slider {
border-width: 0;
background-image: -gtk-win32-theme-part(scrollbar, 2 1, 8 1);
background-image: -gtk-win32-theme-part(scrollbar, 2 1, over (8 1));
}
.scrollbar.slider:prelight {
background-image: -gtk-win32-theme-part(scrollbar, 2 2, 8 2);
background-image: -gtk-win32-theme-part(scrollbar, 2 2, over (8 2));
}
.scrollbar.slider.vertical {
background-image: -gtk-win32-theme-part(scrollbar, 3 1, 9 1);
background-image: -gtk-win32-theme-part(scrollbar, 3 1, over (9 1));
}
.scrollbar.slider.vertical:prelight {
background-image: -gtk-win32-theme-part(scrollbar, 3 2, 9 2);
background-image: -gtk-win32-theme-part(scrollbar, 3 2, over (9 2));
}
/* Entry */

View File

@ -192,18 +192,14 @@ G_DEFINE_BOXED_TYPE_WITH_CODE (GtkWin32ThemePart, _gtk_win32_theme_part,
_gtk_win32_theme_part_ref, _gtk_win32_theme_part_unref,
_gtk_win32_theme_init() )
typedef enum {
RENDER_OVER,
RENDER_MIX
} ThemePartRenderOps;
struct _GtkWin32ThemePart {
HTHEME theme;
int part;
int state;
double over_alpha;
int part2;
int state2;
ThemePartRenderOps op;
gint ref_count;
};
@ -212,7 +208,7 @@ GtkWin32ThemePart *
_gtk_win32_theme_part_new (const char *class,
int xp_part, int state,
int xp_part2, int state2,
ThemePartRenderOps op)
double over_alpha)
{
GtkWin32ThemePart *part;
@ -224,7 +220,7 @@ _gtk_win32_theme_part_new (const char *class,
part->state = state;
part->part2 = xp_part2;
part->state2 = state2;
part->op = op;
part->over_alpha = over_alpha;
return part;
}
@ -259,7 +255,7 @@ _gtk_win32_theme_part_parse (GtkCssParser *parser,
{
char *class;
int xp_part, state, xp_part2, state2;
ThemePartRenderOps op;
double over_alpha;
GtkWin32ThemePart *theme_part;
if (!_gtk_css_parser_try (parser, "-gtk-win32-theme-part", TRUE))
@ -306,33 +302,54 @@ _gtk_win32_theme_part_parse (GtkCssParser *parser,
_gtk_css_parser_error (parser, "Expected a valid integer value");
return 0;
}
op = RENDER_OVER;
over_alpha = 1.0;
xp_part2 = -1;
state2 = -1;
if ( _gtk_css_parser_try (parser, ",", TRUE))
{
if ( _gtk_css_parser_try (parser, "over", TRUE))
{
op = RENDER_OVER;
}
else if ( _gtk_css_parser_try (parser, "mix", TRUE))
{
op = RENDER_MIX;
}
if (!_gtk_css_parser_try (parser, "(", TRUE))
{
_gtk_css_parser_error (parser,
"Expected '(' after 'over'");
return 0;
}
if (!_gtk_css_parser_try_int (parser, &xp_part2))
{
g_free (class);
_gtk_css_parser_error (parser, "Expected a valid integer value");
return 0;
}
if (!_gtk_css_parser_try_int (parser, &xp_part2))
{
g_free (class);
_gtk_css_parser_error (parser, "Expected a valid integer value");
return 0;
}
if (!_gtk_css_parser_try_int (parser, &state2))
{
g_free (class);
_gtk_css_parser_error (parser, "Expected a valid integer value");
return 0;
if (!_gtk_css_parser_try_int (parser, &state2))
{
g_free (class);
_gtk_css_parser_error (parser, "Expected a valid integer value");
return 0;
}
if ( _gtk_css_parser_try (parser, ",", TRUE))
{
if (!_gtk_css_parser_try_double (parser, &over_alpha))
{
g_free (class);
_gtk_css_parser_error (parser, "Expected a valid double value");
return 0;
}
}
if (!_gtk_css_parser_try (parser, ")", TRUE))
{
_gtk_css_parser_error (parser,
"Expected ')' at end of 'over'");
return 0;
}
}
}
@ -348,7 +365,7 @@ _gtk_win32_theme_part_parse (GtkCssParser *parser,
theme_part = _gtk_win32_theme_part_new (class,
xp_part, state,
xp_part2, state2,
op);
over_alpha);
g_free (class);
g_value_take_boxed (value, theme_part);
@ -403,30 +420,15 @@ _gtk_win32_theme_part_render (GtkWin32ThemePart *part,
width, height);
if (part->op == RENDER_MIX)
{
cr = cairo_create (surface);
cr = cairo_create (surface);
pattern = cairo_pattern_create_for_surface (surface2);
cairo_set_source (cr, pattern);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint_with_alpha (cr, 0.5);
pattern = cairo_pattern_create_for_surface (surface2);
cairo_set_source (cr, pattern);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint_with_alpha (cr, part->over_alpha);
cairo_destroy (cr);
cairo_pattern_destroy (pattern);
}
else /* OVER */
{
cr = cairo_create (surface);
pattern = cairo_pattern_create_for_surface (surface2);
cairo_set_source (cr, pattern);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint (cr);
cairo_destroy (cr);
cairo_pattern_destroy (pattern);
}
cairo_destroy (cr);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (surface2);
}