[Bf-blender-cvs] [6e487228a59] master: File Browser UI: Allow dragging anywhere in a file preview tile to drag

Julian Eisel noreply at git.blender.org
Thu Mar 3 15:18:14 CET 2022


Commit: 6e487228a5952ac538718e56241d8d2082baa279
Author: Julian Eisel
Date:   Thu Mar 3 15:13:04 2022 +0100
Branches: master
https://developer.blender.org/rB6e487228a5952ac538718e56241d8d2082baa279

File Browser UI: Allow dragging anywhere in a file preview tile to drag

Previously you'd have to be careful to drag the image itself. Dragging
anywhere else on the tile (e.g. between the preview and the text, or the
text itself) would trigger border select. This often conflicts with user
expectations and causes frustration when trying to work quick, I've seen
many people complain about this.

Note that the "hitbox" for dragging is a bit smaller than the tile, to
not make border select by dragging from in-between the tiles too hard.

Differential Revision: https://developer.blender.org/D14228

===================================================================

M	source/blender/editors/space_file/file_draw.c

===================================================================

diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 92469773ed4..6c67d95674f 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -476,7 +476,26 @@ static void file_draw_preview(const SpaceFile *sfile,
     immUnbindProgram();
   }
 
-  but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, NULL);
+  /* Invisible button for dragging. */
+  rcti drag_rect = *tile_draw_rect;
+  /* A bit smaller than the full tile, to increase the gap between items that users can drag from
+   * for box select. */
+  BLI_rcti_pad(&drag_rect, -layout->tile_border_x, -layout->tile_border_y);
+
+  but = uiDefBut(block,
+                 UI_BTYPE_LABEL,
+                 0,
+                 "",
+                 drag_rect.xmin,
+                 drag_rect.ymin,
+                 BLI_rcti_size_x(&drag_rect),
+                 BLI_rcti_size_y(&drag_rect),
+                 NULL,
+                 0.0,
+                 0.0,
+                 0,
+                 0,
+                 NULL);
 
   /* Drag-region. */
   if (drag) {



More information about the Bf-blender-cvs mailing list