[gtk/wip/otte/canvas: 2/2] canvas: scale(-1) the widgets when allocation size is negative
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/canvas: 2/2] canvas: scale(-1) the widgets when allocation size is negative
- Date: Fri, 8 Jul 2022 05:37:32 +0000 (UTC)
commit 9ae808c14785be4ae09fb305966f77bfcdede0de
Author: Benjamin Otte <otte redhat com>
Date: Tue Jul 5 07:30:51 2022 +0200
canvas: scale(-1) the widgets when allocation size is negative
Just flip the widgets, because hey, that makes planarity work!
gtk/gtkcanvasitem.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcanvasitem.c b/gtk/gtkcanvasitem.c
index e19c9017e1..c396bc5f0d 100644
--- a/gtk/gtkcanvasitem.c
+++ b/gtk/gtkcanvasitem.c
@@ -271,20 +271,28 @@ gtk_canvas_item_allocate_widget (GtkCanvasItem *self,
float dy)
{
graphene_rect_t allocation;
+ GskTransform *transform;
if (self->widget == NULL)
return;
gtk_canvas_box_to_rect (&self->allocation, &allocation);
- graphene_rect_normalize (&allocation);
-
- gtk_widget_size_allocate (self->widget,
- &(GtkAllocation) {
- allocation.origin.x - dx,
- allocation.origin.y - dy,
- allocation.size.width,
- allocation.size.height
- }, -1);
+
+ transform = gsk_transform_translate (NULL,
+ &GRAPHENE_POINT_INIT (
+ allocation.origin.x - dx
+ + (signbit (self->allocation.size.width) ? allocation.size.width :
0),
+ allocation.origin.y - dy
+ + (signbit (self->allocation.size.height) ? allocation.size.height
: 0)));
+ transform = gsk_transform_scale (transform,
+ signbit (self->allocation.size.width) ? -1 : 1,
+ signbit (self->allocation.size.height) ? -1 : 1);
+
+ gtk_widget_allocate (self->widget,
+ allocation.size.width,
+ allocation.size.height,
+ -1,
+ transform);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]