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
This commit is contained in:
committed by
Harley Acheson
parent
424242115f
commit
022c85fec3
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user