forked from AuroraMiddleware/gtk
snapshot: Add functions to append shadows
This commit is contained in:
parent
0d119f81c8
commit
1ef250f44a
@ -4412,6 +4412,8 @@ gtk_snapshot_append_layout
|
||||
gtk_snapshot_append_linear_gradient
|
||||
gtk_snapshot_append_repeating_linear_gradient
|
||||
gtk_snapshot_append_border
|
||||
gtk_snapshot_append_inset_shadow
|
||||
gtk_snapshot_append_outset_shadow
|
||||
gtk_snapshot_render_background
|
||||
gtk_snapshot_render_frame
|
||||
gtk_snapshot_render_focus
|
||||
|
@ -349,28 +349,19 @@ gtk_css_shadow_value_snapshot_outset (const GtkCssValue *shadow,
|
||||
GtkSnapshot *snapshot,
|
||||
const GskRoundedRect *border_box)
|
||||
{
|
||||
GskRoundedRect outline;
|
||||
GskRenderNode *node;
|
||||
int off_x, off_y;
|
||||
|
||||
g_return_if_fail (shadow->class == >K_CSS_VALUE_SHADOW);
|
||||
|
||||
/* We don't need to draw invisible shadows */
|
||||
if (gdk_rgba_is_clear (_gtk_css_rgba_value_get_rgba (shadow->color)))
|
||||
return;
|
||||
|
||||
gtk_snapshot_get_offset (snapshot, &off_x, &off_y);
|
||||
gsk_rounded_rect_init_copy (&outline, border_box);
|
||||
gsk_rounded_rect_offset (&outline, off_x, off_y);
|
||||
|
||||
node = gsk_outset_shadow_node_new (&outline,
|
||||
gtk_snapshot_append_outset_shadow (snapshot,
|
||||
border_box,
|
||||
_gtk_css_rgba_value_get_rgba (shadow->color),
|
||||
_gtk_css_number_value_get (shadow->hoffset, 0),
|
||||
_gtk_css_number_value_get (shadow->voffset, 0),
|
||||
_gtk_css_number_value_get (shadow->spread, 0),
|
||||
_gtk_css_number_value_get (shadow->radius, 0));
|
||||
gtk_snapshot_append_node_internal (snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
void
|
||||
@ -378,28 +369,19 @@ gtk_css_shadow_value_snapshot_inset (const GtkCssValue *shadow,
|
||||
GtkSnapshot *snapshot,
|
||||
const GskRoundedRect*padding_box)
|
||||
{
|
||||
GskRoundedRect outline;
|
||||
GskRenderNode *node;
|
||||
int off_x, off_y;
|
||||
|
||||
g_return_if_fail (shadow->class == >K_CSS_VALUE_SHADOW);
|
||||
|
||||
/* We don't need to draw invisible shadows */
|
||||
if (gdk_rgba_is_clear (_gtk_css_rgba_value_get_rgba (shadow->color)))
|
||||
return;
|
||||
|
||||
gtk_snapshot_get_offset (snapshot, &off_x, &off_y);
|
||||
gsk_rounded_rect_init_copy (&outline, padding_box);
|
||||
gsk_rounded_rect_offset (&outline, off_x, off_y);
|
||||
|
||||
node = gsk_inset_shadow_node_new (&outline,
|
||||
gtk_snapshot_append_inset_shadow (snapshot,
|
||||
padding_box,
|
||||
_gtk_css_rgba_value_get_rgba (shadow->color),
|
||||
_gtk_css_number_value_get (shadow->hoffset, 0),
|
||||
_gtk_css_number_value_get (shadow->voffset, 0),
|
||||
_gtk_css_number_value_get (shadow->spread, 0),
|
||||
_gtk_css_number_value_get (shadow->radius, 0));
|
||||
gtk_snapshot_append_node_internal (snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -1636,3 +1636,91 @@ gtk_snapshot_append_border (GtkSnapshot *snapshot,
|
||||
gtk_snapshot_append_node_internal (snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_snapshot_append_inset_shadow:
|
||||
* @snapshot: a #GtkSnapshot
|
||||
* @outline: outline of the region surrounded by shadow
|
||||
* @color: color of the shadow
|
||||
* @dx: horizontal offset of shadow
|
||||
* @dy: vertical offset of shadow
|
||||
* @spread: how far the shadow spreads towards the inside
|
||||
* @blur_radius: how much blur to apply to the shadow
|
||||
*
|
||||
* Appends an inset shadow into the box given by @outline.
|
||||
*/
|
||||
void
|
||||
gtk_snapshot_append_inset_shadow (GtkSnapshot *snapshot,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
float dy,
|
||||
float spread,
|
||||
float blur_radius)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
GskRoundedRect real_outline;
|
||||
float scale_x, scale_y, x, y;
|
||||
|
||||
g_return_if_fail (snapshot != NULL);
|
||||
g_return_if_fail (outline != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &x, &y);
|
||||
gtk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
|
||||
|
||||
node = gsk_inset_shadow_node_new (&real_outline,
|
||||
color,
|
||||
scale_x * dx + x,
|
||||
scale_y * dy + y,
|
||||
spread,
|
||||
blur_radius);
|
||||
|
||||
gtk_snapshot_append_node_internal (snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_snapshot_append_outset_shadow:
|
||||
* @snapshot: a #GtkSnapshot
|
||||
* @outline: outline of the region surrounded by shadow
|
||||
* @color: color of the shadow
|
||||
* @dx: horizontal offset of shadow
|
||||
* @dy: vertical offset of shadow
|
||||
* @spread: how far the shadow spreads towards the outside
|
||||
* @blur_radius: how much blur to apply to the shadow
|
||||
*
|
||||
* Appends an outset shadow node around the box given by @outline.
|
||||
*/
|
||||
void
|
||||
gtk_snapshot_append_outset_shadow (GtkSnapshot *snapshot,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
float dy,
|
||||
float spread,
|
||||
float blur_radius)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
GskRoundedRect real_outline;
|
||||
float scale_x, scale_y, x, y;
|
||||
|
||||
g_return_if_fail (snapshot != NULL);
|
||||
g_return_if_fail (outline != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &x, &y);
|
||||
gtk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
|
||||
|
||||
node = gsk_outset_shadow_node_new (&real_outline,
|
||||
color,
|
||||
scale_x * dx + x,
|
||||
scale_y * dy + y,
|
||||
spread,
|
||||
blur_radius);
|
||||
|
||||
|
||||
gtk_snapshot_append_node_internal (snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
|
@ -146,6 +146,22 @@ void gtk_snapshot_append_border (GtkSnapshot
|
||||
const GskRoundedRect *outline,
|
||||
const float border_width[4],
|
||||
const GdkRGBA border_color[4]);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_snapshot_append_inset_shadow (GtkSnapshot *snapshot,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
float dy,
|
||||
float spread,
|
||||
float blur_radius);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_snapshot_append_outset_shadow (GtkSnapshot *snapshot,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
float dy,
|
||||
float spread,
|
||||
float blur_radius);
|
||||
/* next function implemented in gskpango.c */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_snapshot_append_layout (GtkSnapshot *snapshot,
|
||||
|
Loading…
Reference in New Issue
Block a user