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.
This commit is contained in:
@ -69,6 +69,13 @@ static void gtk_viewport_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous_style);
|
||||
|
||||
static void gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkViewport, gtk_viewport, GTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
@ -829,44 +836,67 @@ gtk_viewport_style_set (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size)
|
||||
{
|
||||
GtkWidget *child;
|
||||
GtkRequisition child_min, child_nat;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (layout));
|
||||
|
||||
minimum_size->width = GTK_CONTAINER (layout)->border_width;
|
||||
minimum_size->height = GTK_CONTAINER (layout)->border_width;
|
||||
natural_size->width = GTK_CONTAINER (layout)->border_width;
|
||||
natural_size->height = GTK_CONTAINER (layout)->border_width;
|
||||
|
||||
if (GTK_VIEWPORT (layout)->shadow_type != GTK_SHADOW_NONE)
|
||||
{
|
||||
minimum_size->width += 2 * GTK_WIDGET (layout)->style->xthickness;
|
||||
minimum_size->height += 2 * GTK_WIDGET (layout)->style->ythickness;
|
||||
natural_size->width += 2 * GTK_WIDGET (layout)->style->xthickness;
|
||||
natural_size->height += 2 * GTK_WIDGET (layout)->style->ythickness;
|
||||
}
|
||||
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
|
||||
|
||||
minimum_size->width += child_min.width;
|
||||
minimum_size->height += child_min.height;
|
||||
natural_size->width += child_nat.width;
|
||||
natural_size->height += child_nat.height;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
{
|
||||
iface->get_desired_size = gtk_viewport_get_desired_size;
|
||||
iface->get_desired_width = gtk_viewport_get_desired_width;
|
||||
iface->get_desired_height = gtk_viewport_get_desired_height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkWidget *child;
|
||||
gint child_min, child_nat;
|
||||
gint minimum, natural;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (layout));
|
||||
|
||||
/* XXX This should probably be (border_width * 2); but GTK+ has
|
||||
* been doing this with a single border for a while now...
|
||||
*/
|
||||
minimum = GTK_CONTAINER (layout)->border_width;
|
||||
|
||||
if (GTK_VIEWPORT (layout)->shadow_type != GTK_SHADOW_NONE)
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
minimum += 2 * GTK_WIDGET (layout)->style->xthickness;
|
||||
else
|
||||
minimum += 2 * GTK_WIDGET (layout)->style->ythickness;
|
||||
}
|
||||
|
||||
natural = minimum;
|
||||
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
|
||||
else
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
|
||||
|
||||
minimum += child_min;
|
||||
natural += child_nat;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
#define __GTK_VIEWPORT_C__
|
||||
|
||||
Reference in New Issue
Block a user