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:
authorJulian Eisel <julian@blender.org>2021-07-09 16:50:21 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-07-15 17:12:36 +0300
commit55d48defc50fac7756ccf5b5afbba8f35cf31835 (patch)
tree7cc6d5c561a44c67baf8e0e256fc932e755cbfac /source/blender/makesrna/intern/rna_asset.c
parenta26a059244f247a85c48a28dedeb4a551110c793 (diff)
File/Asset Browser: Extend file-entry and asset handle Python API
Adds the following to `bpy.types.FileSelectEntry`: * `id_type`: The data-block type the file represenets, if any. * `local_id`: The local data-block it represents, if any (assets only). And the following to `bpy.types.AssetHandle`: * `local_id`: The local data-block the asset represents, if any. This kind of information and the references are important for asset related operators and UIs. They will be used by upcoming Pose Library features.
Diffstat (limited to 'source/blender/makesrna/intern/rna_asset.c')
-rw-r--r--source/blender/makesrna/intern/rna_asset.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c
index e0879eb71f9..497f4f37ea3 100644
--- a/source/blender/makesrna/intern/rna_asset.c
+++ b/source/blender/makesrna/intern/rna_asset.c
@@ -143,6 +143,13 @@ static void rna_AssetHandle_get_full_library_path(
ED_asset_handle_get_full_library_path(C, library, &asset, r_result);
}
+static PointerRNA rna_AssetHandle_local_id_get(PointerRNA *ptr)
+{
+ const AssetHandle *asset = ptr->data;
+ ID *id = ED_assetlist_asset_local_id_get(asset);
+ return rna_pointer_inherit_refine(ptr, &RNA_ID, id);
+}
+
static void rna_AssetHandle_file_data_set(PointerRNA *ptr,
PointerRNA value,
struct ReportList *UNUSED(reports))
@@ -344,6 +351,15 @@ static void rna_def_asset_handle(BlenderRNA *brna)
prop, "rna_AssetHandle_file_data_get", "rna_AssetHandle_file_data_set", NULL, NULL);
RNA_def_property_ui_text(prop, "File Entry", "File data used to refer to the asset");
+ prop = RNA_def_property(srna, "local_id", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_pointer_funcs(prop, "rna_AssetHandle_local_id_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop,
+ "",
+ "The local data-block this asset represents; only valid if that is a "
+ "data-block in this file");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+
rna_def_asset_handle_api(srna);
}