From ca58f97cdacc640c38893b7457ba7dfe9d3613d0 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 19 Sep 2023 15:56:11 +0200 Subject: [PATCH] Refactor: Use asset representation for asset browser context query There's no need to use the asset handle type here anymore, it can just use the asset representation type that is supposed to replace it. Part of #102877 and #108806. --- source/blender/editors/space_file/file_context.cc | 9 +++------ source/blender/windowmanager/intern/wm_dragdrop.cc | 12 ++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/space_file/file_context.cc b/source/blender/editors/space_file/file_context.cc index ee0486c4836..08148f6e3d5 100644 --- a/source/blender/editors/space_file/file_context.cc +++ b/source/blender/editors/space_file/file_context.cc @@ -20,7 +20,7 @@ const char *file_context_dir[] = { "active_file", "selected_files", "asset_library_ref", - "selected_asset_files", + "selected_assets", "id", "selected_ids", nullptr, @@ -79,17 +79,14 @@ int /*eContextResult*/ file_context(const bContext *C, result, &screen->id, &RNA_AssetLibraryReference, &asset_params->asset_library_ref); return CTX_RESULT_OK; } - /** TODO temporary AssetHandle design: For now this returns the file entry. Would be better if it - * was `"selected_assets"` and returned the assets (e.g. as `AssetHandle`) directly. See comment - * for #AssetHandle for more info. */ - if (CTX_data_equals(member, "selected_asset_files")) { + if (CTX_data_equals(member, "selected_assets")) { const int num_files_filtered = filelist_files_ensure(sfile->files); for (int file_index = 0; file_index < num_files_filtered; file_index++) { if (filelist_entry_is_selected(sfile->files, file_index)) { FileDirEntry *entry = filelist_file(sfile->files, file_index); if (entry->asset) { - CTX_data_list_add(result, &screen->id, &RNA_FileSelectEntry, entry); + CTX_data_list_add(result, nullptr, &RNA_AssetRepresentation, entry->asset); } } } diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index 70677d6ed6f..2df601e068e 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -211,13 +211,13 @@ wmDrag *WM_drag_data_create( /* The asset-list case is special: We get multiple assets from context and attach them to the * drag item. */ case WM_DRAG_ASSET_LIST: { - ListBase asset_file_links = CTX_data_collection_get(C, "selected_asset_files"); - LISTBASE_FOREACH (const CollectionPointerLink *, link, &asset_file_links) { - const FileDirEntry *asset_file = static_cast(link->ptr.data); - const AssetHandle asset_handle = {asset_file}; - WM_drag_add_asset_list_item(drag, ED_asset_handle_get_representation(&asset_handle)); + ListBase asset_links = CTX_data_collection_get(C, "selected_assets"); + LISTBASE_FOREACH (const CollectionPointerLink *, link, &asset_links) { + const AssetRepresentationHandle *asset = static_cast( + link->ptr.data); + WM_drag_add_asset_list_item(drag, asset); } - BLI_freelistN(&asset_file_links); + BLI_freelistN(&asset_links); break; } default: