From 022c85fec339ad3d869a4b274904da2d09cd5b81 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 6 May 2025 22:35:26 +0200 Subject: [PATCH] UI: Consistent File/Asset Drag Size The size of preview images while dragging from File or Asset Browser is currently related to the size that they are shown in the thumbnail lists, sort of, but also based on the column size and with an incorrect scaling. This PR just makes them a consistent size while dragging, regardless of their thumbnail size. Pull Request: https://projects.blender.org/blender/blender/pulls/138350 --- source/blender/editors/include/UI_interface_icons.hh | 2 ++ source/blender/editors/space_file/file_draw.cc | 4 ++-- source/blender/windowmanager/intern/wm_dragdrop.cc | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/include/UI_interface_icons.hh b/source/blender/editors/include/UI_interface_icons.hh index 7704a9bed4e..99a09bc8d5d 100644 --- a/source/blender/editors/include/UI_interface_icons.hh +++ b/source/blender/editors/include/UI_interface_icons.hh @@ -38,6 +38,8 @@ struct IconTextOverlay { #define PREVIEW_DEFAULT_HEIGHT 128 +#define PREVIEW_DRAG_DRAW_SIZE 96.0f + enum eAlertIcon { ALERT_ICON_NONE = -1, ALERT_ICON_WARNING = 0, diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index dd3480ed43f..1a8092464df 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -644,8 +644,8 @@ static void file_add_preview_drag_but(const SpaceFile *sfile, const ImBuf *drag_image = preview_image ? preview_image : /* Larger directory or document icon. */ filelist_geticon_special_file_image_ex(file); - const auto [scaled_width, scaled_height, scale] = preview_image_scaled_dimensions_get( - drag_image->x, drag_image->y, *layout); + const float scale = (PREVIEW_DRAG_DRAW_SIZE * UI_SCALE_FAC) / + std::max(drag_image->x, drag_image->y); file_but_enable_drag(but, sfile, file, path, drag_image, file_type_icon, scale); file_but_tooltip_func_set(sfile, file, but); } diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index 4fa69d440d0..616a703b280 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -1035,7 +1035,7 @@ static int wm_drag_imbuf_icon_height_get(const wmDrag *drag) static int wm_drag_preview_icon_size_get() { - return UI_preview_tile_size_x(); + return int(PREVIEW_DRAG_DRAW_SIZE * UI_SCALE_FAC); } static void wm_drag_draw_icon(bContext * /*C*/, wmWindow * /*win*/, wmDrag *drag, const int xy[2]) @@ -1072,7 +1072,7 @@ static void wm_drag_draw_icon(bContext * /*C*/, wmWindow * /*win*/, wmDrag *drag x = xy[0] - (size / 2); y = xy[1] - (size / 2); - UI_icon_draw_preview(x, y, drag->preview_icon_id, UI_INV_SCALE_FAC, 0.8, size); + UI_icon_draw_preview(x, y, drag->preview_icon_id, 1.0, 0.8, size); } else { int padding = 4 * UI_SCALE_FAC;