File Browser: Make full file name label draggable #104830

Closed
Julian Eisel wants to merge 8 commits from JulianEisel:temp-file-browser-full-label-drag into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 29 additions and 1 deletions

View File

@ -1037,6 +1037,33 @@ void file_draw_list(const bContext *C, ARegion *region)
}
else {
const int icon = filelist_geticon(files, i, true);
icon_ofs += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X;
/* Add dummy draggable button covering the icon and the label. */
if (do_drag) {
const uiStyle *style = UI_style_get();
const int str_width = UI_fontstyle_string_width(&style->widget, file->name);
const int drag_width = MIN2(str_width + icon_ofs, column_width - ATTRIBUTE_COLUMN_PADDING);
uiBut *drag_but = uiDefBut(block,
UI_BTYPE_LABEL,
0,
"",
tile_draw_rect.xmin,
tile_draw_rect.ymin - 1,
drag_width,
layout->tile_h + layout->tile_border_y * 2,
NULL,
0,
0,
0,
0,
0);
UI_but_dragflag_enable(drag_but, UI_BUT_DRAG_FULL_BUT);
file_but_enable_drag(drag_but, sfile, file, path, NULL, icon, UI_DPI_FAC);
}
/* Add this after the fake draggable button, so the icon button tooltip is displayed. */
uiBut *icon_but = file_add_icon_but(sfile,
block,
path,
@ -1046,9 +1073,10 @@ void file_draw_list(const bContext *C, ARegion *region)
ICON_DEFAULT_HEIGHT_SCALE,
is_hidden);
if (do_drag) {
/* For some reason the dragging is unreliable for the icon button if we don't explicitly
* enable dragging, even though the dummy drag button above covers the same area. */
file_but_enable_drag(icon_but, sfile, file, path, NULL, icon, UI_DPI_FAC);
}
icon_ofs += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X;
}
if (file_selflag & FILE_SEL_EDITING) {