diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_context.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_context.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 4079406e64b..70fb10c54b0 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -58,6 +58,8 @@ const EnumPropertyItem rna_enum_context_mode_items[] = { #ifdef RNA_RUNTIME +# include "DNA_asset_types.h" + # ifdef WITH_PYTHON # include "BPY_extern.h" # endif @@ -134,6 +136,22 @@ static PointerRNA rna_Context_gizmo_group_get(PointerRNA *ptr) return newptr; } +static PointerRNA rna_Context_asset_file_handle_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + bool is_handle_valid; + AssetHandle asset_handle = CTX_wm_asset_handle(C, &is_handle_valid); + if (!is_handle_valid) { + return PointerRNA_NULL; + } + + PointerRNA newptr; + /* Have to cast away const, but the file entry API doesn't allow modifications anyway. */ + RNA_pointer_create( + NULL, &RNA_FileSelectEntry, (struct FileDirEntry *)asset_handle.file_data, &newptr); + return newptr; +} + static PointerRNA rna_Context_main_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; @@ -281,6 +299,17 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_struct_type(prop, "GizmoGroup"); RNA_def_property_pointer_funcs(prop, "rna_Context_gizmo_group_get", NULL, NULL, NULL); + /* TODO can't expose AssetHandle, since there is no permanent storage to it (so we can't + * return a pointer). Instead provide the FileDirEntry pointer it wraps. */ + prop = RNA_def_property(srna, "asset_file_handle", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "FileSelectEntry"); + RNA_def_property_pointer_funcs(prop, "rna_Context_asset_file_handle_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, + "", + "The file of an active asset. Avoid using this, it will be replaced by " + "a proper AssetHandle design"); + /* Data */ prop = RNA_def_property(srna, "blend_data", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); |