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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-08-10 18:26:37 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-08-10 18:45:16 +0300
commit8d37aaeca1f9dc74224da378cecd392fd1cf361b (patch)
tree29729f23ebaa74f607ad6ec4e260112fee924b27 /source/blender/makesrna/intern/rna_ID.c
parent8f837e0ac586fb010c7c6133ddbdc09546f7f851 (diff)
Data previews: add utils to generate/clear previews.
Not much to add, you can now clear previews from current .blend file, or a set of non-opened files. Likewise, you can generate previews (for mat/tex, objects, groups, scenes, ...).
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 65db92ab9e6..19b5a1b8219 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -472,14 +472,14 @@ static void rna_ImagePreview_size_set(PointerRNA *ptr, const int *values, enum e
BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
}
- BKE_previewimg_ensure(prv_img, size);
+ BKE_previewimg_clear_single(prv_img, size);
if (values[0] && values[1]) {
prv_img->rect[size] = MEM_callocN(values[0] * values[1] * sizeof(unsigned int), "prv_rect");
- }
- prv_img->w[size] = values[0];
- prv_img->h[size] = values[1];
+ prv_img->w[size] = values[0];
+ prv_img->h[size] = values[1];
+ }
prv_img->flag[size] |= (PRV_CHANGED | PRV_USER_EDITED);
}
@@ -600,6 +600,14 @@ static void rna_ImagePreview_icon_reload(PreviewImage *prv)
}
}
+static PointerRNA rna_IDPreview_get(PointerRNA *ptr)
+{
+ ID *id = (ID *)ptr->data;
+ PreviewImage *prv_img = BKE_previewimg_id_ensure(id);
+
+ return rna_pointer_inherit_refine(ptr, &RNA_ImagePreview, prv_img);
+}
+
#else
static void rna_def_ID_properties(BlenderRNA *brna)
@@ -840,6 +848,11 @@ static void rna_def_ID(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Library", "Library file the datablock is linked from");
+ prop = RNA_def_pointer(srna, "preview", "ImagePreview", "Preview",
+ "Preview image and icon of this datablock (None if not supported for this type of data)");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop, "rna_IDPreview_get", NULL, NULL, NULL);
+
/* functions */
func = RNA_def_function(srna, "copy", "rna_ID_copy");
RNA_def_function_ui_description(func, "Create a copy of this datablock (not supported for all datablocks)");