*/
#include "fallback-c89.c"
-typedef struct {
- gint idx;
-} GtkThemingBackgroundLayer;
-
static const GtkRoundedBox *
gtk_theming_background_get_box (GtkThemingBackground *bg,
GtkCssArea area)
static void
_gtk_theming_background_paint_layer (GtkThemingBackground *bg,
- GtkThemingBackgroundLayer *layer,
+ guint idx,
cairo_t *cr)
{
GtkCssRepeatStyle hrepeat, vrepeat;
double image_width, image_height;
double width, height;
- pos = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION), layer->idx);
- repeat = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_REPEAT), layer->idx);
+ pos = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION), idx);
+ repeat = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_REPEAT), idx);
hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
image = _gtk_css_image_value_get_image (
_gtk_css_array_value_get_nth (
_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE),
- layer->idx));
+ idx));
origin = gtk_theming_background_get_box (
bg,
_gtk_css_area_value_get (
_gtk_css_array_value_get_nth (
_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_ORIGIN),
- layer->idx)));
+ idx)));
width = origin->box.width;
height = origin->box.height;
if (image == NULL || width <= 0 || height <= 0)
return;
- _gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_SIZE), layer->idx),
+ _gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_SIZE), idx),
image,
width,
height,
_gtk_css_area_value_get (
_gtk_css_array_value_get_nth (
_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP),
- layer->idx))),
+ idx))),
cr);
cairo_clip (cr);
&bg->padding_box);
}
-static void
-_gtk_theming_background_init_layer (GtkThemingBackground *bg,
- GtkThemingBackgroundLayer *layer,
- gint idx)
-{
- layer->idx = idx;
-}
-
static void
_gtk_theming_background_init_context (GtkThemingBackground *bg)
{
GtkStateFlags flags = gtk_style_context_get_state (bg->context);
+ GtkBorder border, padding;
- gtk_style_context_get_border (bg->context, flags, &bg->border);
- gtk_style_context_get_padding (bg->context, flags, &bg->padding);
+ gtk_style_context_get_border (bg->context, flags, &border);
+ gtk_style_context_get_padding (bg->context, flags, &padding);
gtk_style_context_get_background_color (bg->context, flags, &bg->bg_color);
/* In the CSS box model, by default the background positioning area is
bg->padding_box = bg->border_box;
_gtk_rounded_box_shrink (&bg->padding_box,
- bg->border.top, bg->border.right,
- bg->border.bottom, bg->border.left);
+ border.top, border.right,
+ border.bottom, border.left);
bg->content_box = bg->padding_box;
_gtk_rounded_box_shrink (&bg->content_box,
- bg->padding.top, bg->padding.right,
- bg->padding.bottom, bg->padding.left);
+ padding.top, padding.right,
+ padding.bottom, padding.left);
}
void
cairo_t *cr)
{
gint idx;
- GtkThemingBackgroundLayer layer;
GtkCssValue *background_image;
background_image = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
for (idx = _gtk_css_array_value_get_n_values (background_image) - 1; idx >= 0; idx--)
{
- _gtk_theming_background_init_layer (bg, &layer, idx);
- _gtk_theming_background_paint_layer (bg, &layer, cr);
+ _gtk_theming_background_paint_layer (bg, idx, cr);
}
_gtk_theming_background_apply_shadow (bg, cr);