[nautilus/wip/antoniof/hidpi-and-icons-cleanup: 4/5] dnd: Make it easier to identify pile of dragged thumbnails




commit e45b768b956be96b236aa5896e26e90660ea0376
Author: António Fernandes <antoniof gnome org>
Date:   Wed Aug 10 12:14:00 2022 +0100

    dnd: Make it easier to identify pile of dragged thumbnails
    
    Offset each picture 6 pixels in either direction.
    
    Also have a stronger shadow, with same alpha as shadows in the view.

 src/nautilus-dnd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-dnd.c b/src/nautilus-dnd.c
index 131493c5d..7df392037 100644
--- a/src/nautilus-dnd.c
+++ b/src/nautilus-dnd.c
@@ -231,11 +231,12 @@ get_paintable_for_drag_selection (GList *selection,
     GdkPaintable *icon;
     guint n_icons;
     guint icon_size = NAUTILUS_DRAG_SURFACE_ICON_SIZE;
+    float dx;
     float dy;
     /* A wide shadow for the pile of icons gives a sense of floating. */
     GskShadow stack_shadow = {.color = {0, 0, 0, .alpha = 0.15}, .dx = 0, .dy = 2, .radius = 10 };
     /* A slight shadow swhich makes each icon in the stack look separate. */
-    GskShadow icon_shadow = {.color = {0, 0, 0, .alpha = 0.20}, .dx = 0, .dy = 1, .radius = 1 };
+    GskShadow icon_shadow = {.color = {0, 0, 0, .alpha = 0.30}, .dx = 0, .dy = 1, .radius = 1 };
 
     g_return_val_if_fail (NAUTILUS_IS_FILE (selection->data), NULL);
 
@@ -268,6 +269,7 @@ get_paintable_for_drag_selection (GList *selection,
      *                                  '--------'      '--------'
      */
     n_icons = g_queue_get_length (icons);
+    dx = (n_icons % 2 == 1) ? 6 : -6;
     dy = (n_icons == 2) ? 10 : (n_icons == 3) ? 6 : (n_icons >= 4) ? 4 : 0;
 
     /* We want the first icon on top of every other. So we need to start drawing
@@ -276,7 +278,7 @@ get_paintable_for_drag_selection (GList *selection,
      * Also, add 10px horizontal offset, for shadow, to workaround this GTK bug:
      * https://gitlab.gnome.org/GNOME/gtk/-/issues/2341
      */
-    gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (10, dy * n_icons));
+    gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (10 + (dx / 2), dy * n_icons));
     gtk_snapshot_push_shadow (snapshot, &stack_shadow, 1);
     for (GList *l = g_queue_peek_tail_link (icons); l != NULL; l = l->prev)
     {
@@ -286,7 +288,10 @@ get_paintable_for_drag_selection (GList *selection,
         float x = floor ((icon_size - w) / 2);
         float y = floor ((icon_size - h) / 2);
 
-        gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (0, -dy));
+        gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (-dx, -dy));
+
+        /* Alternate horizontal offset direction to give a rough pile look. */
+        dx = -dx;
 
         gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
         gtk_snapshot_push_shadow (snapshot, &icon_shadow, 1);


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