mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
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.
This commit is contained in:
parent
f73adee453
commit
ca58f97cda
2 changed files with 9 additions and 12 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<const FileDirEntry *>(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<const AssetRepresentationHandle *>(
|
||||
link->ptr.data);
|
||||
WM_drag_add_asset_list_item(drag, asset);
|
||||
}
|
||||
BLI_freelistN(&asset_file_links);
|
||||
BLI_freelistN(&asset_links);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue