mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-02 17:00:19 +00:00
headerbar: measure children using gtk_widget_measure
This commit is contained in:
parent
d45e5ef3dc
commit
7f8d0acfd3
@ -598,10 +598,8 @@ add_child_size (GtkWidget *child,
|
|||||||
if (!gtk_widget_get_visible (child))
|
if (!gtk_widget_get_visible (child))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
gtk_widget_measure (child, orientation, -1, &child_minimum, &child_natural,
|
||||||
gtk_widget_get_preferred_width (child, &child_minimum, &child_natural);
|
NULL, NULL);
|
||||||
else
|
|
||||||
gtk_widget_get_preferred_height (child, &child_minimum, &child_natural);
|
|
||||||
|
|
||||||
if (GTK_ORIENTATION_HORIZONTAL == orientation)
|
if (GTK_ORIENTATION_HORIZONTAL == orientation)
|
||||||
{
|
{
|
||||||
@ -715,8 +713,8 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget,
|
|||||||
|
|
||||||
if (gtk_widget_get_visible (child->widget))
|
if (gtk_widget_get_visible (child->widget))
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_width_for_height (child->widget,
|
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, avail_size,
|
||||||
avail_size, &child_size, &child_natural);
|
&child_size, &child_natural, NULL, NULL);
|
||||||
|
|
||||||
required_size += child_size;
|
required_size += child_size;
|
||||||
required_natural += child_natural;
|
required_natural += child_natural;
|
||||||
@ -727,8 +725,8 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget,
|
|||||||
|
|
||||||
if (priv->label_box != NULL)
|
if (priv->label_box != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_width (priv->label_sizing_box,
|
gtk_widget_measure (priv->label_sizing_box, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||||
&child_size, &child_natural);
|
&child_size, &child_natural, NULL, NULL);
|
||||||
required_size += child_size;
|
required_size += child_size;
|
||||||
required_natural += child_natural;
|
required_natural += child_natural;
|
||||||
}
|
}
|
||||||
@ -736,16 +734,17 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget,
|
|||||||
if (priv->custom_title != NULL &&
|
if (priv->custom_title != NULL &&
|
||||||
gtk_widget_get_visible (priv->custom_title))
|
gtk_widget_get_visible (priv->custom_title))
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_width (priv->custom_title,
|
gtk_widget_measure (priv->custom_title, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||||
&child_size, &child_natural);
|
&child_size, &child_natural, NULL, NULL);
|
||||||
|
|
||||||
required_size += child_size;
|
required_size += child_size;
|
||||||
required_natural += child_natural;
|
required_natural += child_natural;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->titlebar_start_box != NULL)
|
if (priv->titlebar_start_box != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_width (priv->titlebar_start_box,
|
gtk_widget_measure (priv->titlebar_start_box, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||||
&child_size, &child_natural);
|
&child_size, &child_natural, NULL, NULL);
|
||||||
required_size += child_size;
|
required_size += child_size;
|
||||||
required_natural += child_natural;
|
required_natural += child_natural;
|
||||||
nvis_children += 1;
|
nvis_children += 1;
|
||||||
@ -753,8 +752,9 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget,
|
|||||||
|
|
||||||
if (priv->titlebar_end_box != NULL)
|
if (priv->titlebar_end_box != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_width (priv->titlebar_end_box,
|
gtk_widget_measure (priv->titlebar_end_box, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||||
&child_size, &child_natural);
|
&child_size, &child_natural, NULL, NULL);
|
||||||
|
|
||||||
required_size += child_size;
|
required_size += child_size;
|
||||||
required_natural += child_natural;
|
required_natural += child_natural;
|
||||||
nvis_children += 1;
|
nvis_children += 1;
|
||||||
@ -806,9 +806,9 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
|
|||||||
|
|
||||||
if (gtk_widget_get_visible (child->widget))
|
if (gtk_widget_get_visible (child->widget))
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_width (child->widget,
|
gtk_widget_measure (child->widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||||
&sizes[i].minimum_size,
|
&sizes[i].minimum_size, &sizes[i].natural_size,
|
||||||
&sizes[i].natural_size);
|
NULL, NULL);
|
||||||
|
|
||||||
size -= sizes[i].minimum_size;
|
size -= sizes[i].minimum_size;
|
||||||
sizes[i].data = child;
|
sizes[i].data = child;
|
||||||
@ -842,8 +842,8 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
|
|||||||
|
|
||||||
child_size = sizes[i].minimum_size;
|
child_size = sizes[i].minimum_size;
|
||||||
|
|
||||||
gtk_widget_get_preferred_height_for_width (child->widget,
|
gtk_widget_measure (child->widget, GTK_ORIENTATION_VERTICAL, child_size,
|
||||||
child_size, &child_minimum, &child_natural);
|
&child_minimum, &child_natural, NULL, NULL);
|
||||||
|
|
||||||
computed_minimum = MAX (computed_minimum, child_minimum);
|
computed_minimum = MAX (computed_minimum, child_minimum);
|
||||||
computed_natural = MAX (computed_natural, child_natural);
|
computed_natural = MAX (computed_natural, child_natural);
|
||||||
@ -854,29 +854,31 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
|
|||||||
center_min = center_nat = 0;
|
center_min = center_nat = 0;
|
||||||
if (priv->label_box != NULL)
|
if (priv->label_box != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_height (priv->label_sizing_box,
|
gtk_widget_measure (priv->label_sizing_box, GTK_ORIENTATION_VERTICAL, -1,
|
||||||
¢er_min, ¢er_nat);
|
¢er_min, ¢er_nat, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->custom_title != NULL &&
|
if (priv->custom_title != NULL &&
|
||||||
gtk_widget_get_visible (priv->custom_title))
|
gtk_widget_get_visible (priv->custom_title))
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_height (priv->custom_title,
|
gtk_widget_measure (priv->custom_title, GTK_ORIENTATION_VERTICAL, -1,
|
||||||
¢er_min, ¢er_nat);
|
¢er_min, ¢er_nat, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->titlebar_start_box != NULL)
|
if (priv->titlebar_start_box != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_height (priv->titlebar_start_box,
|
gtk_widget_measure (priv->titlebar_start_box, GTK_ORIENTATION_VERTICAL, -1,
|
||||||
&child_minimum, &child_natural);
|
¢er_min, ¢er_nat, NULL, NULL);
|
||||||
|
|
||||||
computed_minimum = MAX (computed_minimum, child_minimum);
|
computed_minimum = MAX (computed_minimum, child_minimum);
|
||||||
computed_natural = MAX (computed_natural, child_natural);
|
computed_natural = MAX (computed_natural, child_natural);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->titlebar_end_box != NULL)
|
if (priv->titlebar_end_box != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_height (priv->titlebar_end_box,
|
gtk_widget_measure (priv->titlebar_end_box, GTK_ORIENTATION_VERTICAL, -1,
|
||||||
&child_minimum, &child_natural);
|
¢er_min, ¢er_nat, NULL, NULL);
|
||||||
|
|
||||||
computed_minimum = MAX (computed_minimum, child_minimum);
|
computed_minimum = MAX (computed_minimum, child_minimum);
|
||||||
computed_natural = MAX (computed_natural, child_natural);
|
computed_natural = MAX (computed_natural, child_natural);
|
||||||
}
|
}
|
||||||
@ -985,10 +987,10 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget,
|
|||||||
if (gtk_widget_compute_expand (child->widget, GTK_ORIENTATION_HORIZONTAL))
|
if (gtk_widget_compute_expand (child->widget, GTK_ORIENTATION_HORIZONTAL))
|
||||||
nexpand_children[child->pack_type]++;
|
nexpand_children[child->pack_type]++;
|
||||||
|
|
||||||
gtk_widget_get_preferred_width_for_height (child->widget,
|
gtk_widget_measure (child->widget, GTK_ORIENTATION_HORIZONTAL, height,
|
||||||
height,
|
&sizes[i].minimum_size, &sizes[i].natural_size,
|
||||||
&sizes[i].minimum_size,
|
NULL, NULL);
|
||||||
&sizes[i].natural_size);
|
|
||||||
width -= sizes[i].minimum_size;
|
width -= sizes[i].minimum_size;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -1006,10 +1008,10 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget,
|
|||||||
|
|
||||||
if (title_widget)
|
if (title_widget)
|
||||||
{
|
{
|
||||||
gtk_widget_get_preferred_width_for_height (title_widget,
|
gtk_widget_measure (title_widget, GTK_ORIENTATION_HORIZONTAL, height,
|
||||||
height,
|
&title_minimum_size, &title_natural_size,
|
||||||
&title_minimum_size,
|
NULL, NULL);
|
||||||
&title_natural_size);
|
|
||||||
width -= title_natural_size;
|
width -= title_natural_size;
|
||||||
|
|
||||||
title_expands = gtk_widget_compute_expand (title_widget, GTK_ORIENTATION_HORIZONTAL);
|
title_expands = gtk_widget_compute_expand (title_widget, GTK_ORIENTATION_HORIZONTAL);
|
||||||
@ -1019,9 +1021,10 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget,
|
|||||||
if (priv->titlebar_start_box != NULL)
|
if (priv->titlebar_start_box != NULL)
|
||||||
{
|
{
|
||||||
gint min, nat;
|
gint min, nat;
|
||||||
gtk_widget_get_preferred_width_for_height (priv->titlebar_start_box,
|
gtk_widget_measure (priv->titlebar_start_box, GTK_ORIENTATION_HORIZONTAL, height,
|
||||||
height,
|
&min, &nat,
|
||||||
&min, &nat);
|
NULL, NULL);
|
||||||
|
|
||||||
start_width = nat + priv->spacing;
|
start_width = nat + priv->spacing;
|
||||||
}
|
}
|
||||||
width -= start_width;
|
width -= start_width;
|
||||||
@ -1030,9 +1033,10 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget,
|
|||||||
if (priv->titlebar_end_box != NULL)
|
if (priv->titlebar_end_box != NULL)
|
||||||
{
|
{
|
||||||
gint min, nat;
|
gint min, nat;
|
||||||
gtk_widget_get_preferred_width_for_height (priv->titlebar_end_box,
|
gtk_widget_measure (priv->titlebar_end_box, GTK_ORIENTATION_HORIZONTAL, height,
|
||||||
height,
|
&min, &nat,
|
||||||
&min, &nat);
|
NULL, NULL);
|
||||||
|
|
||||||
end_width = nat + priv->spacing;
|
end_width = nat + priv->spacing;
|
||||||
}
|
}
|
||||||
width -= end_width;
|
width -= end_width;
|
||||||
|
Loading…
Reference in New Issue
Block a user