[gtk+/wip/baedert/drawing: 268/301] widget: Consider css margins when setting clip



commit 142af955c80f0926092a4cfabacc2ccce27f21f5
Author: Timm Bäder <mail baedert org>
Date:   Mon May 15 15:01:29 2017 +0200

    widget: Consider css margins when setting clip
    
    This is optional for positive margins as they just increase the widget
    allocation. However, with negative css margins, the allocation is
    smaller than the clip.
    
    This fixes scale sliders leaving a small trail behind.

 gtk/gtkwidget.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8ca66d4..045cb3c 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13447,6 +13447,7 @@ gtk_widget_set_clip (GtkWidget           *widget,
   GtkWidgetPrivate *priv;
   GtkBorder shadow;
   GtkAllocation allocation;
+  GtkBorder margin;
   GtkCssStyle *style;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -13480,13 +13481,14 @@ gtk_widget_set_clip (GtkWidget           *widget,
 
   /* Always untion the given clip with the widget allocation */
   /* ... and with the box shadow size */
-  allocation = priv->allocation;
   style = gtk_css_node_get_style (priv->cssnode);
+  allocation = priv->allocation;
+  get_box_margin (style, &margin);
   _gtk_css_shadows_value_get_extents (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BOX_SHADOW), &shadow);
-  allocation.x -= shadow.left;
-  allocation.y -= shadow.top;
-  allocation.width += shadow.left + shadow.right;
-  allocation.height += shadow.top + shadow.bottom;
+  allocation.x += margin.left - shadow.left;
+  allocation.y += margin.top - shadow.top;
+  allocation.width += shadow.left + shadow.right - margin.left - margin.right;
+  allocation.height += shadow.top + shadow.bottom - margin.top - margin.bottom;
   gdk_rectangle_union (&allocation, clip, &priv->clip);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]