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());
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;
100 asset_to_save = *
paint->brush_asset_reference;
124 else if (!use_toggle) {
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";
150 "Switch between the current and assigned brushes on consecutive uses.");
161 if (!
paint->brush_asset_reference) {
188 if (name[0] ==
'\0') {
198 if (is_local_library) {
223 if (is_local_library) {
244 if (catalog_path_c[0]) {
252 if (!is_local_library) {
255 *bmain,
brush->id, name, *user_library, brush_asset_reference, *op->
reports);
256 if (!final_full_asset_filepath) {
259 library->catalog_service().write_to_disk(*final_full_asset_filepath);
269 brush->has_unsaved_changes =
false;
281 if (is_local_library) {
310 std::optional<AssetLibraryReference> dest_library_ref =
313 if (!dest_library_ref) {
318 "asset_library_reference",
357 const char *edit_text,
367 ot->
name =
"Save as Brush Asset";
369 "Save a copy of the active brush asset into the default asset library, and make it the "
371 ot->
idname =
"BRUSH_OT_asset_save_as";
378 ot->
srna,
"name",
nullptr,
MAX_NAME,
"Name",
"Name for the new brush asset");
385 ot->
srna,
"catalog_path",
nullptr,
MAX_NAME,
"Catalog",
"Catalog to use for the new asset");
408 MEM_SAFE_DELETE(meta_data.
author);
413 if (catalog_path_c[0]) {
467 const char *edit_text,
473 *
C, brush_weak_ref,
nullptr);
497 if (!brush_weak_ref) {
507 const std::optional<AssetLibraryReference> library_ref =
508 asset->owner_asset_library().library_reference();
513 if (
asset->owner_asset_library().is_read_only()) {
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";
535 ot->
srna,
"catalog_path",
nullptr,
MAX_NAME,
"Catalog",
"The asset's catalog path");
586 ot->
name =
"Load Preview Image";
587 ot->
description =
"Choose a preview image for the brush";
588 ot->
idname =
"BRUSH_OT_asset_load_preview";
630 paint->brush_asset_reference->asset_library_identifier) :
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."),
668 ot->
name =
"Delete Brush Asset";
670 ot->
idname =
"BRUSH_OT_asset_delete";
686 if (!brush_weak_ref) {
696 return asset->owner_asset_library().library_reference();
742 brush->has_unsaved_changes =
false;
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";
806 ot->
name =
"Revert Brush Asset";
808 "Revert the active brush settings to the default values from the asset library";
809 ot->
idname =
"BRUSH_OT_asset_revert";
Main runtime representation of an asset.
File and directory operations.
#define STRNCPY_UTF8(dst, src)
#define ID_IS_LINKED(_id)
#define BLI_assert_unreachable()
static AssetCatalogPath from_user_input(const char *path)
const CatalogID catalog_id
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)
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)
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)
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)
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)
void BKE_asset_metadata_catalog_id_set(AssetMetaData *asset_data, bUUID catalog_id, const char *catalog_simple_name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
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)
@ 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
void BKE_report(ReportList *reports, eReportType type, const char *message)
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)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void WM_file_tag_modified()
Main * CTX_data_main(const bContext *C)
Paint * BKE_paint_get_active_from_context(const bContext *C)
ID_Type GS(const char *name)
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()
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
const char * asset_library_identifier
struct AssetMetaData * asset_data
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports