Asset Browser: Activate catalog after adding
Adding a catalog should also activate it, like we do it for adding other data in Blender. The tree-view code will make sure the newly added item will not have collapsed parents.
This commit is contained in:
parent
bca9ec767c
commit
71adad288b
|
@ -427,7 +427,12 @@ static int asset_catalog_new_exec(bContext *C, wmOperator *op)
|
|||
struct AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
char *parent_path = RNA_string_get_alloc(op->ptr, "parent_path", nullptr, 0, nullptr);
|
||||
|
||||
ED_asset_catalog_add(asset_library, "Catalog", parent_path);
|
||||
blender::bke::AssetCatalog *new_catalog = ED_asset_catalog_add(
|
||||
asset_library, "Catalog", parent_path);
|
||||
|
||||
if (sfile) {
|
||||
ED_fileselect_activate_asset_catalog(sfile, new_catalog->catalog_id);
|
||||
}
|
||||
|
||||
MEM_freeN(parent_path);
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "DNA_uuid_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -145,6 +147,8 @@ 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);
|
||||
|
||||
void ED_fileselect_activate_asset_catalog(const struct SpaceFile *sfile, bUUID catalog_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,
|
||||
|
|
|
@ -483,6 +483,18 @@ struct ID *ED_fileselect_active_asset_get(const SpaceFile *sfile)
|
|||
return filelist_file_get_id(file);
|
||||
}
|
||||
|
||||
void ED_fileselect_activate_asset_catalog(const SpaceFile *sfile, const bUUID catalog_id)
|
||||
{
|
||||
if (!ED_fileselect_is_asset_browser(sfile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileAssetSelectParams *params = ED_fileselect_get_asset_params(sfile);
|
||||
params->asset_catalog_visibility = FILE_SHOW_ASSETS_FROM_CATALOG;
|
||||
params->catalog_id = catalog_id;
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, NULL);
|
||||
}
|
||||
|
||||
static void on_reload_activate_by_id(SpaceFile *sfile, onReloadFnData custom_data)
|
||||
{
|
||||
ID *asset_id = (ID *)custom_data;
|
||||
|
|
Loading…
Reference in New Issue