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_space.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_space.c')
-rw-r--r--source/blender/makesrna/intern/rna_space.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 966e3e34b24..f934b1400ee 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2694,6 +2694,32 @@ static int rna_FileBrowser_FileSelectEntry_name_length(PointerRNA *ptr)
return (int)strlen(entry->name);
}
+static const EnumPropertyItem *rna_FileBrowser_FileSelectEntry_id_type_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+{
+ const FileDirEntry *entry = ptr->data;
+ if (entry->blentype == 0) {
+ const static EnumPropertyItem none_items[] = {
+ {0, "NONE", 0, "None", ""},
+ };
+ return none_items;
+ }
+
+ return rna_enum_id_type_items;
+}
+
+static int rna_FileBrowser_FileSelectEntry_id_type_get(PointerRNA *ptr)
+{
+ const FileDirEntry *entry = ptr->data;
+ return entry->blentype;
+}
+
+static PointerRNA rna_FileBrowser_FileSelectEntry_local_id_get(PointerRNA *ptr)
+{
+ const FileDirEntry *entry = ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_ID, entry->id);
+}
+
static int rna_FileBrowser_FileSelectEntry_preview_icon_id_get(PointerRNA *ptr)
{
const FileDirEntry *entry = ptr->data;
@@ -6306,6 +6332,28 @@ static void rna_def_fileselect_entry(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_struct_name_property(srna, prop);
+ prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_id_type_items);
+ RNA_def_property_enum_funcs(prop,
+ "rna_FileBrowser_FileSelectEntry_id_type_get",
+ NULL,
+ "rna_FileBrowser_FileSelectEntry_id_type_itemf");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(
+ prop,
+ "Data-block Type",
+ "The type of the data-block, if the file represents one ('NONE' otherwise)");
+
+ 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_FileBrowser_FileSelectEntry_local_id_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop,
+ "",
+ "The local data-block this file represents; only valid if that is a "
+ "data-block in this file");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+
prop = RNA_def_int(
srna,
"preview_icon_id",