[libhandy] css: Split hdy_css_size_allocate() into self() and children()



commit ed2076542d837cd599effc66ce5454d2c162c24e
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Sep 13 02:15:06 2020 +0500

    css: Split hdy_css_size_allocate() into self() and children()

 src/hdy-css-private.h |  6 ++++++
 src/hdy-css.c         | 41 +++++++++++++++++++++++++++++++++++------
 2 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/src/hdy-css-private.h b/src/hdy-css-private.h
index d8190b57..34ed4512 100644
--- a/src/hdy-css-private.h
+++ b/src/hdy-css-private.h
@@ -22,4 +22,10 @@ void hdy_css_measure (GtkWidget      *widget,
 void hdy_css_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation);
 
+void hdy_css_size_allocate_self (GtkWidget     *widget,
+                                 GtkAllocation *allocation);
+
+void hdy_css_size_allocate_children (GtkWidget     *widget,
+                                     GtkAllocation *allocation);
+
 G_END_DECLS
diff --git a/src/hdy-css.c b/src/hdy-css.c
index 7a056e29..054fd125 100644
--- a/src/hdy-css.c
+++ b/src/hdy-css.c
@@ -49,25 +49,54 @@ hdy_css_measure (GtkWidget      *widget,
 void
 hdy_css_size_allocate (GtkWidget     *widget,
                        GtkAllocation *allocation)
+{
+  hdy_css_size_allocate_self (widget, allocation);
+  hdy_css_size_allocate_children (widget, allocation);
+}
+
+void
+hdy_css_size_allocate_self (GtkWidget     *widget,
+                            GtkAllocation *allocation)
 {
   GtkStyleContext *style_context;
   GtkStateFlags state_flags;
-  GtkBorder border, margin, padding;
+  GtkBorder margin;
 
   /* Manually apply the border, the padding and the margin as we can't use the
    * private GtkGagdet.
    */
   style_context = gtk_widget_get_style_context (widget);
   state_flags = gtk_widget_get_state_flags (widget);
-  gtk_style_context_get_border (style_context, state_flags, &border);
+
   gtk_style_context_get_margin (style_context, state_flags, &margin);
+
+  allocation->width -= margin.left + margin.right;
+  allocation->height -= margin.top + margin.bottom;
+  allocation->x += margin.left;
+  allocation->y += margin.top;
+}
+
+void
+hdy_css_size_allocate_children (GtkWidget     *widget,
+                                GtkAllocation *allocation)
+{
+  GtkStyleContext *style_context;
+  GtkStateFlags state_flags;
+  GtkBorder border, padding;
+
+  /* Manually apply the border, the padding and the margin as we can't use the
+   * private GtkGagdet.
+   */
+  style_context = gtk_widget_get_style_context (widget);
+  state_flags = gtk_widget_get_state_flags (widget);
+
+  gtk_style_context_get_border (style_context, state_flags, &border);
   gtk_style_context_get_padding (style_context, state_flags, &padding);
+
   allocation->width -= border.left + border.right +
-                       margin.left + margin.right +
                        padding.left + padding.right;
   allocation->height -= border.top + border.bottom +
-                        margin.top + margin.bottom +
                         padding.top + padding.bottom;
-  allocation->x += border.left + margin.left + padding.left;
-  allocation->y += border.top + margin.top + padding.top;
+  allocation->x += border.left + padding.left;
+  allocation->y += border.top + padding.top;
 }


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