mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-30 15:31:34 +00:00
box: Use measure() to measure child sizes
This commit is contained in:
parent
76ff53193a
commit
6488dde4fd
100
gtk/gtkbox.c
100
gtk/gtkbox.c
@ -492,17 +492,12 @@ gtk_box_size_allocate_no_center (GtkWidget *widget,
|
|||||||
if (!_gtk_widget_get_visible (child->widget))
|
if (!_gtk_widget_get_visible (child->widget))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
gtk_widget_measure (child->widget,
|
||||||
gtk_widget_get_preferred_width_for_height (child->widget,
|
private->orientation,
|
||||||
allocation->height,
|
private->orientation == GTK_ORIENTATION_HORIZONTAL ?
|
||||||
&sizes[i].minimum_size,
|
allocation->height : allocation->width,
|
||||||
&sizes[i].natural_size);
|
&sizes[i].minimum_size, &sizes[i].natural_size,
|
||||||
else
|
NULL, NULL);
|
||||||
gtk_widget_get_preferred_height_and_baseline_for_width (child->widget,
|
|
||||||
allocation->width,
|
|
||||||
&sizes[i].minimum_size,
|
|
||||||
&sizes[i].natural_size,
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
/* Assert the api is working properly */
|
/* Assert the api is working properly */
|
||||||
if (sizes[i].minimum_size < 0)
|
if (sizes[i].minimum_size < 0)
|
||||||
@ -623,10 +618,10 @@ gtk_box_size_allocate_no_center (GtkWidget *widget,
|
|||||||
|
|
||||||
child_minimum_baseline = -1;
|
child_minimum_baseline = -1;
|
||||||
child_natural_baseline = -1;
|
child_natural_baseline = -1;
|
||||||
gtk_widget_get_preferred_height_and_baseline_for_width (child->widget,
|
gtk_widget_measure (child->widget, GTK_ORIENTATION_VERTICAL,
|
||||||
child_allocation_width,
|
child_allocation_width,
|
||||||
&child_minimum_height, &child_natural_height,
|
&child_minimum_height, &child_natural_height,
|
||||||
&child_minimum_baseline, &child_natural_baseline);
|
&child_minimum_baseline, &child_natural_baseline);
|
||||||
|
|
||||||
if (child_minimum_baseline >= 0)
|
if (child_minimum_baseline >= 0)
|
||||||
{
|
{
|
||||||
@ -848,17 +843,12 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
req = &(sizes[child->pack][idx[child->pack]]);
|
req = &(sizes[child->pack][idx[child->pack]]);
|
||||||
|
|
||||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
gtk_widget_measure (child->widget,
|
||||||
gtk_widget_get_preferred_width_for_height (child->widget,
|
priv->orientation,
|
||||||
allocation->height,
|
priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
|
||||||
&req->minimum_size,
|
allocation->height : allocation->width,
|
||||||
&req->natural_size);
|
&req->minimum_size, &req->natural_size,
|
||||||
else
|
NULL, NULL);
|
||||||
gtk_widget_get_preferred_height_and_baseline_for_width (child->widget,
|
|
||||||
allocation->width,
|
|
||||||
&req->minimum_size,
|
|
||||||
&req->natural_size,
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
if (child != priv->center)
|
if (child != priv->center)
|
||||||
{
|
{
|
||||||
@ -967,10 +957,11 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
|
|||||||
|
|
||||||
child_minimum_baseline = -1;
|
child_minimum_baseline = -1;
|
||||||
child_natural_baseline = -1;
|
child_natural_baseline = -1;
|
||||||
gtk_widget_get_preferred_height_and_baseline_for_width (child->widget,
|
gtk_widget_measure (child->widget,
|
||||||
child_allocation_width,
|
GTK_ORIENTATION_VERTICAL,
|
||||||
&child_minimum_height, &child_natural_height,
|
child_allocation_width,
|
||||||
&child_minimum_baseline, &child_natural_baseline);
|
&child_minimum_height, &child_natural_height,
|
||||||
|
&child_minimum_baseline, &child_natural_baseline);
|
||||||
|
|
||||||
if (child_minimum_baseline >= 0)
|
if (child_minimum_baseline >= 0)
|
||||||
{
|
{
|
||||||
@ -1528,13 +1519,11 @@ gtk_box_get_size (GtkWidget *widget,
|
|||||||
gint child_minimum, child_natural;
|
gint child_minimum, child_natural;
|
||||||
gint child_minimum_baseline = -1, child_natural_baseline = -1;
|
gint child_minimum_baseline = -1, child_natural_baseline = -1;
|
||||||
|
|
||||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
gtk_widget_measure (child->widget,
|
||||||
gtk_widget_get_preferred_width (child->widget,
|
orientation,
|
||||||
&child_minimum, &child_natural);
|
-1,
|
||||||
else
|
&child_minimum, &child_natural,
|
||||||
gtk_widget_get_preferred_height_and_baseline_for_width (child->widget, -1,
|
&child_minimum_baseline, &child_natural_baseline);
|
||||||
&child_minimum, &child_natural,
|
|
||||||
&child_minimum_baseline, &child_natural_baseline);
|
|
||||||
|
|
||||||
if (private->orientation == orientation)
|
if (private->orientation == orientation)
|
||||||
{
|
{
|
||||||
@ -1694,14 +1683,11 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
|
|||||||
|
|
||||||
if (_gtk_widget_get_visible (child->widget))
|
if (_gtk_widget_get_visible (child->widget))
|
||||||
{
|
{
|
||||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
gtk_widget_measure (child->widget,
|
||||||
gtk_widget_get_preferred_width (child->widget,
|
private->orientation,
|
||||||
&sizes[i].minimum_size,
|
-1,
|
||||||
&sizes[i].natural_size);
|
&sizes[i].minimum_size, &sizes[i].natural_size,
|
||||||
else
|
NULL, NULL);
|
||||||
gtk_widget_get_preferred_height (child->widget,
|
|
||||||
&sizes[i].minimum_size,
|
|
||||||
&sizes[i].natural_size);
|
|
||||||
|
|
||||||
/* Assert the api is working properly */
|
/* Assert the api is working properly */
|
||||||
if (sizes[i].minimum_size < 0)
|
if (sizes[i].minimum_size < 0)
|
||||||
@ -1815,13 +1801,11 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
|
|||||||
|
|
||||||
child_minimum_baseline = child_natural_baseline = -1;
|
child_minimum_baseline = child_natural_baseline = -1;
|
||||||
/* Assign the child's position. */
|
/* Assign the child's position. */
|
||||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
gtk_widget_measure (child->widget,
|
||||||
gtk_widget_get_preferred_height_and_baseline_for_width (child->widget, child_size,
|
OPPOSITE_ORIENTATION (private->orientation),
|
||||||
&child_minimum, &child_natural,
|
child_size,
|
||||||
&child_minimum_baseline, &child_natural_baseline);
|
&child_minimum, &child_natural,
|
||||||
else /* (private->orientation == GTK_ORIENTATION_VERTICAL) */
|
&child_minimum_baseline, &child_natural_baseline);
|
||||||
gtk_widget_get_preferred_width_for_height (child->widget,
|
|
||||||
child_size, &child_minimum, &child_natural);
|
|
||||||
|
|
||||||
if (child_minimum_baseline >= 0)
|
if (child_minimum_baseline >= 0)
|
||||||
{
|
{
|
||||||
@ -1893,13 +1877,11 @@ gtk_box_compute_size_for_orientation (GtkBox *box,
|
|||||||
if (_gtk_widget_get_visible (child->widget))
|
if (_gtk_widget_get_visible (child->widget))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
gtk_widget_measure (child->widget,
|
||||||
gtk_widget_get_preferred_width_for_height (child->widget,
|
private->orientation,
|
||||||
avail_size, &child_size, &child_natural);
|
avail_size,
|
||||||
else
|
&child_size, &child_natural,
|
||||||
gtk_widget_get_preferred_height_for_width (child->widget,
|
NULL, NULL);
|
||||||
avail_size, &child_size, &child_natural);
|
|
||||||
|
|
||||||
|
|
||||||
if (child_size > largest_child)
|
if (child_size > largest_child)
|
||||||
largest_child = child_size;
|
largest_child = child_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user