Added some rules to GtkCellAreaBox for rendering the last cell.

- When we reach a cell that is out of the render area, break out
   of the loop (for columns user resized too small)
 - CLAMP the size of the last renderer to fit into the area
   (so that renderers get a chance to ellipsize when rendered
   with a space less than allocation, same reason as above).
 - Hand out remaining space in the render area to the last cell,
   this is for shallow rows in the expand column which may recieve
   more than the allocated width.
This commit is contained in:
Tristan Van Berkom 2010-12-01 22:42:54 +09:00
parent a852deeb03
commit 30561228ed
2 changed files with 33 additions and 1 deletions

View File

@ -1172,6 +1172,38 @@ gtk_cell_area_box_render (GtkCellArea *area,
cell_background.height = cell->size;
}
/* Stop rendering cells if they flow out of the render area,
* this can happen because the render area can actually be
* smaller than the requested area (treeview columns can
* be user resizable and can be resized to be smaller than
* the actual requested area). */
if (cell_background.x > cell_area->x + cell_area->width ||
cell_background.y > cell_area->y + cell_area->height)
break;
/* Special case for the last cell... let the last cell consume the remaining
* space in the area (the last cell is allowed to consume the remaining space if
* the space given for rendering is actually larger than allocation, this can
* happen in the expander GtkTreeViewColumn where only the deepest depth column
* receives the allocation... shallow columns recieve more width). */
if (!l->next)
{
cell_background.width = cell_area->x + cell_area->width - cell_background.x;
cell_background.height = cell_area->y + cell_area->height - cell_background.y;
}
else
{
/* If the cell we are rendering doesnt fit into the remaining space, clip it
* so that the underlying renderer has a chance to deal with it (for instance
* text renderers get a chance to ellipsize).
*/
if (cell_background.x + cell_background.width > cell_area->x + cell_area->width)
cell_background.width = cell_area->x + cell_area->width - cell_background.x;
if (cell_background.y + cell_background.height > cell_area->y + cell_area->height)
cell_background.height = cell_area->y + cell_area->height - cell_background.y;
}
/* Remove margins from the background area to produce the cell area
*/
gtk_cell_area_inner_cell_area (area, widget, &cell_background, &inner_area);

View File

@ -351,7 +351,7 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
gtk_tree_view_set_rules_hint (tree_view, TRUE);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes ("Column 1",
rend,
"text", 1,