snapshot: Add gtk_snapshot_append_border()

This is adding functions for the remaining render nodes.
This commit is contained in:
Benjamin Otte 2019-02-21 02:11:13 +01:00
parent 4a293aa762
commit e1570e9ebc
5 changed files with 49 additions and 14 deletions

View File

@ -4409,6 +4409,9 @@ gtk_snapshot_append_cairo
gtk_snapshot_append_texture
gtk_snapshot_append_color
gtk_snapshot_append_layout
gtk_snapshot_append_linear_gradient
gtk_snapshot_append_repeating_linear_gradient
gtk_snapshot_append_border
gtk_snapshot_render_background
gtk_snapshot_render_frame
gtk_snapshot_render_focus

View File

@ -712,9 +712,10 @@ gsk_border_node_peek_colors (GskRenderNode *node)
/**
* gsk_border_node_new:
* @outline: a #GskRoundedRect describing the outline of the border
* @border_width: the stroke width of the border on the top, right, bottom and
* left side respectively.
* @border_color: the color used on the top, right, bottom and left side.
* @border_width: (array fixed-size=4): the stroke width of the border on
* the top, right, bottom and left side respectively.
* @border_color: (array fixed-size=4): the color used on the top, right,
* bottom and left side.
*
* Creates a #GskRenderNode that will stroke a border rectangle inside the
* given @outline. The 4 sides of the border can have different widths and

View File

@ -342,10 +342,6 @@ snapshot_frame_fill (GtkSnapshot *snapshot,
const GdkRGBA colors[4],
guint hidden_side)
{
GskRoundedRect offset_outline;
GskRenderNode *node;
int off_x, off_y;
if (hidden_side)
{
GdkRGBA real_colors[4];
@ -363,13 +359,7 @@ snapshot_frame_fill (GtkSnapshot *snapshot,
return;
}
gtk_snapshot_get_offset (snapshot, &off_x, &off_y);
gsk_rounded_rect_init_copy (&offset_outline, outline);
gsk_rounded_rect_offset (&offset_outline, off_x, off_y);
node = gsk_border_node_new (&offset_outline, border_width, colors);
gtk_snapshot_append_node_internal (snapshot, node);
gsk_render_node_unref (node);
gtk_snapshot_append_border (snapshot, outline, border_width, colors);
}
static void

View File

@ -1558,3 +1558,39 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot *snapshot,
gtk_snapshot_append_node_internal (snapshot, node);
gsk_render_node_unref (node);
}
/**
* gtk_snapshot_append_border:
* @snapshot: a #GtkSnapshot
* @outline: a #GskRoundedRect describing the outline of the border
* @border_width: (array fixed-size=4): the stroke width of the border on
* the top, right, bottom and left side respectively.
* @border_color: (array fixed-size=4): the color used on the top, right,
* bottom and left side.
*
* Appends a stroked border rectangle inside the given @outline. The
* 4 sides of the border can have different widths and colors.
**/
void
gtk_snapshot_append_border (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const float border_width[4],
const GdkRGBA border_color[4])
{
GskRenderNode *node;
GskRoundedRect real_outline;
float scale_x, scale_y, dx, dy;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (outline != NULL);
g_return_if_fail (border_width != NULL);
g_return_if_fail (border_color != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
gtk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, dx, dy);
node = gsk_border_node_new (&real_outline, border_width, border_color);
gtk_snapshot_append_node_internal (snapshot, node);
gsk_render_node_unref (node);
}

View File

@ -141,6 +141,11 @@ void gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot
const graphene_point_t *end_point,
const GskColorStop *stops,
gsize n_stops);
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_append_border (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const float border_width[4],
const GdkRGBA border_color[4]);
/* next function implemented in gskpango.c */
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_append_layout (GtkSnapshot *snapshot,