76 std::optional<AssetWeakReference> asset_to_save;
79 if (brush_asset_reference == *
paint->brush_asset_reference) {
80 if (
paint->runtime->previous_active_brush_reference !=
nullptr) {
81 brush_asset_reference = *
paint->runtime->previous_active_brush_reference;
85 asset_to_save = *
paint->brush_asset_reference;
103 else if (!use_toggle) {
117 ot->name =
"Activate Brush Asset";
118 ot->description =
"Activate a brush asset as current sculpt and paint tool";
119 ot->idname =
"BRUSH_OT_asset_activate";
129 "Switch between the current and assigned brushes on consecutive uses.");
137 if (
paint ==
nullptr || brush ==
nullptr) {
140 if (!
paint->brush_asset_reference) {
167 if (
name[0] ==
'\0') {
172 "asset_library_reference");
177 if (is_local_library) {
202 if (is_local_library) {
203 const Brush *original_brush = brush;
223 if (catalog_path_c[0]) {
226 *library, catalog_path);
230 if (!is_local_library) {
233 *bmain, brush->
id,
name, *user_library, brush_asset_reference, *op->
reports);
234 if (!final_full_asset_filepath) {
239 brush =
reinterpret_cast<Brush *
>(
253 if (is_local_library) {
284 const std::optional<AssetLibraryReference> library_ref = library.
library_reference();
297 "asset_library_reference",
304 "asset_library_reference",
342 const char *edit_text,
352 ot->name =
"Save as Brush Asset";
354 "Save a copy of the active brush asset into the default asset library, and make it the "
356 ot->idname =
"BRUSH_OT_asset_save_as";
363 ot->srna,
"name",
nullptr,
MAX_NAME,
"Name",
"Name for the new brush asset");
370 ot->srna,
"catalog_path",
nullptr,
MAX_NAME,
"Catalog",
"Catalog to use for the new asset");
398 if (catalog_path_c[0]) {
401 library, catalog_path);
451 const char *edit_text,
457 *
C, brush_weak_ref,
nullptr);
473 if (
paint ==
nullptr || brush ==
nullptr) {
481 if (!brush_weak_ref) {
491 const std::optional<AssetLibraryReference> library_ref =
492 asset->owner_asset_library().library_reference();
510 ot->name =
"Edit Metadata";
511 ot->description =
"Edit asset information like the catalog, preview image, tags, or author";
512 ot->idname =
"BRUSH_OT_asset_edit_metadata";
519 ot->srna,
"catalog_path",
nullptr,
MAX_NAME,
"Catalog",
"The asset's catalog path");
570 ot->name =
"Load Preview Image";
571 ot->description =
"Choose a preview image for the brush";
572 ot->idname =
"BRUSH_OT_asset_load_preview";
591 if (
paint ==
nullptr || brush ==
nullptr) {
614 paint->brush_asset_reference->asset_library_identifier) :
641 IFACE_(
"Delete Brush Asset"),
643 IFACE_(
"Permanently delete brush asset blend file. This cannot be undone.") :
644 IFACE_(
"Permanently delete brush. This cannot be undone."),
652 ot->name =
"Delete Brush Asset";
653 ot->description =
"Delete the active brush asset";
654 ot->idname =
"BRUSH_OT_asset_delete";
670 if (!brush_weak_ref) {
680 return asset->owner_asset_library().library_reference();
687 if (
paint ==
nullptr || brush ==
nullptr) {
738 ot->name =
"Save Brush Asset";
739 ot->description =
"Update the active brush asset in the asset library with current settings";
740 ot->idname =
"BRUSH_OT_asset_save";
750 if (
paint ==
nullptr || brush ==
nullptr) {
792 ot->name =
"Revert Brush Asset";
794 "Revert the active brush settings to the default values from the asset library";
795 ot->idname =
"BRUSH_OT_asset_revert";
blender::asset_system::AssetLibrary * AS_asset_library_load(const Main *bmain, const AssetLibraryReference &library_reference)
Main runtime representation of an asset.
AssetMetaData * BKE_asset_metadata_copy(const AssetMetaData *source)
void BKE_asset_metadata_free(AssetMetaData **asset_data)
void BKE_asset_metadata_catalog_id_set(AssetMetaData *asset_data, bUUID catalog_id, const char *catalog_simple_name)
Brush * BKE_brush_duplicate(Main *bmain, Brush *brush, eDupli_ID_Flags dupflag, uint duplicate_options)
ReportList * CTX_wm_reports(const bContext *C)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
Main * CTX_data_main(const bContext *C)
IDNewNameResult BKE_libblock_rename(Main &bmain, ID &id, blender::StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
@ LIB_ID_DUPLICATE_IS_ROOT_ID
bool BKE_paint_brush_set(Paint *paint, Brush *brush)
void BKE_paint_previous_asset_reference_set(Paint *paint, AssetWeakReference &&asset_weak_reference)
void BKE_paint_previous_asset_reference_clear(Paint *paint)
Paint * BKE_paint_get_active_from_context(const bContext *C)
bool BKE_paint_brush_set_default(Main *bmain, Paint *paint)
Brush * BKE_paint_brush(Paint *paint)
struct bUserAssetLibrary * BKE_preferences_asset_library_find_by_name(const struct UserDef *userdef, const char *name) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BKE_previewimg_id_custom_set(ID *id, const char *filepath)
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_unreachable()
File and directory operations.
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define STRNCPY_UTF8(dst, src)
#define ID_IS_LINKED(_id)
@ ASSET_LIBRARY_ESSENTIALS
@ PROP_STRING_SEARCH_SUGGESTION
AssetCatalog * find_catalog(CatalogID catalog_id) const
bool write_to_disk(const CatalogFilePath &blend_file_path)
const CatalogID catalog_id
AssetCatalogService & catalog_service() const
virtual std::optional< AssetLibraryReference > library_reference() const =0
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)
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)
bool asset_edit_id_save(Main &global_main, const ID &id, ReportList &reports)
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)
const EnumPropertyItem * library_reference_to_rna_enum_itemf(bool include_readonly, bool include_current_file)
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)
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)
const bUserAssetLibrary * get_asset_library_from_opptr(PointerRNA &ptr)
void refresh_asset_library_from_asset(const bContext *C, const blender::asset_system::AssetRepresentation &asset)
AssetLibraryReference user_library_to_library_ref(const bUserAssetLibrary &user_library)
blender::asset_system::AssetCatalog & library_ensure_catalogs_in_path(blender::asset_system::AssetLibrary &library, const blender::asset_system::AssetCatalogPath &path)
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 bool library_is_editable(const AssetLibraryReference &library)
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 RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
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)
void RNA_def_property_string_search_func_runtime(PropertyRNA *prop, StringPropertySearchFunc search_fn, const eStringPropertySearchFlag search_flag)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
const char * asset_library_identifier
struct AssetMetaData * asset_data
struct ReportList * reports
void WM_main_add_notifier(uint type, void *reference)
void WM_file_tag_modified()
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)
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)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)
wmOperatorStatus WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *)