Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/context.c')
-rw-r--r--source/blender/blenkernel/intern/context.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 1028790856c..dced945bea0 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1448,6 +1448,36 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
return ctx_data_collection_get(C, "editable_gpencil_strokes", list);
}
+const AssetLibraryReference *CTX_wm_asset_library(const bContext *C)
+{
+ return ctx_data_pointer_get(C, "asset_library");
+}
+
+AssetHandle CTX_wm_asset_handle(const bContext *C, bool *r_is_valid)
+{
+ AssetHandle *asset_handle_p =
+ (AssetHandle *)CTX_data_pointer_get_type(C, "asset_handle", &RNA_AssetHandle).data;
+ if (asset_handle_p) {
+ *r_is_valid = true;
+ return *asset_handle_p;
+ }
+
+ /* If the asset handle was not found in context directly, try if there's an active file with
+ * asset data there instead. Not nice to have this here, would be better to have this in
+ * `ED_asset.h`, but we can't include that in BKE. Even better would be not needing this at all
+ * and being able to have editors return this in the usual `context` callback. But that would
+ * require returning a non-owning pointer, which we don't have in the Asset Browser (yet). */
+ FileDirEntry *file =
+ (FileDirEntry *)CTX_data_pointer_get_type(C, "active_file", &RNA_FileSelectEntry).data;
+ if (file && file->asset_data) {
+ *r_is_valid = true;
+ return (AssetHandle){.file_data = file};
+ }
+
+ *r_is_valid = false;
+ return (AssetHandle){0};
+}
+
Depsgraph *CTX_data_depsgraph_pointer(const bContext *C)
{
Main *bmain = CTX_data_main(C);