Commit: 71adad288b02ae98608693d728843b5917f336e6
Author: Julian Eisel
Date: Wed Oct 27 18:25:29 2021 +0200
Branches: master
https://developer.blender.org/rB71adad288b02ae98608693d728843b5917f336e6
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.
===================================================================
M source/blender/editors/asset/intern/asset_ops.cc
M source/blender/editors/include/ED_fileselect.h
M source/blender/editors/space_file/filesel.c
===================================================================
diff --git a/source/blender/editors/asset/intern/asset_ops.cc
b/source/blender/editors/asset/intern/asset_ops.cc
index 158e877ed7d..d2fd8ab88a4 100644
--- a/source/blender/editors/asset/intern/asset_ops.cc
+++ b/source/blender/editors/asset/intern/asset_ops.cc
@@ -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);
diff --git a/source/blender/editors/include/ED_fileselect.h
b/source/blender/editors/include/ED_fileselect.h
index 48ff742ef3a..68b6e44371c 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -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,
diff --git a/source/blender/editors/space_file/filesel.c
b/source/blender/editors/space_file/filesel.c
index 5299b8ba580..11757975a62 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -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;
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs