themingbackground: Use a GtkCssStyle instead of GtkStyleContext
This commit is contained in:
@ -500,7 +500,7 @@ gtk_do_render_background (GtkStyleContext *context,
|
|||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height)
|
gdouble height)
|
||||||
{
|
{
|
||||||
gtk_theming_background_render (context,
|
gtk_theming_background_render (gtk_style_context_lookup_style (context),
|
||||||
cr,
|
cr,
|
||||||
x, y,
|
x, y,
|
||||||
width, height,
|
width, height,
|
||||||
@ -1615,7 +1615,7 @@ gtk_do_render_extension (GtkStyleContext *context,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_theming_background_render (context,
|
gtk_theming_background_render (gtk_style_context_lookup_style (context),
|
||||||
cr,
|
cr,
|
||||||
x, y,
|
x, y,
|
||||||
width, height,
|
width, height,
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
#include "gtkcsspositionvalueprivate.h"
|
#include "gtkcsspositionvalueprivate.h"
|
||||||
#include "gtkcssrepeatvalueprivate.h"
|
#include "gtkcssrepeatvalueprivate.h"
|
||||||
#include "gtkcssrgbavalueprivate.h"
|
#include "gtkcssrgbavalueprivate.h"
|
||||||
|
#include "gtkcssstyleprivate.h"
|
||||||
#include "gtkcsstypesprivate.h"
|
#include "gtkcsstypesprivate.h"
|
||||||
#include "gtkstylecontextprivate.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ typedef struct _GtkThemingBackground GtkThemingBackground;
|
|||||||
#define N_BOXES (3)
|
#define N_BOXES (3)
|
||||||
|
|
||||||
struct _GtkThemingBackground {
|
struct _GtkThemingBackground {
|
||||||
GtkStyleContext *context;
|
GtkCssStyle *style;
|
||||||
|
|
||||||
GtkRoundedBox boxes[N_BOXES];
|
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);
|
gint n_values = _gtk_css_array_value_get_n_values (background_image);
|
||||||
GtkCssArea clip = _gtk_css_area_value_get
|
GtkCssArea clip = _gtk_css_area_value_get
|
||||||
(_gtk_css_array_value_get_nth
|
(_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));
|
n_values - 1));
|
||||||
|
|
||||||
_gtk_rounded_box_path (&bg->boxes[clip], cr);
|
_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 image_width, image_height;
|
||||||
double width, height;
|
double width, height;
|
||||||
|
|
||||||
pos = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION), 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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_REPEAT), 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);
|
hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
|
||||||
vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
|
vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
|
||||||
image = _gtk_css_image_value_get_image (
|
image = _gtk_css_image_value_get_image (
|
||||||
_gtk_css_array_value_get_nth (
|
_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));
|
idx));
|
||||||
origin = &bg->boxes[
|
origin = &bg->boxes[
|
||||||
_gtk_css_area_value_get (
|
_gtk_css_area_value_get (
|
||||||
_gtk_css_array_value_get_nth (
|
_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))];
|
idx))];
|
||||||
width = origin->box.width;
|
width = origin->box.width;
|
||||||
height = origin->box.height;
|
height = origin->box.height;
|
||||||
@ -102,7 +102,7 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
|
|||||||
if (image == NULL || width <= 0 || height <= 0)
|
if (image == NULL || width <= 0 || height <= 0)
|
||||||
return;
|
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,
|
image,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@ -125,7 +125,7 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
|
|||||||
&bg->boxes[
|
&bg->boxes[
|
||||||
_gtk_css_area_value_get (
|
_gtk_css_area_value_get (
|
||||||
_gtk_css_array_value_get_nth (
|
_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))],
|
idx))],
|
||||||
cr);
|
cr);
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
@ -253,21 +253,21 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gtk_theming_background_init_context (GtkThemingBackground *bg,
|
_gtk_theming_background_init_style (GtkThemingBackground *bg,
|
||||||
double width,
|
double width,
|
||||||
double height,
|
double height,
|
||||||
GtkJunctionSides junction)
|
GtkJunctionSides junction)
|
||||||
{
|
{
|
||||||
GtkBorder border, padding;
|
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.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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BORDER_RIGHT_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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BORDER_BOTTOM_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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BORDER_LEFT_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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_TOP), 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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_RIGHT), 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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_BOTTOM), 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_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_PADDING_LEFT), 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
|
/* 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,
|
* 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.
|
* 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_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];
|
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],
|
_gtk_rounded_box_shrink (&bg->boxes[GTK_CSS_AREA_PADDING_BOX],
|
||||||
@ -292,13 +292,13 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_theming_background_render (GtkStyleContext *context,
|
gtk_theming_background_render (GtkCssStyle *style,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
GtkJunctionSides junction)
|
GtkJunctionSides junction)
|
||||||
{
|
{
|
||||||
GtkThemingBackground bg;
|
GtkThemingBackground bg;
|
||||||
gint idx;
|
gint idx;
|
||||||
@ -306,9 +306,9 @@ gtk_theming_background_render (GtkStyleContext *context,
|
|||||||
GtkCssValue *box_shadow;
|
GtkCssValue *box_shadow;
|
||||||
const GdkRGBA *bg_color;
|
const GdkRGBA *bg_color;
|
||||||
|
|
||||||
background_image = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
|
background_image = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
|
||||||
bg_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
|
bg_color = _gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
|
||||||
box_shadow = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BOX_SHADOW);
|
box_shadow = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BOX_SHADOW);
|
||||||
|
|
||||||
/* This is the common default case of no background */
|
/* This is the common default case of no background */
|
||||||
if (gtk_rgba_is_clear (bg_color) &&
|
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))
|
_gtk_css_shadows_value_is_none (box_shadow))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bg.context = context;
|
bg.style = style;
|
||||||
_gtk_theming_background_init_context (&bg, width, height, junction);
|
_gtk_theming_background_init_style (&bg, width, height, junction);
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_translate (cr, x, y);
|
cairo_translate (cr, x, y);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
void gtk_theming_background_render (GtkStyleContext *context,
|
void gtk_theming_background_render (GtkCssStyle *style,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
|
Reference in New Issue
Block a user