diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-06-05 11:34:51 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-06-05 13:27:50 -0400 |
commit | 40f6a9d830cbbf40b6c7d0e53054ddb24cd8688d (patch) | |
tree | c54cfac71e8c43bf1546f6f70e643569c13644b6 /gtk/gtkcolumnviewlayout.c | |
parent | f6da3246708ad2a40c7be35adf15444200f2447d (diff) | |
download | gtk+-40f6a9d830cbbf40b6c7d0e53054ddb24cd8688d.tar.gz |
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.
Diffstat (limited to 'gtk/gtkcolumnviewlayout.c')
-rw-r--r-- | gtk/gtkcolumnviewlayout.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gtk/gtkcolumnviewlayout.c b/gtk/gtkcolumnviewlayout.c index 44d99df673..1b56a3b6ff 100644 --- a/gtk/gtkcolumnviewlayout.c +++ b/gtk/gtkcolumnviewlayout.c @@ -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); |