diff options
author | Benjamin Otte <otte@redhat.com> | 2022-06-29 01:22:53 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2022-07-04 08:26:31 +0200 |
commit | 1d5f54ee9668c06f8546380be09f86c9bdb2eb9a (patch) | |
tree | a61153527dc996ba780d440c1ad28cd1377ef793 | |
parent | 35534b7143f5203cec7ee8d9bd22032ea5c0580e (diff) | |
download | gtk+-1d5f54ee9668c06f8546380be09f86c9bdb2eb9a.tar.gz |
canvas: Handle oversized widgets properly
If a widget needs more size than given via its bounds, expand it
according to its origin.
-rw-r--r-- | gtk/gtkcanvas.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gtk/gtkcanvas.c b/gtk/gtkcanvas.c index 26236ec5dd..7238ad69a0 100644 --- a/gtk/gtkcanvas.c +++ b/gtk/gtkcanvas.c @@ -227,13 +227,16 @@ gtk_canvas_allocate (GtkWidget *widget, { GtkCanvasItem *ci = gtk_canvas_items_get (&self->items, i); GtkWidget *child = gtk_canvas_item_get_widget (ci); + const GtkCanvasBox *bounds; + float origin_x, origin_y; graphene_rect_t rect; int x, y, w, h; if (child == NULL) continue; - if (!gtk_canvas_box_eval (gtk_canvas_item_get_bounds (ci), &rect)) + bounds = gtk_canvas_item_get_bounds (ci); + if (!gtk_canvas_box_eval (bounds, &rect)) rect = *graphene_rect_zero (); if (gtk_widget_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH) @@ -251,9 +254,15 @@ gtk_canvas_allocate (GtkWidget *widget, w = MAX (w, ceil (rect.size.width)); } - /* FIXME: Adapt to growing rect */ - x = round (rect.origin.x); - y = round (rect.origin.y); + gtk_canvas_box_get_origin (bounds, &origin_x, &origin_y); + if (w > rect.size.width) + x = round (rect.origin.x + origin_x * (rect.size.width - w)); + else + x = round (rect.origin.x); + if (h > rect.size.height) + y = round (rect.origin.y + origin_y * (rect.size.height - h)); + else + y = round (rect.origin.y); gtk_widget_size_allocate (child, &(GtkAllocation) { x, y, w, h }, -1); } |