[gtk/for-master: 2/2] widget: fix CSS transforms with margins
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/for-master: 2/2] widget: fix CSS transforms with margins
- Date: Fri, 31 May 2019 03:38:51 +0000 (UTC)
commit 6b2518a190314d0aa01f0885f0b77d57a7a7707d
Author: Benjamin Otte <otte redhat com>
Date: Fri May 31 05:35:04 2019 +0200
widget: fix CSS transforms with margins
The CSS transform should operate on the border-box, not the margin box.
So we need to shrink the bounds by the margin before we apply the CSS
transform.
gtk/gtkwidget.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 67456abcd5..427edfaf7a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4382,8 +4382,15 @@ gtk_widget_allocate (GtkWidget *widget,
}
style = gtk_css_node_get_style (priv->cssnode);
+ get_box_margin (style, &margin);
+ get_box_border (style, &border);
+ get_box_padding (style, &padding);
/* Apply CSS transformation */
+ adjusted.x += margin.left;
+ adjusted.y += margin.top;
+ adjusted.width -= margin.left + margin.right;
+ adjusted.height -= margin.top + margin.bottom;
css_transform = gtk_css_transform_value_get_transform (gtk_css_style_get_value (style,
GTK_CSS_PROPERTY_TRANSFORM));
if (css_transform)
@@ -4396,18 +4403,15 @@ gtk_widget_allocate (GtkWidget *widget,
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- adjusted.width / 2, -
adjusted.height / 2));
}
- get_box_margin (style, &margin);
- get_box_border (style, &border);
- get_box_padding (style, &padding);
- adjusted.x += margin.left + border.left + padding.left;
- adjusted.y += margin.top + border.top + padding.top;
+ adjusted.x += border.left + padding.left;
+ adjusted.y += border.top + padding.top;
/* Since gtk_widget_measure does it for us, we can be sure here that
* the given alloaction is large enough for the css margin/bordder/padding */
- adjusted.width -= margin.left + border.left + padding.left +
- margin.right + border.right + padding.right;
- adjusted.height -= margin.top + border.top + padding.top +
- margin.bottom + border.bottom + padding.bottom;
+ adjusted.width -= border.left + padding.left +
+ border.right + padding.right;
+ adjusted.height -= border.top + padding.top +
+ border.bottom + padding.bottom;
if (baseline >= 0)
baseline -= margin.top + border.top + padding.top;
if (adjusted.x || adjusted.y)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]