26 "Show assets from all of the listed asset libraries"},
31 "Show the assets currently available in this Blender session"},
36 "Show the basic building blocks and utilities coming with Blender"},
41 "Show assets from the asset libraries configured in the Preferences"},
42 {0,
nullptr, 0,
nullptr,
nullptr},
48# include <fmt/format.h>
68static std::optional<std::string> rna_AssetMetaData_path(
const PointerRNA * )
73static bool rna_AssetMetaData_editable_from_owner_id(
const ID *owner_id,
77 if (owner_id && asset_data && (owner_id->
asset_data == asset_data)) {
83 "Asset metadata from external asset libraries cannot be edited, only assets stored in the "
93 return rna_AssetMetaData_editable_from_owner_id(
ptr->owner_id, asset_data, r_info) ?
98static std::optional<std::string> rna_AssetTag_path(
const PointerRNA *
ptr)
101 char asset_tag_name_esc[
sizeof(asset_tag->
name) * 2];
103 return fmt::format(
"asset_data.tags[\"{}\"]", asset_tag_name_esc);
106static int rna_AssetTag_editable(
const PointerRNA *
ptr,
const char **r_info)
109 ID *owner_id =
ptr->owner_id;
112 "The owner of the asset tag pointer is not the asset ID containing the tag");
116 return rna_AssetMetaData_editable_from_owner_id(
117 ptr->owner_id, owner_id ? owner_id->
asset_data :
nullptr, r_info) ?
122static AssetTag *rna_AssetMetaData_tag_new(
125 const char *disabled_info =
nullptr;
126 if (!rna_AssetMetaData_editable_from_owner_id(
id, asset_data, &disabled_info)) {
133 if (skip_if_exists) {
138 reports,
RPT_WARNING,
"Tag '%s' already present for given asset",
result.tag->name);
150static void rna_AssetMetaData_tag_remove(
ID *
id,
155 const char *disabled_info =
nullptr;
156 if (!rna_AssetMetaData_editable_from_owner_id(
id, asset_data, &disabled_info)) {
177static void rna_AssetMetaData_author_get(
PointerRNA *
ptr,
char *value)
182 strcpy(value, asset_data->
author);
192 return asset_data->
author ? strlen(asset_data->
author) : 0;
195static void rna_AssetMetaData_author_set(
PointerRNA *
ptr,
const char *value)
207 asset_data->
author =
nullptr;
211static void rna_AssetMetaData_description_get(
PointerRNA *
ptr,
char *value)
223static int rna_AssetMetaData_description_length(
PointerRNA *
ptr)
229static void rna_AssetMetaData_description_set(
PointerRNA *
ptr,
const char *value)
245static void rna_AssetMetaData_copyright_get(
PointerRNA *
ptr,
char *value)
257static int rna_AssetMetaData_copyright_length(
PointerRNA *
ptr)
263static void rna_AssetMetaData_copyright_set(
PointerRNA *
ptr,
const char *value)
279static void rna_AssetMetaData_license_get(
PointerRNA *
ptr,
char *value)
284 strcpy(value, asset_data->
license);
297static void rna_AssetMetaData_license_set(
PointerRNA *
ptr,
const char *value)
313static void rna_AssetMetaData_active_tag_range(
318 *
max = *softmax = std::max(
int(asset_data->
tot_tags - 1), 0);
321static void rna_AssetMetaData_catalog_id_get(
PointerRNA *
ptr,
char *value)
327static int rna_AssetMetaData_catalog_id_length(
PointerRNA * )
332static void rna_AssetMetaData_catalog_id_set(
PointerRNA *
ptr,
const char *value)
337 if (value[0] ==
'\0') {
344 printf(
"UUID %s not formatted correctly, ignoring new value\n", value);
358 if (sfile ==
nullptr) {
366 if (asset_library ==
nullptr) {
375static void rna_AssetRepresentation_name_get(
PointerRNA *
ptr,
char *value)
382static int rna_AssetRepresentation_name_length(
PointerRNA *
ptr)
407static int rna_AssetRepresentation_id_type_get(
PointerRNA *
ptr)
419static void rna_AssetRepresentation_full_library_path_get(
PointerRNA *
ptr,
char *value)
423 BLI_strncpy(value, full_library_path.c_str(), full_library_path.size() + 1);
426static int rna_AssetRepresentation_full_library_path_length(
PointerRNA *
ptr)
430 return full_library_path.size();
433static void rna_AssetRepresentation_full_path_get(
PointerRNA *
ptr,
char *value)
436 const std::string full_path = asset->
full_path();
437 BLI_strncpy(value, full_path.c_str(), full_path.size() + 1);
440static int rna_AssetRepresentation_full_path_length(
PointerRNA *
ptr)
443 const std::string full_path = asset->
full_path();
444 return full_path.size();
504 "Do not add a new tag if one of the same type already exists");
540 "rna_AssetMetaData_author_get",
541 "rna_AssetMetaData_author_length",
542 "rna_AssetMetaData_author_set");
548 "rna_AssetMetaData_description_get",
549 "rna_AssetMetaData_description_length",
550 "rna_AssetMetaData_description_set");
552 prop,
"Description",
"A description of the asset to be displayed for the user");
557 "rna_AssetMetaData_copyright_get",
558 "rna_AssetMetaData_copyright_length",
559 "rna_AssetMetaData_copyright_set");
563 "Copyright notice for this asset. An empty copyright notice does not necessarily indicate "
564 "that this is copyright-free. Contact the author if any clarification is needed.");
569 "rna_AssetMetaData_license_get",
570 "rna_AssetMetaData_license_length",
571 "rna_AssetMetaData_license_set");
574 "The type of license this asset is distributed under. An empty license "
575 "name does not necessarily indicate that this is free of licensing "
576 "terms. Contact the author if any clarification is needed.");
583 "Custom tags (name tokens) for the asset, used for filtering and "
584 "general asset management");
593 "rna_AssetMetaData_catalog_id_get",
594 "rna_AssetMetaData_catalog_id_length",
595 "rna_AssetMetaData_catalog_id_set");
600 "Identifier for the asset's catalog, used by Blender to look up the "
601 "asset's catalog path. Must be a UUID according to RFC4122.");
606 "Catalog Simple Name",
607 "Simple name of the asset's catalog, for debugging and "
608 "data recovery purposes");
618 "Asset Representation",
619 "Information about an entity that makes it possible for the asset system "
620 "to deal with the entity as asset");
625 prop,
"rna_AssetRepresentation_name_get",
"rna_AssetRepresentation_name_length",
nullptr);
632 prop,
"rna_AssetRepresentation_metadata_get",
nullptr,
nullptr,
nullptr);
644 "The type of the data-block, if the asset represents one ('NONE' otherwise)");
650 prop,
"rna_AssetRepresentation_local_id_get",
nullptr,
nullptr,
nullptr);
653 "The local data-block this asset represents; only valid if that is a "
654 "data-block in this file");
659 "rna_AssetRepresentation_full_library_path_get",
660 "rna_AssetRepresentation_full_library_path_length",
664 prop,
"Full Library Path",
"Absolute path to the .blend file containing this asset");
669 "rna_AssetRepresentation_full_path_get",
670 "rna_AssetRepresentation_full_path_length",
676 "Absolute path to the .blend file containing this asset extended with the path "
677 "of the asset inside the file");
684 srna,
"Asset Library Reference",
"Identifier to refer to the asset library");
Main runtime representation of an asset.
AssetTag AssetTagEnsureResult BKE_asset_metadata_tag_ensure(AssetMetaData *asset_data, const char *name)
AssetTag * BKE_asset_metadata_tag_add(AssetMetaData *asset_data, const char *name) ATTR_NONNULL(1
void BKE_asset_metadata_catalog_id_clear(AssetMetaData *asset_data)
void BKE_asset_metadata_catalog_id_set(AssetMetaData *asset_data, bUUID catalog_id, const char *catalog_simple_name)
void BKE_asset_metadata_tag_remove(AssetMetaData *asset_data, AssetTag *tag)
SpaceFile * CTX_wm_space_file(const bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_msg(a, msg)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define UNUSED_VARS_NDEBUG(...)
bool BLI_uuid_parse_string(bUUID *uuid, const char *buffer) ATTR_NONNULL()
void BLI_uuid_format(char *buffer, bUUID uuid) ATTR_NONNULL()
#define BLT_I18NCONTEXT_ID_ID
@ ASSET_LIBRARY_ESSENTIALS
blender::asset_system::AssetLibrary * ED_fileselect_active_asset_library_get(const SpaceFile *sfile)
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
void refresh_catalog_simplename(AssetMetaData *asset_data)
std::string full_path() const
AssetMetaData & get_metadata() const
ID_Type get_id_type() const
std::string full_library_path() const
StringRefNull get_name() const
void MEM_freeN(void *vmemh)
const EnumPropertyItem * library_reference_to_rna_enum_itemf(bool include_readonly, bool include_current_file)
const EnumPropertyItem rna_enum_id_type_items[]
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
PointerRNA RNA_id_pointer_create(ID *id)
static void rna_def_asset_data(BlenderRNA *brna)
static void rna_def_asset_tag(BlenderRNA *brna)
static void rna_def_asset_library_reference(BlenderRNA *brna)
const EnumPropertyItem rna_enum_asset_library_type_items[]
static void rna_def_asset_tags_api(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_asset_representation(BlenderRNA *brna)
static void rna_def_asset_weak_reference(BlenderRNA *brna)
void RNA_def_asset(BlenderRNA *brna)
PropertyRNA * rna_def_asset_library_reference_common(StructRNA *srna, const char *get, const char *set)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_define_animate_sdna(bool animate)
void RNA_def_struct_flag(StructRNA *srna, int flag)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
const EnumPropertyItem * rna_asset_library_reference_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
int rna_AssetMetaData_editable(const PointerRNA *ptr, const char **r_info)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
User defined tag. Currently only used by assets, could be used more often at some point....
struct AssetMetaData * asset_data
Universally Unique Identifier according to RFC4122.