[gtk+/treeview-refactor] Added some rules to GtkCellAreaBox for rendering the last cell.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor] Added some rules to GtkCellAreaBox for rendering the last cell.
- Date: Wed, 1 Dec 2010 13:51:11 +0000 (UTC)
commit 30561228ed3dfc88866852ceecf81063a640e0d5
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Dec 1 22:42:54 2010 +0900
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.
gtk/gtkcellareabox.c | 32 ++++++++++++++++++++++++++++++++
tests/testtreeview.c | 2 +-
2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcellareabox.c b/gtk/gtkcellareabox.c
index 12988e6..a3a241c 100644
--- a/gtk/gtkcellareabox.c
+++ b/gtk/gtkcellareabox.c
@@ -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);
diff --git a/tests/testtreeview.c b/tests/testtreeview.c
index d28cb35..c252ebf 100644
--- a/tests/testtreeview.c
+++ b/tests/testtreeview.c
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]