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 13:56:26 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-07-15 17:12:36 +0300
commita26a059244f247a85c48a28dedeb4a551110c793 (patch)
tree2a616854c0863626fef17de19b48303b7b2d35d4 /source/blender/makesrna/intern/rna_asset.c
parentadd6fa09249636cf5709675c9c0ef9a444bb4443 (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/rna_asset.c')
-rw-r--r--source/blender/makesrna/intern/rna_asset.c38
1 files changed, 38 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)