Asset Browser: Add selected_ids to filebrowser context #104692
@ -50,19 +50,20 @@ static PointerRNAVec asset_operation_get_ids_from_context(const bContext *C)
|
||||
{
|
||||
PointerRNAVec ids;
|
||||
|
||||
ListBase ids_list;
|
||||
/* First check if there is a selected_ids list to use. */
|
||||
if (CTX_data_selected_ids(C, &ids_list)) {
|
||||
LISTBASE_FOREACH (CollectionPointerLink *, link, &ids_list) {
|
||||
ids.append(link->ptr);
|
||||
}
|
||||
BLI_freelistN(&ids_list);
|
||||
return ids;
|
||||
}
|
||||
PointerRNA idptr = CTX_data_pointer_get_type(C, "id", &RNA_ID);
|
||||
if (idptr.data) {
|
||||
/* Single ID. */
|
||||
ids.append(idptr);
|
||||
}
|
||||
else {
|
||||
ListBase list;
|
||||
CTX_data_selected_ids(C, &list);
|
||||
LISTBASE_FOREACH (CollectionPointerLink *, link, &list) {
|
||||
ids.append(link->ptr);
|
||||
}
|
||||
BLI_freelistN(&list);
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
@ -959,6 +959,22 @@ static int /*eContextResult*/ file_context(const bContext *C,
|
||||
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
||||
return CTX_RESULT_OK;
|
||||
}
|
||||
if (CTX_data_equals(member, "selected_ids")) {
|
||||
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);
|
||||
ID *id = filelist_file_get_id(entry);
|
||||
if (id == NULL) {
|
||||
continue;
|
||||
}
|
||||
CTX_data_id_list_add(result, id);
|
||||
}
|
||||
}
|
||||
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
||||
return CTX_RESULT_OK;
|
||||
}
|
||||
if (CTX_data_equals(member, "id")) {
|
||||
const FileDirEntry *file = filelist_file(sfile->files, params->active_file);
|
||||
if (file == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user