[libhandy/wip/exalm/css: 10/13] avatar: Account for box-shadow when clipping



commit 18b015eaf8cb69fc7b33aaf99491948a7f218868
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu May 21 00:45:42 2020 +0500

    avatar: Account for box-shadow when clipping

 src/hdy-avatar.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/src/hdy-avatar.c b/src/hdy-avatar.c
index 588ab7a3..324292e7 100644
--- a/src/hdy-avatar.c
+++ b/src/hdy-avatar.c
@@ -461,6 +461,23 @@ hdy_avatar_get_request_mode (GtkWidget *widget)
   return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
 }
 
+static void
+hdy_avatar_size_allocate (GtkWidget     *widget,
+                          GtkAllocation *allocation)
+{
+  GtkAllocation clip;
+
+  gtk_render_background_get_clip (gtk_widget_get_style_context (widget),
+                                  allocation->x,
+                                  allocation->y,
+                                  allocation->width,
+                                  allocation->height,
+                                  &clip);
+
+  GTK_WIDGET_CLASS (hdy_avatar_parent_class)->size_allocate (widget, allocation);
+  gtk_widget_set_clip (widget, &clip);
+}
+
 static void
 hdy_avatar_class_init (HdyAvatarClass *klass)
 {
@@ -478,6 +495,7 @@ hdy_avatar_class_init (HdyAvatarClass *klass)
   widget_class->get_preferred_height = hdy_avatar_get_preferred_height;
   widget_class->get_preferred_width_for_height = hdy_avatar_get_preferred_width_for_height;
   widget_class->get_preferred_height_for_width = hdy_avatar_get_preferred_height_for_width;
+  widget_class->size_allocate = hdy_avatar_size_allocate;
 
   /**
    * HdyAvatar:size:


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