gridview: Add a filler tile for empty space

That stupid space in the bottom right when n_items isn't a multiple of
n_columns needs its own tile, or we'll get errors about not finding a
tile.

So make one.
This commit is contained in:
Benjamin Otte 2023-03-04 03:32:12 +01:00 committed by Benjamin Otte
parent 882dcda53b
commit e8c5a771e5
3 changed files with 22 additions and 0 deletions

View File

@ -737,6 +737,21 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
i = 0;
}
}
/* Add a filler tile for empty space in the bottom right */
if (i < self->n_columns)
{
GtkListTile *filler;
tile = gtk_list_item_manager_get_last (self->item_manager);
filler = gtk_list_tile_split (self->item_manager, tile, tile->n_items);
gtk_list_tile_set_area_position (self->item_manager,
filler,
ceil (self->column_width * i),
y);
gtk_list_tile_set_area_size (self->item_manager,
filler,
ceil (self->column_width * self->n_columns) - filler->area.x,
tile->area.height);
}
/* step 4: allocate the rest */
gtk_list_base_allocate (GTK_LIST_BASE (self));

View File

@ -184,6 +184,12 @@ gtk_list_item_manager_get_first (GtkListItemManager *self)
return gtk_rb_tree_get_first (self->items);
}
gpointer
gtk_list_item_manager_get_last (GtkListItemManager *self)
{
return gtk_rb_tree_get_last (self->items);
}
gpointer
gtk_list_item_manager_get_root (GtkListItemManager *self)
{

View File

@ -71,6 +71,7 @@ void gtk_list_item_manager_get_tile_bounds (GtkListItemMana
GdkRectangle *out_bounds);
gpointer gtk_list_item_manager_get_root (GtkListItemManager *self);
gpointer gtk_list_item_manager_get_first (GtkListItemManager *self);
gpointer gtk_list_item_manager_get_last (GtkListItemManager *self);
gpointer gtk_list_item_manager_get_nth (GtkListItemManager *self,
guint position,
guint *offset);