[PATCH] Measure label width if not yet done so
- From: Christian Neumair <chris gnome-de org>
- To: nautilus-list gnome org
- Subject: [PATCH] Measure label width if not yet done so
- Date: Tue, 28 Feb 2006 12:51:43 +0100
The attached patch fixes the issue of jumping icons when the text width
is not yet calculated but nautilus_icon_canvas_item_get_text_rectangle
is called for determining the initial layout.
--
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-icon-canvas-item.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.c,v
retrieving revision 1.196
diff -u -p -r1.196 nautilus-icon-canvas-item.c
--- libnautilus-private/nautilus-icon-canvas-item.c 27 Feb 2006 12:45:41 -0000 1.196
+++ libnautilus-private/nautilus-icon-canvas-item.c 28 Feb 2006 11:47:17 -0000
@@ -2043,7 +2047,7 @@ nautilus_icon_canvas_item_get_icon_recta
}
ArtDRect
-nautilus_icon_canvas_item_get_text_rectangle (const NautilusIconCanvasItem *item)
+nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item)
{
/* FIXME */
ArtIRect icon_rectangle;
@@ -2058,10 +2062,16 @@ nautilus_icon_canvas_item_get_text_recta
icon_rectangle.y0 = item->details->y;
pixbuf = item->details->pixbuf;
+
pixels_per_unit = EEL_CANVAS_ITEM (item)->canvas->pixels_per_unit;
icon_rectangle.x1 = icon_rectangle.x0 + (pixbuf == NULL ? 0 : gdk_pixbuf_get_width (pixbuf)) / pixels_per_unit;
icon_rectangle.y1 = icon_rectangle.y0 + (pixbuf == NULL ? 0 : gdk_pixbuf_get_height (pixbuf)) / pixels_per_unit;
+
+ /* measure text width if not yet done */
+ if (item->details->text_width < 0) {
+ measure_label_text (item);
+ }
text_rectangle = compute_text_rectangle (item, icon_rectangle, FALSE);
Index: libnautilus-private/nautilus-icon-canvas-item.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.h,v
retrieving revision 1.28
diff -u -p -r1.28 nautilus-icon-canvas-item.h
--- libnautilus-private/nautilus-icon-canvas-item.h 28 Oct 2005 12:41:19 -0000 1.28
+++ libnautilus-private/nautilus-icon-canvas-item.h 28 Feb 2006 11:47:17 -0000
@@ -88,7 +88,7 @@ gboolean nautilus_icon_canvas_item_hi
GtkCornerType *corner);
void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
ArtDRect nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item);
-ArtDRect nautilus_icon_canvas_item_get_text_rectangle (const NautilusIconCanvasItem *item);
+ArtDRect nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item);
void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item,
double i2w_dx, double i2w_dy);
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.411
diff -u -p -r1.411 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c 28 Feb 2006 11:22:38 -0000 1.411
+++ libnautilus-private/nautilus-icon-container.c 28 Feb 2006 11:47:30 -0000
@@ -1015,9 +1015,7 @@ lay_down_icons_horizontal (NautilusIconC
max_icon_width = MAX (max_icon_width, ceil (icon_bounds.x1 - icon_bounds.x0));
text_bounds = nautilus_icon_canvas_item_get_text_rectangle (icon->item);
- max_text_width = MAX (max_text_width, ceil (text_bounds.x1 - text_bounds.x0 < 0
- ? MAX_TEXT_WIDTH_BESIDE
- : text_bounds.x1 - text_bounds.x0));
+ max_text_width = MAX (max_text_width, ceil (text_bounds.x1 - text_bounds.x0));
}
grid_width = max_icon_width + max_text_width + ICON_PAD_LEFT + ICON_PAD_RIGHT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]