From 7bffddfa6e877bd6e66cf5641515ebd07267f145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 26 Oct 2021 19:21:22 +0200 Subject: Don't deselect assets in `ED_fileselect_activate_by_id` `ED_fileselect_activate_by_id()` activates an asset (i.e. marks it as the active asset in the asset browser). To avoid an "active but not selected" state, it also selects it. Before this commit, the function would also deselect all other assets, but that's considered doing too much. If deselection is required, the `ED_fileselect_deselect_all()` function can be called. Manifest Task: T92152 --- source/blender/editors/include/ED_fileselect.h | 2 +- source/blender/editors/space_file/filesel.c | 4 +--- source/blender/makesrna/intern/rna_space_api.c | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index 3beabaf2d1d..48ff742ef3a 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -145,7 +145,7 @@ bool ED_fileselect_is_asset_browser(const struct SpaceFile *sfile); struct AssetLibrary *ED_fileselect_active_asset_library_get(const struct SpaceFile *sfile); struct ID *ED_fileselect_active_asset_get(const struct SpaceFile *sfile); -/* Activate the file that corresponds to the given ID. +/* Activate and select the file that corresponds to the given ID. * Pass deferred=true to wait for the next refresh before activating. */ void ED_fileselect_activate_by_id(struct SpaceFile *sfile, struct ID *asset_id, diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 2b4f14451e7..4cd05237138 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -514,14 +514,12 @@ void ED_fileselect_activate_by_id(SpaceFile *sfile, ID *asset_id, const bool def const FileDirEntry *file = filelist_file_ex(files, file_index, false); if (filelist_file_get_id(file) != asset_id) { - filelist_entry_select_set(files, file, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); continue; } params->active_file = file_index; filelist_entry_select_set(files, file, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); - - /* Keep looping to deselect the other files. */ + break; } WM_main_add_notifier(NC_ASSET | NA_ACTIVATED, NULL); diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c index 295ecf590bb..c5569683c9c 100644 --- a/source/blender/makesrna/intern/rna_space_api.c +++ b/source/blender/makesrna/intern/rna_space_api.c @@ -122,7 +122,8 @@ void RNA_api_space_filebrowser(StructRNA *srna) PropertyRNA *parm; func = RNA_def_function(srna, "activate_asset_by_id", "ED_fileselect_activate_by_id"); - RNA_def_function_ui_description(func, "Activate the asset entry that represents the given ID"); + RNA_def_function_ui_description( + func, "Activate and select the asset entry that represents the given ID"); parm = RNA_def_property(func, "id_to_activate", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(parm, "ID"); -- cgit v1.2.3