Commit dd220228 authored by Benjamin Otte's avatar Benjamin Otte

themingbackground: Use a GtkCssStyle instead of GtkStyleContext

parent 8d94140d
......@@ -500,7 +500,7 @@ gtk_do_render_background (GtkStyleContext *context,
gdouble width,
gdouble height)
{
gtk_theming_background_render (context,
gtk_theming_background_render (gtk_style_context_lookup_style (context),
cr,
x, y,
width, height,
......@@ -1615,7 +1615,7 @@ gtk_do_render_extension (GtkStyleContext *context,
break;
}
gtk_theming_background_render (context,
gtk_theming_background_render (gtk_style_context_lookup_style (context),
cr,
x, y,
width, height,
......
......@@ -32,8 +32,8 @@
#include "gtkcsspositionvalueprivate.h"
#include "gtkcssrepeatvalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkstylecontextprivate.h"
#include <math.h>
......@@ -49,7 +49,7 @@ typedef struct _GtkThemingBackground GtkThemingBackground;
#define N_BOXES (3)
struct _GtkThemingBackground {
GtkStyleContext *context;
GtkCssStyle *style;
GtkRoundedBox boxes[N_BOXES];
};
......@@ -63,7 +63,7 @@ _gtk_theming_background_paint_color (GtkThemingBackground *bg,
gint n_values = _gtk_css_array_value_get_n_values (background_image);
GtkCssArea clip = _gtk_css_area_value_get
(_gtk_css_array_value_get_nth
(_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP),
(gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_CLIP),
n_values - 1));
_gtk_rounded_box_path (&bg->boxes[clip], cr);
......@@ -83,18 +83,18 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
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), idx);
repeat = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_REPEAT), idx);
pos = _gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_POSITION), idx);
repeat = _gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style, 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),
gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE),
idx));
origin = &bg->boxes[
_gtk_css_area_value_get (
_gtk_css_array_value_get_nth (
_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_ORIGIN),
gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_ORIGIN),
idx))];
width = origin->box.width;
height = origin->box.height;
......@@ -102,7 +102,7 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
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), idx),
_gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_SIZE), idx),
image,
width,
height,
......@@ -125,7 +125,7 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
&bg->boxes[
_gtk_css_area_value_get (
_gtk_css_array_value_get_nth (
_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP),
gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_CLIP),
idx))],
cr);
cairo_clip (cr);
......@@ -253,21 +253,21 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
}
static void
_gtk_theming_background_init_context (GtkThemingBackground *bg,
double width,
double height,
GtkJunctionSides junction)
_gtk_theming_background_init_style (GtkThemingBackground *bg,
double width,
double height,
GtkJunctionSides junction)
{
GtkBorder border, padding;
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
padding.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_TOP), 100);
padding.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_RIGHT), 100);
padding.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_BOTTOM), 100);
padding.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_LEFT), 100);
border.top = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
padding.top = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_TOP), 100);
padding.right = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_RIGHT), 100);
padding.bottom = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_BOTTOM), 100);
padding.left = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_LEFT), 100);
/* In the CSS box model, by default the background positioning area is
* the padding-box, i.e. all the border-box minus the borders themselves,
......@@ -278,7 +278,7 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg,
* right now we just shrink to the default.
*/
_gtk_rounded_box_init_rect (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], 0, 0, width, height);
_gtk_rounded_box_apply_border_radius_for_style (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], gtk_style_context_lookup_style (bg->context), junction);
_gtk_rounded_box_apply_border_radius_for_style (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], bg->style, junction);
bg->boxes[GTK_CSS_AREA_PADDING_BOX] = bg->boxes[GTK_CSS_AREA_BORDER_BOX];
_gtk_rounded_box_shrink (&bg->boxes[GTK_CSS_AREA_PADDING_BOX],
......@@ -292,13 +292,13 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg,
}
void
gtk_theming_background_render (GtkStyleContext *context,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkJunctionSides junction)
gtk_theming_background_render (GtkCssStyle *style,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GtkJunctionSides junction)
{
GtkThemingBackground bg;
gint idx;
......@@ -306,9 +306,9 @@ gtk_theming_background_render (GtkStyleContext *context,
GtkCssValue *box_shadow;
const GdkRGBA *bg_color;
background_image = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
bg_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
box_shadow = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BOX_SHADOW);
background_image = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
bg_color = _gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
box_shadow = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BOX_SHADOW);
/* This is the common default case of no background */
if (gtk_rgba_is_clear (bg_color) &&
......@@ -317,8 +317,8 @@ gtk_theming_background_render (GtkStyleContext *context,
_gtk_css_shadows_value_is_none (box_shadow))
return;
bg.context = context;
_gtk_theming_background_init_context (&bg, width, height, junction);
bg.style = style;
_gtk_theming_background_init_style (&bg, width, height, junction);
cairo_save (cr);
cairo_translate (cr, x, y);
......
......@@ -29,7 +29,7 @@
G_BEGIN_DECLS
void gtk_theming_background_render (GtkStyleContext *context,
void gtk_theming_background_render (GtkCssStyle *style,
cairo_t *cr,
gdouble x,
gdouble y,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment