constrain cell area to passed in cell_area, #147867

Tue Aug 31 17:07:41 2004  Jonathan Blandford  <jrb@redhat.com>

        * gtk/gtktreeviewcolumn.c
        (gtk_tree_view_column_cell_process_action): constrain cell area to
        passed in cell_area, #147867

        * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if
        ellipsizing, get_size is only 3 chars wide.

        * docs/tree-column-sizing.png: Add Matthias's excellent image.
This commit is contained in:
Jonathan Blandford 2004-08-31 21:15:51 +00:00 committed by Jonathan Blandford
parent c0ba86bc81
commit 08bc720614
8 changed files with 107 additions and 5 deletions

View File

@ -1,3 +1,14 @@
Tue Aug 31 17:07:41 2004 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c
(gtk_tree_view_column_cell_process_action): constrain cell area to
passed in cell_area, #147867
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if
ellipsizing, get_size is only 3 chars wide.
* docs/tree-column-sizing.png: Add Matthias's excellent image.
2004-08-28 Robert Ögren <gtk@roboros.com>
On Win32, do not produce tablet motion or button events while a

View File

@ -1,3 +1,14 @@
Tue Aug 31 17:07:41 2004 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c
(gtk_tree_view_column_cell_process_action): constrain cell area to
passed in cell_area, #147867
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if
ellipsizing, get_size is only 3 chars wide.
* docs/tree-column-sizing.png: Add Matthias's excellent image.
2004-08-28 Robert Ögren <gtk@roboros.com>
On Win32, do not produce tablet motion or button events while a

View File

@ -1,3 +1,14 @@
Tue Aug 31 17:07:41 2004 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c
(gtk_tree_view_column_cell_process_action): constrain cell area to
passed in cell_area, #147867
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if
ellipsizing, get_size is only 3 chars wide.
* docs/tree-column-sizing.png: Add Matthias's excellent image.
2004-08-28 Robert Ögren <gtk@roboros.com>
On Win32, do not produce tablet motion or button events while a

View File

@ -1,3 +1,14 @@
Tue Aug 31 17:07:41 2004 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c
(gtk_tree_view_column_cell_process_action): constrain cell area to
passed in cell_area, #147867
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if
ellipsizing, get_size is only 3 chars wide.
* docs/tree-column-sizing.png: Add Matthias's excellent image.
2004-08-28 Robert Ögren <gtk@roboros.com>
On Win32, do not produce tablet motion or button events while a

View File

@ -52,6 +52,19 @@ End:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_from_file_at_scale ##### -->
<para>
</para>
@filename:
@width:
@height:
@keep_aspect_ratio:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_file_info ##### -->
<para>

BIN
docs/tree-column-sizing.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1382,12 +1382,32 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
pango_layout_get_pixel_extents (layout, NULL, &rect);
if (width)
*width = GTK_CELL_RENDERER (celltext)->xpad * 2 + rect.width;
if (height)
*height = GTK_CELL_RENDERER (celltext)->ypad * 2 + rect.height;
/* The minimum size for ellipsized labels is ~ 3 chars */
if (width)
{
if (priv->ellipsize)
{
PangoContext *context;
PangoFontMetrics *metrics;
gint char_width;
context = pango_layout_get_context (layout);
metrics = pango_context_get_metrics (context, widget->style->font_desc, NULL);
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
*width += (PANGO_PIXELS (char_width) * 3);
}
else
{
*width = GTK_CELL_RENDERER (celltext)->xpad * 2 + rect.width;
}
}
if (cell_area)
{
if (x_offset)

View File

@ -2621,6 +2621,9 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
/* rendering, event handling and rendering focus are somewhat complicated, and
* quite a bit of code. Rather than duplicate them, we put them together to
* keep the code in one place.
*
* To better understand what's going on, check out
* docs/tree-column-sizing.png
*/
enum {
CELL_ACTION_RENDER,
@ -2713,10 +2716,10 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
if (info->expand == TRUE)
expand_cell_count ++;
full_requested_width += info->requested_width;
/* FIXME: We prolly need to include tree_column->spacing here */
}
extra_space = cell_area->width + horizontal_separator - full_requested_width;
extra_space = cell_area->width - full_requested_width;
if (extra_space < 0)
extra_space = 0;
else if (extra_space > 0 && expand_cell_count > 0)
@ -2740,13 +2743,26 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
info->real_width = info->requested_width + (info->expand?extra_space:0);
/* We constrain ourselves to only the width available */
if (real_cell_area.x + info->real_width > cell_area->x + cell_area->width)
{
info->real_width = cell_area->x + cell_area->width - real_cell_area.x;
}
if (real_cell_area.x > cell_area->x + cell_area->width)
break;
real_cell_area.width = info->real_width;
real_background_area.width=
real_cell_area.x + real_cell_area.width - real_background_area.x;
real_cell_area.width -= 2 * focus_line_width;
rtl_cell_area = real_cell_area;
rtl_background_area = real_background_area;
if (rtl)
{
rtl_cell_area.x = cell_area->x + cell_area->width - (real_cell_area.x - cell_area->x) - real_cell_area.width;
@ -2895,6 +2911,15 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
info->real_width = info->requested_width + (info->expand?extra_space:0);
/* We constrain ourselves to only the width available */
if (real_cell_area.x + info->real_width > cell_area->x + cell_area->width)
{
info->real_width = cell_area->x + cell_area->width - real_cell_area.x;
}
if (real_cell_area.x > cell_area->x + cell_area->width)
break;
real_cell_area.width = info->real_width;
real_background_area.width =
real_cell_area.x + real_cell_area.width - real_background_area.x;