Blender V5.0
rna_asset.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "BLT_translation.hh"
12
13#include "RNA_define.hh"
14#include "RNA_enum_types.hh"
15
16#include "DNA_asset_types.h"
17#include "DNA_defs.h"
18
19#include "rna_internal.hh"
20
23 "ALL",
24 0,
25 "All Libraries",
26 "Show assets from all of the listed asset libraries"},
28 "LOCAL",
29 0,
30 "Current File",
31 "Show the assets currently available in this Blender session"},
33 "ESSENTIALS",
34 0,
35 "Essentials",
36 "Show the basic building blocks and utilities coming with Blender"},
38 "CUSTOM",
39 0,
40 "Custom",
41 "Show assets from the asset libraries configured in the Preferences"},
42 {0, nullptr, 0, nullptr, nullptr},
43};
44
45#ifdef RNA_RUNTIME
46
47# include <algorithm>
48# include <fmt/format.h>
49
50# include "AS_asset_library.hh"
52
53# include "BKE_asset.hh"
54# include "BKE_context.hh"
55# include "BKE_report.hh"
56
57# include "BLI_listbase.h"
58# include "BLI_string.h"
59# include "BLI_uuid.h"
60
61# include "ED_asset.hh"
62# include "ED_fileselect.hh"
63
64# include "RNA_access.hh"
65
66using namespace blender::asset_system;
67
68static std::optional<std::string> rna_AssetMetaData_path(const PointerRNA * /*ptr*/)
69{
70 return "asset_data";
71}
72
73static bool rna_AssetMetaData_editable_from_owner_id(const ID *owner_id,
74 const AssetMetaData *asset_data,
75 const char **r_info)
76{
77 if (owner_id && asset_data && (owner_id->asset_data == asset_data)) {
78 return true;
79 }
80
81 if (r_info) {
82 *r_info = N_(
83 "Asset metadata from external asset libraries cannot be edited, only assets stored in the "
84 "current file can");
85 }
86 return false;
87}
88
89int rna_AssetMetaData_editable(const PointerRNA *ptr, const char **r_info)
90{
91 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
92
93 return rna_AssetMetaData_editable_from_owner_id(ptr->owner_id, asset_data, r_info) ?
95 PropertyFlag(0);
96}
97
98static std::optional<std::string> rna_AssetTag_path(const PointerRNA *ptr)
99{
100 const AssetTag *asset_tag = static_cast<const AssetTag *>(ptr->data);
101 char asset_tag_name_esc[sizeof(asset_tag->name) * 2];
102 BLI_str_escape(asset_tag_name_esc, asset_tag->name, sizeof(asset_tag_name_esc));
103 return fmt::format("asset_data.tags[\"{}\"]", asset_tag_name_esc);
104}
105
106static int rna_AssetTag_editable(const PointerRNA *ptr, const char **r_info)
107{
108 AssetTag *asset_tag = static_cast<AssetTag *>(ptr->data);
109 ID *owner_id = ptr->owner_id;
110 if (owner_id && owner_id->asset_data) {
111 BLI_assert_msg(BLI_findindex(&owner_id->asset_data->tags, asset_tag) != -1,
112 "The owner of the asset tag pointer is not the asset ID containing the tag");
113 UNUSED_VARS_NDEBUG(asset_tag);
114 }
115
116 return rna_AssetMetaData_editable_from_owner_id(
117 ptr->owner_id, owner_id ? owner_id->asset_data : nullptr, r_info) ?
119 PropertyFlag(0);
120}
121
122static AssetTag *rna_AssetMetaData_tag_new(
123 ID *id, AssetMetaData *asset_data, ReportList *reports, const char *name, bool skip_if_exists)
124{
125 const char *disabled_info = nullptr;
126 if (!rna_AssetMetaData_editable_from_owner_id(id, asset_data, &disabled_info)) {
127 BKE_report(reports, RPT_WARNING, disabled_info);
128 return nullptr;
129 }
130
131 AssetTag *tag = nullptr;
132
133 if (skip_if_exists) {
135
136 if (!result.is_new) {
138 reports, RPT_WARNING, "Tag '%s' already present for given asset", result.tag->name);
139 /* Report, but still return valid item. */
140 }
141 tag = result.tag;
142 }
143 else {
144 tag = BKE_asset_metadata_tag_add(asset_data, name);
145 }
146
147 return tag;
148}
149
150static void rna_AssetMetaData_tag_remove(ID *id,
151 AssetMetaData *asset_data,
152 ReportList *reports,
153 PointerRNA *tag_ptr)
154{
155 const char *disabled_info = nullptr;
156 if (!rna_AssetMetaData_editable_from_owner_id(id, asset_data, &disabled_info)) {
157 BKE_report(reports, RPT_WARNING, disabled_info);
158 return;
159 }
160
161 AssetTag *tag = static_cast<AssetTag *>(tag_ptr->data);
162 if (BLI_findindex(&asset_data->tags, tag) == -1) {
163 BKE_reportf(reports, RPT_ERROR, "Tag '%s' not found in given asset", tag->name);
164 return;
165 }
166
167 BKE_asset_metadata_tag_remove(asset_data, tag);
168 tag_ptr->invalidate();
169}
170
171static IDProperty **rna_AssetMetaData_idprops(PointerRNA *ptr)
172{
173 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
174 return &asset_data->properties;
175}
176
177static void rna_AssetMetaData_author_get(PointerRNA *ptr, char *value)
178{
179 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
180
181 if (asset_data->author) {
182 strcpy(value, asset_data->author);
183 }
184 else {
185 value[0] = '\0';
186 }
187}
188
189static int rna_AssetMetaData_author_length(PointerRNA *ptr)
190{
191 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
192 return asset_data->author ? strlen(asset_data->author) : 0;
193}
194
195static void rna_AssetMetaData_author_set(PointerRNA *ptr, const char *value)
196{
197 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
198
199 if (asset_data->author) {
200 MEM_freeN(asset_data->author);
201 }
202
203 if (value[0]) {
204 asset_data->author = BLI_strdup(value);
205 }
206 else {
207 asset_data->author = nullptr;
208 }
209}
210
211static void rna_AssetMetaData_description_get(PointerRNA *ptr, char *value)
212{
213 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
214
215 if (asset_data->description) {
216 strcpy(value, asset_data->description);
217 }
218 else {
219 value[0] = '\0';
220 }
221}
222
223static int rna_AssetMetaData_description_length(PointerRNA *ptr)
224{
225 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
226 return asset_data->description ? strlen(asset_data->description) : 0;
227}
228
229static void rna_AssetMetaData_description_set(PointerRNA *ptr, const char *value)
230{
231 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
232
233 if (asset_data->description) {
234 MEM_freeN(asset_data->description);
235 }
236
237 if (value[0]) {
238 asset_data->description = BLI_strdup(value);
239 }
240 else {
241 asset_data->description = nullptr;
242 }
243}
244
245static void rna_AssetMetaData_copyright_get(PointerRNA *ptr, char *value)
246{
247 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
248
249 if (asset_data->copyright) {
250 strcpy(value, asset_data->copyright);
251 }
252 else {
253 value[0] = '\0';
254 }
255}
256
257static int rna_AssetMetaData_copyright_length(PointerRNA *ptr)
258{
259 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
260 return asset_data->copyright ? strlen(asset_data->copyright) : 0;
261}
262
263static void rna_AssetMetaData_copyright_set(PointerRNA *ptr, const char *value)
264{
265 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
266
267 if (asset_data->copyright) {
268 MEM_freeN(asset_data->copyright);
269 }
270
271 if (value[0]) {
272 asset_data->copyright = BLI_strdup(value);
273 }
274 else {
275 asset_data->copyright = nullptr;
276 }
277}
278
279static void rna_AssetMetaData_license_get(PointerRNA *ptr, char *value)
280{
281 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
282
283 if (asset_data->license) {
284 strcpy(value, asset_data->license);
285 }
286 else {
287 value[0] = '\0';
288 }
289}
290
291static int rna_AssetMetaData_license_length(PointerRNA *ptr)
292{
293 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
294 return asset_data->license ? strlen(asset_data->license) : 0;
295}
296
297static void rna_AssetMetaData_license_set(PointerRNA *ptr, const char *value)
298{
299 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
300
301 if (asset_data->license) {
302 MEM_freeN(asset_data->license);
303 }
304
305 if (value[0]) {
306 asset_data->license = BLI_strdup(value);
307 }
308 else {
309 asset_data->license = nullptr;
310 }
311}
312
313static void rna_AssetMetaData_active_tag_range(
314 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
315{
316 const AssetMetaData *asset_data = static_cast<const AssetMetaData *>(ptr->data);
317 *min = *softmin = 0;
318 *max = *softmax = std::max(int(asset_data->tot_tags - 1), 0);
319}
320
321static void rna_AssetMetaData_catalog_id_get(PointerRNA *ptr, char *value)
322{
323 const AssetMetaData *asset_data = static_cast<const AssetMetaData *>(ptr->data);
324 BLI_uuid_format(value, asset_data->catalog_id);
325}
326
327static int rna_AssetMetaData_catalog_id_length(PointerRNA * /*ptr*/)
328{
329 return UUID_STRING_SIZE - 1;
330}
331
332static void rna_AssetMetaData_catalog_id_set(PointerRNA *ptr, const char *value)
333{
334 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
335 bUUID new_uuid;
336
337 if (value[0] == '\0') {
339 return;
340 }
341
342 if (!BLI_uuid_parse_string(&new_uuid, value)) {
343 /* TODO(@sybren): raise ValueError exception once that's possible from an RNA setter. */
344 printf("UUID %s not formatted correctly, ignoring new value\n", value);
345 return;
346 }
347
348 /* This just sets the new UUID and clears the catalog simple name. The actual
349 * catalog simple name will be updated by some update function, as it
350 * needs the asset library from the context. */
351 /* TODO(Sybren): write that update function. */
352 BKE_asset_metadata_catalog_id_set(asset_data, new_uuid, "");
353}
354
355void rna_AssetMetaData_catalog_id_update(bContext *C, PointerRNA *ptr)
356{
357 SpaceFile *sfile = CTX_wm_space_file(C);
358 if (sfile == nullptr) {
359 /* Until there is a proper Asset Service available, it's only possible to get the asset library
360 * from within the asset browser context. */
361 return;
362 }
363
365 sfile);
366 if (asset_library == nullptr) {
367 /* The SpaceFile may not be an asset browser but a regular file browser. */
368 return;
369 }
370
371 AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
372 asset_library->refresh_catalog_simplename(asset_data);
373}
374
375static void rna_AssetRepresentation_name_get(PointerRNA *ptr, char *value)
376{
377 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
378 const blender::StringRefNull name = asset->get_name();
379 BLI_strncpy(value, name.c_str(), name.size() + 1);
380}
381
382static int rna_AssetRepresentation_name_length(PointerRNA *ptr)
383{
384 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
385 const blender::StringRefNull name = asset->get_name();
386 return name.size();
387}
388
389static PointerRNA rna_AssetRepresentation_metadata_get(PointerRNA *ptr)
390{
391 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
392
393 AssetMetaData &asset_data = asset->get_metadata();
394
395 /* Note that for local ID assets, the asset metadata is owned by the ID. Let the pointer inherit
396 * accordingly, so that the #PointerRNA.owner_id is set to the ID, and the metadata can be
397 * recognized as editable. */
398
399 if (asset->is_local_id()) {
400 PointerRNA id_ptr = RNA_id_pointer_create(asset->local_id());
401 return RNA_pointer_create_with_parent(id_ptr, &RNA_AssetMetaData, &asset_data);
402 }
403
404 return RNA_pointer_create_with_parent(*ptr, &RNA_AssetMetaData, &asset_data);
405}
406
407static int rna_AssetRepresentation_id_type_get(PointerRNA *ptr)
408{
409 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
410 return asset->get_id_type();
411}
412
413static PointerRNA rna_AssetRepresentation_local_id_get(PointerRNA *ptr)
414{
415 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
416 return RNA_id_pointer_create(asset->local_id());
417}
418
419static void rna_AssetRepresentation_full_library_path_get(PointerRNA *ptr, char *value)
420{
421 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
422 const std::string full_library_path = asset->full_library_path();
423 BLI_strncpy(value, full_library_path.c_str(), full_library_path.size() + 1);
424}
425
426static int rna_AssetRepresentation_full_library_path_length(PointerRNA *ptr)
427{
428 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
429 const std::string full_library_path = asset->full_library_path();
430 return full_library_path.size();
431}
432
433static void rna_AssetRepresentation_full_path_get(PointerRNA *ptr, char *value)
434{
435 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
436 const std::string full_path = asset->full_path();
437 BLI_strncpy(value, full_path.c_str(), full_path.size() + 1);
438}
439
440static int rna_AssetRepresentation_full_path_length(PointerRNA *ptr)
441{
442 const AssetRepresentation *asset = static_cast<const AssetRepresentation *>(ptr->data);
443 const std::string full_path = asset->full_path();
444 return full_path.size();
445}
446
448 PointerRNA * /*ptr*/,
449 PropertyRNA * /*prop*/,
450 bool *r_free)
451{
453 /* Include all valid libraries for the user to choose from. */
454 /*include_readonly=*/true,
455 /*include_current_file=*/true);
456 if (!items) {
457 *r_free = false;
459 }
460 *r_free = true;
461 return items;
462}
463
464#else
465
467{
468 StructRNA *srna;
469 PropertyRNA *prop;
470
471 srna = RNA_def_struct(brna, "AssetTag", nullptr);
472 RNA_def_struct_path_func(srna, "rna_AssetTag_path");
473 RNA_def_struct_ui_text(srna, "Asset Tag", "User defined tag (name token)");
474
475 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
476 RNA_def_property_editable_func(prop, "rna_AssetTag_editable");
478 RNA_def_property_ui_text(prop, "Name", "The identifier that makes up this tag");
480}
481
483{
484 StructRNA *srna;
485
486 FunctionRNA *func;
487 PropertyRNA *parm;
488
489 RNA_def_property_srna(cprop, "AssetTags");
490 srna = RNA_def_struct(brna, "AssetTags", nullptr);
491 RNA_def_struct_sdna(srna, "AssetMetaData");
492 RNA_def_struct_ui_text(srna, "Asset Tags", "Collection of custom asset tags");
493
494 /* Tag collection */
495 func = RNA_def_function(srna, "new", "rna_AssetMetaData_tag_new");
496 RNA_def_function_ui_description(func, "Add a new tag to this asset");
498 parm = RNA_def_string(func, "name", nullptr, MAX_NAME, "Name", "");
500 parm = RNA_def_boolean(func,
501 "skip_if_exists",
502 false,
503 "Skip if Exists",
504 "Do not add a new tag if one of the same type already exists");
505 /* return type */
506 parm = RNA_def_pointer(func, "tag", "AssetTag", "", "New tag");
507 RNA_def_function_return(func, parm);
508
509 func = RNA_def_function(srna, "remove", "rna_AssetMetaData_tag_remove");
510 RNA_def_function_ui_description(func, "Remove an existing tag from this asset");
512 /* tag to remove */
513 parm = RNA_def_pointer(func, "tag", "AssetTag", "", "Removed tag");
516}
517
519{
520 StructRNA *srna;
521 PropertyRNA *prop;
522
523 srna = RNA_def_struct(brna, "AssetMetaData", nullptr);
524 RNA_def_struct_path_func(srna, "rna_AssetMetaData_path");
525 RNA_def_struct_ui_text(srna, "Asset Data", "Additional data stored for an asset data-block");
526 // RNA_def_struct_ui_icon(srna, ICON_ASSET); /* TODO: Icon doesn't exist! */
527 /* The struct has custom properties, but no pointer properties to other IDs! */
528 /* FIXME: These need to remain 'user-defined' properties for now, as they are _not_ accessible
529 * through RNA system.
530 * Current situation is not great, as these idprops are technically system-defined (users have no
531 * access/control over them), yet they behave as user-defined ones.
532 * Ultimately it's a similar issue as with the 'Node Modifier' - though not sure the same
533 * solution (actually using RNA access to them) would be desired here?. */
534 RNA_def_struct_idprops_func(srna, "rna_AssetMetaData_idprops");
536
537 prop = RNA_def_property(srna, "author", PROP_STRING, PROP_NONE);
538 RNA_def_property_editable_func(prop, "rna_AssetMetaData_editable");
540 "rna_AssetMetaData_author_get",
541 "rna_AssetMetaData_author_length",
542 "rna_AssetMetaData_author_set");
543 RNA_def_property_ui_text(prop, "Author", "Name of the creator of the asset");
544
545 prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
546 RNA_def_property_editable_func(prop, "rna_AssetMetaData_editable");
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");
553
554 prop = RNA_def_property(srna, "copyright", PROP_STRING, PROP_NONE);
555 RNA_def_property_editable_func(prop, "rna_AssetMetaData_editable");
557 "rna_AssetMetaData_copyright_get",
558 "rna_AssetMetaData_copyright_length",
559 "rna_AssetMetaData_copyright_set");
561 prop,
562 "Copyright",
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.");
565
566 prop = RNA_def_property(srna, "license", PROP_STRING, PROP_NONE);
567 RNA_def_property_editable_func(prop, "rna_AssetMetaData_editable");
569 "rna_AssetMetaData_license_get",
570 "rna_AssetMetaData_license_length",
571 "rna_AssetMetaData_license_set");
573 "License",
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.");
577
578 prop = RNA_def_property(srna, "tags", PROP_COLLECTION, PROP_NONE);
579 RNA_def_property_struct_type(prop, "AssetTag");
580 RNA_def_property_editable_func(prop, "rna_AssetMetaData_editable");
582 "Tags",
583 "Custom tags (name tokens) for the asset, used for filtering and "
584 "general asset management");
585 rna_def_asset_tags_api(brna, prop);
586
587 prop = RNA_def_property(srna, "active_tag", PROP_INT, PROP_NONE);
588 RNA_def_property_int_funcs(prop, nullptr, nullptr, "rna_AssetMetaData_active_tag_range");
589 RNA_def_property_ui_text(prop, "Active Tag", "Index of the tag set for editing");
590
591 prop = RNA_def_property(srna, "catalog_id", PROP_STRING, PROP_NONE);
593 "rna_AssetMetaData_catalog_id_get",
594 "rna_AssetMetaData_catalog_id_length",
595 "rna_AssetMetaData_catalog_id_set");
597 RNA_def_property_update(prop, 0, "rna_AssetMetaData_catalog_id_update");
599 "Catalog UUID",
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.");
602
603 prop = RNA_def_property(srna, "catalog_simple_name", PROP_STRING, PROP_NONE);
606 "Catalog Simple Name",
607 "Simple name of the asset's catalog, for debugging and "
608 "data recovery purposes");
609}
610
612{
613 StructRNA *srna;
614 PropertyRNA *prop;
615
616 srna = RNA_def_struct(brna, "AssetRepresentation", nullptr);
618 "Asset Representation",
619 "Information about an entity that makes it possible for the asset system "
620 "to deal with the entity as asset");
621
622 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_FILENAME);
625 prop, "rna_AssetRepresentation_name_get", "rna_AssetRepresentation_name_length", nullptr);
626 RNA_def_property_ui_text(prop, "Name", "");
628
629 prop = RNA_def_property(srna, "metadata", PROP_POINTER, PROP_NONE);
630 RNA_def_property_struct_type(prop, "AssetMetaData");
632 prop, "rna_AssetRepresentation_metadata_get", nullptr, nullptr, nullptr);
633 RNA_def_property_ui_text(prop, "Asset Metadata", "Additional information about the asset");
634
635 prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
637 RNA_def_property_enum_funcs(prop, "rna_AssetRepresentation_id_type_get", nullptr, nullptr);
640 prop,
641 "Data-block Type",
642 /* Won't ever actually return 'NONE' currently, this is just for information for once non-ID
643 * assets are supported. */
644 "The type of the data-block, if the asset represents one ('NONE' otherwise)");
646
647 prop = RNA_def_property(srna, "local_id", PROP_POINTER, PROP_NONE);
650 prop, "rna_AssetRepresentation_local_id_get", nullptr, nullptr, nullptr);
652 "",
653 "The local data-block this asset represents; only valid if that is a "
654 "data-block in this file");
655
656 prop = RNA_def_property(srna, "full_library_path", PROP_STRING, PROP_FILENAME);
659 "rna_AssetRepresentation_full_library_path_get",
660 "rna_AssetRepresentation_full_library_path_length",
661 nullptr);
662
664 prop, "Full Library Path", "Absolute path to the .blend file containing this asset");
665
666 prop = RNA_def_property(srna, "full_path", PROP_STRING, PROP_FILENAME);
669 "rna_AssetRepresentation_full_path_get",
670 "rna_AssetRepresentation_full_path_length",
671 nullptr);
672
674 prop,
675 "Full Path",
676 "Absolute path to the .blend file containing this asset extended with the path "
677 "of the asset inside the file");
678}
679
681{
682 StructRNA *srna = RNA_def_struct(brna, "AssetLibraryReference", nullptr);
684 srna, "Asset Library Reference", "Identifier to refer to the asset library");
685}
686
688 const char *get,
689 const char *set)
690{
691 PropertyRNA *prop = RNA_def_property(srna, "asset_library_reference", PROP_ENUM, PROP_NONE);
693 RNA_def_property_enum_funcs(prop, get, set, "rna_asset_library_reference_itemf");
694
695 return prop;
696}
697
699{
700 StructRNA *srna;
701 PropertyRNA *prop;
702
703 srna = RNA_def_struct(brna, "AssetWeakReference", nullptr);
704 RNA_def_struct_ui_text(srna, "Asset Weak Reference", "Weak reference to some asset");
705
706 prop = RNA_def_property(srna, "asset_library_type", PROP_ENUM, PROP_NONE);
709
710 prop = RNA_def_property(srna, "asset_library_identifier", PROP_STRING, PROP_NONE);
712
713 prop = RNA_def_property(srna, "relative_asset_identifier", PROP_STRING, PROP_NONE);
715}
716
729
730#endif
Main runtime representation of an asset.
AssetTag AssetTagEnsureResult BKE_asset_metadata_tag_ensure(AssetMetaData *asset_data, const char *name)
Definition asset.cc:118
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)
Definition asset.cc:154
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)
Definition asset.cc:140
SpaceFile * CTX_wm_space_file(const bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
@ RPT_ERROR
Definition BKE_report.hh:39
@ RPT_WARNING
Definition BKE_report.hh:38
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:53
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.cc:41
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()
Definition uuid.cc:112
void BLI_uuid_format(char *buffer, bUUID uuid) ATTR_NONNULL()
Definition uuid.cc:89
#define BLT_I18NCONTEXT_ID_ID
@ ASSET_LIBRARY_CUSTOM
@ ASSET_LIBRARY_ESSENTIALS
@ ASSET_LIBRARY_LOCAL
@ ASSET_LIBRARY_ALL
#define MAX_NAME
Definition DNA_defs.h:50
#define UUID_STRING_SIZE
blender::asset_system::AssetLibrary * ED_fileselect_active_asset_library_get(const SpaceFile *sfile)
Definition filesel.cc:472
ParameterFlag
Definition RNA_types.hh:544
@ PARM_RNAPTR
Definition RNA_types.hh:547
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition RNA_types.hh:970
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
PropertyFlag
Definition RNA_types.hh:300
@ PROP_THICK_WRAP
Definition RNA_types.hh:423
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:407
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_FILENAME
Definition RNA_types.hh:238
@ PROP_NONE
Definition RNA_types.hh:233
#define C
Definition RandGen.cpp:29
void refresh_catalog_simplename(AssetMetaData *asset_data)
#define printf(...)
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
const EnumPropertyItem * library_reference_to_rna_enum_itemf(bool include_readonly, bool include_current_file)
const char * name
const EnumPropertyItem rna_enum_id_type_items[]
Definition rna_ID.cc:29
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)
Definition rna_asset.cc:518
static void rna_def_asset_tag(BlenderRNA *brna)
Definition rna_asset.cc:466
static void rna_def_asset_library_reference(BlenderRNA *brna)
Definition rna_asset.cc:680
const EnumPropertyItem rna_enum_asset_library_type_items[]
Definition rna_asset.cc:21
static void rna_def_asset_tags_api(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_asset.cc:482
static void rna_def_asset_representation(BlenderRNA *brna)
Definition rna_asset.cc:611
static void rna_def_asset_weak_reference(BlenderRNA *brna)
Definition rna_asset.cc:698
void RNA_def_asset(BlenderRNA *brna)
Definition rna_asset.cc:717
PropertyRNA * rna_def_asset_library_reference_common(StructRNA *srna, const char *get, const char *set)
Definition rna_asset.cc:687
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[]
Definition rna_rna.cc:26
#define min(a, b)
Definition sort.cc:36
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
struct IDProperty * properties
struct bUUID catalog_id
User defined tag. Currently only used by assets, could be used more often at some point....
char name[64]
Definition DNA_ID.h:414
struct AssetMetaData * asset_data
Definition DNA_ID.h:423
void invalidate()
Definition RNA_types.hh:110
void * data
Definition RNA_types.hh:53
Universally Unique Identifier according to RFC4122.
max
Definition text_draw.cc:251
#define N_(msgid)
PointerRNA * ptr
Definition wm_files.cc:4238