[gtk+/wip/css-is-awesome: 6/6] gtkbox: Add support for padding using the new helper APIs



commit 7fb047cdc3912abe13098cb2ccb1f3056dc1f61a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Nov 1 15:07:21 2013 -0400

    gtkbox: Add support for padding using the new helper APIs
    
    Now, finally, we can have padded boxes! And look at that implementation!
    That's how easy it is to add correct box model behavior to your widgets!
    I'll be fixing a whole slew of these now...
    
    Note that some reftests need fixing, not because this actually breaks
    anything, but because Raleigh has a really silly style: * { padding: 2px; }
    and reftests often use GtkBox to emulate other widgets like grids. We need
    to add some CSS that resets all properties to make sure that this padding
    isn't added to the boxes when trying to e.g. emulate grids.
    
    Obviously, Raleigh is pretty broken here regardless, but layout tests like
    this shouldn't be affected by style.
    
    Adwaita is perfectly fine.

 gtk/gtkbox.c                                       |   11 +++++++++++
 testsuite/reftests/Makefile.am                     |    5 +++++
 testsuite/reftests/box-child-expand.css            |    1 +
 testsuite/reftests/box-packing.css                 |    2 ++
 testsuite/reftests/grid-spacing1.css               |    1 +
 testsuite/reftests/grid-spacing2.css               |    1 +
 testsuite/reftests/grid-spacing3.css               |    2 ++
 testsuite/reftests/gtk-image-effect-inherit.css    |    2 ++
 testsuite/reftests/nth-child.css                   |    2 ++
 testsuite/reftests/separator-size.css              |    1 +
 .../sizegroups-evolution-identity-page.css         |    1 +
 testsuite/reftests/window-border-width.css         |    1 +
 12 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index cb25399..eaf323b 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -1226,6 +1226,7 @@ gtk_box_get_preferred_width (GtkWidget *widget,
                              gint      *natural_size)
 {
   gtk_box_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size, NULL, NULL);
+  _gtk_widget_adjust_preferred_width (widget, minimum_size, natural_size);
 }
 
 static void
@@ -1234,6 +1235,7 @@ gtk_box_get_preferred_height (GtkWidget *widget,
                               gint      *natural_size)
 {
   gtk_box_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size, NULL, NULL);
+  _gtk_widget_adjust_preferred_height (widget, minimum_size, natural_size);
 }
 
 static void
@@ -1528,10 +1530,14 @@ gtk_box_get_preferred_width_for_height (GtkWidget *widget,
   GtkBox        *box     = GTK_BOX (widget);
   GtkBoxPrivate *private = box->priv;
 
+  _gtk_widget_adjust_for_height (widget, &height);
+
   if (private->orientation == GTK_ORIENTATION_VERTICAL)
     gtk_box_compute_size_for_opposing_orientation (box, height, minimum_width, natural_width, NULL, NULL);
   else
     gtk_box_compute_size_for_orientation (box, height, minimum_width, natural_width);
+
+  _gtk_widget_adjust_preferred_width (widget, minimum_width, natural_width);
 }
 
 static void
@@ -1545,6 +1551,8 @@ gtk_box_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
   GtkBox        *box     = GTK_BOX (widget);
   GtkBoxPrivate *private = box->priv;
 
+  _gtk_widget_adjust_for_width (widget, &width);
+
   if (width < 0)
     gtk_box_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_height, natural_height, minimum_baseline, 
natural_baseline);
   else
@@ -1560,6 +1568,9 @@ gtk_box_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
          gtk_box_compute_size_for_orientation (box, width, minimum_height, natural_height);
        }
     }
+
+  _gtk_widget_adjust_preferred_height (widget, minimum_height, natural_height);
+  _gtk_widget_adjust_baseline (widget, minimum_baseline, natural_baseline);
 }
 
 static void
diff --git a/testsuite/reftests/Makefile.am b/testsuite/reftests/Makefile.am
index 4353fc5..d8b8637 100644
--- a/testsuite/reftests/Makefile.am
+++ b/testsuite/reftests/Makefile.am
@@ -115,6 +115,7 @@ testdata = \
        border-style.css \
        border-style.ref.ui \
        border-style.ui \
+       box-child-expand.css \
        box-child-expand.ref.ui \
        box-child-expand.ui \
        box-packing.css \
@@ -197,8 +198,10 @@ testdata = \
        grid-homogeneous.css \
        grid-homogeneous.ref.ui \
        grid-homogeneous.ui \
