Blender  V2.93
BKE_icons.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2006-2007 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include "BLI_compiler_attrs.h"
38 
39 typedef void (*DrawInfoFreeFP)(void *drawinfo);
40 
41 enum {
54 };
55 
59 struct Icon {
60  void *drawinfo;
66  void *obj;
67  char obj_type;
69  char flag;
71  short id_type;
73 };
74 
76 struct Icon_Geom {
77  int icon_id;
79  int coords_range[2];
80  unsigned char (*coords)[2];
81  unsigned char (*colors)[4];
82  /* when not NULL, the memory of coords and colors is a sub-region of this pointer. */
83  const void *mem;
84 };
85 
86 typedef struct Icon Icon;
87 
88 struct BlendDataReader;
89 struct BlendWriter;
90 struct ID;
91 struct ImBuf;
92 struct PreviewImage;
93 struct StudioLight;
94 struct bGPDlayer;
95 
96 enum eIconSizes;
97 
98 void BKE_icons_init(int first_dyn_id);
99 
100 /* return icon id for library object or create new icon if not found */
101 int BKE_icon_id_ensure(struct ID *id);
102 
103 /* return icon id for Grease Pencil layer (color preview) or create new icon if not found */
105 
106 int BKE_icon_preview_ensure(struct ID *id, struct PreviewImage *preview);
107 
110 
111 /* retrieve icon for id */
112 struct Icon *BKE_icon_get(const int icon_id);
113 
114 /* set icon for id if not already defined */
115 /* used for inserting the internal icons */
116 void BKE_icon_set(const int icon_id, struct Icon *icon);
117 
118 /* remove icon and free data if library object becomes invalid */
119 void BKE_icon_id_delete(struct ID *id);
120 
121 bool BKE_icon_delete(const int icon_id);
122 bool BKE_icon_delete_unmanaged(const int icon_id);
123 
124 /* report changes - icon needs to be recalculated */
125 void BKE_icon_changed(const int icon_id);
126 
127 /* free all icons */
128 void BKE_icons_free(void);
129 
130 /* free all icons marked for deferred deletion */
131 void BKE_icons_deferred_free(void);
132 
133 /* free the preview image for use in list */
134 void BKE_previewimg_freefunc(void *link);
135 
136 /* free the preview image */
137 void BKE_previewimg_free(struct PreviewImage **prv);
138 
139 /* clear the preview image or icon, but does not free it */
140 void BKE_previewimg_clear(struct PreviewImage *prv);
141 
142 /* clear the preview image or icon at a specific size */
144 
145 /* get the preview from any pointer */
146 struct PreviewImage **BKE_previewimg_id_get_p(const struct ID *id);
147 struct PreviewImage *BKE_previewimg_id_get(const struct ID *id);
148 
149 bool BKE_previewimg_id_supports_jobs(const struct ID *id);
150 
151 /* Trigger deferred loading of a custom image file into the preview buffer. */
152 void BKE_previewimg_id_custom_set(struct ID *id, const char *path);
153 
154 /* free the preview image belonging to the id */
155 void BKE_previewimg_id_free(struct ID *id);
156 
157 /* create a new preview image */
158 struct PreviewImage *BKE_previewimg_create(void);
159 
160 /* create a copy of the preview image */
161 struct PreviewImage *BKE_previewimg_copy(const struct PreviewImage *prv);
162 
163 void BKE_previewimg_id_copy(struct ID *new_id, const struct ID *old_id);
164 
165 /* retrieve existing or create new preview image */
166 struct PreviewImage *BKE_previewimg_id_ensure(struct ID *id);
167 
168 void BKE_previewimg_ensure(struct PreviewImage *prv, const int size);
169 
170 struct ImBuf *BKE_previewimg_to_imbuf(struct PreviewImage *prv, const int size);
171 
172 void BKE_previewimg_finish(struct PreviewImage *prv, const int size);
173 bool BKE_previewimg_is_finished(const struct PreviewImage *prv, const int size);
174 
175 struct PreviewImage *BKE_previewimg_cached_get(const char *name);
176 
177 struct PreviewImage *BKE_previewimg_cached_ensure(const char *name);
178 
179 struct PreviewImage *BKE_previewimg_cached_thumbnail_read(const char *name,
180  const char *path,
181  const int source,
182  bool force_update);
183 
184 void BKE_previewimg_cached_release(const char *name);
185 
187 
188 void BKE_previewimg_blend_write(struct BlendWriter *writer, const struct PreviewImage *prv);
189 void BKE_previewimg_blend_read(struct BlendDataReader *reader, struct PreviewImage *prv);
190 
191 int BKE_icon_geom_ensure(struct Icon_Geom *geom);
192 struct Icon_Geom *BKE_icon_geom_from_memory(uchar *data, size_t data_len);
193 struct Icon_Geom *BKE_icon_geom_from_file(const char *filename);
194 
195 struct ImBuf *BKE_icon_geom_rasterize(const struct Icon_Geom *geom,
196  const unsigned int size_x,
197  const unsigned int size_y);
198 void BKE_icon_geom_invert_lightness(struct Icon_Geom *geom);
199 
200 int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type);
201 
202 #define ICON_RENDER_DEFAULT_HEIGHT 32
203 
204 #ifdef __cplusplus
205 }
206 #endif
struct PreviewImage * BKE_previewimg_id_ensure(struct ID *id)
Definition: icons.cc:400
bool BKE_previewimg_id_supports_jobs(const struct ID *id)
void BKE_icon_id_delete(struct ID *id)
Definition: icons.cc:919
struct ImBuf * BKE_icon_imbuf_get_buffer(int icon_id) ATTR_WARN_UNUSED_RESULT
Definition: icons.cc:866
void BKE_previewimg_cached_release(const char *name)
Definition: icons.cc:530
void BKE_icon_changed(const int icon_id)
Definition: icons.cc:678
void(* DrawInfoFreeFP)(void *drawinfo)
Definition: BKE_icons.h:39
struct PreviewImage * BKE_previewimg_create(void)
Definition: icons.cc:273
int BKE_icon_imbuf_create(struct ImBuf *ibuf) ATTR_WARN_UNUSED_RESULT
Definition: icons.cc:856
void BKE_previewimg_id_free(struct ID *id)
Definition: icons.cc:392
struct PreviewImage * BKE_previewimg_cached_get(const char *name)
Definition: icons.cc:455
void BKE_previewimg_ensure(struct PreviewImage *prv, const int size)
Definition: icons.cc:543
void BKE_previewimg_free(struct PreviewImage **prv)
Definition: icons.cc:295
struct Icon_Geom * BKE_icon_geom_from_file(const char *filename)
Definition: icons.cc:1040
void BKE_previewimg_id_copy(struct ID *new_id, const struct ID *old_id)
void BKE_previewimg_freefunc(void *link)
Definition: icons.cc:278
struct Icon_Geom * BKE_icon_geom_from_memory(uchar *data, size_t data_len)
Definition: icons.cc:1001
void BKE_icons_deferred_free(void)
Definition: icons.cc:229
void BKE_icon_set(const int icon_id, struct Icon *icon)
Definition: icons.cc:897
void BKE_previewimg_clear(struct PreviewImage *prv)
Definition: icons.cc:315
struct PreviewImage * BKE_previewimg_copy(const struct PreviewImage *prv)
@ ICON_DATA_IMBUF
Definition: BKE_icons.h:45
@ ICON_DATA_STUDIOLIGHT
Definition: BKE_icons.h:51
@ ICON_DATA_PREVIEW
Definition: BKE_icons.h:47
@ ICON_DATA_ID
Definition: BKE_icons.h:43
@ ICON_DATA_GPLAYER
Definition: BKE_icons.h:53
@ ICON_DATA_GEOM
Definition: BKE_icons.h:49
struct ImBuf * BKE_previewimg_to_imbuf(struct PreviewImage *prv, const int size)
Definition: icons.cc:597
void BKE_previewimg_blend_read(struct BlendDataReader *reader, struct PreviewImage *prv)
Definition: icons.cc:651
struct PreviewImage ** BKE_previewimg_id_get_p(const struct ID *id)
int BKE_icon_gplayer_color_ensure(struct bGPDlayer *gpl)
Definition: icons.cc:785
bool BKE_previewimg_is_finished(const struct PreviewImage *prv, const int size)
struct PreviewImage * BKE_previewimg_cached_ensure(const char *name)
Definition: icons.cc:464
void BKE_previewimg_finish(struct PreviewImage *prv, const int size)
Definition: icons.cc:614
void BKE_previewimg_id_custom_set(struct ID *id, const char *path)
Definition: icons.cc:414
void BKE_icons_free(void)
Definition: icons.cc:212
void BKE_previewimg_clear_single(struct PreviewImage *prv, enum eIconSizes size)
Definition: icons.cc:303
struct PreviewImage * BKE_previewimg_id_get(const struct ID *id)
int BKE_icon_preview_ensure(struct ID *id, struct PreviewImage *preview)
Definition: icons.cc:811
int BKE_icon_geom_ensure(struct Icon_Geom *geom)
Definition: icons.cc:985
void BKE_previewimg_deferred_release(struct PreviewImage *prv)
Definition: icons.cc:440
struct PreviewImage * BKE_previewimg_cached_thumbnail_read(const char *name, const char *path, const int source, bool force_update)
Definition: icons.cc:485
void BKE_icon_geom_invert_lightness(struct Icon_Geom *geom)
void BKE_previewimg_blend_write(struct BlendWriter *writer, const struct PreviewImage *prv)
bool BKE_icon_delete_unmanaged(const int icon_id)
Definition: icons.cc:957
struct Icon * BKE_icon_get(const int icon_id)
Definition: icons.cc:881
int BKE_icon_id_ensure(struct ID *id)
Definition: icons.cc:740
int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type)
Definition: icons.cc:1057
void BKE_icons_init(int first_dyn_id)
Definition: icons.cc:195
bool BKE_icon_delete(const int icon_id)
Definition: icons.cc:940
struct ImBuf * BKE_icon_geom_rasterize(const struct Icon_Geom *geom, const unsigned int size_x, const unsigned int size_y)
void BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() ATTR_WARN_UNUSED_RESULT
unsigned char uchar
Definition: BLI_sys_types.h:86
eIconSizes
Definition: DNA_ID_enums.h:28
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
Definition: DNA_ID.h:273
int coords_len
Definition: BKE_icons.h:78
const void * mem
Definition: BKE_icons.h:83
unsigned char(* colors)[4]
Definition: BKE_icons.h:81
int icon_id
Definition: BKE_icons.h:77
unsigned char(* coords)[2]
Definition: BKE_icons.h:80
int coords_range[2]
Definition: BKE_icons.h:79
Definition: BKE_icons.h:59
void * obj
Definition: BKE_icons.h:66
char flag
Definition: BKE_icons.h:69
char obj_type
Definition: BKE_icons.h:67
void * drawinfo
Definition: BKE_icons.h:60
short id_type
Definition: BKE_icons.h:71
DrawInfoFreeFP drawinfo_free
Definition: BKE_icons.h:72