render: Take a GtkCssStyle for rendering frames
... and move the whole function into gtkthemingbackground.c
This commit is contained in:
parent
d0a12d477e
commit
d25b4105d6
134
gtk/gtkrender.c
134
gtk/gtkrender.c
@ -492,21 +492,6 @@ color_shade (const GdkRGBA *color,
|
|||||||
_gdk_rgba_init_from_hsla (color_return, &hsla);
|
_gdk_rgba_init_from_hsla (color_return, &hsla);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_do_render_background (GtkStyleContext *context,
|
|
||||||
cairo_t *cr,
|
|
||||||
gdouble x,
|
|
||||||
gdouble y,
|
|
||||||
gdouble width,
|
|
||||||
gdouble height)
|
|
||||||
{
|
|
||||||
gtk_theming_background_render (gtk_style_context_lookup_style (context),
|
|
||||||
cr,
|
|
||||||
x, y,
|
|
||||||
width, height,
|
|
||||||
gtk_style_context_get_junction_sides (context));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_render_background:
|
* gtk_render_background:
|
||||||
* @context: a #GtkStyleContext
|
* @context: a #GtkStyleContext
|
||||||
@ -542,7 +527,9 @@ gtk_render_background (GtkStyleContext *context,
|
|||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_new_path (cr);
|
cairo_new_path (cr);
|
||||||
|
|
||||||
gtk_do_render_background (context, cr, x, y, width, height);
|
gtk_css_style_render_background (gtk_style_context_lookup_style (context),
|
||||||
|
cr, x, y, width, height,
|
||||||
|
gtk_style_context_get_junction_sides (context));
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
@ -892,7 +879,7 @@ render_border (cairo_t *cr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
render_frame_internal (GtkStyleContext *context,
|
gtk_css_style_render_frame (GtkCssStyle *style,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
@ -904,12 +891,12 @@ render_frame_internal (GtkStyleContext *context,
|
|||||||
GtkBorderImage border_image;
|
GtkBorderImage border_image;
|
||||||
double border_width[4];
|
double border_width[4];
|
||||||
|
|
||||||
border_width[0] = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
||||||
border_width[1] = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
border_width[1] = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
||||||
border_width[2] = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
border_width[2] = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
||||||
border_width[3] = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
border_width[3] = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
||||||
|
|
||||||
if (_gtk_border_image_init (&border_image, gtk_style_context_lookup_style (context)))
|
if (_gtk_border_image_init (&border_image, style))
|
||||||
{
|
{
|
||||||
_gtk_border_image_render (&border_image, border_width, cr, x, y, width, height);
|
_gtk_border_image_render (&border_image, border_width, cr, x, y, width, height);
|
||||||
}
|
}
|
||||||
@ -926,42 +913,25 @@ render_frame_internal (GtkStyleContext *context,
|
|||||||
border_width[3] == 0)
|
border_width[3] == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
border_style[0] = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
|
border_style[0] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
|
||||||
border_style[1] = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
|
border_style[1] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
|
||||||
border_style[2] = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
|
border_style[2] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
|
||||||
border_style[3] = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
|
border_style[3] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
|
||||||
|
|
||||||
hide_border_sides (border_width, border_style, hidden_side);
|
hide_border_sides (border_width, border_style, hidden_side);
|
||||||
|
|
||||||
colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
|
colors[0] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
|
||||||
colors[1] = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR));
|
colors[1] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR));
|
||||||
colors[2] = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR));
|
colors[2] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR));
|
||||||
colors[3] = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_COLOR));
|
colors[3] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_COLOR));
|
||||||
|
|
||||||
_gtk_rounded_box_init_rect (&border_box, x, y, width, height);
|
_gtk_rounded_box_init_rect (&border_box, x, y, width, height);
|
||||||
_gtk_rounded_box_apply_border_radius_for_style (&border_box, gtk_style_context_lookup_style (context), junction);
|
_gtk_rounded_box_apply_border_radius_for_style (&border_box, style, junction);
|
||||||
|
|
||||||
render_border (cr, &border_box, border_width, hidden_side, colors, border_style);
|
render_border (cr, &border_box, border_width, hidden_side, colors, border_style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_do_render_frame (GtkStyleContext *context,
|
|
||||||
cairo_t *cr,
|
|
||||||
gdouble x,
|
|
||||||
gdouble y,
|
|
||||||
gdouble width,
|
|
||||||
gdouble height)
|
|
||||||
{
|
|
||||||
GtkJunctionSides junction;
|
|
||||||
|
|
||||||
junction = gtk_style_context_get_junction_sides (context);
|
|
||||||
|
|
||||||
render_frame_internal (context, cr,
|
|
||||||
x, y, width, height,
|
|
||||||
0, junction);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_render_frame:
|
* gtk_render_frame:
|
||||||
* @context: a #GtkStyleContext
|
* @context: a #GtkStyleContext
|
||||||
@ -997,7 +967,12 @@ gtk_render_frame (GtkStyleContext *context,
|
|||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_new_path (cr);
|
cairo_new_path (cr);
|
||||||
|
|
||||||
gtk_do_render_frame (context, cr, x, y, width, height);
|
gtk_css_style_render_frame (gtk_style_context_lookup_style (context),
|
||||||
|
cr,
|
||||||
|
x, y, width, height,
|
||||||
|
0,
|
||||||
|
gtk_style_context_get_junction_sides (context));
|
||||||
|
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
@ -1376,8 +1351,21 @@ gtk_do_render_slider (GtkStyleContext *context,
|
|||||||
gdouble height,
|
gdouble height,
|
||||||
GtkOrientation orientation)
|
GtkOrientation orientation)
|
||||||
{
|
{
|
||||||
gtk_do_render_background (context, cr, x, y, width, height);
|
GtkCssStyle *style;
|
||||||
gtk_do_render_frame (context, cr, x, y, width, height);
|
GtkJunctionSides junction;
|
||||||
|
|
||||||
|
style = gtk_style_context_lookup_style (context);
|
||||||
|
junction = gtk_style_context_get_junction_sides (context);
|
||||||
|
|
||||||
|
gtk_css_style_render_background (style,
|
||||||
|
cr,
|
||||||
|
x, y, width, height,
|
||||||
|
junction);
|
||||||
|
gtk_css_style_render_frame (style,
|
||||||
|
cr,
|
||||||
|
x, y, width, height,
|
||||||
|
0,
|
||||||
|
junction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1424,7 +1412,7 @@ gtk_render_slider (GtkStyleContext *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_do_render_frame_gap (GtkStyleContext *context,
|
gtk_css_style_render_frame_gap (GtkCssStyle *style,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
@ -1432,24 +1420,22 @@ gtk_do_render_frame_gap (GtkStyleContext *context,
|
|||||||
gdouble height,
|
gdouble height,
|
||||||
GtkPositionType gap_side,
|
GtkPositionType gap_side,
|
||||||
gdouble xy0_gap,
|
gdouble xy0_gap,
|
||||||
gdouble xy1_gap)
|
gdouble xy1_gap,
|
||||||
|
GtkJunctionSides junction)
|
||||||
{
|
{
|
||||||
GtkJunctionSides junction;
|
|
||||||
gint border_width;
|
gint border_width;
|
||||||
GtkCssValue *corner[4];
|
GtkCssValue *corner[4];
|
||||||
gdouble x0, y0, x1, y1, xc = 0.0, yc = 0.0, wc = 0.0, hc = 0.0;
|
gdouble x0, y0, x1, y1, xc = 0.0, yc = 0.0, wc = 0.0, hc = 0.0;
|
||||||
GtkBorder border;
|
GtkBorder border;
|
||||||
|
|
||||||
junction = gtk_style_context_get_junction_sides (context);
|
border.top = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
||||||
|
border.right = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
||||||
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
border.bottom = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
||||||
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
border.left = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
||||||
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
corner[GTK_CSS_TOP_LEFT] = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS);
|
||||||
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
corner[GTK_CSS_TOP_RIGHT] = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS);
|
||||||
corner[GTK_CSS_TOP_LEFT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS);
|
corner[GTK_CSS_BOTTOM_LEFT] = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS);
|
||||||
corner[GTK_CSS_TOP_RIGHT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS);
|
corner[GTK_CSS_BOTTOM_RIGHT] = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS);
|
||||||
corner[GTK_CSS_BOTTOM_LEFT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS);
|
|
||||||
corner[GTK_CSS_BOTTOM_RIGHT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS);
|
|
||||||
|
|
||||||
border_width = MIN (MIN (border.top, border.bottom),
|
border_width = MIN (MIN (border.top, border.bottom),
|
||||||
MIN (border.left, border.right));
|
MIN (border.left, border.right));
|
||||||
@ -1518,7 +1504,7 @@ gtk_do_render_frame_gap (GtkStyleContext *context,
|
|||||||
cairo_rectangle (cr, x0, yc + hc, x1 - x0, y1 - (yc + hc));
|
cairo_rectangle (cr, x0, yc + hc, x1 - x0, y1 - (yc + hc));
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
|
|
||||||
render_frame_internal (context, cr,
|
gtk_css_style_render_frame (style, cr,
|
||||||
x, y, width, height,
|
x, y, width, height,
|
||||||
0, junction);
|
0, junction);
|
||||||
|
|
||||||
@ -1576,15 +1562,18 @@ gtk_render_frame_gap (GtkStyleContext *context,
|
|||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_new_path (cr);
|
cairo_new_path (cr);
|
||||||
|
|
||||||
gtk_do_render_frame_gap (context, cr,
|
gtk_css_style_render_frame_gap (gtk_style_context_lookup_style (context),
|
||||||
|
cr,
|
||||||
x, y, width, height, gap_side,
|
x, y, width, height, gap_side,
|
||||||
xy0_gap, xy1_gap);
|
xy0_gap, xy1_gap,
|
||||||
|
gtk_style_context_get_junction_sides (context));
|
||||||
|
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_do_render_extension (GtkStyleContext *context,
|
gtk_css_style_render_extension (GtkCssStyle *style,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
@ -1615,13 +1604,13 @@ gtk_do_render_extension (GtkStyleContext *context,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_theming_background_render (gtk_style_context_lookup_style (context),
|
gtk_css_style_render_background (style,
|
||||||
cr,
|
cr,
|
||||||
x, y,
|
x, y,
|
||||||
width, height,
|
width, height,
|
||||||
junction);
|
junction);
|
||||||
|
|
||||||
render_frame_internal (context, cr,
|
gtk_css_style_render_frame (style, cr,
|
||||||
x, y, width, height,
|
x, y, width, height,
|
||||||
hidden_side, junction);
|
hidden_side, junction);
|
||||||
}
|
}
|
||||||
@ -1664,7 +1653,10 @@ gtk_render_extension (GtkStyleContext *context,
|
|||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_new_path (cr);
|
cairo_new_path (cr);
|
||||||
|
|
||||||
gtk_do_render_extension (context, cr, x, y, width, height, gap_side);
|
gtk_css_style_render_extension (gtk_style_context_lookup_style (context),
|
||||||
|
cr,
|
||||||
|
x, y, width, height,
|
||||||
|
gap_side);
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ _gtk_theming_background_init_style (GtkThemingBackground *bg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_theming_background_render (GtkCssStyle *style,
|
gtk_css_style_render_background (GtkCssStyle *style,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
|
@ -23,13 +23,12 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
#include "gtkcssimageprivate.h"
|
#include "gtkcsstypesprivate.h"
|
||||||
#include "gtkroundedboxprivate.h"
|
|
||||||
#include "gtktypes.h"
|
#include "gtktypes.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
void gtk_theming_background_render (GtkCssStyle *style,
|
void gtk_css_style_render_background (GtkCssStyle *style,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
|
Loading…
Reference in New Issue
Block a user