[gtk/wip/otte/canvas: 8/8] canvas: Handle oversized widgets properly
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/canvas: 8/8] canvas: Handle oversized widgets properly
- Date: Tue, 28 Jun 2022 23:26:44 +0000 (UTC)
commit d16b4ec1a041b092f9e9a99dfaa10ee1314f0dc4
Author: Benjamin Otte <otte redhat com>
Date: Wed Jun 29 01:22:53 2022 +0200
canvas: Handle oversized widgets properly
If a widget needs more size than given via its bounds, expand it
according to its origin.
gtk/gtkcanvas.c | 17 +++++++++++++----
1 file 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]