forked from AuroraMiddleware/gtk
widget: Store the render node in the widget's coordinate system
Also require gtk_widget_snapshot() to be in the widget's coordinate system.
This commit is contained in:
parent
694d7c378b
commit
86978d2654
@ -13121,7 +13121,7 @@ gtk_widget_create_render_node (GtkWidget *widget,
|
||||
|
||||
if (!GTK_IS_WINDOW (widget))
|
||||
{
|
||||
gtk_snapshot_offset (snapshot, margin.left, margin.top);
|
||||
gtk_snapshot_offset (snapshot, - padding.left - border.left, - border.top - padding.top);
|
||||
gtk_css_style_snapshot_background (style,
|
||||
snapshot,
|
||||
allocation.width - margin.left - margin.right,
|
||||
@ -13130,12 +13130,9 @@ gtk_widget_create_render_node (GtkWidget *widget,
|
||||
snapshot,
|
||||
allocation.width - margin.left - margin.right,
|
||||
allocation.height - margin.top - margin.bottom);
|
||||
gtk_snapshot_offset (snapshot, - margin.left, - margin.top);
|
||||
gtk_snapshot_offset (snapshot, padding.left + border.left, border.top + padding.top);
|
||||
}
|
||||
|
||||
/* Offset to content allocation */
|
||||
gtk_snapshot_offset (snapshot, margin.left + padding.left + border.left, margin.top + border.top + padding.top);
|
||||
|
||||
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
||||
{
|
||||
gtk_snapshot_push_clip (snapshot,
|
||||
@ -13156,7 +13153,8 @@ gtk_widget_create_render_node (GtkWidget *widget,
|
||||
snapshot,
|
||||
allocation.width - margin.left - margin.right,
|
||||
allocation.height - margin.top - margin.bottom);
|
||||
gtk_snapshot_offset (snapshot, - margin.left, - margin.top);
|
||||
|
||||
gtk_snapshot_offset (snapshot, padding.left + border.left, border.top + padding.top);
|
||||
|
||||
if (opacity < 1.0)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
@ -13217,6 +13215,7 @@ gtk_widget_render (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot;
|
||||
GskRenderer *renderer;
|
||||
GskRenderNode *root;
|
||||
int x, y;
|
||||
|
||||
if (!GTK_IS_ROOT (widget))
|
||||
return;
|
||||
@ -13230,7 +13229,10 @@ gtk_widget_render (GtkWidget *widget,
|
||||
return;
|
||||
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gtk_root_get_surface_transform (GTK_ROOT (widget), &x, &y);
|
||||
gtk_snapshot_offset (snapshot, x, y);
|
||||
gtk_widget_snapshot (widget, snapshot);
|
||||
gtk_snapshot_offset (snapshot, -x, -y);
|
||||
root = gtk_snapshot_free_to_node (snapshot);
|
||||
|
||||
if (root != NULL)
|
||||
@ -13542,14 +13544,12 @@ gtk_widget_snapshot_child (GtkWidget *widget,
|
||||
GtkWidget *child,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (child);
|
||||
int x, y;
|
||||
|
||||
g_return_if_fail (_gtk_widget_get_parent (child) == widget);
|
||||
g_return_if_fail (snapshot != NULL);
|
||||
|
||||
x = priv->transform.x;
|
||||
y = priv->transform.y;
|
||||
gtk_widget_get_origin_relative_to_parent (child, &x, &y);
|
||||
|
||||
gtk_snapshot_offset (snapshot, x, y);
|
||||
gtk_widget_snapshot (child, snapshot);
|
||||
|
@ -92,13 +92,15 @@ gtk_widget_paintable_paintable_snapshot (GdkPaintable *paintable,
|
||||
else if (self->snapshot_count > 0)
|
||||
{
|
||||
graphene_matrix_t transform;
|
||||
graphene_rect_t bounds;
|
||||
|
||||
gtk_snapshot_push_clip (snapshot,
|
||||
&GRAPHENE_RECT_INIT(0, 0, width, height));
|
||||
graphene_matrix_init_scale (&transform,
|
||||
width / gtk_widget_get_allocated_width (self->widget),
|
||||
height / gtk_widget_get_allocated_height (self->widget),
|
||||
1.0);
|
||||
gtk_widget_compute_bounds (self->widget, self->widget, &bounds);
|
||||
graphene_matrix_init_from_2d (&transform,
|
||||
width / bounds.size.width, 0.0,
|
||||
0.0, height / bounds.size.height,
|
||||
bounds.origin.x, bounds.origin.y);
|
||||
gtk_snapshot_push_transform (snapshot, &transform);
|
||||
|
||||
gtk_widget_snapshot (self->widget, snapshot);
|
||||
|
@ -2521,8 +2521,17 @@ gtk_window_root_get_surface_transform (GtkRoot *root,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
GtkWindow *self = GTK_WINDOW (root);
|
||||
GtkStyleContext *context;
|
||||
GtkBorder margin, border, padding;
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (self));
|
||||
gtk_style_context_get_margin (context, &margin);
|
||||
gtk_style_context_get_border (context, &border);
|
||||
gtk_style_context_get_padding (context, &padding);
|
||||
|
||||
*x = margin.left + border.left + padding.left;
|
||||
*y = margin.top + border.top + padding.top;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user