diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 430 |
1 files changed, 409 insertions, 21 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 83fe56102ac..88065d29a50 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -34,6 +34,8 @@ #include "BLI_utildefines.h" +#include "BKE_icons.h" + #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -60,25 +62,31 @@ EnumPropertyItem id_type_items[] = { {ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""}, {ID_LS, "LINESTYLE", ICON_LINE_DATA, "Line Style", ""}, {ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""}, + {ID_MSK, "MASK", ICON_MOD_MASK, "Mask", ""}, {ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""}, {ID_MB, "META", ICON_META_DATA, "MetaBall", ""}, {ID_ME, "MESH", ICON_MESH_DATA, "Mesh", ""}, + {ID_MC, "MOVIECLIP", ICON_CLIP, "MovieClip", ""}, {ID_NT, "NODETREE", ICON_NODETREE, "NodeTree", ""}, {ID_OB, "OBJECT", ICON_OBJECT_DATA, "Object", ""}, + {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""}, + {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""}, {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""}, {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""}, {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""}, - {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, + {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, {ID_TXT, "TEXT", ICON_TEXT, "Text", ""}, {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, - {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, {ID_WM, "WINDOWMANAGER", ICON_FULLSCREEN, "Window Manager", ""}, + {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, {0, NULL, 0, NULL, NULL} }; #ifdef RNA_RUNTIME +#include "DNA_anim_types.h" + #include "BKE_font.h" #include "BKE_idprop.h" #include "BKE_library.h" @@ -138,23 +146,23 @@ short RNA_type_to_ID_code(StructRNA *type) if (RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT; if (RNA_struct_is_a(type, &RNA_Material)) return ID_MA; if (RNA_struct_is_a(type, &RNA_MetaBall)) return ID_MB; - if (RNA_struct_is_a(type, &RNA_NodeTree)) return ID_NT; + if (RNA_struct_is_a(type, &RNA_MovieClip)) return ID_MC; if (RNA_struct_is_a(type, &RNA_Mesh)) return ID_ME; + if (RNA_struct_is_a(type, &RNA_Mask)) return ID_MSK; + if (RNA_struct_is_a(type, &RNA_NodeTree)) return ID_NT; if (RNA_struct_is_a(type, &RNA_Object)) return ID_OB; if (RNA_struct_is_a(type, &RNA_ParticleSettings)) return ID_PA; + if (RNA_struct_is_a(type, &RNA_Palette)) return ID_PAL; + if (RNA_struct_is_a(type, &RNA_PaintCurve)) return ID_PC; if (RNA_struct_is_a(type, &RNA_Scene)) return ID_SCE; if (RNA_struct_is_a(type, &RNA_Screen)) return ID_SCR; - if (RNA_struct_is_a(type, &RNA_Speaker)) return ID_SPK; if (RNA_struct_is_a(type, &RNA_Sound)) return ID_SO; - if (RNA_struct_is_a(type, &RNA_Text)) return ID_TXT; + if (RNA_struct_is_a(type, &RNA_Speaker)) return ID_SPK; if (RNA_struct_is_a(type, &RNA_Texture)) return ID_TE; + if (RNA_struct_is_a(type, &RNA_Text)) return ID_TXT; if (RNA_struct_is_a(type, &RNA_VectorFont)) return ID_VF; if (RNA_struct_is_a(type, &RNA_World)) return ID_WO; if (RNA_struct_is_a(type, &RNA_WindowManager)) return ID_WM; - if (RNA_struct_is_a(type, &RNA_MovieClip)) return ID_MC; - if (RNA_struct_is_a(type, &RNA_Mask)) return ID_MSK; - if (RNA_struct_is_a(type, &RNA_Palette)) return ID_PAL; - if (RNA_struct_is_a(type, &RNA_PaintCurve)) return ID_PC; return 0; } @@ -177,23 +185,23 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_LT: return &RNA_Lattice; case ID_MA: return &RNA_Material; case ID_MB: return &RNA_MetaBall; - case ID_NT: return &RNA_NodeTree; + case ID_MC: return &RNA_MovieClip; case ID_ME: return &RNA_Mesh; + case ID_MSK: return &RNA_Mask; + case ID_NT: return &RNA_NodeTree; case ID_OB: return &RNA_Object; case ID_PA: return &RNA_ParticleSettings; + case ID_PAL: return &RNA_Palette; + case ID_PC: return &RNA_PaintCurve; case ID_SCE: return &RNA_Scene; case ID_SCR: return &RNA_Screen; - case ID_SPK: return &RNA_Speaker; case ID_SO: return &RNA_Sound; - case ID_TXT: return &RNA_Text; + case ID_SPK: return &RNA_Speaker; case ID_TE: return &RNA_Texture; + case ID_TXT: return &RNA_Text; case ID_VF: return &RNA_VectorFont; - case ID_WO: return &RNA_World; case ID_WM: return &RNA_WindowManager; - case ID_MC: return &RNA_MovieClip; - case ID_MSK: return &RNA_Mask; - case ID_PAL: return &RNA_Palette; - case ID_PC: return &RNA_PaintCurve; + case ID_WO: return &RNA_World; default: return &RNA_ID; } @@ -325,6 +333,19 @@ static void rna_ID_user_clear(ID *id) id->flag &= ~LIB_FAKEUSER; } +static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain) +{ + AnimData *adt = BKE_animdata_add_id(id); + DAG_relations_tag_update(bmain); + return adt; +} + +static void rna_ID_animation_data_free(ID *id, Main *bmain) +{ + BKE_animdata_free(id); + DAG_relations_tag_update(bmain); +} + static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { IDProperty *prop = (IDProperty *)ptr->data; @@ -402,6 +423,288 @@ static void rna_Library_filepath_set(PointerRNA *ptr, const char *value) BKE_library_filepath_set(lib, value); } +/* ***** ImagePreview ***** */ + +static void rna_ImagePreview_is_custom_set(PointerRNA *ptr, int value, enum eIconSizes size) +{ + ID *id = ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + if ((value && (prv_img->flag[size] & PRV_USER_EDITED)) || (!value && !(prv_img->flag[size] & PRV_USER_EDITED))) { + return; + } + + if (value) + prv_img->flag[size] |= PRV_USER_EDITED; + else + prv_img->flag[size] &= ~PRV_USER_EDITED; + + prv_img->flag[size] |= PRV_CHANGED; + + BKE_previewimg_clear_single(prv_img, size); +} + +static void rna_ImagePreview_size_get(PointerRNA *ptr, int *values, enum eIconSizes size) +{ + ID *id = (ID *)ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + BKE_previewimg_ensure(prv_img, size); + + values[0] = prv_img->w[size]; + values[1] = prv_img->h[size]; +} + +static void rna_ImagePreview_size_set(PointerRNA *ptr, const int *values, enum eIconSizes size) +{ + ID *id = (ID *)ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + 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->flag[size] |= (PRV_CHANGED | PRV_USER_EDITED); +} + + +static int rna_ImagePreview_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION], enum eIconSizes size) +{ + ID *id = ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + BKE_previewimg_ensure(prv_img, size); + + length[0] = prv_img->w[size] * prv_img->h[size]; + + return length[0]; +} + +static void rna_ImagePreview_pixels_get(PointerRNA *ptr, int *values, enum eIconSizes size) +{ + ID *id = ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + BKE_previewimg_ensure(prv_img, size); + + memcpy(values, prv_img->rect[size], prv_img->w[size] * prv_img->h[size] * sizeof(unsigned int)); +} + +static void rna_ImagePreview_pixels_set(PointerRNA *ptr, const int *values, enum eIconSizes size) +{ + ID *id = ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + memcpy(prv_img->rect[size], values, prv_img->w[size] * prv_img->h[size] * sizeof(unsigned int)); + prv_img->flag[size] |= PRV_USER_EDITED; +} + + +static int rna_ImagePreview_pixels_float_get_length( + PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION], enum eIconSizes size) +{ + ID *id = ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + BLI_assert(sizeof(unsigned int) == 4); + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + BKE_previewimg_ensure(prv_img, size); + + length[0] = prv_img->w[size] * prv_img->h[size] * 4; + + return length[0]; +} + +static void rna_ImagePreview_pixels_float_get(PointerRNA *ptr, float *values, enum eIconSizes size) +{ + ID *id = ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + unsigned char *data = (unsigned char *)prv_img->rect[size]; + const size_t len = prv_img->w[size] * prv_img->h[size] * 4; + size_t i; + + BLI_assert(sizeof(unsigned int) == 4); + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + BKE_previewimg_ensure(prv_img, size); + + for (i = 0; i < len; i++) { + values[i] = data[i] * (1.0f / 255.0f); + } +} + +static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr, const float *values, enum eIconSizes size) +{ + ID *id = ptr->id.data; + PreviewImage *prv_img = (PreviewImage *)ptr->data; + + unsigned char *data = (unsigned char *)prv_img->rect[size]; + const size_t len = prv_img->w[size] * prv_img->h[size] * 4; + size_t i; + + BLI_assert(sizeof(unsigned int) == 4); + + if (id != NULL) { + BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); + } + + for (i = 0; i < len; i++) { + data[i] = FTOCHAR(values[i]); + } + prv_img->flag[size] |= PRV_USER_EDITED; +} + + +static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, int value) +{ + rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_PREVIEW); +} + +static void rna_ImagePreview_image_size_get(PointerRNA *ptr, int *values) +{ + rna_ImagePreview_size_get(ptr, values, ICON_SIZE_PREVIEW); +} + +static void rna_ImagePreview_image_size_set(PointerRNA *ptr, const int *values) +{ + rna_ImagePreview_size_set(ptr, values, ICON_SIZE_PREVIEW); +} + +static int rna_ImagePreview_image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) +{ + return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_PREVIEW); +} + +static void rna_ImagePreview_image_pixels_get(PointerRNA *ptr, int *values) +{ + rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_PREVIEW); +} + +static void rna_ImagePreview_image_pixels_set(PointerRNA *ptr, const int *values) +{ + rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_PREVIEW); +} + +static int rna_ImagePreview_image_pixels_float_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) +{ + return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_PREVIEW); +} + +static void rna_ImagePreview_image_pixels_float_get(PointerRNA *ptr, float *values) +{ + rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_PREVIEW); +} + +static void rna_ImagePreview_image_pixels_float_set(PointerRNA *ptr, const float *values) +{ + rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_PREVIEW); +} + + +static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, int value) +{ + rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_ICON); +} + +static void rna_ImagePreview_icon_size_get(PointerRNA *ptr, int *values) +{ + rna_ImagePreview_size_get(ptr, values, ICON_SIZE_ICON); +} + +static void rna_ImagePreview_icon_size_set(PointerRNA *ptr, const int *values) +{ + rna_ImagePreview_size_set(ptr, values, ICON_SIZE_ICON); +} + +static int rna_ImagePreview_icon_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) +{ + return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_ICON); +} + +static void rna_ImagePreview_icon_pixels_get(PointerRNA *ptr, int *values) +{ + rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_ICON); +} + +static void rna_ImagePreview_icon_pixels_set(PointerRNA *ptr, const int *values) +{ + rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_ICON); +} + +static int rna_ImagePreview_icon_pixels_float_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) +{ + return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_ICON); +} + +static void rna_ImagePreview_icon_pixels_float_get(PointerRNA *ptr, float *values) +{ + rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_ICON); +} + +static void rna_ImagePreview_icon_pixels_float_set(PointerRNA *ptr, const float *values) +{ + rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_ICON); +} + + +static int rna_ImagePreview_icon_id_get(PointerRNA *ptr) +{ + /* Using a callback here allows us to only generate icon matching that preview when icon_id is requested. */ + return BKE_icon_preview_ensure((PreviewImage *)(ptr->data)); +} +static void rna_ImagePreview_icon_reload(PreviewImage *prv) +{ + /* will lazy load on next use, but only in case icon is not user-modified! */ + if (!(prv->flag[ICON_SIZE_ICON] & PRV_USER_EDITED) && !(prv->flag[ICON_SIZE_PREVIEW] & PRV_USER_EDITED)) { + BKE_previewimg_clear(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) @@ -520,6 +823,79 @@ static void rna_def_ID_materials(BlenderRNA *brna) RNA_def_boolean(func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned"); } +static void rna_def_image_preview(BlenderRNA *brna) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ImagePreview", NULL); + RNA_def_struct_sdna(srna, "PreviewImage"); + RNA_def_struct_ui_text(srna, "Image Preview", "Preview image and icon"); + + prop = RNA_def_property(srna, "is_image_custom", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag[ICON_SIZE_PREVIEW]", PRV_USER_EDITED); + RNA_def_property_boolean_funcs(prop, NULL, "rna_ImagePreview_is_image_custom_set"); + RNA_def_property_ui_text(prop, "Custom Image", "True if this preview image has been modified by py script," + "and is no more auto-generated by Blender"); + + prop = RNA_def_int_vector(srna, "image_size", 2, NULL, 0, 0, "Image Size", + "Width and height in pixels", 0, 0); + RNA_def_property_subtype(prop, PROP_PIXEL); + RNA_def_property_int_funcs(prop, "rna_ImagePreview_image_size_get", "rna_ImagePreview_image_size_set", NULL); + + prop = RNA_def_property(srna, "image_pixels", PROP_INT, PROP_NONE); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_multi_array(prop, 1, NULL); + RNA_def_property_ui_text(prop, "Image Pixels", "Image pixels, as bytes (always RGBA 32bits)"); + RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_get_length"); + RNA_def_property_int_funcs(prop, "rna_ImagePreview_image_pixels_get", "rna_ImagePreview_image_pixels_set", NULL); + + prop = RNA_def_property(srna, "image_pixels_float", PROP_FLOAT, PROP_NONE); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_multi_array(prop, 1, NULL); + RNA_def_property_ui_text(prop, "Float Image Pixels", + "Image pixels components, as floats (RGBA concatenated values)"); + RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_float_get_length"); + RNA_def_property_float_funcs(prop, "rna_ImagePreview_image_pixels_float_get", + "rna_ImagePreview_image_pixels_float_set", NULL); + + + prop = RNA_def_property(srna, "is_icon_custom", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag[ICON_SIZE_ICON]", PRV_USER_EDITED); + RNA_def_property_boolean_funcs(prop, NULL, "rna_ImagePreview_is_icon_custom_set"); + RNA_def_property_ui_text(prop, "Custom Icon", "True if this preview icon has been modified by py script," + "and is no more auto-generated by Blender"); + + prop = RNA_def_int_vector(srna, "icon_size", 2, NULL, 0, 0, "Icon Size", + "Width and height in pixels", 0, 0); + RNA_def_property_subtype(prop, PROP_PIXEL); + RNA_def_property_int_funcs(prop, "rna_ImagePreview_icon_size_get", "rna_ImagePreview_icon_size_set", NULL); + + prop = RNA_def_property(srna, "icon_pixels", PROP_INT, PROP_NONE); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_multi_array(prop, 1, NULL); + RNA_def_property_ui_text(prop, "Icon Pixels", "Icon pixels, as bytes (always RGBA 32bits)"); + RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_get_length"); + RNA_def_property_int_funcs(prop, "rna_ImagePreview_icon_pixels_get", "rna_ImagePreview_icon_pixels_set", NULL); + + prop = RNA_def_property(srna, "icon_pixels_float", PROP_FLOAT, PROP_NONE); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_multi_array(prop, 1, NULL); + RNA_def_property_ui_text(prop, "Float Icon Pixels", "Icon pixels components, as floats (RGBA concatenated values)"); + RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_float_get_length"); + RNA_def_property_float_funcs(prop, "rna_ImagePreview_icon_pixels_float_get", + "rna_ImagePreview_icon_pixels_float_set", NULL); + + prop = RNA_def_int(srna, "icon_id", 0, INT_MIN, INT_MAX, "Icon ID", + "Unique integer identifying this preview as an icon (zero means invalid)", INT_MIN, INT_MAX); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_ImagePreview_icon_id_get", NULL, NULL); + + func = RNA_def_function(srna, "reload", "rna_ImagePreview_icon_reload"); + RNA_def_function_ui_description(func, "Reload the preview from its source path"); +} + static void rna_def_ID(BlenderRNA *brna) { StructRNA *srna; @@ -562,7 +938,9 @@ static void rna_def_ID(BlenderRNA *brna) prop = RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_DOIT); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); - RNA_def_property_ui_text(prop, "Tag", "Tools can use this to tag data (initial state is undefined)"); + RNA_def_property_ui_text(prop, "Tag", + "Tools can use this to tag data for their own purposes " + "(initial state is undefined)"); prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_ID_RECALC); @@ -584,6 +962,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)"); @@ -594,17 +977,21 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, " "on reload the data will be removed"); - func = RNA_def_function(srna, "animation_data_create", "BKE_id_add_animdata"); + func = RNA_def_function(srna, "animation_data_create", "rna_ID_animation_data_create"); + RNA_def_function_flag(func, FUNC_USE_MAIN); RNA_def_function_ui_description(func, "Create animation data to this ID, note that not all ID types support this"); parm = RNA_def_pointer(func, "anim_data", "AnimData", "", "New animation data or NULL"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "animation_data_clear", "BKE_free_animdata"); + func = RNA_def_function(srna, "animation_data_clear", "rna_ID_animation_data_free"); + RNA_def_function_flag(func, FUNC_USE_MAIN); RNA_def_function_ui_description(func, "Clear animation on this this ID"); func = RNA_def_function(srna, "update_tag", "rna_ID_update_tag"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Tag the ID to update its display data"); + RNA_def_function_ui_description(func, + "Tag the ID to update its display data, " + "e.g. when calling :class:`bpy.types.Scene.update`"); RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform"); } @@ -643,6 +1030,7 @@ void RNA_def_ID(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Any Type", "RNA type used for pointers to any possible data"); rna_def_ID(brna); + rna_def_image_preview(brna); rna_def_ID_properties(brna); rna_def_ID_materials(brna); rna_def_library(brna); |