listitemmanager: Augment header/footer info

This commit is contained in:
Benjamin Otte 2023-04-07 20:49:06 +02:00
parent e680abc723
commit 8bf6498265
2 changed files with 31 additions and 0 deletions

View File

@ -101,11 +101,36 @@ gtk_list_item_manager_augment_node (GtkRbTree *tree,
aug->n_items = tile->n_items; aug->n_items = tile->n_items;
aug->area = tile->area; aug->area = tile->area;
switch (tile->type)
{
case GTK_LIST_TILE_HEADER:
case GTK_LIST_TILE_UNMATCHED_HEADER:
aug->has_header = TRUE;
aug->has_footer = FALSE;
break;
case GTK_LIST_TILE_FOOTER:
case GTK_LIST_TILE_UNMATCHED_FOOTER:
aug->has_header = FALSE;
aug->has_footer = TRUE;
break;
case GTK_LIST_TILE_ITEM:
case GTK_LIST_TILE_FILLER:
case GTK_LIST_TILE_REMOVED:
aug->has_header = FALSE;
aug->has_footer = FALSE;
break;
default:
g_assert_not_reached ();
break;
}
if (left) if (left)
{ {
GtkListTileAugment *left_aug = gtk_rb_tree_get_augment (tree, left); GtkListTileAugment *left_aug = gtk_rb_tree_get_augment (tree, left);
aug->n_items += left_aug->n_items; aug->n_items += left_aug->n_items;
aug->has_header |= left_aug->has_header;
aug->has_footer |= left_aug->has_footer;
potentially_empty_rectangle_union (&aug->area, &left_aug->area); potentially_empty_rectangle_union (&aug->area, &left_aug->area);
} }
@ -114,6 +139,8 @@ gtk_list_item_manager_augment_node (GtkRbTree *tree,
GtkListTileAugment *right_aug = gtk_rb_tree_get_augment (tree, right); GtkListTileAugment *right_aug = gtk_rb_tree_get_augment (tree, right);
aug->n_items += right_aug->n_items; aug->n_items += right_aug->n_items;
aug->has_header |= right_aug->has_header;
aug->has_footer |= right_aug->has_footer;
potentially_empty_rectangle_union (&aug->area, &right_aug->area); potentially_empty_rectangle_union (&aug->area, &right_aug->area);
} }
} }

View File

@ -66,6 +66,10 @@ struct _GtkListTile
struct _GtkListTileAugment struct _GtkListTileAugment
{ {
guint n_items; guint n_items;
guint has_header :1;
guint has_footer :1;
/* union of all areas of tile and children */ /* union of all areas of tile and children */
cairo_rectangle_int_t area; cairo_rectangle_int_t area;
}; };