diff options
author | Julian Eisel <julian@blender.org> | 2021-07-09 13:56:26 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-07-15 17:12:36 +0300 |
commit | a26a059244f247a85c48a28dedeb4a551110c793 (patch) | |
tree | 2a616854c0863626fef17de19b48303b7b2d35d4 /source/blender/makesrna/intern | |
parent | add6fa09249636cf5709675c9c0ef9a444bb4443 (diff) |
Assets: Initial Asset List as part of the Asset System design
Implements a basic, WIP version of the asset list. This is needed to
give the asset view UI template asset reading and displaying
functionality.
See:
* Asset System: Data Storage, Reading & UI Access - https://developer.blender.org/T88184
Especially the asset list internals should change. It uses the
File/Asset Browser's `FileList` API, which isn't really meant for access
from outside the File Browser. But as explained in T88184, it does a lot
of the stuff we currently need, so we (Sybren Stüvel and I) decided to
go this route for now. Work on a file-list rewrite which integrates well
with the asset system started in the `asset-system-filelist` branch.
Further includes:
* Operator to reload the asset list.
* New `bpy.types.AssetHandle.get_full_library_path()` function, which
gets the full path of the asset via the asset-list.
* Changes to preview loading to prevent the preview loading job to run
eternally for asset views. File Browsers have this issue too, but
should be fixed separately.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_asset.c | 38 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace.c | 1 |
3 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c index 82430d3e174..e0879eb71f9 100644 --- a/source/blender/makesrna/intern/rna_asset.c +++ b/source/blender/makesrna/intern/rna_asset.c @@ -25,6 +25,7 @@ #include "DNA_asset_types.h" #include "DNA_defs.h" +#include "DNA_space_types.h" #include "rna_internal.h" @@ -131,6 +132,17 @@ static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_FileSelectEntry, asset_handle->file_data); } +static void rna_AssetHandle_get_full_library_path( + // AssetHandle *asset, + bContext *C, + FileDirEntry *asset_file, + AssetLibraryReference *library, + char r_result[FILE_MAX_LIBEXTRA]) +{ + AssetHandle asset = {.file_data = asset_file}; + ED_asset_handle_get_full_library_path(C, library, &asset, r_result); +} + static void rna_AssetHandle_file_data_set(PointerRNA *ptr, PointerRNA value, struct ReportList *UNUSED(reports)) @@ -292,6 +304,30 @@ static void rna_def_asset_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active Tag", "Index of the tag set for editing"); } +static void rna_def_asset_handle_api(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func = RNA_def_function(srna, "get_full_library_path", "rna_AssetHandle_get_full_library_path"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + /* TODO temporarily static function, for until .py can receive the asset handle from context + * properly. `asset_file_handle` should go away too then. */ + RNA_def_function_flag(func, FUNC_NO_SELF); + parm = RNA_def_pointer(func, "asset_file_handle", "FileSelectEntry", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, + "asset_library", + "AssetLibraryReference", + "", + "The asset library containing the given asset, only valid if the asset " + "library is external (i.e. not the \"Current File\" one"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_string(func, "result", NULL, FILE_MAX_LIBEXTRA, "result", ""); + RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); + RNA_def_function_output(func, parm); +} + static void rna_def_asset_handle(BlenderRNA *brna) { StructRNA *srna; @@ -307,6 +343,8 @@ static void rna_def_asset_handle(BlenderRNA *brna) RNA_def_property_pointer_funcs( 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"); + + rna_def_asset_handle_api(srna); } static void rna_def_asset_library_reference(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index bcc6e54f4fd..966e3e34b24 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -509,6 +509,7 @@ static const EnumPropertyItem rna_enum_curve_display_handle_items[] = { #ifdef RNA_RUNTIME # include "DNA_anim_types.h" +# include "DNA_asset_types.h" # include "DNA_scene_types.h" # include "DNA_screen_types.h" # include "DNA_userdef_types.h" diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index 15bdeae16b6..b053bb0ff62 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -425,6 +425,7 @@ static void rna_def_workspace(BlenderRNA *brna) "Asset Library", "Active asset library to show in the UI, not used by the Asset Browser " "(which has its own active asset library)"); + RNA_def_property_update(prop, NC_ASSET | ND_ASSET_LIST_READING, NULL); RNA_api_workspace(srna); } |