[Bf-blender-cvs] [9f61207] asset-engine: Minor updates to asset engine API, and add some more basic file listing stuff to RNA.

Bastien Montagne noreply at git.blender.org
Thu Mar 5 10:10:44 CET 2015


Commit: 9f61207b23b5c1fe2289ed321d01e66be343ce9c
Author: Bastien Montagne
Date:   Thu Feb 19 16:32:56 2015 +0100
Branches: asset-engine
https://developer.blender.org/rB9f61207b23b5c1fe2289ed321d01e66be343ce9c

Minor updates to asset engine API, and add some more basic file listing stuff to RNA.

===================================================================

M	source/blender/blenkernel/BKE_asset.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_asset.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_asset.h b/source/blender/blenkernel/BKE_asset.h
index 1c69efc..34255a4 100644
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@ -38,11 +38,13 @@ extern "C" {
 
 struct AssetEngine;
 struct AssetEngineType;
-struct direntry;
+struct FileDirEntryArr;
 struct ExtensionRNA;
 struct ListBase;
 struct uiLayout;
 
+#include "DNA_space_types.h"
+
 #if 0
 #include "DNA_scene_types.h"
 #include "RE_bake.h"
@@ -107,27 +109,25 @@ typedef float (*ae_progress)(struct AssetEngine *engine, const int job_id);
  */
 
 /* Return (list) everything available at given root path. */
-typedef int (*ae_list_dir)(struct AssetEngine *engine, const int id, const char *root_path, struct direntry **entries_r);
+typedef int (*ae_list_dir)(struct AssetEngine *engine, const int id, struct FileDirEntryArr *entries_r);
 /* Ensure given direntries are really available for append/link (some kind of 'anticipated loading'...). */
-typedef int (*ae_ensure_entries)(struct AssetEngine *engine, const int id, struct direntry *entries);
+typedef int (*ae_ensure_entries)(struct AssetEngine *engine, const int id, char *uuids[ASSET_UUID_LENGTH], const int nbr_uuids);
 
 /* ***** All callbacks below are blocking. They shall be completed upon return. ***** */
 
 /* 'pre-loading' hook, called before opening/appending/linking given entries.
  * E.g. allows the engine to ensure entries' paths are actually valid by downloading requested data, etc.
- * Note it is also allowed to change that list, add/remove items, etc. This allows to present 'fake' entries to user,
- * and then import actual data.
+ * Note that the generated list shall be simpler than the one generated by ae_list_dir, since only the path from
+ * active revision is used, no need to bother with variants, previews, etc.
+ * This allows to present 'fake' entries to user, and then import actual data.
  */
-typedef bool (*ae_load_pre)(struct AssetEngine *engine, struct direntry *entries, int *num_entries);
+typedef bool (*ae_load_pre)(struct AssetEngine *engine, char *uuids[ASSET_UUID_LENGTH], const int nbr_uuids,
+                            struct FileDirEntryArr *entries_r);
 
 /* 'post-loading' hook, called after opening/appending/linking given entries.
  * E.g. allows an advanced engine to make fancy scripted operations over loaded items. */
 typedef bool (*ae_load_post)(struct AssetEngine *engine, struct ID *items, const int *num_items);
 
-/* Draw callback for the engine's panel. */
-typedef bool (*ae_draw_panel)(struct AssetEngine *engine, struct uiLayout *layout);
-
-
 typedef struct AssetEngineType {
 	struct AssetEngineType *next, *prev;
 
@@ -146,8 +146,6 @@ typedef struct AssetEngineType {
 	ae_load_pre load_pre;
 	ae_load_post load_post;
 
-	ae_draw_panel draw_panel;
-
 	/* RNA integration */
 	struct ExtensionRNA ext;
 } AssetEngineType;
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index bccdaef..e790c12 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -731,7 +731,7 @@ typedef enum eFileSel_File_Types {
 	FILE_TYPE_OPERATOR          = (1 << 14), /* from filter_glob operator property */
 	FILE_TYPE_APPLICATIONBUNDLE = (1 << 15),
 
-	FILE_TYPE_DIR               = (1 << 30),  /* An FS directory (i.e. S_ISDIR on its path is true). */
+	FILE_TYPE_DIR               = (1 << 30),  /* A directory. */
 	FILE_TYPE_BLENDERLIB        = (1 << 31),
 } eFileSel_File_Types;
 
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c
index 6c38b30..69e7da6 100644
--- a/source/blender/makesrna/intern/rna_asset.c
+++ b/source/blender/makesrna/intern/rna_asset.c
@@ -355,6 +355,26 @@ static void rna_def_asset_revision(BlenderRNA *brna)
 	PropertyRNA *prop;
 //	FunctionRNA *func;
 
+	EnumPropertyItem asset_revision_types[] = {
+	    {FILE_TYPE_BLENDER, "BLENDER", 0, "Blender File", ""},
+//	    {FILE_TYPE_BLENDER_BACKUP, "", 0, "", ""},
+	    {FILE_TYPE_IMAGE, "IMAGE", 0, "Image", ""},
+	    {FILE_TYPE_MOVIE, "MOVIE", 0, "Movie", ""},
+	    {FILE_TYPE_PYSCRIPT, "PYSCRIPT", 0, "Python Script", ""},
+	    {FILE_TYPE_FTFONT, "FONT", 0, "Font", ""},
+	    {FILE_TYPE_SOUND, "SOUND", 0, "Sound", ""},
+	    {FILE_TYPE_TEXT, "TEXT", 0, "Text", ""},
+//	    {FILE_TYPE_MOVIE_ICON, "", 0, "", ""},
+//	    {FILE_TYPE_FOLDER, "", 0, "", ""},
+//	    {FILE_TYPE_BTX, "", 0, "", ""},
+//	    {FILE_TYPE_COLLADA, "", 0, "", ""},
+//	    {FILE_TYPE_OPERATOR, "", 0, "", ""},
+//	    {FILE_TYPE_APPLICATIONBUNDLE, "", 0, "", ""},
+	    {FILE_TYPE_DIR, "DIR", 0, "Directory", "An entry that can be used as 'root' path too"},
+	    {FILE_TYPE_BLENDERLIB, "BLENLIB", 0, "Blender Library", "An entry that is part of a .blend file"},
+	    {0, NULL, 0, NULL, NULL}
+	};
+
 	srna = RNA_def_struct(brna, "AssetRevision", NULL);
 	RNA_def_struct_sdna(srna, "FileDirEntryRevision");
 	RNA_def_struct_ui_text(srna, "Asset Entry Revision", "A revision of a single asset item");
@@ -364,7 +384,19 @@ static void rna_def_asset_revision(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Revision UUID",
 	                         "Unique identifier of this revision (actual content depends on asset engine)");
 
-	/* TODO: all direntry items (through accessors even!) */
+	prop = RNA_def_property(srna, "relpath", PROP_STRING, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Relative Path", "Relative AssetList's root_path");
+
+	prop = RNA_def_property(srna, "abspath", PROP_STRING, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Absolute Path", "");
+
+	prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_bitflag_sdna(prop, NULL, "typeflag");
+	RNA_def_property_enum_items(prop, asset_revision_types);
+
+	/* TODO: size, time, etc. */
+
+	/* TODO: image (i.e. preview)? */
 }
 
 static void rna_def_asset_variant(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list