Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_ID.c
| Show First 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| ID *id = (ID *)ptr->id.data; | ID *id = (ID *)ptr->id.data; | ||||
| PreviewImage *prv_img = (PreviewImage *)ptr->data; | PreviewImage *prv_img = (PreviewImage *)ptr->data; | ||||
| if (id != NULL) { | if (id != NULL) { | ||||
| BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); | 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]) { | if (values[0] && values[1]) { | ||||
| prv_img->rect[size] = MEM_callocN(values[0] * values[1] * sizeof(unsigned int), "prv_rect"); | prv_img->rect[size] = MEM_callocN(values[0] * values[1] * sizeof(unsigned int), "prv_rect"); | ||||
| } | |||||
| prv_img->w[size] = values[0]; | prv_img->w[size] = values[0]; | ||||
| prv_img->h[size] = values[1]; | prv_img->h[size] = values[1]; | ||||
| } | |||||
| prv_img->flag[size] |= (PRV_CHANGED | PRV_USER_EDITED); | 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) | static int rna_ImagePreview_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION], enum eIconSizes size) | ||||
| { | { | ||||
| ID *id = ptr->id.data; | ID *id = ptr->id.data; | ||||
| PreviewImage *prv_img = (PreviewImage *)ptr->data; | PreviewImage *prv_img = (PreviewImage *)ptr->data; | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
| static void rna_ImagePreview_icon_reload(PreviewImage *prv) | static void rna_ImagePreview_icon_reload(PreviewImage *prv) | ||||
| { | { | ||||
| /* will lazy load on next use, but only in case icon is not user-modified! */ | /* 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)) { | if (!(prv->flag[ICON_SIZE_ICON] & PRV_USER_EDITED) && !(prv->flag[ICON_SIZE_PREVIEW] & PRV_USER_EDITED)) { | ||||
| BKE_previewimg_clear(prv); | 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 | #else | ||||
| static void rna_def_ID_properties(BlenderRNA *brna) | static void rna_def_ID_properties(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* this is struct is used for holding the virtual | /* this is struct is used for holding the virtual | ||||
| ▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | static void rna_def_ID(BlenderRNA *brna) | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "Is Indirect", "Is this ID block linked indirectly"); | RNA_def_property_ui_text(prop, "Is Indirect", "Is this ID block linked indirectly"); | ||||
| prop = RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_pointer_sdna(prop, NULL, "lib"); | RNA_def_property_pointer_sdna(prop, NULL, "lib"); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "Library", "Library file the datablock is linked from"); | 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 */ | /* functions */ | ||||
| func = RNA_def_function(srna, "copy", "rna_ID_copy"); | 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)"); | RNA_def_function_ui_description(func, "Create a copy of this datablock (not supported for all datablocks)"); | ||||
| parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID"); | parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID"); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear"); | func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear"); | ||||
| RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, " | RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, " | ||||
| ▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines | |||||