Blender V5.3
brush_asset_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_fileops.hh"
10#include "BLI_listbase.hh"
11#include "BLI_path_utils.hh"
12#include "BLI_string_utf8.hh"
13
14#include "DNA_brush_types.h"
15#include "DNA_scene_types.h"
16#include "DNA_space_types.h"
17#include "DNA_userdef_types.h"
18
19#include "BKE_asset.hh"
20#include "BKE_asset_edit.hh"
21#include "BKE_blendfile.hh"
22#include "BKE_brush.hh"
23#include "BKE_context.hh"
24#include "BKE_global.hh"
25#include "BKE_lib_id.hh"
26#include "BKE_paint.hh"
27#include "BKE_paint_types.hh"
28#include "BKE_preferences.h"
29#include "BKE_preview_image.hh"
30#include "BKE_report.hh"
31
33#include "AS_asset_library.hh"
35
36#include "RNA_access.hh"
37#include "RNA_define.hh"
38
39#include "ED_asset.hh"
40#include "ED_asset_library.hh"
41#include "ED_asset_list.hh"
44#include "ED_asset_shelf.hh"
45
46#include "UI_interface_icons.hh"
47
48#include "BLT_translation.hh"
49
50#include "WM_api.hh"
51#include "WM_toolsystem.hh"
52
53#include "paint_intern.hh"
54
56
58{
59 /* This operator currently covers both cases: the file/asset browser file list and the asset list
60 * used for the asset-view template. Once the asset list design is used by the Asset Browser,
61 * this can be simplified to just that case. */
62 Main *bmain = CTX_data_main(C);
63
64 if (G.background) {
65 /* As asset loading can take upwards of a few minutes on production libraries, we typically
66 * do not want this to execute in a blocking fashion. However, for testing / profiling
67 * purposes, this is an acceptable workaround for now until a proper python API is created
68 * for this use case. */
70 }
73 if (!asset) {
74 return OPERATOR_CANCELLED;
75 }
76
77 if (asset->get_id_type() != ID_BR) {
78 BKE_reportf(op->reports, RPT_ERROR, "Asset '%s' is not a brush", asset->get_name().c_str());
79 return OPERATOR_CANCELLED;
80 }
81 if (asset->is_online_only()) {
84 "Brush '%s' needs downloading before it can be used (check context menu)",
85 asset->get_name().c_str());
86 return OPERATOR_CANCELLED;
87 }
88
89 const bool use_toggle = RNA_boolean_get(op->ptr, "use_toggle");
90 AssetWeakReference brush_asset_reference = asset->make_weak_reference();
92 std::optional<AssetWeakReference> asset_to_save;
93 if (use_toggle && paint->brush_asset_reference) {
94 if (brush_asset_reference == *paint->brush_asset_reference) {
95 if (paint->runtime->previous_active_brush_reference != nullptr) {
96 brush_asset_reference = *paint->runtime->previous_active_brush_reference;
97 }
98 }
99 else {
100 asset_to_save = *paint->brush_asset_reference;
101 }
102 }
103 Brush *brush = reinterpret_cast<Brush *>(
104 bke::asset_edit_id_from_weak_reference(*bmain, ID_BR, brush_asset_reference));
105 if (!brush) {
106 /* The asset may have been removed or renamed externally (e.g. in another Blender session),
107 * leaving a stale reference behind. */
108 BKE_reportf(op->reports, RPT_ERROR, "Brush asset '%s' not found", asset->get_name().c_str());
109 return OPERATOR_CANCELLED;
110 }
111
112 /* Activate brush through tool system rather than calling #BKE_paint_brush_set() directly, to let
113 * the tool system switch tools if necessary, and update which brush was the last recently used
114 * one for the current tool. */
116 /* Note brush datablock was still added, so was not a no-op. */
117 BKE_report(op->reports, RPT_WARNING, "Unable to activate brush, wrong object mode");
118 return OPERATOR_FINISHED;
119 }
120
121 if (asset_to_save) {
122 BKE_paint_previous_asset_reference_set(paint, std::move(*asset_to_save));
123 }
124 else if (!use_toggle) {
125 /* If we aren't toggling, clear the previous reference so that we don't swap back to an
126 * incorrect "previous" asset */
128 }
129
132
133 return OPERATOR_FINISHED;
134}
135
137{
138 ot->name = "Activate Brush Asset";
139 ot->description = "Activate a brush asset as current sculpt and paint tool";
140 ot->idname = "BRUSH_OT_asset_activate";
141
143
145 PropertyRNA *prop;
146 prop = RNA_def_boolean(ot->srna,
147 "use_toggle",
148 false,
149 "Toggle",
150 "Switch between the current and assigned brushes on consecutive uses.");
152}
153
155{
157 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
158 if (paint == nullptr || brush == nullptr) {
159 return false;
160 }
161 if (!paint->brush_asset_reference) {
162 /* The brush should always be an imported asset. We use this asset reference to find
163 * which library and catalog the brush came from, as defaults for the popup. */
164 return false;
165 }
166
167 return true;
168}
169
171{
172 Main *bmain = CTX_data_main(C);
174 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
175
176 /* Determine file path to save to. */
177 PropertyRNA *name_prop = RNA_struct_find_property(op->ptr, "name");
178 /* FIXME: MAX_ID_NAME & FILE_MAXFILE
179 *
180 * This `name` should be `MAX_ID_NAME - 2` long.
181 *
182 * This name might also be used as filename for the saved asset, thus hitting the size issue
183 * between ID names and file names (FILE_MAXFILE). */
184 char name[MAX_NAME] = "";
185 if (RNA_property_is_set(op->ptr, name_prop)) {
186 RNA_property_string_get(op->ptr, name_prop, name);
187 }
188 if (name[0] == '\0') {
189 STRNCPY_UTF8(name, brush->id.name + 2);
190 }
191
192 const eAssetLibraryType enum_value = eAssetLibraryType(
193 RNA_enum_get(op->ptr, "asset_library_reference"));
194 const bool is_local_library = enum_value == ASSET_LIBRARY_LOCAL;
195
196 AssetLibraryReference library_reference;
197 const bUserAssetLibrary *user_library = nullptr;
198 if (is_local_library) {
200 }
201 else {
202 user_library = asset::get_asset_library_from_opptr(*op->ptr);
203 if (!user_library) {
204 return OPERATOR_CANCELLED;
205 }
206 library_reference = asset::user_library_to_library_ref(*user_library);
207 }
208 asset_system::AssetLibrary *library = AS_asset_library_load(bmain, library_reference);
209 if (!library) {
210 BKE_report(op->reports, RPT_ERROR, "Failed to load asset library");
211 return OPERATOR_CANCELLED;
212 }
213
214 BLI_assert(is_local_library || user_library);
215
216 /* Turn brush into asset if it isn't yet. */
217 if (!ID_IS_ASSET(&brush->id)) {
218 asset::mark_id(&brush->id);
220 }
222
223 if (is_local_library) {
224 const Brush *original_brush = brush;
227
228 BKE_libblock_rename(*bmain, brush->id, name);
229 asset::mark_id(&brush->id);
230 BLI_assert(brush->id.us == 1);
231
232 BKE_asset_metadata_free(&brush->id.asset_data);
233 brush->id.asset_data = BKE_asset_metadata_copy(original_brush->id.asset_data);
234 BLI_assert(brush->id.asset_data != nullptr);
235 }
236
237 /* Add asset to catalog. */
238 /* Note: This needs to happen after the local asset is created but BEFORE a non-local library
239 * is saved */
240 char catalog_path_c[MAX_NAME];
241 RNA_string_get(op->ptr, "catalog_path", catalog_path_c);
242
243 AssetMetaData &meta_data = *brush->id.asset_data;
244 if (catalog_path_c[0]) {
245 const asset_system::AssetCatalogPath catalog_path =
248 *library, catalog_path);
249 BKE_asset_metadata_catalog_id_set(&meta_data, catalog.catalog_id, catalog.simple_name.c_str());
250 }
251
252 if (!is_local_library) {
253 AssetWeakReference brush_asset_reference;
254 const std::optional<std::string> final_full_asset_filepath = bke::asset_edit_id_save_as(
255 *bmain, brush->id, name, *user_library, brush_asset_reference, *op->reports);
256 if (!final_full_asset_filepath) {
257 return OPERATOR_CANCELLED;
258 }
259 library->catalog_service().write_to_disk(*final_full_asset_filepath);
260
261 brush = reinterpret_cast<Brush *>(
262 bke::asset_edit_id_from_weak_reference(*bmain, ID_BR, brush_asset_reference));
263 if (!brush) {
264 BKE_report(op->reports, RPT_ERROR, "Failed to load saved brush asset");
265 asset::refresh_asset_library(C, library_reference);
267 return OPERATOR_FINISHED;
268 }
269 brush->has_unsaved_changes = false;
270 }
271
273
275 /* Note brush asset was still saved in editable asset library, so was not a no-op. */
276 BKE_report(op->reports, RPT_WARNING, "Unable to activate just-saved brush asset");
277 }
278
279 asset::refresh_asset_library(C, library_reference);
281 if (is_local_library) {
284 }
285 else {
287 }
288
289 return OPERATOR_FINISHED;
290}
291
293 wmOperator *op,
294 const wmEvent * /*event*/)
295{
297 const AssetWeakReference &brush_weak_ref = *paint->brush_asset_reference;
299 *C, brush_weak_ref, op->reports);
300 if (!asset) {
301 return OPERATOR_CANCELLED;
302 }
303 const asset_system::AssetLibrary &library = asset->owner_asset_library();
304
305 RNA_string_set(op->ptr, "name", asset->get_name().c_str());
306
307 /* If the library isn't saved from the operator's last execution, use the asset's owner library
308 * or fall back to the first library if the current library isn't editable. */
309 if (!RNA_struct_property_is_set_ex(op->ptr, "asset_library_reference", false)) {
310 std::optional<AssetLibraryReference> dest_library_ref =
312
313 if (!dest_library_ref) {
314 BKE_report(op->reports, RPT_WARNING, "No editable asset library to save into");
315 return OPERATOR_CANCELLED;
316 }
317 RNA_enum_set(op->ptr,
318 "asset_library_reference",
319 asset::library_reference_to_enum_value(&*dest_library_ref));
320 }
321
322 /* By default, put the new asset in the same catalog as the existing asset. */
323 if (!RNA_struct_property_is_set(op->ptr, "catalog_path")) {
324 const asset_system::CatalogID &id = asset->get_metadata().catalog_id;
325 if (const asset_system::AssetCatalog *catalog = library.catalog_service().find_catalog(id)) {
326 RNA_string_set(op->ptr, "catalog_path", catalog->path.c_str());
327 }
328 }
329
330 return WM_operator_props_dialog_popup(C, op, 400, std::nullopt, IFACE_("Save"));
331}
332
334 PointerRNA * /*ptr*/,
335 PropertyRNA * /*prop*/,
336 bool *r_free)
337{
339 /* Only get writable libraries. */
340 /*include_readonly=*/false,
341 /*include_current_file=*/true,
342 /*include_remote_libraries=*/false,
343 /*include_separate_online_essentials=*/false);
344 if (!items) {
345 *r_free = false;
346 return nullptr;
347 }
348
349 *r_free = true;
350 return items;
351}
352
354 const bContext *C,
355 PointerRNA *ptr,
356 PropertyRNA * /*prop*/,
357 const char *edit_text,
359{
360 /* NOTE: Using the all library would also be a valid choice. */
362 *CTX_data_main(C), asset::get_asset_library_ref_from_opptr(*ptr), edit_text, visit_fn);
363}
364
366{
367 ot->name = "Save as Brush Asset";
368 ot->description =
369 "Save a copy of the active brush asset into the default asset library, and make it the "
370 "active brush";
371 ot->idname = "BRUSH_OT_asset_save_as";
372
376
377 ot->prop = RNA_def_string(
378 ot->srna, "name", nullptr, MAX_NAME, "Name", "Name for the new brush asset");
379
380 PropertyRNA *prop = RNA_def_property(ot->srna, "asset_library_reference", PROP_ENUM, PROP_NONE);
382 RNA_def_property_ui_text(prop, "Library", "Asset library used to store the new brush");
383
384 prop = RNA_def_string(
385 ot->srna, "catalog_path", nullptr, MAX_NAME, "Catalog", "Catalog to use for the new asset");
388}
389
391{
392 Main *bmain = CTX_data_main(C);
396 const AssetWeakReference &brush_weak_ref = *paint->brush_asset_reference;
398 *C, brush_weak_ref, op->reports);
399 if (!asset) {
400 return OPERATOR_CANCELLED;
401 }
402 asset_system::AssetLibrary &library = asset->owner_asset_library();
403
404 char catalog_path_c[MAX_NAME];
405 RNA_string_get(op->ptr, "catalog_path", catalog_path_c);
406
407 AssetMetaData &meta_data = *brush->id.asset_data;
408 MEM_SAFE_DELETE(meta_data.author);
409 meta_data.author = RNA_string_get_alloc(op->ptr, "author", nullptr, 0, nullptr);
410 MEM_SAFE_DELETE(meta_data.description);
411 meta_data.description = RNA_string_get_alloc(op->ptr, "description", nullptr, 0, nullptr);
412
413 if (catalog_path_c[0]) {
414 const asset_system::AssetCatalogPath catalog_path =
417 library, catalog_path);
418 BKE_asset_metadata_catalog_id_set(&meta_data, catalog.catalog_id, catalog.simple_name.c_str());
419 }
420
421 if (!bke::asset_edit_id_save(*bmain, brush->id, *op->reports)) {
422 return OPERATOR_CANCELLED;
423 }
424
426
429
430 return OPERATOR_FINISHED;
431}
432
434 wmOperator *op,
435 const wmEvent * /*event*/)
436{
438 const AssetWeakReference &brush_weak_ref = *paint->brush_asset_reference;
440 *C, brush_weak_ref, op->reports);
441 if (!asset) {
442 return OPERATOR_CANCELLED;
443 }
444 const asset_system::AssetLibrary &library = asset->owner_asset_library();
445 const AssetMetaData &meta_data = asset->get_metadata();
446
447 if (!RNA_struct_property_is_set(op->ptr, "catalog_path")) {
448 const asset_system::CatalogID &id = meta_data.catalog_id;
449 if (const asset_system::AssetCatalog *catalog = library.catalog_service().find_catalog(id)) {
450 RNA_string_set(op->ptr, "catalog_path", catalog->path.c_str());
451 }
452 }
453 if (!RNA_struct_property_is_set(op->ptr, "author")) {
454 RNA_string_set(op->ptr, "author", meta_data.author ? meta_data.author : "");
455 }
456 if (!RNA_struct_property_is_set(op->ptr, "description")) {
457 RNA_string_set(op->ptr, "description", meta_data.description ? meta_data.description : "");
458 }
459
460 return WM_operator_props_dialog_popup(C, op, 400, std::nullopt, IFACE_("Edit Metadata"));
461}
462
464 const bContext *C,
465 PointerRNA * /*ptr*/,
466 PropertyRNA * /*prop*/,
467 const char *edit_text,
469{
471 const AssetWeakReference &brush_weak_ref = *paint->brush_asset_reference;
473 *C, brush_weak_ref, nullptr);
474 if (!asset) {
475 return;
476 }
477
478 const asset_system::AssetLibrary &library = asset->owner_asset_library();
479
480 /* NOTE: Using the all library would also be a valid choice. */
482 *CTX_data_main(C), *library.library_reference(), edit_text, visit_fn);
483}
484
486{
488 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
489 if (paint == nullptr || brush == nullptr) {
490 return false;
491 }
492 if (!ID_IS_ASSET(&brush->id)) {
494 return false;
495 }
496 const AssetWeakReference *brush_weak_ref = paint->brush_asset_reference;
497 if (!brush_weak_ref) {
499 return false;
500 }
502 *C, *brush_weak_ref, CTX_wm_reports(C));
503 if (!asset) {
504 /* May happen if library loading hasn't finished. */
505 return false;
506 }
507 const std::optional<AssetLibraryReference> library_ref =
508 asset->owner_asset_library().library_reference();
509 if (!library_ref) {
511 return false;
512 }
513 if (asset->owner_asset_library().is_read_only()) {
514 CTX_wm_operator_poll_msg_set(C, "Asset library is not editable");
515 return false;
516 }
517 if (!(library_ref->type & ASSET_LIBRARY_LOCAL) && !bke::asset_edit_id_is_writable(brush->id)) {
518 CTX_wm_operator_poll_msg_set(C, "Asset file is not editable");
519 return false;
520 }
521 return true;
522}
523
525{
526 ot->name = "Edit Metadata";
527 ot->description = "Edit asset information like the catalog, preview image, tags, or author";
528 ot->idname = "BRUSH_OT_asset_edit_metadata";
529
533
535 ot->srna, "catalog_path", nullptr, MAX_NAME, "Catalog", "The asset's catalog path");
538 RNA_def_string(ot->srna, "author", nullptr, 0, "Author", "");
539 RNA_def_string(ot->srna, "description", nullptr, 0, "Description", "");
540}
541
543{
544 Main *bmain = CTX_data_main(C);
548 const AssetWeakReference &brush_weak_ref = *paint->brush_asset_reference;
550 *C, brush_weak_ref, op->reports);
551 if (!asset) {
552 return OPERATOR_CANCELLED;
553 }
554
555 char filepath[FILE_MAX];
556 RNA_string_get(op->ptr, "filepath", filepath);
557 if (!BLI_is_file(filepath)) {
558 BKE_reportf(op->reports, RPT_ERROR, "File not found '%s'", filepath);
559 return OPERATOR_CANCELLED;
560 }
561
562 BKE_previewimg_id_custom_set(&brush->id, filepath);
563
564 if (!bke::asset_edit_id_save(*bmain, brush->id, *op->reports)) {
565 return OPERATOR_CANCELLED;
566 }
567
570
571 return OPERATOR_FINISHED;
572}
573
575 wmOperator *op,
576 const wmEvent *event)
577{
578 if (RNA_struct_property_is_set(op->ptr, "filepath")) {
580 }
581 return WM_operator_filesel(C, op, event);
582}
583
585{
586 ot->name = "Load Preview Image";
587 ot->description = "Choose a preview image for the brush";
588 ot->idname = "BRUSH_OT_asset_load_preview";
589
593
601}
602
604{
606 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
607 if (paint == nullptr || brush == nullptr) {
608 return false;
609 }
610
611 /* Linked brush, check if belongs to an editable blend file. */
612 if (ID_IS_LINKED(brush)) {
614 CTX_wm_operator_poll_msg_set(C, "Asset blend file is not editable");
615 return false;
616 }
617 }
618
619 return true;
620}
621
623{
626 Main *bmain = CTX_data_main(C);
627 bUserAssetLibrary *library = (paint->brush_asset_reference) ?
629 &U,
630 paint->brush_asset_reference->asset_library_identifier) :
631 nullptr;
632
633 bke::asset_edit_id_delete(*bmain, brush->id, *op->reports);
634
636
637 if (library) {
639 }
640
643
644 return OPERATOR_FINISHED;
645}
646
648 wmOperator *op,
649 const wmEvent * /*event*/)
650{
653
655 C,
656 op,
657 IFACE_("Delete Brush Asset"),
659 IFACE_("Permanently delete brush asset blend file. This cannot be undone.") :
660 IFACE_("Permanently delete brush. This cannot be undone."),
661 IFACE_("Delete"),
663 false);
664}
665
667{
668 ot->name = "Delete Brush Asset";
669 ot->description = "Delete the active brush asset";
670 ot->idname = "BRUSH_OT_asset_delete";
671
675}
676
677static std::optional<AssetLibraryReference> get_asset_library_reference(const bContext &C,
678 const Paint &paint,
679 const Brush &brush)
680{
681 if (!ID_IS_ASSET(&brush.id)) {
683 return std::nullopt;
684 }
685 const AssetWeakReference *brush_weak_ref = paint.brush_asset_reference;
686 if (!brush_weak_ref) {
688 return std::nullopt;
689 }
691 C, *brush_weak_ref, CTX_wm_reports(&C));
692 if (!asset) {
693 /* May happen if library loading hasn't finished. */
694 return std::nullopt;
695 }
696 return asset->owner_asset_library().library_reference();
697}
698
700{
702 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
703 if (paint == nullptr || brush == nullptr) {
704 return false;
705 }
706
707 const std::optional<AssetLibraryReference> library_ref = get_asset_library_reference(
708 *C, *paint, *brush);
709 if (!library_ref) {
710 return false;
711 }
712
713 if (library_ref->type == ASSET_LIBRARY_LOCAL) {
714 CTX_wm_operator_poll_msg_set(C, "Assets in the current file cannot be individually saved");
715 return false;
716 }
717
719 CTX_wm_operator_poll_msg_set(C, "Asset blend file is not editable");
720 return false;
721 }
722
723 return true;
724}
725
727{
728 Main *bmain = CTX_data_main(C);
731 const AssetWeakReference *asset_weak_ref = paint->brush_asset_reference;
732
734 &U, asset_weak_ref->asset_library_identifier);
735 if (!user_library) {
736 return OPERATOR_CANCELLED;
737 }
738
740
741 bke::asset_edit_id_save(*bmain, brush->id, *op->reports);
742 brush->has_unsaved_changes = false;
743
744 asset::refresh_asset_library(C, *user_library);
747
748 return OPERATOR_FINISHED;
749}
750
752{
753 ot->name = "Save Brush Asset";
754 ot->description = "Update the active brush asset in the asset library with current settings";
755 ot->idname = "BRUSH_OT_asset_save";
756
759}
760
762{
764 Brush *brush = (paint) ? BKE_paint_brush(paint) : nullptr;
765 if (paint == nullptr || brush == nullptr) {
766 return false;
767 }
768
769 const std::optional<AssetLibraryReference> library_ref = get_asset_library_reference(
770 *C, *paint, *brush);
771 if (!library_ref) {
772 return false;
773 }
774 if (library_ref->type == ASSET_LIBRARY_LOCAL) {
775 CTX_wm_operator_poll_msg_set(C, "Assets in the current file cannot be reverted");
776 return false;
777 }
778
780}
781
783{
784 Main *bmain = CTX_data_main(C);
787
788 if (ID *reverted_id = bke::asset_edit_id_revert(*bmain, brush->id, *op->reports)) {
789 BLI_assert(GS(reverted_id->name) == ID_BR);
790 BKE_paint_brush_set(paint, reinterpret_cast<Brush *>(reverted_id));
791 }
792 else {
793 /* bke::asset_edit_id_revert() deleted the brush for sure, even on failure. Fall back to the
794 * default. */
796 }
797
800
801 return OPERATOR_FINISHED;
802}
803
805{
806 ot->name = "Revert Brush Asset";
807 ot->description =
808 "Revert the active brush settings to the default values from the asset library";
809 ot->idname = "BRUSH_OT_asset_revert";
810
813}
814
815} // namespace blender::ed::sculpt_paint
Main runtime representation of an asset.
File and directory operations.
#define FILE_MAX
#define STRNCPY_UTF8(dst, src)
#define IFACE_(msgid)
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_IS_ASSET(_id)
Definition DNA_ID.h:743
#define MAX_NAME
Definition DNA_defs.h:63
#define C
Definition RandGen.cpp:29
#define NA_ACTIVATED
Definition WM_types.hh:640
#define NC_BRUSH
Definition WM_types.hh:398
#define NC_SCENE
Definition WM_types.hh:391
#define NA_ADDED
Definition WM_types.hh:636
#define ND_NODES
Definition WM_types.hh:455
#define ND_TOOLSETTINGS
Definition WM_types.hh:468
#define NA_EDITED
Definition WM_types.hh:634
#define NC_ASSET
Definition WM_types.hh:417
#define NA_REMOVED
Definition WM_types.hh:637
#define NC_TEXTURE
Definition WM_types.hh:394
#define ND_ASSET_LIST
Definition WM_types.hh:591
#define BLI_assert_unreachable()
static AssetCatalogPath from_user_input(const char *path)
AssetLibraryReference all_library_reference()
AssetLibraryReference current_file_library_reference()
ID * asset_edit_id_from_weak_reference(Main &global_main, ID_Type id_type, const AssetWeakReference &weak_ref)
bool asset_edit_id_save(Main &global_main, ID &id, ReportList &reports)
std::optional< std::string > asset_edit_id_save_as(Main &global_main, const ID &id, StringRefNull name, const bUserAssetLibrary &user_library, AssetWeakReference &r_weak_ref, ReportList &reports)
ID * asset_edit_id_revert(Main &global_main, ID &id, ReportList &reports)
bool asset_edit_id_delete(Main &global_main, ID &id, ReportList &reports)
bool asset_edit_id_is_writable(const ID &id)
bool asset_edit_id_is_editable(const ID &id)
void storage_fetch_blocking(const AssetLibraryReference &library_reference, const bContext &C)
void show_catalog_in_visible_shelves(const bContext &C, const StringRefNull catalog_path)
const asset_system::AssetRepresentation * find_asset_from_weak_ref(const bContext &C, const AssetWeakReference &weak_ref, ReportList *reports)
AssetLibraryReference get_asset_library_ref_from_opptr(PointerRNA &ptr)
int library_reference_to_enum_value(const AssetLibraryReference *library)
void refresh_asset_library(const bContext *C, const AssetLibraryReference &library_ref)
void operator_asset_reference_props_register(StructRNA &srna)
void catalogs_save_from_asset_reference(asset_system::AssetLibrary &library, const AssetWeakReference &reference)
void generate_preview(const bContext *C, ID *id)
asset_system::AssetCatalog & library_ensure_catalogs_in_path(asset_system::AssetLibrary &library, const asset_system::AssetCatalogPath &path)
const asset_system::AssetRepresentation * operator_asset_reference_props_get_asset_from_all_library(const bContext &C, PointerRNA &ptr, ReportList *reports)
void visit_library_catalogs_catalog_for_search(const Main &bmain, const AssetLibraryReference lib, const StringRef edit_text, const FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
std::optional< AssetLibraryReference > get_user_library_ref_for_save(const asset_system::AssetLibrary *preferred_library)
const bUserAssetLibrary * get_asset_library_from_opptr(PointerRNA &ptr)
void refresh_asset_library_from_asset(const bContext *C, const asset_system::AssetRepresentation &asset)
const EnumPropertyItem * library_reference_to_rna_enum_itemf(bool include_readonly, bool include_current_file, bool include_remote_libraries, bool include_separate_online_essentials)
AssetLibraryReference user_library_to_library_ref(const bUserAssetLibrary &user_library)
void BRUSH_OT_asset_save(wmOperatorType *ot)
static bool brush_asset_edit_metadata_poll(bContext *C)
static std::optional< AssetLibraryReference > get_asset_library_reference(const bContext &C, const Paint &paint, const Brush &brush)
void BRUSH_OT_asset_delete(wmOperatorType *ot)
static wmOperatorStatus brush_asset_save_as_exec(bContext *C, wmOperator *op)
void BRUSH_OT_asset_edit_metadata(wmOperatorType *ot)
static bool brush_asset_delete_poll(bContext *C)
static void visit_library_prop_catalogs_catalog_for_search_fn(const bContext *C, PointerRNA *ptr, PropertyRNA *, const char *edit_text, FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
static wmOperatorStatus brush_asset_revert_exec(bContext *C, wmOperator *op)
static void visit_active_library_catalogs_catalog_for_search_fn(const bContext *C, PointerRNA *, PropertyRNA *, const char *edit_text, FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
static wmOperatorStatus brush_asset_load_preview_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void BRUSH_OT_asset_load_preview(wmOperatorType *ot)
static wmOperatorStatus brush_asset_delete_invoke(bContext *C, wmOperator *op, const wmEvent *)
static bool brush_asset_save_as_poll(bContext *C)
static wmOperatorStatus brush_asset_delete_exec(bContext *C, wmOperator *op)
static bool brush_asset_revert_poll(bContext *C)
static wmOperatorStatus brush_asset_load_preview_exec(bContext *C, wmOperator *op)
static wmOperatorStatus brush_asset_activate_exec(bContext *C, wmOperator *op)
static wmOperatorStatus brush_asset_edit_metadata_exec(bContext *C, wmOperator *op)
static wmOperatorStatus brush_asset_edit_metadata_invoke(bContext *C, wmOperator *op, const wmEvent *)
void BRUSH_OT_asset_revert(wmOperatorType *ot)
static bool brush_asset_save_poll(bContext *C)
void BRUSH_OT_asset_save_as(wmOperatorType *ot)
static wmOperatorStatus brush_asset_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *)
static const EnumPropertyItem * rna_asset_library_reference_itemf(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
void BRUSH_OT_asset_activate(wmOperatorType *ot)
static wmOperatorStatus brush_asset_save_exec(bContext *C, wmOperator *op)
void WM_main_add_notifier(uint type, void *reference)
void BKE_previewimg_id_custom_set(ID *id, const char *filepath)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_WARNING
Definition BKE_report.hh:40
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
wmOperatorStatus WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *)
bool BKE_paint_brush_set_default(Main *bmain, Paint *paint)
AssetMetaData * BKE_asset_metadata_copy(const AssetMetaData *source)
Definition asset.cc:42
void BKE_paint_previous_asset_reference_clear(Paint *paint)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void BKE_asset_metadata_free(AssetMetaData **asset_data)
Definition asset.cc:36
bool WM_toolsystem_activate_brush_and_tool(bContext *C, Paint *paint, Brush *brush)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
Brush * BKE_brush_duplicate(Main *bmain, Brush *brush, eDupli_ID_Flags dupflag, uint duplicate_options)
Definition brush.cc:761
void BKE_asset_metadata_catalog_id_set(AssetMetaData *asset_data, bUUID catalog_id, const char *catalog_simple_name)
Definition asset.cc:164
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
@ ASSET_LIBRARY_LOCAL
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
Global G
Definition blender.cc:57
@ LIB_ID_DUPLICATE_IS_ROOT_ID
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
@ PROP_STRING_SEARCH_SUGGESTION
Definition RNA_types.hh:883
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
@ WM_FILESEL_FILEPATH
Definition WM_api.hh:1332
void RNA_def_property_string_search_func_runtime(PropertyRNA *prop, StringPropertySearchFunc search_fn, const eStringPropertySearchFlag search_flag)
struct bUserAssetLibrary * BKE_preferences_asset_library_find_by_name(const struct UserDef *userdef, const char *name) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message, const bool show_icon)
bool BKE_paint_brush_set(Paint *paint, Brush *brush)
asset_system::AssetLibrary * AS_asset_library_load(const Main *bmain, const AssetLibraryReference &library_reference)
void BKE_paint_previous_asset_reference_set(Paint *paint, AssetWeakReference &&asset_weak_reference)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
IDNewNameResult BKE_libblock_rename(Main &bmain, ID &id, StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
Definition lib_id.cc:2632
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ FILE_OPENFILE
Definition WM_api.hh:1341
void WM_file_tag_modified()
Definition wm_files.cc:188
Main * CTX_data_main(const bContext *C)
Paint * BKE_paint_get_active_from_context(const bContext *C)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
Brush * BKE_paint_brush(Paint *paint)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ReportList * CTX_wm_reports(const bContext *C)
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:469
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
struct AssetMetaData * asset_data
Definition DNA_ID.h:424
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
struct ReportList * reports