mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
columnviewlayout: Handle for_size propertly
When we are given a for_size as width for the whole column view, we need to distribute it over the columns as gtk_column_view_allocate_columns would, in order to find out which for_size to give to each cell. This is a bit recursive, but works. Since we are doing this recursion for every row, we should consider adding a cache for those distributed widths.
This commit is contained in:
parent
f6da324670
commit
40f6a9d830
@ -47,10 +47,19 @@ gtk_column_view_layout_measure_along (GtkColumnViewLayout *self,
|
||||
{
|
||||
GtkOrientation orientation = GTK_ORIENTATION_VERTICAL;
|
||||
GtkWidget *child;
|
||||
guint i, n;
|
||||
GtkRequestedSize *sizes = NULL;
|
||||
|
||||
for (child = _gtk_widget_get_first_child (widget);
|
||||
if (for_size > -1)
|
||||
{
|
||||
n = g_list_model_get_n_items (gtk_column_view_get_columns (self->view));
|
||||
sizes = g_newa (GtkRequestedSize, n);
|
||||
gtk_column_view_distribute_width (self->view, for_size, sizes);
|
||||
}
|
||||
|
||||
for (child = _gtk_widget_get_first_child (widget), i = 0;
|
||||
child != NULL;
|
||||
child = _gtk_widget_get_next_sibling (child))
|
||||
child = _gtk_widget_get_next_sibling (child), i++)
|
||||
{
|
||||
int child_min = 0;
|
||||
int child_nat = 0;
|
||||
@ -60,7 +69,8 @@ gtk_column_view_layout_measure_along (GtkColumnViewLayout *self,
|
||||
if (!gtk_widget_should_layout (child))
|
||||
continue;
|
||||
|
||||
gtk_widget_measure (child, orientation, for_size,
|
||||
gtk_widget_measure (child, orientation,
|
||||
for_size > -1 ? sizes[i].minimum_size : -1,
|
||||
&child_min, &child_nat,
|
||||
&child_min_baseline, &child_nat_baseline);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user