+       grid-spacing1.css \
        grid-spacing1.ref.ui \
        grid-spacing1.ui \
+       grid-spacing2.css \
        grid-spacing2.ref.ui \
        grid-spacing2.ui \
        grid-spacing3.css \
@@ -273,6 +276,7 @@ testdata = \
        reset-to-defaults.css \
        rotated-layout.ref.ui \
        rotated-layout.ui \
+       separator-size.css \
        separator-size.ref.ui \
        separator-size.ui \
        shorthand-entry-border.css \
@@ -283,6 +287,7 @@ testdata = \
        sizegroups-basics.css \
        sizegroups-basics.ui \
        sizegroups-basics.ref.ui \
+       sizegroups-evolution-identity-page.css \
        sizegroups-evolution-identity-page.ui \
        sizegroups-evolution-identity-page.ref.ui \
        sizegroups-get-preferred-null.ui \
diff --git a/testsuite/reftests/box-child-expand.css b/testsuite/reftests/box-child-expand.css
new file mode 100644
index 0000000..1160e00
--- /dev/null
+++ b/testsuite/reftests/box-child-expand.css
@@ -0,0 +1 @@
+ import "reset-to-defaults.css";
diff --git a/testsuite/reftests/box-packing.css b/testsuite/reftests/box-packing.css
index 7d3df2a..7ba0c69 100644
--- a/testsuite/reftests/box-packing.css
+++ b/testsuite/reftests/box-packing.css
@@ -1,3 +1,5 @@
+ import "reset-to-defaults.css";
+
 #red {
   background-color: red;
 }
diff --git a/testsuite/reftests/grid-spacing1.css b/testsuite/reftests/grid-spacing1.css
new file mode 100644
index 0000000..1160e00
--- /dev/null
+++ b/testsuite/reftests/grid-spacing1.css
@@ -0,0 +1 @@
+ import "reset-to-defaults.css";
diff --git a/testsuite/reftests/grid-spacing2.css b/testsuite/reftests/grid-spacing2.css
new file mode 100644
index 0000000..1160e00
--- /dev/null
+++ b/testsuite/reftests/grid-spacing2.css
@@ -0,0 +1 @@
+ import "reset-to-defaults.css";
diff --git a/testsuite/reftests/grid-spacing3.css b/testsuite/reftests/grid-spacing3.css
index 7d3df2a..7ba0c69 100644
--- a/testsuite/reftests/grid-spacing3.css
+++ b/testsuite/reftests/grid-spacing3.css
@@ -1,3 +1,5 @@
+ import "reset-to-defaults.css";
+
 #red {
   background-color: red;
 }
diff --git a/testsuite/reftests/gtk-image-effect-inherit.css b/testsuite/reftests/gtk-image-effect-inherit.css
index 2a6b041..dd5069e 100644
--- a/testsuite/reftests/gtk-image-effect-inherit.css
+++ b/testsuite/reftests/gtk-image-effect-inherit.css
@@ -1,3 +1,5 @@
+ import "reset-to-defaults.css";
+
 GtkBox > :nth-child(1) {
   -gtk-image-effect: none;
 }
diff --git a/testsuite/reftests/nth-child.css b/testsuite/reftests/nth-child.css
index c704625..6a39c51 100644
--- a/testsuite/reftests/nth-child.css
+++ b/testsuite/reftests/nth-child.css
@@ -1,3 +1,5 @@
+ import "reset-to-defaults.css";
+
 /* For nth-child, we have a custom rule for every multiple of
  * the prime numbers.
  * For nth-last-child, we also color the prime number itself.
diff --git a/testsuite/reftests/separator-size.css b/testsuite/reftests/separator-size.css
new file mode 100644
index 0000000..1160e00
--- /dev/null
+++ b/testsuite/reftests/separator-size.css
@@ -0,0 +1 @@
+ import "reset-to-defaults.css";
diff --git a/testsuite/reftests/sizegroups-evolution-identity-page.css 
b/testsuite/reftests/sizegroups-evolution-identity-page.css
new file mode 100644
index 0000000..1160e00
--- /dev/null
+++ b/testsuite/reftests/sizegroups-evolution-identity-page.css
@@ -0,0 +1 @@
+ import "reset-to-defaults.css";
diff --git a/testsuite/reftests/window-border-width.css b/testsuite/reftests/window-border-width.css
new file mode 100644
index 0000000..1160e00
--- /dev/null
+++ b/testsuite/reftests/window-border-width.css
@@ -0,0 +1 @@
+ import "reset-to-defaults.css";


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