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')
-rw-r--r--source/blender/editors/asset/ED_asset_mark_clear.h9
-rw-r--r--source/blender/editors/asset/intern/asset_mark_clear.cc9
-rw-r--r--source/blender/editors/asset/intern/asset_ops.cc4
-rw-r--r--source/blender/makesrna/intern/rna_ID.c18
4 files changed, 32 insertions, 8 deletions
diff --git a/source/blender/editors/asset/ED_asset_mark_clear.h b/source/blender/editors/asset/ED_asset_mark_clear.h
index d8b8f15a109..bab1d1bf8a5 100644
--- a/source/blender/editors/asset/ED_asset_mark_clear.h
+++ b/source/blender/editors/asset/ED_asset_mark_clear.h
@@ -34,7 +34,14 @@ struct bContext;
*
* \return whether the datablock was marked as asset; false when it is not capable of becoming an
* asset, or when it already was an asset. */
-bool ED_asset_mark_id(const struct bContext *C, struct ID *id);
+bool ED_asset_mark_id(struct ID *id);
+
+/**
+ * Generate preview image for the given datablock.
+ *
+ * The preview image might be generated using a background thread.
+ */
+void ED_asset_generate_preview(const struct bContext *C, struct ID *id);
/**
* Remove the asset metadata, turning the ID into a "normal" ID.
diff --git a/source/blender/editors/asset/intern/asset_mark_clear.cc b/source/blender/editors/asset/intern/asset_mark_clear.cc
index 8290124c209..e7516bc94c4 100644
--- a/source/blender/editors/asset/intern/asset_mark_clear.cc
+++ b/source/blender/editors/asset/intern/asset_mark_clear.cc
@@ -40,7 +40,7 @@
#include "ED_asset_list.h"
#include "ED_asset_mark_clear.h"
-bool ED_asset_mark_id(const bContext *C, ID *id)
+bool ED_asset_mark_id(ID *id)
{
if (id->asset_data) {
return false;
@@ -53,14 +53,17 @@ bool ED_asset_mark_id(const bContext *C, ID *id)
id->asset_data = BKE_asset_metadata_create();
- UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
-
/* Important for asset storage to update properly! */
ED_assetlist_storage_tag_main_data_dirty();
return true;
}
+void ED_asset_generate_preview(const bContext *C, ID *id)
+{
+ UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
+}
+
bool ED_asset_clear_id(ID *id)
{
if (!id->asset_data) {
diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc
index bf532903c7c..33a22775280 100644
--- a/source/blender/editors/asset/intern/asset_ops.cc
+++ b/source/blender/editors/asset/intern/asset_ops.cc
@@ -145,7 +145,9 @@ void AssetMarkHelper::operator()(const bContext &C, PointerRNAVec &ids)
continue;
}
- if (ED_asset_mark_id(&C, id)) {
+ if (ED_asset_mark_id(id)) {
+ ED_asset_generate_preview(&C, id);
+
stats.last_id = id;
stats.tot_created++;
}
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 1776da7e62d..fe03d5245ba 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -669,14 +669,22 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
return newid;
}
-static void rna_ID_asset_mark(ID *id, bContext *C)
+static void rna_ID_asset_mark(ID *id)
{
- if (ED_asset_mark_id(C, id)) {
+ if (ED_asset_mark_id(id)) {
WM_main_add_notifier(NC_ID | NA_EDITED, NULL);
WM_main_add_notifier(NC_ASSET | NA_ADDED, NULL);
}
}
+static void rna_ID_asset_generate_preview(ID *id, bContext *C)
+{
+ ED_asset_generate_preview(C, id);
+
+ WM_main_add_notifier(NC_ID | NA_EDITED, NULL);
+ WM_main_add_notifier(NC_ASSET | NA_EDITED, NULL);
+}
+
static void rna_ID_asset_clear(ID *id)
{
if (ED_asset_clear_id(id)) {
@@ -1986,13 +1994,17 @@ static void rna_def_ID(BlenderRNA *brna)
func,
"Enable easier reuse of the data-block through the Asset Browser, with the help of "
"customizable metadata (like previews, descriptions and tags)");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func = RNA_def_function(srna, "asset_clear", "rna_ID_asset_clear");
RNA_def_function_ui_description(
func,
"Delete all asset metadata and turn the asset data-block back into a normal data-block");
+ func = RNA_def_function(srna, "asset_generate_preview", "rna_ID_asset_generate_preview");
+ RNA_def_function_ui_description(
+ func, "Generate preview image (might be scheduled in a background thread)");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+
func = RNA_def_function(srna, "override_create", "rna_ID_override_create");
RNA_def_function_ui_description(func,
"Create an overridden local copy of this linked data-block (not "