mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-02 08:50:28 +00:00
snapshot: Implement gtk_snapshot_push_opacity()
Use it in GtkWidget's opacity handling.
This commit is contained in:
parent
6b29dbf26a
commit
9822fe81a3
@ -275,6 +275,58 @@ gtk_snapshot_push_transform (GtkSnapshot *snapshot,
|
|||||||
real_transform);
|
real_transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GskRenderNode *
|
||||||
|
gtk_snapshot_collect_opacity (GskRenderNode **nodes,
|
||||||
|
guint n_nodes,
|
||||||
|
const char *name,
|
||||||
|
gpointer opacity)
|
||||||
|
{
|
||||||
|
GskRenderNode *node, *opacity_node;
|
||||||
|
|
||||||
|
node = gtk_snapshot_collect_default (nodes, n_nodes, name, NULL);
|
||||||
|
if (node == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
opacity_node = gsk_opacity_node_new (node, *(double *) opacity);
|
||||||
|
gsk_render_node_set_name (opacity_node, name);
|
||||||
|
|
||||||
|
gsk_render_node_unref (node);
|
||||||
|
g_free (opacity);
|
||||||
|
|
||||||
|
return opacity_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_snapshot_push_opacity (GtkSnapshot *snapshot,
|
||||||
|
double opacity,
|
||||||
|
const char *name,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
double *real_opacity;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start (args, name);
|
||||||
|
str = g_strdup_vprintf (name, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
str = NULL;
|
||||||
|
|
||||||
|
real_opacity = g_memdup (&opacity, sizeof (gdouble));
|
||||||
|
|
||||||
|
snapshot->state = gtk_snapshot_state_new (snapshot->state,
|
||||||
|
str,
|
||||||
|
snapshot->state->clip_region,
|
||||||
|
snapshot->state->translate_x,
|
||||||
|
snapshot->state->translate_y,
|
||||||
|
gtk_snapshot_collect_opacity,
|
||||||
|
real_opacity);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
|
rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
|
||||||
const graphene_rect_t *graphene)
|
const graphene_rect_t *graphene)
|
||||||
|
@ -47,6 +47,11 @@ void gtk_snapshot_push_transform (GtkSnapshot
|
|||||||
const char *name,
|
const char *name,
|
||||||
...) G_GNUC_PRINTF (3, 4);
|
...) G_GNUC_PRINTF (3, 4);
|
||||||
GDK_AVAILABLE_IN_3_90
|
GDK_AVAILABLE_IN_3_90
|
||||||
|
void gtk_snapshot_push_opacity (GtkSnapshot *snapshot,
|
||||||
|
double opacity,
|
||||||
|
const char *name,
|
||||||
|
...) G_GNUC_PRINTF (3, 4);
|
||||||
|
GDK_AVAILABLE_IN_3_90
|
||||||
void gtk_snapshot_push_clip (GtkSnapshot *snapshot,
|
void gtk_snapshot_push_clip (GtkSnapshot *snapshot,
|
||||||
const graphene_rect_t *bounds,
|
const graphene_rect_t *bounds,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
@ -15573,7 +15573,7 @@ gtk_widget_snapshot (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opacity < 1.0)
|
if (opacity < 1.0)
|
||||||
gtk_snapshot_push (snapshot, TRUE, "OpacityGroup<%s>", G_OBJECT_TYPE_NAME (widget));
|
gtk_snapshot_push_opacity (snapshot, opacity, "Opacity<%s,%f>", G_OBJECT_TYPE_NAME (widget), opacity);
|
||||||
|
|
||||||
klass->snapshot (widget, snapshot);
|
klass->snapshot (widget, snapshot);
|
||||||
|
|
||||||
@ -15593,17 +15593,7 @@ gtk_widget_snapshot (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opacity < 1.0)
|
if (opacity < 1.0)
|
||||||
{
|
gtk_snapshot_pop_and_append (snapshot);
|
||||||
GskRenderNode *opacity_node, *node;
|
|
||||||
|
|
||||||
node = gtk_snapshot_pop (snapshot);
|
|
||||||
opacity_node = gsk_opacity_node_new (node, opacity);
|
|
||||||
gsk_render_node_set_name (opacity_node, "Opacity");
|
|
||||||
gsk_render_node_unref (node);
|
|
||||||
|
|
||||||
gtk_snapshot_append_node (snapshot, opacity_node);
|
|
||||||
gsk_render_node_unref (opacity_node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user