IO: Add support for multiple drag-n-drop files #107230
|
@ -1173,15 +1173,11 @@ struct wmDragAssetListItem {
|
|||
};
|
||||
|
||||
struct wmDragPath {
|
||||
const blender::Vector<std::string> paths;
|
||||
blender::Vector<std::string> paths;
|
||||
/* Note that even though the enum type uses bit-flags, this should never have multiple type-bits
|
||||
* set, so `ELEM()` like comparison is possible. */
|
||||
const int file_type; /* eFileSel_File_Types */
|
||||
const std::string tooltip;
|
||||
wmDragPath(const blender::Vector<std::string> &paths, const std::string &tooltip, int file_type)
|
||||
: paths(std::move(paths)), file_type(file_type), tooltip(tooltip)
|
||||
{
|
||||
}
|
||||
int file_type; /* eFileSel_File_Types */
|
||||
std::string tooltip;
|
||||
};
|
||||
|
||||
struct wmDragGreasePencilLayer {
|
||||
|
|
|
@ -761,27 +761,32 @@ const ListBase *WM_drag_asset_list_get(const wmDrag *drag)
|
|||
|
||||
wmDragPath *WM_drag_create_path_data(blender::Span<const char *> paths)
|
||||
{
|
||||
wmDragPath *path_data = MEM_new<wmDragPath>("wmDragPath");
|
||||
|
||||
path_data->file_type = ED_path_extension_type(paths[0]);
|
||||
|
||||
const char *extension = BLI_path_extension(paths[0]);
|
||||
blender::Vector<std::string> filtered_paths;
|
||||
|
||||
for (auto path : paths) {
|
||||
const char *test_ext = BLI_path_extension(path);
|
||||
if (extension == test_ext || (extension && test_ext && STREQ(extension, test_ext))) {
|
||||
filtered_paths.append(path);
|
||||
path_data->paths.append(path);
|
||||
}
|
||||
}
|
||||
const char *tooltip = paths[0];
|
||||
|
||||
const char *tooltip = path_data->paths[0].c_str();
|
||||
guishe marked this conversation as resolved
|
||||
char tooltip_buffer[256];
|
||||
if (filtered_paths.size() > 1) {
|
||||
|
||||
if (path_data->paths.size() > 1) {
|
||||
BLI_snprintf(tooltip_buffer,
|
||||
ARRAY_SIZE(tooltip_buffer),
|
||||
TIP_("Dragging %d %s files."),
|
||||
filtered_paths.size(),
|
||||
path_data->paths.size(),
|
||||
extension ? extension : TIP_("Folder"));
|
||||
tooltip = tooltip_buffer;
|
||||
}
|
||||
|
||||
wmDragPath *path_data = MEM_new<wmDragPath>(
|
||||
"wmDragPath", filtered_paths, tooltip, ED_path_extension_type(paths[0]));
|
||||
path_data->tooltip = tooltip;
|
||||
|
||||
return path_data;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
No final point in our UI strings:
"Dragging {} files"