diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-04-12 22:21:46 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-04-12 22:21:46 -0400 |
commit | d2c35ec62a595dc02542edae920b6a63dbb57446 (patch) | |
tree | 6eaa336a1b72f6bac9c0dcda1a0f27ed17e96bc4 /gtk/gtkalignment.c | |
parent | 1b2be80f10964e1ded1591294acc603f78980c93 (diff) | |
download | gtk+-d2c35ec62a595dc02542edae920b6a63dbb57446.tar.gz |
Mega commit to change ->get_desired_size() for ->get_desired_width/height().
This commit changes gtk_extended_layout_get_desired_size() for
per dimension variants. Furthermore this commit reverts the actions
done in size-groups for now as it needs a different approach.
The natural width/height parameters added to aux_info have been changed
for a per width cache for heights and a per height cache for widths.
gtk-demo is still working, currently sizegroups are not taken
into account as mentioned above - size groups need to be alerted both
when the widths and heights are updated independantly and then that
information needs to repropagate also to other extended layout implementors.
Diffstat (limited to 'gtk/gtkalignment.c')
-rw-r--r-- | gtk/gtkalignment.c | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c index 55a210d705..7e879ca056 100644 --- a/gtk/gtkalignment.c +++ b/gtk/gtkalignment.c @@ -66,10 +66,13 @@ static void gtk_alignment_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static void gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface); -static void gtk_alignment_get_desired_size (GtkExtendedLayout *layout, - GtkRequisition *minimum_size, - GtkRequisition *natural_size); +static void gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface); +static void gtk_alignment_get_desired_width (GtkExtendedLayout *layout, + gint *minimum_size, + gint *natural_size); +static void gtk_alignment_get_desired_height (GtkExtendedLayout *layout, + gint *minimum_size, + gint *natural_size); G_DEFINE_TYPE_WITH_CODE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN, G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT, @@ -484,42 +487,69 @@ gtk_alignment_size_allocate (GtkWidget *widget, static void gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface) { - iface->get_desired_size = gtk_alignment_get_desired_size; + iface->get_desired_width = gtk_alignment_get_desired_width; + iface->get_desired_height = gtk_alignment_get_desired_height; } static void gtk_alignment_get_desired_size (GtkExtendedLayout *layout, - GtkRequisition *minimum_size, - GtkRequisition *natural_size) + GtkOrientation orientation, + gint *minimum_size, + gint *natural_size) { GtkWidget *child; GtkAlignmentPrivate *priv; + gint minimum, natural; priv = GTK_ALIGNMENT_GET_PRIVATE (layout); - minimum_size->width = GTK_CONTAINER (layout)->border_width * 2; - minimum_size->height = GTK_CONTAINER (layout)->border_width * 2; - - *natural_size = *minimum_size; + natural = minimum = GTK_CONTAINER (layout)->border_width * 2; if ((child = gtk_bin_get_child (GTK_BIN (layout))) && gtk_widget_get_visible (child)) { - GtkRequisition child_min, child_nat; + gint child_min, child_nat; /* Request extra space for the padding: */ - minimum_size->width += (priv->padding_left + priv->padding_right); - minimum_size->height += (priv->padding_top + priv->padding_bottom); - - *natural_size = *minimum_size; + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + minimum += (priv->padding_left + priv->padding_right); + gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), + &child_min, &child_nat); + } + else + { + minimum += (priv->padding_top + priv->padding_bottom); + gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), + &child_min, &child_nat); + } - gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (child), - &child_min, &child_nat); + natural = minimum; - minimum_size->width += child_min.width; - minimum_size->height += child_min.height; - natural_size->width += child_nat.width; - natural_size->height += child_nat.height; + minimum += child_min; + natural += child_nat; } + + if (minimum_size) + *minimum_size = minimum; + + if (natural_size) + *natural_size = natural; +} + +static void +gtk_alignment_get_desired_width (GtkExtendedLayout *layout, + gint *minimum_size, + gint *natural_size) +{ + gtk_alignment_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size); +} + +static void +gtk_alignment_get_desired_height (GtkExtendedLayout *layout, + gint *minimum_size, + gint *natural_size) +{ + gtk_alignment_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size); } /** |