diff options
author | Benjamin Otte <otte@redhat.com> | 2012-04-04 11:44:57 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-04-17 08:59:18 +0200 |
commit | f785f7177c455369f1482ff6582cebf69ddddb7a (patch) | |
tree | 67d4d3131bd8e69d7ba7c9e7c225beb0ce970ba6 /gtk/gtkthemingbackground.c | |
parent | 5377169ef33d7b17d953ccd464e64dbd32335c47 (diff) | |
download | gtk+-f785f7177c455369f1482ff6582cebf69ddddb7a.tar.gz |
cssvalue: Add a custom value for repeats
In particular, that's background-repeat and border-image-repeat.
Also, fix up the border-image shorthand to allow any order.
Diffstat (limited to 'gtk/gtkthemingbackground.c')
-rw-r--r-- | gtk/gtkthemingbackground.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/gtk/gtkthemingbackground.c b/gtk/gtkthemingbackground.c index e937464f5f..4cb43aaa45 100644 --- a/gtk/gtkthemingbackground.c +++ b/gtk/gtkthemingbackground.c @@ -28,6 +28,7 @@ #include "gtkcssimagevalueprivate.h" #include "gtkcssshadowsvalueprivate.h" #include "gtkcsspositionvalueprivate.h" +#include "gtkcssrepeatvalueprivate.h" #include "gtkcsstypesprivate.h" #include "gtkthemingengineprivate.h" @@ -160,19 +161,17 @@ _gtk_theming_background_paint (GtkThemingBackground *bg, && bg->image_rect.width > 0 && bg->image_rect.height > 0) { - GtkCssBackgroundRepeat hrepeat, vrepeat; const GtkCssBackgroundSize *size; - const GtkCssValue *pos; + const GtkCssValue *pos, *repeat; double image_width, image_height; double width, height; + GtkCssRepeatStyle hrepeat, vrepeat; size = _gtk_css_value_get_background_size (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_SIZE)); pos = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION); - gtk_style_context_get (bg->context, bg->flags, - "background-repeat", &hrepeat, - NULL); - vrepeat = GTK_CSS_BACKGROUND_VERTICAL (hrepeat); - hrepeat = GTK_CSS_BACKGROUND_HORIZONTAL (hrepeat); + repeat = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_REPEAT); + hrepeat = _gtk_css_background_repeat_value_get_x (repeat); + vrepeat = _gtk_css_background_repeat_value_get_y (repeat); width = bg->image_rect.width; height = bg->image_rect.height; @@ -193,13 +192,13 @@ _gtk_theming_background_paint (GtkThemingBackground *bg, /* optimization */ if (image_width == width) - hrepeat = GTK_CSS_BACKGROUND_NO_REPEAT; + hrepeat = GTK_CSS_REPEAT_STYLE_NO_REPEAT; if (image_height == height) - vrepeat = GTK_CSS_BACKGROUND_NO_REPEAT; + vrepeat = GTK_CSS_REPEAT_STYLE_NO_REPEAT; cairo_translate (cr, bg->image_rect.x, bg->image_rect.y); - if (hrepeat == GTK_CSS_BACKGROUND_NO_REPEAT && vrepeat == GTK_CSS_BACKGROUND_NO_REPEAT) + if (hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT && vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT) { cairo_translate (cr, _gtk_css_position_value_get_x (pos, width - image_width), @@ -229,24 +228,24 @@ _gtk_theming_background_paint (GtkThemingBackground *bg, * a third step: that other dimension is scaled so that the original * aspect ratio is restored. */ - if (hrepeat == GTK_CSS_BACKGROUND_ROUND) + if (hrepeat == GTK_CSS_REPEAT_STYLE_ROUND) { double n = round (width / image_width); n = MAX (1, n); - if (vrepeat != GTK_CSS_BACKGROUND_ROUND + if (vrepeat != GTK_CSS_REPEAT_STYLE_ROUND /* && vsize == auto (it is by default) */) image_height *= width / (image_width * n); image_width = width / n; } - if (vrepeat == GTK_CSS_BACKGROUND_ROUND) + if (vrepeat == GTK_CSS_REPEAT_STYLE_ROUND) { double n = round (height / image_height); n = MAX (1, n); - if (hrepeat != GTK_CSS_BACKGROUND_ROUND + if (hrepeat != GTK_CSS_REPEAT_STYLE_ROUND /* && hsize == auto (it is by default) */) image_width *= height / (image_height * n); image_height = height / n; @@ -254,7 +253,7 @@ _gtk_theming_background_paint (GtkThemingBackground *bg, /* if hrepeat or vrepeat is 'space', we create a somewhat larger surface * to store the extra space. */ - if (hrepeat == GTK_CSS_BACKGROUND_SPACE) + if (hrepeat == GTK_CSS_REPEAT_STYLE_SPACE) { double n = floor (width / image_width); surface_width = n ? round (width / n) : 0; @@ -262,7 +261,7 @@ _gtk_theming_background_paint (GtkThemingBackground *bg, else surface_width = round (image_width); - if (vrepeat == GTK_CSS_BACKGROUND_SPACE) + if (vrepeat == GTK_CSS_REPEAT_STYLE_SPACE) { double n = floor (height / image_height); surface_height = n ? round (height / n) : 0; @@ -288,8 +287,8 @@ _gtk_theming_background_paint (GtkThemingBackground *bg, cairo_rectangle (cr, 0, 0, - hrepeat == GTK_CSS_BACKGROUND_NO_REPEAT ? image_width : width, - vrepeat == GTK_CSS_BACKGROUND_NO_REPEAT ? image_height : height); + hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT ? image_width : width, + vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT ? image_height : height); cairo_fill (cr); } } |