[PATCH] Fix canvas item bounds calculation



The attached patch fixes various glitches, inter alia problems with
icons drags of icons containing emblems which are not totally inside the
icon rect, drawing artefacts after moving icons with zoom levels !=
100%, and hit box problems with zoom levels != 100%.

-- 
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.193
diff -u -p -r1.193 nautilus-icon-canvas-item.c
--- libnautilus-private/nautilus-icon-canvas-item.c	28 Oct 2005 12:41:19 -0000	1.193
+++ libnautilus-private/nautilus-icon-canvas-item.c	12 Nov 2005 12:35:16 -0000
@@ -1940,7 +1957,9 @@ nautilus_icon_canvas_item_bounds (EelCan
 		total_rect = details->bounds_cache;
 	} else {	
 		measure_label_text (icon_item);
-		
+
+		pixels_per_unit = item->canvas->pixels_per_unit;
+
 		/* Compute icon rectangle. */
 		icon_rect.x0 = 0;
 		icon_rect.y0 = 0;
@@ -1948,7 +1967,6 @@ nautilus_icon_canvas_item_bounds (EelCan
 			icon_rect.x1 = icon_rect.x0;
 			icon_rect.y1 = icon_rect.y0;
 		} else {
-			pixels_per_unit = item->canvas->pixels_per_unit;
 			icon_rect.x1 = icon_rect.x0 + gdk_pixbuf_get_width (details->pixbuf) / pixels_per_unit;
 			icon_rect.y1 = icon_rect.y0 + gdk_pixbuf_get_height (details->pixbuf) / pixels_per_unit;
 		}
@@ -1960,6 +1978,11 @@ nautilus_icon_canvas_item_bounds (EelCan
 		art_irect_union (&total_rect, &icon_rect, &text_rect);
 		emblem_layout_reset (&emblem_layout, icon_item, icon_rect);
 		while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect)) {
+			emblem_rect.x0 = floor (emblem_rect.x0 / pixels_per_unit);
+			emblem_rect.y0 = floor (emblem_rect.y0 / pixels_per_unit);
+			emblem_rect.x1 = ceil (emblem_rect.x1 / pixels_per_unit);
+			emblem_rect.y1 = ceil (emblem_rect.y1 / pixels_per_unit);
+
 			art_irect_union (&total_rect, &total_rect, &emblem_rect);
 		}
 

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]