Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/asset/intern/asset_mark_clear.cc')
-rw-r--r--source/blender/editors/asset/intern/asset_mark_clear.cc50
1 files changed, 38 insertions, 12 deletions
diff --git a/source/blender/editors/asset/intern/asset_mark_clear.cc b/source/blender/editors/asset/intern/asset_mark_clear.cc
index 8290124c209..2e5bdb63359 100644
--- a/source/blender/editors/asset/intern/asset_mark_clear.cc
+++ b/source/blender/editors/asset/intern/asset_mark_clear.cc
@@ -20,18 +20,14 @@
* Functions for marking and clearing assets.
*/
-#include <memory>
-#include <string>
+#include "DNA_ID.h"
#include "BKE_asset.h"
#include "BKE_context.h"
+#include "BKE_icons.h"
+#include "BKE_idtype.h"
#include "BKE_lib_id.h"
-
-#include "BLO_readfile.h"
-
-#include "DNA_ID.h"
-#include "DNA_asset_types.h"
-#include "DNA_space_types.h"
+#include "BKE_main.h"
#include "UI_interface_icons.h"
@@ -39,8 +35,9 @@
#include "ED_asset_list.h"
#include "ED_asset_mark_clear.h"
+#include "ED_asset_type.h"
-bool ED_asset_mark_id(const bContext *C, ID *id)
+bool ED_asset_mark_id(ID *id)
{
if (id->asset_data) {
return false;
@@ -51,9 +48,9 @@ bool ED_asset_mark_id(const bContext *C, ID *id)
id_fake_user_set(id);
+ const IDTypeInfo *id_type_info = BKE_idtype_get_info_from_id(id);
id->asset_data = BKE_asset_metadata_create();
-
- UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
+ id->asset_data->local_type_info = id_type_info->asset_type_info;
/* Important for asset storage to update properly! */
ED_assetlist_storage_tag_main_data_dirty();
@@ -61,6 +58,16 @@ bool ED_asset_mark_id(const bContext *C, ID *id)
return true;
}
+void ED_asset_generate_preview(const bContext *C, ID *id)
+{
+ PreviewImage *preview = BKE_previewimg_id_get(id);
+ if (preview) {
+ BKE_previewimg_clear(preview);
+ }
+
+ UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
+}
+
bool ED_asset_clear_id(ID *id)
{
if (!id->asset_data) {
@@ -75,8 +82,27 @@ bool ED_asset_clear_id(ID *id)
return true;
}
+void ED_assets_pre_save(struct Main *bmain)
+{
+ ID *id;
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
+ if (!id->asset_data || !id->asset_data->local_type_info) {
+ continue;
+ }
+
+ if (id->asset_data->local_type_info->pre_save_fn) {
+ id->asset_data->local_type_info->pre_save_fn(id, id->asset_data);
+ }
+ }
+ FOREACH_MAIN_ID_END;
+}
+
bool ED_asset_can_mark_single_from_context(const bContext *C)
{
/* Context needs a "id" pointer to be set for #ASSET_OT_mark()/#ASSET_OT_clear() to use. */
- return CTX_data_pointer_get_type_silent(C, "id", &RNA_ID).data != nullptr;
+ const ID *id = static_cast<ID *>(CTX_data_pointer_get_type_silent(C, "id", &RNA_ID).data);
+ if (!id) {
+ return false;
+ }
+ return ED_asset_type_is_supported(id);
}