diff options
author | Benjamin Otte <otte@redhat.com> | 2019-10-22 04:59:34 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2019-10-28 10:49:01 +0100 |
commit | 305d0aaae1300e7b2ac0bb2f5f241f925e6932c1 (patch) | |
tree | 7fe2310a37efe126d3f380b7c9d1e028044f196b | |
parent | e22f480af9b834e6a8974a2f120de748c85efff2 (diff) | |
download | gtk+-305d0aaae1300e7b2ac0bb2f5f241f925e6932c1.tar.gz |
gridview: Simplify allocation code
It doesn't fix the bug I'm after, but it looks a lot better.
-rw-r--r-- | gtk/gtkgridview.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c index 97e0f31ce8..2a3436ce88 100644 --- a/gtk/gtkgridview.c +++ b/gtk/gtkgridview.c @@ -1022,46 +1022,40 @@ gtk_grid_view_size_allocate (GtkWidget *widget, x = - gtk_grid_view_update_adjustment (self, opposite_orientation); y = - gtk_grid_view_update_adjustment (self, self->orientation); - i = 0; + i = self->n_columns; /* so we run the sizing step at the beginning of the for loop */ row_height = 0; + for (cell = gtk_list_item_manager_get_first (self->item_manager); cell != NULL; cell = gtk_rb_tree_node_get_next (cell)) { - if (cell->parent.widget) + if (i >= self->n_columns) { - if (i == 0) + y += row_height; + row_height = cell->size; + i -= self->n_columns; + + if (i > self->n_columns) { - y += row_height; - row_height = cell->size; + guint unknown_rows = (i - 1) / self->n_columns; + int unknown_height = unknown_rows * self->unknown_row_height; + row_height -= unknown_height; + y += unknown_height; + i %= self->n_columns; } + } + + if (cell->parent.widget) + { gtk_grid_view_size_allocate_child (self, cell->parent.widget, x + ceil (self->column_width * i), y, ceil (self->column_width * (i + 1)) - ceil (self->column_width * i), row_height); - i = (i + 1) % self->n_columns; - } - else - { - i += cell->parent.n_items; - if (i > self->n_columns) - { - i -= self->n_columns; - y += row_height; - row_height = cell->size; - - if (i > self->n_columns) - { - guint unknown_rows = (i - 1) / self->n_columns; - int unknown_height = unknown_rows * self->unknown_row_height; - row_height -= unknown_height; - y += unknown_height; - i %= self->n_columns; - } - } } + + i += cell->parent.n_items; } } |