Fixed initial bugs in GtkCellArea implementation, starting to render

Tested all of this with some scaffolding code, test case comming soon.
This commit is contained in:
Tristan Van Berkom 2010-11-08 17:43:27 +09:00
parent 0336838366
commit 92b9f432dd
3 changed files with 37 additions and 21 deletions

View File

@ -402,6 +402,7 @@ cell_groups_rebuild (GtkCellAreaBox *box)
{
GtkCellAreaBoxPrivate *priv = box->priv;
CellGroup group = { 0, };
CellGroup *group_ptr;
GList *cells, *l;
guint id = 0;
@ -414,6 +415,7 @@ cell_groups_rebuild (GtkCellAreaBox *box)
/* First group is implied */
g_array_append_val (priv->groups, group);
group_ptr = &g_array_index (priv->groups, CellGroup, id);
for (l = cells; l; l = l->next)
{
@ -426,21 +428,22 @@ cell_groups_rebuild (GtkCellAreaBox *box)
group.id = ++id;
g_array_append_val (priv->groups, group);
group_ptr = &g_array_index (priv->groups, CellGroup, id);
}
group.cells = g_list_prepend (group.cells, info);
group.n_cells++;
group_ptr->cells = g_list_prepend (group_ptr->cells, info);
group_ptr->n_cells++;
/* A group expands if it contains any expand cells */
if (info->expand)
group.expand_cells++;
group_ptr->expand_cells++;
}
g_list_free (cells);
for (id = 0; id < priv->groups->len; id++)
{
CellGroup *group_ptr = &g_array_index (priv->groups, CellGroup, id);
group_ptr = &g_array_index (priv->groups, CellGroup, id);
group_ptr->cells = g_list_reverse (group_ptr->cells);
}
@ -583,6 +586,8 @@ get_allocated_cells (GtkCellAreaBox *box,
return NULL;
}
g_print ("Allocating cells for rendering, group allocs %d\n", n_allocs);
for (i = 0; i < n_allocs; i++)
{
/* We dont always allocate all groups, sometimes the requested group has only invisible
@ -1054,6 +1059,9 @@ gtk_cell_area_box_render (GtkCellArea *area,
* of alignments and pack order etc. */
allocated_cells = get_allocated_cells (box, box_iter, widget);
g_print ("Rendering an area with allocated cells %d\n",
g_slist_length (allocated_cells));
for (l = allocated_cells; l; l = l->next)
{
AllocatedCell *cell = l->data;
@ -1075,6 +1083,9 @@ gtk_cell_area_box_render (GtkCellArea *area,
/* XXX We have to do some per-cell considerations for the 'flags'
* for focus handling */
g_print ("Rendering a cell at x: %d y: %d width %d height %d\n",
inner_area.x, inner_area.y, inner_area.width, inner_area.height);
gtk_cell_renderer_render (cell->renderer, cr, widget,
&background_area, &inner_area,
flags);
@ -1200,7 +1211,8 @@ gtk_cell_area_box_create_iter (GtkCellArea *area)
GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
GtkCellAreaBoxPrivate *priv = box->priv;
GtkCellAreaIter *iter =
(GtkCellAreaIter *)g_object_new (GTK_TYPE_CELL_AREA_BOX_ITER, NULL);
(GtkCellAreaIter *)g_object_new (GTK_TYPE_CELL_AREA_BOX_ITER,
"area", area, NULL);
priv->iters = g_slist_prepend (priv->iters, iter);
@ -1251,7 +1263,7 @@ compute_size (GtkCellAreaBox *box,
gint renderer_min_size, renderer_nat_size;
if (!gtk_cell_renderer_get_visible (info->renderer))
continue;
continue;
gtk_cell_area_request_renderer (area, info->renderer, orientation, widget, for_size,
&renderer_min_size, &renderer_nat_size);

View File

@ -175,7 +175,7 @@ gtk_cell_area_box_iter_flush_preferred_width (GtkCellAreaIter *iter)
size->nat_size = 0;
}
GTK_CELL_AREA_ITER_GET_CLASS
GTK_CELL_AREA_ITER_CLASS
(gtk_cell_area_box_iter_parent_class)->flush_preferred_width (iter);
}
@ -192,7 +192,7 @@ gtk_cell_area_box_iter_flush_preferred_height_for_width (GtkCellAreaIter *iter,
else
g_hash_table_remove (priv->heights, GINT_TO_POINTER (width));
GTK_CELL_AREA_ITER_GET_CLASS
GTK_CELL_AREA_ITER_CLASS
(gtk_cell_area_box_iter_parent_class)->flush_preferred_height_for_width (iter, width);
}
@ -211,7 +211,7 @@ gtk_cell_area_box_iter_flush_preferred_height (GtkCellAreaIter *iter)
size->nat_size = 0;
}
GTK_CELL_AREA_ITER_GET_CLASS
GTK_CELL_AREA_ITER_CLASS
(gtk_cell_area_box_iter_parent_class)->flush_preferred_height (iter);
}
@ -228,7 +228,7 @@ gtk_cell_area_box_iter_flush_preferred_width_for_height (GtkCellAreaIter *iter,
else
g_hash_table_remove (priv->widths, GINT_TO_POINTER (height));
GTK_CELL_AREA_ITER_GET_CLASS
GTK_CELL_AREA_ITER_CLASS
(gtk_cell_area_box_iter_parent_class)->flush_preferred_width_for_height (iter, height);
}
@ -479,7 +479,8 @@ static GtkCellAreaBoxAllocation *
allocate_for_orientation (GtkCellAreaBoxIter *iter,
GtkOrientation orientation,
gint spacing,
gint size)
gint size,
gint *n_allocs)
{
GtkCellAreaBoxIterPrivate *priv = iter->priv;
GtkRequestedSize *orientation_sizes;
@ -549,6 +550,9 @@ allocate_for_orientation (GtkCellAreaBoxIter *iter,
position += spacing;
}
if (n_allocs)
*n_allocs = n_groups;
g_free (orientation_sizes);
return allocs;
@ -571,10 +575,11 @@ gtk_cell_area_box_iter_allocate_width (GtkCellAreaIter *iter,
gint spacing = gtk_cell_area_box_get_spacing (GTK_CELL_AREA_BOX (area));
g_free (priv->orientation_allocs);
priv->orientation_allocs = allocate_for_orientation (box_iter, orientation, spacing, width);
priv->orientation_allocs = allocate_for_orientation (box_iter, orientation, spacing, width,
&priv->n_orientation_allocs);
}
GTK_CELL_AREA_ITER_GET_CLASS (iter)->allocate_width (iter, width);
GTK_CELL_AREA_ITER_CLASS (gtk_cell_area_box_iter_parent_class)->allocate_width (iter, width);
}
static void
@ -594,10 +599,11 @@ gtk_cell_area_box_iter_allocate_height (GtkCellAreaIter *iter,
gint spacing = gtk_cell_area_box_get_spacing (GTK_CELL_AREA_BOX (area));
g_free (priv->orientation_allocs);
priv->orientation_allocs = allocate_for_orientation (box_iter, orientation, spacing, height);
priv->orientation_allocs = allocate_for_orientation (box_iter, orientation, spacing, height,
&priv->n_orientation_allocs);
}
GTK_CELL_AREA_ITER_GET_CLASS (iter)->allocate_height (iter, height);
GTK_CELL_AREA_ITER_CLASS (gtk_cell_area_box_iter_parent_class)->allocate_height (iter, height);
}
/*************************************************************
@ -612,7 +618,7 @@ gtk_cell_area_box_init_groups (GtkCellAreaBoxIter *box_iter,
gint i;
g_return_if_fail (GTK_IS_CELL_AREA_BOX_ITER (box_iter));
g_return_if_fail (n_groups > 0 || expand_groups != NULL);
g_return_if_fail (n_groups == 0 || expand_groups != NULL);
/* When the group dimensions change, all info must be flushed
* Note this already clears the min/nat values on the BaseSizes

View File

@ -126,22 +126,20 @@ gtk_cell_area_iter_class_init (GtkCellAreaIterClass *class)
object_class->get_property = gtk_cell_area_iter_get_property;
object_class->set_property = gtk_cell_area_iter_set_property;
/* GtkCellAreaIterClass */
class->flush_preferred_width = gtk_cell_area_iter_real_flush_preferred_width;
class->flush_preferred_height_for_width = gtk_cell_area_iter_real_flush_preferred_height_for_width;
class->flush_preferred_height = gtk_cell_area_iter_real_flush_preferred_height;
class->flush_preferred_width_for_height = gtk_cell_area_iter_real_flush_preferred_width_for_height;
class->flush_allocation = gtk_cell_area_iter_real_flush_allocation;
class->allocate_width = gtk_cell_area_iter_real_allocate_width;
class->allocate_height = gtk_cell_area_iter_real_allocate_height;
class->sum_preferred_width = NULL;
class->sum_preferred_height_for_width = NULL;
class->sum_preferred_height = NULL;
class->sum_preferred_width_for_height = NULL;
class->allocate_width = NULL;
class->allocate_height = NULL;
class->allocate_width = gtk_cell_area_iter_real_allocate_width;
class->allocate_height = gtk_cell_area_iter_real_allocate_height;
cell_area_iter_signals[SIGNAL_HEIGHT_CHANGED] =
g_signal_new (I_("height-changed"),