[nautilus] canvas-container: fix bounding box on different pixels per unit



commit 7d96b11f195594c62d347c94e373f8d455c027f6
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Sep 8 09:42:14 2015 +0200

    canvas-container: fix bounding box on different pixels per unit
    
    We were returning the bounding box without taking care of the pixels
    per unit, so the clients of it were using the wrong bounding box
    calculation. For instance the rename popover was wrong calculated
    for the canvas view if the pixel per unit was different than 1.
    
    The bounding boxes are usually not calculated with pixels per unit
    adjustment, but is very convenient to have it here, so add a comment
    explaining it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754620

 libnautilus-private/nautilus-canvas-container.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index d40b77a..042dd58 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -6380,7 +6380,8 @@ nautilus_canvas_container_get_icon_locations (NautilusCanvasContainer *container
        return result;
 }
 
-/* Returns an array of GdkRectangles of the icons. */
+/* Returns an array of GdkRectangles of the icons. The bounding box is adjusted
+ * with the pixels_per_unit already, so they are the final positions on the canvas */
 static GArray *
 nautilus_canvas_container_get_icons_bounding_box (NautilusCanvasContainer *container,
                                                   GList                   *icons)
@@ -6396,11 +6397,11 @@ nautilus_canvas_container_get_icons_bounding_box (NautilusCanvasContainer *conta
         for (index = 0, node = icons; node != NULL; index++, node = node->next) {
                icon_get_bounding_box ((NautilusCanvasIcon *)node->data,
                                        &x1, &y1, &x2, &y2,
-                                      BOUNDS_USAGE_FOR_ENTIRE_ITEM);
-                g_array_index (result, GdkRectangle, index).x = x1;
-                g_array_index (result, GdkRectangle, index).width = x2 - x1;
-                g_array_index (result, GdkRectangle, index).y = y1;
-                g_array_index (result, GdkRectangle, index).height = y2 - y1;
+                                      BOUNDS_USAGE_FOR_DISPLAY);
+                g_array_index (result, GdkRectangle, index).x = x1 * EEL_CANVAS (container)->pixels_per_unit;
+                g_array_index (result, GdkRectangle, index).width = (x2 - x1) * EEL_CANVAS 
(container)->pixels_per_unit;
+                g_array_index (result, GdkRectangle, index).y = y1 * EEL_CANVAS (container)->pixels_per_unit;
+                g_array_index (result, GdkRectangle, index).height = (y2 - y1) * EEL_CANVAS 
(container)->pixels_per_unit;
         }
 
         return result;


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