diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-11-01 15:07:21 -0400 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-11-01 16:51:42 -0400 |
commit | 7fb047cdc3912abe13098cb2ccb1f3056dc1f61a (patch) | |
tree | 6ddb054cd089f3853adfd5f3bc157a2b5f28cba0 | |
parent | 810f73381f4d01519d599f1a042bb84dbf27a1b7 (diff) | |
download | gtk+-wip/css-is-awesome.tar.gz |
gtkbox: Add support for padding using the new helper APIswip/css-is-awesome
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.
-rw-r--r-- | gtk/gtkbox.c | 11 | ||||
-rw-r--r-- | testsuite/reftests/Makefile.am | 5 | ||||
-rw-r--r-- | testsuite/reftests/box-child-expand.css | 1 | ||||
-rw-r--r-- | testsuite/reftests/box-packing.css | 2 | ||||
-rw-r--r-- | testsuite/reftests/grid-spacing1.css | 1 | ||||
-rw-r--r-- | testsuite/reftests/grid-spacing2.css | 1 | ||||
-rw-r--r-- | testsuite/reftests/grid-spacing3.css | 2 | ||||
-rw-r--r-- | testsuite/reftests/gtk-image-effect-inherit.css | 2 | ||||
-rw-r--r-- | testsuite/reftests/nth-child.css | 2 | ||||
-rw-r--r-- | testsuite/reftests/separator-size.css | 1 | ||||
-rw-r--r-- | testsuite/reftests/sizegroups-evolution-identity-page.css | 1 | ||||
-rw-r--r-- | 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 cb2539954e..eaf323b42b 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 4353fc5935..d8b8637c72 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 0000000000..1160e00d49 --- /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 7d3df2a7b8..7ba0c69f7f 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 0000000000..1160e00d49 --- /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 0000000000..1160e00d49 --- /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 7d3df2a7b8..7ba0c69f7f 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 2a6b04121f..dd5069efe0 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 c704625109..6a39c51a38 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 0000000000..1160e00d49 --- /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 0000000000..1160e00d49 --- /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 0000000000..1160e00d49 --- /dev/null +++ b/testsuite/reftests/window-border-width.css @@ -0,0 +1 @@ +@import "reset-to-defaults.css"; |