Blender  V2.93
interface_icons.c
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) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <math.h>
25 #include <stdlib.h>
26 #include <string.h>
27 
28 #include "MEM_guardedalloc.h"
29 
30 #include "GPU_batch.h"
31 #include "GPU_batch_presets.h"
32 #include "GPU_immediate.h"
33 #include "GPU_matrix.h"
34 #include "GPU_state.h"
35 #include "GPU_texture.h"
36 
37 #include "BLI_blenlib.h"
38 #include "BLI_fileops_types.h"
39 #include "BLI_math_color_blend.h"
40 #include "BLI_math_vector.h"
41 #include "BLI_utildefines.h"
42 
43 #include "DNA_brush_types.h"
44 #include "DNA_collection_types.h"
45 #include "DNA_curve_types.h"
46 #include "DNA_dynamicpaint_types.h"
47 #include "DNA_gpencil_types.h"
48 #include "DNA_object_types.h"
49 #include "DNA_screen_types.h"
50 #include "DNA_space_types.h"
51 
52 #include "RNA_access.h"
53 
54 #include "BKE_appdir.h"
55 #include "BKE_context.h"
56 #include "BKE_global.h"
57 #include "BKE_icons.h"
58 #include "BKE_paint.h"
59 #include "BKE_studiolight.h"
60 
61 #include "IMB_imbuf.h"
62 #include "IMB_imbuf_types.h"
63 #include "IMB_thumbs.h"
64 
65 #include "BIF_glutil.h"
66 
67 #include "ED_datafiles.h"
68 #include "ED_keyframes_draw.h"
69 #include "ED_render.h"
70 
71 #include "UI_interface.h"
72 #include "UI_interface_icons.h"
73 
74 #include "WM_api.h"
75 #include "WM_types.h"
76 
77 #include "interface_intern.h"
78 
79 #ifndef WITH_HEADLESS
80 # define ICON_GRID_COLS 26
81 # define ICON_GRID_ROWS 30
82 
83 # define ICON_MONO_BORDER_OUTSET 2
84 # define ICON_GRID_MARGIN 10
85 # define ICON_GRID_W 32
86 # define ICON_GRID_H 32
87 #endif /* WITH_HEADLESS */
88 
89 typedef struct IconImage {
90  int w;
91  int h;
96 
97 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
98 
99 #define ICON_TYPE_PREVIEW 0
100 #define ICON_TYPE_COLOR_TEXTURE 1
101 #define ICON_TYPE_MONO_TEXTURE 2
102 #define ICON_TYPE_BUFFER 3
103 #define ICON_TYPE_IMBUF 4
104 #define ICON_TYPE_VECTOR 5
105 #define ICON_TYPE_GEOM 6
106 #define ICON_TYPE_EVENT 7 /* draw keymap entries using custom renderer. */
107 #define ICON_TYPE_GPLAYER 8
108 #define ICON_TYPE_BLANK 9
109 
110 typedef struct DrawInfo {
111  int type;
112 
113  union {
114  /* type specific data */
115  struct {
118  struct {
120  bool inverted;
121  } geom;
122  struct {
125  struct {
126  int x, y, w, h;
129  struct {
130  /* Can be packed into a single int. */
131  short event_type;
132  short event_value;
133  int icon;
134  /* Allow lookups. */
135  struct DrawInfo *next;
136  } input;
137  } data;
139 
140 typedef struct IconTexture {
141  struct GPUTexture *tex[2];
143  int w;
144  int h;
145  float invw;
146  float invh;
148 
149 typedef struct IconType {
150  int type;
153 
154 /* ******************* STATIC LOCAL VARS ******************* */
155 /* Static here to cache results of icon directory scan, so it's not
156  * scanning the file-system each time the menu is drawn. */
157 static struct ListBase iconfilelist = {NULL, NULL};
158 static IconTexture icongltex = {{NULL, NULL}, 0, 0, 0, 0.0f, 0.0f};
159 
160 #ifndef WITH_HEADLESS
161 
162 static const IconType icontypes[] = {
163 # define DEF_ICON(name) {ICON_TYPE_MONO_TEXTURE, 0},
164 # define DEF_ICON_SCENE(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_SCENE},
165 # define DEF_ICON_COLLECTION(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_COLLECTION},
166 # define DEF_ICON_OBJECT(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_OBJECT},
167 # define DEF_ICON_OBJECT_DATA(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_OBJECT_DATA},
168 # define DEF_ICON_MODIFIER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_MODIFIER},
169 # define DEF_ICON_SHADING(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_SHADING},
170 # define DEF_ICON_FOLDER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FOLDER},
171 # define DEF_ICON_FUND(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FUND},
172 # define DEF_ICON_VECTOR(name) {ICON_TYPE_VECTOR, 0},
173 # define DEF_ICON_COLOR(name) {ICON_TYPE_COLOR_TEXTURE, 0},
174 # define DEF_ICON_BLANK(name) {ICON_TYPE_BLANK, 0},
175 # include "UI_icons.h"
176 };
177 
178 /* **************************************************** */
179 
181  ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color)
182 {
183  Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
184 
185  new_icon->obj = NULL; /* icon is not for library object */
186  new_icon->id_type = 0;
187 
188  DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
189  di->type = type;
190 
192  di->data.texture.theme_color = theme_color;
193  di->data.texture.x = xofs;
194  di->data.texture.y = yofs;
195  di->data.texture.w = size;
196  di->data.texture.h = size;
197  }
198  else if (type == ICON_TYPE_BUFFER) {
199  IconImage *iimg = MEM_callocN(sizeof(IconImage), "icon_img");
200  iimg->w = size;
201  iimg->h = size;
202 
203  /* icon buffers can get initialized runtime now, via datatoc */
204  if (bbuf) {
205  int y, imgsize;
206 
207  iimg->rect = MEM_mallocN(size * size * sizeof(uint), "icon_rect");
208 
209  /* Here we store the rect in the icon - same as before */
210  if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) {
211  memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int));
212  }
213  else {
214  /* this code assumes square images */
215  imgsize = bbuf->x;
216  for (y = 0; y < size; y++) {
217  memcpy(
218  &iimg->rect[y * size], &bbuf->rect[(y + yofs) * imgsize + xofs], size * sizeof(int));
219  }
220  }
221  }
222  di->data.buffer.image = iimg;
223  }
224 
226  new_icon->drawinfo = di;
227 
228  BKE_icon_set(icon_id, new_icon);
229 
230  return di;
231 }
232 
233 static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
234 {
235  Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
236 
237  new_icon->obj = NULL; /* icon is not for library object */
238  new_icon->id_type = 0;
239 
240  DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
241  di->type = ICON_TYPE_VECTOR;
242  di->data.vector.func = drawFunc;
243 
244  new_icon->drawinfo_free = NULL;
245  new_icon->drawinfo = di;
246 
247  BKE_icon_set(icon_id, new_icon);
248 }
249 
250 /* Vector Icon Drawing Routines */
251 
252 /* Utilities */
253 
254 static void viconutil_set_point(int pt[2], int x, int y)
255 {
256  pt[0] = x;
257  pt[1] = y;
258 }
259 
260 static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
261 {
262  int pts[3][2];
263  const int cx = x + w / 2 - 4;
264  const int cy = y + w / 2;
265  const int d = w / 5, d2 = w / 7;
266 
267  viconutil_set_point(pts[0], cx - d2, cy + d);
268  viconutil_set_point(pts[1], cx - d2, cy - d);
269  viconutil_set_point(pts[2], cx + d2, cy);
270 
274  immUniformColor4f(0.2f, 0.2f, 0.2f, alpha);
275 
277  immVertex2iv(pos, pts[0]);
278  immVertex2iv(pos, pts[1]);
279  immVertex2iv(pos, pts[2]);
280  immEnd();
281 
283 }
284 
286  int x, int y, int w, int h, float alpha, short key_type, short handle_type)
287 {
288  /* init dummy theme state for Action Editor - where these colors are defined
289  * (since we're doing this offscreen, free from any particular space_id)
290  */
291  struct bThemeState theme_state;
292 
293  UI_Theme_Store(&theme_state);
295 
296  /* the "x" and "y" given are the bottom-left coordinates of the icon,
297  * while the draw_keyframe_shape() function needs the midpoint for
298  * the keyframe
299  */
300  const float xco = x + w / 2 + 0.5f;
301  const float yco = y + h / 2 + 0.5f;
302 
304  const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
305  const uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
306  uint color_id = GPU_vertformat_attr_add(
308  uint outline_color_id = GPU_vertformat_attr_add(
309  format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
310  const uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
311 
314  immUniform1f("outline_scale", 1.0f);
315  immUniform2f("ViewportSize", -1.0f, -1.0f);
317 
318  /* draw keyframe
319  * - size: (default icon size == 16, default dopesheet icon size == 10)
320  * - sel: true unless in handletype icons (so that "keyframe" state shows the iconic yellow icon)
321  */
322  const bool sel = (handle_type == KEYFRAME_HANDLE_NONE);
323 
325  yco,
326  (10.0f / 16.0f) * h,
327  sel,
328  key_type,
330  alpha,
331  pos_id,
332  size_id,
333  color_id,
334  outline_color_id,
335  flags_id,
336  handle_type,
338 
339  immEnd();
340  GPU_program_point_size(false);
342 
343  UI_Theme_Restore(&theme_state);
344 }
345 
346 static void vicon_keytype_keyframe_draw(int x, int y, int w, int h, float alpha)
347 {
349 }
350 
351 static void vicon_keytype_breakdown_draw(int x, int y, int w, int h, float alpha)
352 {
354 }
355 
356 static void vicon_keytype_extreme_draw(int x, int y, int w, int h, float alpha)
357 {
359 }
360 
361 static void vicon_keytype_jitter_draw(int x, int y, int w, int h, float alpha)
362 {
364 }
365 
366 static void vicon_keytype_moving_hold_draw(int x, int y, int w, int h, float alpha)
367 {
369 }
370 
371 static void vicon_handletype_free_draw(int x, int y, int w, int h, float alpha)
372 {
374 }
375 
376 static void vicon_handletype_aligned_draw(int x, int y, int w, int h, float alpha)
377 {
379 }
380 
381 static void vicon_handletype_vector_draw(int x, int y, int w, int h, float alpha)
382 {
384 }
385 
386 static void vicon_handletype_auto_draw(int x, int y, int w, int h, float alpha)
387 {
389 }
390 
391 static void vicon_handletype_auto_clamp_draw(int x, int y, int w, int h, float alpha)
392 {
394 }
395 
396 static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha))
397 {
398  bTheme *btheme = UI_GetTheme();
399  const ThemeWireColor *cs = &btheme->tarm[index];
400 
401  /* Draw three bands of color: One per color
402  * x-----a-----b-----c
403  * | N | S | A |
404  * x-----a-----b-----c
405  */
406  const int a = x + w / 3;
407  const int b = x + w / 3 * 2;
408  const int c = x + w;
409 
413 
414  /* XXX: Include alpha into this... */
415  /* normal */
417  immRecti(pos, x, y, a, y + h);
418 
419  /* selected */
421  immRecti(pos, a, y, b, y + h);
422 
423  /* active */
425  immRecti(pos, b, y, c, y + h);
426 
428 }
429 
430 # define DEF_ICON_VECTOR_COLORSET_DRAW_NTH(prefix, index) \
431  static void vicon_colorset_draw_##prefix(int x, int y, int w, int h, float alpha) \
432  { \
433  vicon_colorset_draw(index, x, y, w, h, alpha); \
434  }
435 
456 
457 # undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH
458 
460  short color_tag, int x, int y, int w, int UNUSED(h), float UNUSED(alpha))
461 {
462  bTheme *btheme = UI_GetTheme();
463  const ThemeCollectionColor *collection_color = &btheme->collection_color[color_tag];
464 
465  const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
466 
468  x, y, ICON_OUTLINER_COLLECTION, aspect, 1.0f, 0.0f, collection_color->color, true);
469 }
470 
471 # define DEF_ICON_COLLECTION_COLOR_DRAW(index, color) \
472  static void vicon_collection_color_draw_##index(int x, int y, int w, int h, float alpha) \
473  { \
474  vicon_collection_color_draw(color, x, y, w, h, alpha); \
475  }
476 
485 
486 # undef DEF_ICON_COLLECTION_COLOR_DRAW
487 
488 /* Dynamically render icon instead of rendering a plain color to a texture/buffer
489  * This is not strictly a "vicon", as it needs access to icon->obj to get the color info,
490  * but it works in a very similar way.
491  */
492 static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h)
493 {
494  bGPDlayer *gpl = (bGPDlayer *)icon->obj;
495 
496  /* Just draw a colored rect - Like for vicon_colorset_draw() */
497  /* TODO: Make this have rounded corners, and maybe be a bit smaller.
498  * However, UI_draw_roundbox_aa() draws the colors too dark, so can't be used.
499  */
503 
505  immRecti(pos, x, y, x + w - 1, y + h - 1);
506 
508 }
509 
510 static void init_brush_icons(void)
511 {
512 
513 # define INIT_BRUSH_ICON(icon_id, name) \
514  { \
515  uchar *rect = (uchar *)datatoc_##name##_png; \
516  const int size = datatoc_##name##_png_size; \
517  DrawInfo *di; \
518 \
519  di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER, 0); \
520  di->data.buffer.image->datatoc_rect = rect; \
521  di->data.buffer.image->datatoc_size = size; \
522  } \
523  ((void)0)
524  /* end INIT_BRUSH_ICON */
525 
526  const int w = 96; /* warning, brush size hardcoded in C, but it gets scaled */
527 
528  INIT_BRUSH_ICON(ICON_BRUSH_BLOB, blob);
529  INIT_BRUSH_ICON(ICON_BRUSH_BLUR, blur);
530  INIT_BRUSH_ICON(ICON_BRUSH_CLAY, clay);
531  INIT_BRUSH_ICON(ICON_BRUSH_CLAY_STRIPS, claystrips);
532  INIT_BRUSH_ICON(ICON_BRUSH_CLONE, clone);
533  INIT_BRUSH_ICON(ICON_BRUSH_CREASE, crease);
534  INIT_BRUSH_ICON(ICON_BRUSH_SCULPT_DRAW, draw);
535  INIT_BRUSH_ICON(ICON_BRUSH_FILL, fill);
536  INIT_BRUSH_ICON(ICON_BRUSH_FLATTEN, flatten);
537  INIT_BRUSH_ICON(ICON_BRUSH_GRAB, grab);
538  INIT_BRUSH_ICON(ICON_BRUSH_INFLATE, inflate);
539  INIT_BRUSH_ICON(ICON_BRUSH_LAYER, layer);
540  INIT_BRUSH_ICON(ICON_BRUSH_MASK, mask);
541  INIT_BRUSH_ICON(ICON_BRUSH_MIX, mix);
542  INIT_BRUSH_ICON(ICON_BRUSH_NUDGE, nudge);
543  INIT_BRUSH_ICON(ICON_BRUSH_PINCH, pinch);
544  INIT_BRUSH_ICON(ICON_BRUSH_SCRAPE, scrape);
545  INIT_BRUSH_ICON(ICON_BRUSH_SMEAR, smear);
546  INIT_BRUSH_ICON(ICON_BRUSH_SMOOTH, smooth);
547  INIT_BRUSH_ICON(ICON_BRUSH_SNAKE_HOOK, snake_hook);
548  INIT_BRUSH_ICON(ICON_BRUSH_SOFTEN, soften);
549  INIT_BRUSH_ICON(ICON_BRUSH_TEXDRAW, texdraw);
550  INIT_BRUSH_ICON(ICON_BRUSH_TEXFILL, texfill);
551  INIT_BRUSH_ICON(ICON_BRUSH_TEXMASK, texmask);
552  INIT_BRUSH_ICON(ICON_BRUSH_THUMB, thumb);
553  INIT_BRUSH_ICON(ICON_BRUSH_ROTATE, twist);
554 
555  /* grease pencil sculpt */
556  INIT_BRUSH_ICON(ICON_GPBRUSH_SMOOTH, gp_brush_smooth);
557  INIT_BRUSH_ICON(ICON_GPBRUSH_THICKNESS, gp_brush_thickness);
558  INIT_BRUSH_ICON(ICON_GPBRUSH_STRENGTH, gp_brush_strength);
559  INIT_BRUSH_ICON(ICON_GPBRUSH_GRAB, gp_brush_grab);
560  INIT_BRUSH_ICON(ICON_GPBRUSH_PUSH, gp_brush_push);
561  INIT_BRUSH_ICON(ICON_GPBRUSH_TWIST, gp_brush_twist);
562  INIT_BRUSH_ICON(ICON_GPBRUSH_PINCH, gp_brush_pinch);
563  INIT_BRUSH_ICON(ICON_GPBRUSH_RANDOMIZE, gp_brush_randomize);
564  INIT_BRUSH_ICON(ICON_GPBRUSH_CLONE, gp_brush_clone);
565  INIT_BRUSH_ICON(ICON_GPBRUSH_WEIGHT, gp_brush_weight);
566 
567  /* grease pencil drawing brushes */
568  INIT_BRUSH_ICON(ICON_GPBRUSH_PENCIL, gp_brush_pencil);
569  INIT_BRUSH_ICON(ICON_GPBRUSH_PEN, gp_brush_pen);
570  INIT_BRUSH_ICON(ICON_GPBRUSH_INK, gp_brush_ink);
571  INIT_BRUSH_ICON(ICON_GPBRUSH_INKNOISE, gp_brush_inknoise);
572  INIT_BRUSH_ICON(ICON_GPBRUSH_BLOCK, gp_brush_block);
573  INIT_BRUSH_ICON(ICON_GPBRUSH_MARKER, gp_brush_marker);
574  INIT_BRUSH_ICON(ICON_GPBRUSH_FILL, gp_brush_fill);
575  INIT_BRUSH_ICON(ICON_GPBRUSH_AIRBRUSH, gp_brush_airbrush);
576  INIT_BRUSH_ICON(ICON_GPBRUSH_CHISEL, gp_brush_chisel);
577  INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_SOFT, gp_brush_erase_soft);
578  INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_HARD, gp_brush_erase_hard);
579  INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_STROKE, gp_brush_erase_stroke);
580 
581 # undef INIT_BRUSH_ICON
582 }
583 
585 
586 int UI_icon_from_event_type(short event_type, short event_value)
587 {
588  if (event_type == EVT_RIGHTSHIFTKEY) {
589  event_type = EVT_LEFTSHIFTKEY;
590  }
591  else if (event_type == EVT_RIGHTCTRLKEY) {
592  event_type = EVT_LEFTCTRLKEY;
593  }
594  else if (event_type == EVT_RIGHTALTKEY) {
595  event_type = EVT_LEFTALTKEY;
596  }
597  else if (event_type == EVT_TWEAK_L) {
598  event_type = LEFTMOUSE;
599  event_value = KM_CLICK_DRAG;
600  }
601  else if (event_type == EVT_TWEAK_M) {
602  event_type = MIDDLEMOUSE;
603  event_value = KM_CLICK_DRAG;
604  }
605  else if (event_type == EVT_TWEAK_R) {
606  event_type = RIGHTMOUSE;
607  event_value = KM_CLICK_DRAG;
608  }
609 
611  do {
612  if (di->data.input.event_type == event_type) {
613  return di->data.input.icon;
614  }
615  } while ((di = di->data.input.next));
616 
617  if (event_type == LEFTMOUSE) {
618  return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_LMB : ICON_MOUSE_LMB_DRAG;
619  }
620  if (event_type == MIDDLEMOUSE) {
621  return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_MMB : ICON_MOUSE_MMB_DRAG;
622  }
623  if (event_type == RIGHTMOUSE) {
624  return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_RMB : ICON_MOUSE_RMB_DRAG;
625  }
626 
627  return ICON_NONE;
628 }
629 
630 int UI_icon_from_keymap_item(const wmKeyMapItem *kmi, int r_icon_mod[4])
631 {
632  if (r_icon_mod) {
633  memset(r_icon_mod, 0x0, sizeof(int[4]));
634  int i = 0;
635  if (!ELEM(kmi->ctrl, KM_NOTHING, KM_ANY)) {
636  r_icon_mod[i++] = ICON_EVENT_CTRL;
637  }
638  if (!ELEM(kmi->alt, KM_NOTHING, KM_ANY)) {
639  r_icon_mod[i++] = ICON_EVENT_ALT;
640  }
641  if (!ELEM(kmi->shift, KM_NOTHING, KM_ANY)) {
642  r_icon_mod[i++] = ICON_EVENT_SHIFT;
643  }
644  if (!ELEM(kmi->oskey, KM_NOTHING, KM_ANY)) {
645  r_icon_mod[i++] = ICON_EVENT_OS;
646  }
647  }
648  return UI_icon_from_event_type(kmi->type, kmi->val);
649 }
650 
651 static void init_event_icons(void)
652 {
653  DrawInfo *di_next = NULL;
654 
655 # define INIT_EVENT_ICON(icon_id, type, value) \
656  { \
657  DrawInfo *di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_EVENT, 0); \
658  di->data.input.event_type = type; \
659  di->data.input.event_value = value; \
660  di->data.input.icon = icon_id; \
661  di->data.input.next = di_next; \
662  di_next = di; \
663  } \
664  ((void)0)
665  /* end INIT_EVENT_ICON */
666 
667  const int w = 16; /* DUMMY */
668 
669  INIT_EVENT_ICON(ICON_EVENT_A, EVT_AKEY, KM_ANY);
670  INIT_EVENT_ICON(ICON_EVENT_B, EVT_BKEY, KM_ANY);
671  INIT_EVENT_ICON(ICON_EVENT_C, EVT_CKEY, KM_ANY);
672  INIT_EVENT_ICON(ICON_EVENT_D, EVT_DKEY, KM_ANY);
673  INIT_EVENT_ICON(ICON_EVENT_E, EVT_EKEY, KM_ANY);
674  INIT_EVENT_ICON(ICON_EVENT_F, EVT_FKEY, KM_ANY);
675  INIT_EVENT_ICON(ICON_EVENT_G, EVT_GKEY, KM_ANY);
676  INIT_EVENT_ICON(ICON_EVENT_H, EVT_HKEY, KM_ANY);
677  INIT_EVENT_ICON(ICON_EVENT_I, EVT_IKEY, KM_ANY);
678  INIT_EVENT_ICON(ICON_EVENT_J, EVT_JKEY, KM_ANY);
679  INIT_EVENT_ICON(ICON_EVENT_K, EVT_KKEY, KM_ANY);
680  INIT_EVENT_ICON(ICON_EVENT_L, EVT_LKEY, KM_ANY);
681  INIT_EVENT_ICON(ICON_EVENT_M, EVT_MKEY, KM_ANY);
682  INIT_EVENT_ICON(ICON_EVENT_N, EVT_NKEY, KM_ANY);
683  INIT_EVENT_ICON(ICON_EVENT_O, EVT_OKEY, KM_ANY);
684  INIT_EVENT_ICON(ICON_EVENT_P, EVT_PKEY, KM_ANY);
685  INIT_EVENT_ICON(ICON_EVENT_Q, EVT_QKEY, KM_ANY);
686  INIT_EVENT_ICON(ICON_EVENT_R, EVT_RKEY, KM_ANY);
687  INIT_EVENT_ICON(ICON_EVENT_S, EVT_SKEY, KM_ANY);
688  INIT_EVENT_ICON(ICON_EVENT_T, EVT_TKEY, KM_ANY);
689  INIT_EVENT_ICON(ICON_EVENT_U, EVT_UKEY, KM_ANY);
690  INIT_EVENT_ICON(ICON_EVENT_V, EVT_VKEY, KM_ANY);
691  INIT_EVENT_ICON(ICON_EVENT_W, EVT_WKEY, KM_ANY);
692  INIT_EVENT_ICON(ICON_EVENT_X, EVT_XKEY, KM_ANY);
693  INIT_EVENT_ICON(ICON_EVENT_Y, EVT_YKEY, KM_ANY);
694  INIT_EVENT_ICON(ICON_EVENT_Z, EVT_ZKEY, KM_ANY);
695  INIT_EVENT_ICON(ICON_EVENT_SHIFT, EVT_LEFTSHIFTKEY, KM_ANY);
696  INIT_EVENT_ICON(ICON_EVENT_CTRL, EVT_LEFTCTRLKEY, KM_ANY);
697  INIT_EVENT_ICON(ICON_EVENT_ALT, EVT_LEFTALTKEY, KM_ANY);
698  INIT_EVENT_ICON(ICON_EVENT_OS, EVT_OSKEY, KM_ANY);
699  INIT_EVENT_ICON(ICON_EVENT_F1, EVT_F1KEY, KM_ANY);
700  INIT_EVENT_ICON(ICON_EVENT_F2, EVT_F2KEY, KM_ANY);
701  INIT_EVENT_ICON(ICON_EVENT_F3, EVT_F3KEY, KM_ANY);
702  INIT_EVENT_ICON(ICON_EVENT_F4, EVT_F4KEY, KM_ANY);
703  INIT_EVENT_ICON(ICON_EVENT_F5, EVT_F5KEY, KM_ANY);
704  INIT_EVENT_ICON(ICON_EVENT_F6, EVT_F6KEY, KM_ANY);
705  INIT_EVENT_ICON(ICON_EVENT_F7, EVT_F7KEY, KM_ANY);
706  INIT_EVENT_ICON(ICON_EVENT_F8, EVT_F8KEY, KM_ANY);
707  INIT_EVENT_ICON(ICON_EVENT_F9, EVT_F9KEY, KM_ANY);
708  INIT_EVENT_ICON(ICON_EVENT_F10, EVT_F10KEY, KM_ANY);
709  INIT_EVENT_ICON(ICON_EVENT_F11, EVT_F11KEY, KM_ANY);
710  INIT_EVENT_ICON(ICON_EVENT_F12, EVT_F12KEY, KM_ANY);
711  INIT_EVENT_ICON(ICON_EVENT_ESC, EVT_ESCKEY, KM_ANY);
712  INIT_EVENT_ICON(ICON_EVENT_TAB, EVT_TABKEY, KM_ANY);
713  INIT_EVENT_ICON(ICON_EVENT_PAGEUP, EVT_PAGEUPKEY, KM_ANY);
714  INIT_EVENT_ICON(ICON_EVENT_PAGEDOWN, EVT_PAGEDOWNKEY, KM_ANY);
715  INIT_EVENT_ICON(ICON_EVENT_RETURN, EVT_RETKEY, KM_ANY);
716  INIT_EVENT_ICON(ICON_EVENT_SPACEKEY, EVT_SPACEKEY, KM_ANY);
717 
718  g_di_event_list = di_next;
719 
720 # undef INIT_EVENT_ICON
721 }
722 
723 static void icon_verify_datatoc(IconImage *iimg)
724 {
725  /* if it has own rect, things are all OK */
726  if (iimg->rect) {
727  return;
728  }
729 
730  if (iimg->datatoc_rect) {
732  iimg->datatoc_rect, iimg->datatoc_size, IB_rect, NULL, "<matcap icon>");
733  /* w and h were set on initialize */
734  if (bbuf->x != iimg->h && bbuf->y != iimg->w) {
735  IMB_scaleImBuf(bbuf, iimg->w, iimg->h);
736  }
737 
738  iimg->rect = bbuf->rect;
739  bbuf->rect = NULL;
740  IMB_freeImBuf(bbuf);
741  }
742 }
743 
745  int resolution_divider,
746  float border_intensity)
747 {
748  ImBuf *result = IMB_dupImBuf(buf);
749  const float border_sharpness = 16.0 / (resolution_divider * resolution_divider);
750 
751  float blurred_alpha_buffer[(ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) *
753  const int icon_width = (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) / resolution_divider;
754  const int icon_height = (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) / resolution_divider;
755 
756  for (int y = 0; y < ICON_GRID_ROWS; y++) {
757  for (int x = 0; x < ICON_GRID_COLS; x++) {
758  const IconType icontype = icontypes[y * ICON_GRID_COLS + x];
759  if (icontype.type != ICON_TYPE_MONO_TEXTURE) {
760  continue;
761  }
762 
765  sx = sx / resolution_divider;
766  sy = sy / resolution_divider;
767 
768  /* blur the alpha channel and store it in blurred_alpha_buffer */
769  const int blur_size = 2 / resolution_divider;
770  for (int bx = 0; bx < icon_width; bx++) {
771  const int asx = MAX2(bx - blur_size, 0);
772  const int aex = MIN2(bx + blur_size + 1, icon_width);
773  for (int by = 0; by < icon_height; by++) {
774  const int asy = MAX2(by - blur_size, 0);
775  const int aey = MIN2(by + blur_size + 1, icon_height);
776 
777  /* blur alpha channel */
778  const int write_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx;
779  float alpha_accum = 0.0;
780  uint alpha_samples = 0;
781  for (int ax = asx; ax < aex; ax++) {
782  for (int ay = asy; ay < aey; ay++) {
783  const int offset_read = (sy + ay) * buf->x + (sx + ax);
784  const uint color_read = buf->rect[offset_read];
785  const float alpha_read = ((color_read & 0xff000000) >> 24) / 255.0;
786  alpha_accum += alpha_read;
787  alpha_samples += 1;
788  }
789  }
790  blurred_alpha_buffer[write_offset] = alpha_accum / alpha_samples;
791  }
792  }
793 
794  /* apply blurred alpha */
795  for (int bx = 0; bx < icon_width; bx++) {
796  for (int by = 0; by < icon_height; by++) {
797  const int blurred_alpha_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx;
798  const int offset_write = (sy + by) * buf->x + (sx + bx);
799  const float blurred_alpha = blurred_alpha_buffer[blurred_alpha_offset];
800  const float border_srgb[4] = {
801  0, 0, 0, MIN2(1.0, blurred_alpha * border_sharpness) * border_intensity};
802 
803  const uint color_read = buf->rect[offset_write];
804  const uchar *orig_color = (uchar *)&color_read;
805 
806  float border_rgba[4];
807  float orig_rgba[4];
808  float dest_rgba[4];
809  float dest_srgb[4];
810 
811  srgb_to_linearrgb_v4(border_rgba, border_srgb);
812  srgb_to_linearrgb_uchar4(orig_rgba, orig_color);
813  blend_color_interpolate_float(dest_rgba, orig_rgba, border_rgba, 1.0 - orig_rgba[3]);
814  linearrgb_to_srgb_v4(dest_srgb, dest_rgba);
815 
816  const uint alpha_mask = ((uint)(dest_srgb[3] * 255)) << 24;
817  const uint cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask;
818  result->rect[offset_write] = cpack;
819  }
820  }
821  }
822  }
823  return result;
824 }
825 
826 static void free_icons_textures(void)
827 {
828  if (icongltex.num_textures > 0) {
829  for (int i = 0; i < 2; i++) {
830  if (icongltex.tex[i]) {
832  icongltex.tex[i] = NULL;
833  }
834  }
836  }
837 }
838 
839 /* Reload the textures for internal icons.
840  * This function will release the previous textures. */
842 {
843  bTheme *btheme = UI_GetTheme();
844  ImBuf *b16buf = NULL, *b32buf = NULL, *b16buf_border = NULL, *b32buf_border = NULL;
845  const float icon_border_intensity = btheme->tui.icon_border_intensity;
846  const bool need_icons_with_border = icon_border_intensity > 0.0f;
847 
848  if (b16buf == NULL) {
851  IB_rect,
852  NULL,
853  "<blender icons>");
854  }
855  if (b16buf) {
856  if (need_icons_with_border) {
857  b16buf_border = create_mono_icon_with_border(b16buf, 2, icon_border_intensity);
858  IMB_premultiply_alpha(b16buf_border);
859  }
860  IMB_premultiply_alpha(b16buf);
861  }
862 
863  if (b32buf == NULL) {
866  IB_rect,
867  NULL,
868  "<blender icons>");
869  }
870  if (b32buf) {
871  if (need_icons_with_border) {
872  b32buf_border = create_mono_icon_with_border(b32buf, 1, icon_border_intensity);
873  IMB_premultiply_alpha(b32buf_border);
874  }
875  IMB_premultiply_alpha(b32buf);
876  }
877 
878  if (b16buf && b32buf) {
879  /* Free existing texture if any. */
881 
882  /* Allocate OpenGL texture. */
883  icongltex.num_textures = need_icons_with_border ? 2 : 1;
884 
885  /* Note the filter and LOD bias were tweaked to better preserve icon
886  * sharpness at different UI scales. */
887  if (icongltex.tex[0] == NULL) {
888  icongltex.w = b32buf->x;
889  icongltex.h = b32buf->y;
890  icongltex.invw = 1.0f / b32buf->x;
891  icongltex.invh = 1.0f / b32buf->y;
892 
893  icongltex.tex[0] = GPU_texture_create_2d("icons", b32buf->x, b32buf->y, 2, GPU_RGBA8, NULL);
896  }
897 
898  if (need_icons_with_border && icongltex.tex[1] == NULL) {
900  "icons_border", b32buf_border->x, b32buf_border->y, 2, GPU_RGBA8, NULL);
901  GPU_texture_update_mipmap(icongltex.tex[1], 0, GPU_DATA_UBYTE, b32buf_border->rect);
902  GPU_texture_update_mipmap(icongltex.tex[1], 1, GPU_DATA_UBYTE, b16buf_border->rect);
903  }
904  }
905 
906  IMB_freeImBuf(b16buf);
907  IMB_freeImBuf(b32buf);
908  IMB_freeImBuf(b16buf_border);
909  IMB_freeImBuf(b32buf_border);
910 }
911 
912 static void init_internal_icons(void)
913 {
914 # if 0 /* temp disabled */
915  if ((btheme != NULL) && btheme->tui.iconfile[0]) {
916  char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
917  char iconfilestr[FILE_MAX];
918 
919  if (icondir) {
920  BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
921 
922  /* if the image is missing bbuf will just be NULL */
923  bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL);
924 
925  if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
926  printf(
927  "\n***WARNING***\n"
928  "Icons file '%s' too small.\n"
929  "Using built-in Icons instead\n",
930  iconfilestr);
931  IMB_freeImBuf(bbuf);
932  bbuf = NULL;
933  }
934  }
935  else {
936  printf("%s: 'icons' data path not found, continuing\n", __func__);
937  }
938  }
939 # endif
940 
941  /* Define icons. */
942  for (int y = 0; y < ICON_GRID_ROWS; y++) {
943  /* Row W has monochrome icons. */
944  for (int x = 0; x < ICON_GRID_COLS; x++) {
945  const IconType icontype = icontypes[y * ICON_GRID_COLS + x];
947  continue;
948  }
949 
954  ICON_GRID_W,
955  icontype.type,
956  icontype.theme_color);
957  }
958  }
959 
960  def_internal_vicon(ICON_SMALL_TRI_RIGHT_VEC, vicon_small_tri_right_draw);
961 
962  def_internal_vicon(ICON_KEYTYPE_KEYFRAME_VEC, vicon_keytype_keyframe_draw);
963  def_internal_vicon(ICON_KEYTYPE_BREAKDOWN_VEC, vicon_keytype_breakdown_draw);
964  def_internal_vicon(ICON_KEYTYPE_EXTREME_VEC, vicon_keytype_extreme_draw);
965  def_internal_vicon(ICON_KEYTYPE_JITTER_VEC, vicon_keytype_jitter_draw);
966  def_internal_vicon(ICON_KEYTYPE_MOVING_HOLD_VEC, vicon_keytype_moving_hold_draw);
967 
968  def_internal_vicon(ICON_HANDLETYPE_FREE_VEC, vicon_handletype_free_draw);
969  def_internal_vicon(ICON_HANDLETYPE_ALIGNED_VEC, vicon_handletype_aligned_draw);
970  def_internal_vicon(ICON_HANDLETYPE_VECTOR_VEC, vicon_handletype_vector_draw);
971  def_internal_vicon(ICON_HANDLETYPE_AUTO_VEC, vicon_handletype_auto_draw);
972  def_internal_vicon(ICON_HANDLETYPE_AUTO_CLAMP_VEC, vicon_handletype_auto_clamp_draw);
973 
974  def_internal_vicon(ICON_COLORSET_01_VEC, vicon_colorset_draw_01);
975  def_internal_vicon(ICON_COLORSET_02_VEC, vicon_colorset_draw_02);
976  def_internal_vicon(ICON_COLORSET_03_VEC, vicon_colorset_draw_03);
977  def_internal_vicon(ICON_COLORSET_04_VEC, vicon_colorset_draw_04);
978  def_internal_vicon(ICON_COLORSET_05_VEC, vicon_colorset_draw_05);
979  def_internal_vicon(ICON_COLORSET_06_VEC, vicon_colorset_draw_06);
980  def_internal_vicon(ICON_COLORSET_07_VEC, vicon_colorset_draw_07);
981  def_internal_vicon(ICON_COLORSET_08_VEC, vicon_colorset_draw_08);
982  def_internal_vicon(ICON_COLORSET_09_VEC, vicon_colorset_draw_09);
983  def_internal_vicon(ICON_COLORSET_10_VEC, vicon_colorset_draw_10);
984  def_internal_vicon(ICON_COLORSET_11_VEC, vicon_colorset_draw_11);
985  def_internal_vicon(ICON_COLORSET_12_VEC, vicon_colorset_draw_12);
986  def_internal_vicon(ICON_COLORSET_13_VEC, vicon_colorset_draw_13);
987  def_internal_vicon(ICON_COLORSET_14_VEC, vicon_colorset_draw_14);
988  def_internal_vicon(ICON_COLORSET_15_VEC, vicon_colorset_draw_15);
989  def_internal_vicon(ICON_COLORSET_16_VEC, vicon_colorset_draw_16);
990  def_internal_vicon(ICON_COLORSET_17_VEC, vicon_colorset_draw_17);
991  def_internal_vicon(ICON_COLORSET_18_VEC, vicon_colorset_draw_18);
992  def_internal_vicon(ICON_COLORSET_19_VEC, vicon_colorset_draw_19);
993  def_internal_vicon(ICON_COLORSET_20_VEC, vicon_colorset_draw_20);
994 
995  def_internal_vicon(ICON_COLLECTION_COLOR_01, vicon_collection_color_draw_01);
996  def_internal_vicon(ICON_COLLECTION_COLOR_02, vicon_collection_color_draw_02);
997  def_internal_vicon(ICON_COLLECTION_COLOR_03, vicon_collection_color_draw_03);
998  def_internal_vicon(ICON_COLLECTION_COLOR_04, vicon_collection_color_draw_04);
999  def_internal_vicon(ICON_COLLECTION_COLOR_05, vicon_collection_color_draw_05);
1000  def_internal_vicon(ICON_COLLECTION_COLOR_06, vicon_collection_color_draw_06);
1001  def_internal_vicon(ICON_COLLECTION_COLOR_07, vicon_collection_color_draw_07);
1002  def_internal_vicon(ICON_COLLECTION_COLOR_08, vicon_collection_color_draw_08);
1003 }
1004 
1005 static void init_iconfile_list(struct ListBase *list)
1006 {
1007  BLI_listbase_clear(list);
1008  const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
1009 
1010  if (icondir == NULL) {
1011  return;
1012  }
1013 
1014  struct direntry *dir;
1015  const int totfile = BLI_filelist_dir_contents(icondir, &dir);
1016 
1017  int index = 1;
1018  for (int i = 0; i < totfile; i++) {
1019  if ((dir[i].type & S_IFREG)) {
1020  const char *filename = dir[i].relname;
1021 
1022  if (BLI_path_extension_check(filename, ".png")) {
1023  /* loading all icons on file start is overkill & slows startup
1024  * its possible they change size after blender load anyway. */
1025 # if 0
1026  int ifilex, ifiley;
1027  char iconfilestr[FILE_MAX + 16]; /* allow 256 chars for file+dir */
1028  ImBuf *bbuf = NULL;
1029  /* check to see if the image is the right size, continue if not */
1030  /* copying strings here should go ok, assuming that we never get back
1031  * a complete path to file longer than 256 chars */
1032  BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, filename);
1033  bbuf = IMB_loadiffname(iconfilestr, IB_rect);
1034 
1035  if (bbuf) {
1036  ifilex = bbuf->x;
1037  ifiley = bbuf->y;
1038  IMB_freeImBuf(bbuf);
1039  }
1040  else {
1041  ifilex = ifiley = 0;
1042  }
1043 
1044  /* bad size or failed to load */
1045  if ((ifilex != ICON_IMAGE_W) || (ifiley != ICON_IMAGE_H)) {
1046  printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
1047  continue;
1048  }
1049 # endif /* removed */
1050 
1051  /* found a potential icon file, so make an entry for it in the cache list */
1052  IconFile *ifile = MEM_callocN(sizeof(IconFile), "IconFile");
1053 
1054  BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
1055  ifile->index = index;
1056 
1057  BLI_addtail(list, ifile);
1058 
1059  index++;
1060  }
1061  }
1062  }
1063 
1064  BLI_filelist_free(dir, totfile);
1065  dir = NULL;
1066 }
1067 
1068 static void free_iconfile_list(struct ListBase *list)
1069 {
1070  IconFile *ifile = NULL, *next_ifile = NULL;
1071 
1072  for (ifile = list->first; ifile; ifile = next_ifile) {
1073  next_ifile = ifile->next;
1074  BLI_freelinkN(list, ifile);
1075  }
1076 }
1077 
1078 #else
1079 
1081 {
1082 }
1083 
1084 #endif /* WITH_HEADLESS */
1085 
1086 int UI_iconfile_get_index(const char *filename)
1087 {
1088  IconFile *ifile;
1089  ListBase *list = &(iconfilelist);
1090 
1091  for (ifile = list->first; ifile; ifile = ifile->next) {
1092  if (BLI_path_cmp(filename, ifile->filename) == 0) {
1093  return ifile->index;
1094  }
1095  }
1096 
1097  return 0;
1098 }
1099 
1101 {
1102  ListBase *list = &(iconfilelist);
1103 
1104  return list;
1105 }
1106 
1107 void UI_icons_free(void)
1108 {
1109 #ifndef WITH_HEADLESS
1112 #endif
1113  BKE_icons_free();
1114 }
1115 
1116 void UI_icons_free_drawinfo(void *drawinfo)
1117 {
1118  DrawInfo *di = drawinfo;
1119 
1120  if (di == NULL) {
1121  return;
1122  }
1123 
1124  if (di->type == ICON_TYPE_BUFFER) {
1125  if (di->data.buffer.image) {
1126  if (di->data.buffer.image->rect) {
1127  MEM_freeN(di->data.buffer.image->rect);
1128  }
1129  MEM_freeN(di->data.buffer.image);
1130  }
1131  }
1132  else if (di->type == ICON_TYPE_GEOM) {
1133  if (di->data.geom.image_cache) {
1134  IMB_freeImBuf(di->data.geom.image_cache);
1135  }
1136  }
1137 
1138  MEM_freeN(di);
1139 }
1140 
1145 {
1146  const int icon_data_type = icon->obj_type;
1147 
1148  DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "di_icon");
1149 
1150  if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) {
1151  di->type = ICON_TYPE_PREVIEW;
1152  }
1153  else if (icon_data_type == ICON_DATA_IMBUF) {
1154  di->type = ICON_TYPE_IMBUF;
1155  }
1156  else if (icon_data_type == ICON_DATA_GEOM) {
1157  di->type = ICON_TYPE_GEOM;
1158  }
1159  else if (icon_data_type == ICON_DATA_STUDIOLIGHT) {
1160  di->type = ICON_TYPE_BUFFER;
1161  }
1162  else if (icon_data_type == ICON_DATA_GPLAYER) {
1163  di->type = ICON_TYPE_GPLAYER;
1164  }
1165  else {
1166  BLI_assert(0);
1167  }
1168 
1169  return di;
1170 }
1171 
1173 {
1174  if (icon->drawinfo) {
1175  return icon->drawinfo;
1176  }
1177  DrawInfo *di = icon_create_drawinfo(icon);
1178  icon->drawinfo = di;
1180  return di;
1181 }
1182 
1183 /* note!, returns unscaled by DPI */
1184 int UI_icon_get_width(int icon_id)
1185 {
1186  Icon *icon = BKE_icon_get(icon_id);
1187 
1188  if (icon == NULL) {
1189  if (G.debug & G_DEBUG) {
1190  printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
1191  }
1192  return 0;
1193  }
1194 
1195  DrawInfo *di = icon_ensure_drawinfo(icon);
1196  if (di) {
1197  return ICON_DEFAULT_WIDTH;
1198  }
1199 
1200  return 0;
1201 }
1202 
1203 int UI_icon_get_height(int icon_id)
1204 {
1205  Icon *icon = BKE_icon_get(icon_id);
1206  if (icon == NULL) {
1207  if (G.debug & G_DEBUG) {
1208  printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
1209  }
1210  return 0;
1211  }
1212 
1213  DrawInfo *di = icon_ensure_drawinfo(icon);
1214  if (di) {
1215  return ICON_DEFAULT_HEIGHT;
1216  }
1217 
1218  return 0;
1219 }
1220 
1221 bool UI_icon_get_theme_color(int icon_id, uchar color[4])
1222 {
1223  Icon *icon = BKE_icon_get(icon_id);
1224  if (icon == NULL) {
1225  return false;
1226  }
1227 
1228  DrawInfo *di = icon_ensure_drawinfo(icon);
1229  return UI_GetIconThemeColor4ubv(di->data.texture.theme_color, color);
1230 }
1231 
1233 {
1234 #ifndef WITH_HEADLESS
1238  init_brush_icons();
1239  init_event_icons();
1240 #endif
1241 }
1242 
1243 /* Render size for preview images and icons
1244  */
1246 {
1247  switch (size) {
1248  case ICON_SIZE_ICON:
1250  case ICON_SIZE_PREVIEW:
1252  default:
1253  return 0;
1254  }
1255 }
1256 
1257 /* Create rect for the icon
1258  */
1259 static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
1260 {
1261  const uint render_size = UI_icon_preview_to_render_size(size);
1262 
1263  if (!prv_img) {
1264  if (G.debug & G_DEBUG) {
1265  printf("%s, error: requested preview image does not exist", __func__);
1266  }
1267  }
1268  else if (!prv_img->rect[size]) {
1269  prv_img->w[size] = render_size;
1270  prv_img->h[size] = render_size;
1271  prv_img->flag[size] |= (PRV_CHANGED | PRV_UNFINISHED);
1272  prv_img->changed_timestamp[size] = 0;
1273  prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(uint), "prv_rect");
1274  }
1275 }
1276 
1278  const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job);
1279 
1280 static void ui_studiolight_icon_job_exec(void *customdata,
1281  short *UNUSED(stop),
1282  short *UNUSED(do_update),
1283  float *UNUSED(progress))
1284 {
1285  Icon **tmp = (Icon **)customdata;
1286  Icon *icon = *tmp;
1287  DrawInfo *di = icon_ensure_drawinfo(icon);
1288  StudioLight *sl = icon->obj;
1289  BKE_studiolight_preview(di->data.buffer.image->rect, sl, icon->id_type);
1290 }
1291 
1293 {
1294  Icon *icon = BKE_icon_get(icon_id);
1296  icon->obj = NULL;
1297 }
1298 
1300 {
1301  wmWindowManager *wm = data;
1302 
1303  /* Happens if job was canceled or already finished. */
1304  if (wm == NULL) {
1305  return;
1306  }
1307 
1308  /* get icons_id, get icons and kill wm jobs */
1309  if (sl->icon_id_radiance) {
1311  }
1312  if (sl->icon_id_irradiance) {
1314  }
1315  if (sl->icon_id_matcap) {
1317  }
1318  if (sl->icon_id_matcap_flipped) {
1320  }
1321 }
1322 
1323 static void ui_studiolight_icon_job_end(void *customdata)
1324 {
1325  Icon **tmp = (Icon **)customdata;
1326  Icon *icon = *tmp;
1327  StudioLight *sl = icon->obj;
1329 }
1330 
1331 void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
1332 {
1333  Icon *icon = BKE_icon_get(icon_id);
1334 
1335  if (icon == NULL) {
1336  return;
1337  }
1338 
1339  DrawInfo *di = icon_ensure_drawinfo(icon);
1340 
1341  if (di == NULL) {
1342  return;
1343  }
1344 
1345  switch (di->type) {
1346  case ICON_TYPE_PREVIEW: {
1347  ID *id = (icon->id_type != 0) ? icon->obj : NULL;
1348  PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
1349  /* Using jobs for screen previews crashes due to offscreen rendering.
1350  * XXX would be nicer if PreviewImage could store if it supports jobs */
1351  const bool use_jobs = !id || (GS(id->name) != ID_SCR);
1352 
1353  if (prv) {
1354  const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON;
1355 
1356  if (id || (prv->tag & PRV_TAG_DEFFERED) != 0) {
1357  ui_id_preview_image_render_size(C, NULL, id, prv, size, use_jobs);
1358  }
1359  }
1360  break;
1361  }
1362  case ICON_TYPE_BUFFER: {
1363  if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
1364  if (di->data.buffer.image == NULL) {
1366  StudioLight *sl = icon->obj;
1368  IconImage *img = MEM_mallocN(sizeof(IconImage), __func__);
1369 
1370  img->w = STUDIOLIGHT_ICON_SIZE;
1371  img->h = STUDIOLIGHT_ICON_SIZE;
1372  const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint);
1373  img->rect = MEM_mallocN(size, __func__);
1374  memset(img->rect, 0, size);
1375  di->data.buffer.image = img;
1376 
1377  wmJob *wm_job = WM_jobs_get(
1378  wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT);
1379  Icon **tmp = MEM_callocN(sizeof(Icon *), __func__);
1380  *tmp = icon;
1381  WM_jobs_customdata_set(wm_job, tmp, MEM_freeN);
1382  WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW);
1385  WM_jobs_start(CTX_wm_manager(C), wm_job);
1386  }
1387  }
1388  break;
1389  }
1390  }
1391 }
1392 
1399 static void icon_set_image(const bContext *C,
1400  Scene *scene,
1401  ID *id,
1402  PreviewImage *prv_img,
1403  enum eIconSizes size,
1404  const bool use_job)
1405 {
1406  if (!prv_img) {
1407  if (G.debug & G_DEBUG) {
1408  printf("%s: no preview image for this ID: %s\n", __func__, id->name);
1409  }
1410  return;
1411  }
1412 
1413  if (prv_img->flag[size] & PRV_USER_EDITED) {
1414  /* user-edited preview, do not auto-update! */
1415  return;
1416  }
1417 
1418  const bool delay = prv_img->rect[size] != NULL;
1419  icon_create_rect(prv_img, size);
1420 
1421  if (use_job && (!id || BKE_previewimg_id_supports_jobs(id))) {
1422  /* Job (background) version */
1424  C, prv_img, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size], delay);
1425  }
1426  else {
1427  if (!scene) {
1428  scene = CTX_data_scene(C);
1429  }
1430  /* Immediate version */
1431  ED_preview_icon_render(C, scene, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size]);
1432  }
1433 }
1434 
1436 {
1437  Icon *icon = BKE_icon_get(icon_id);
1438 
1439  if (icon == NULL) {
1440  return NULL;
1441  }
1442 
1443  DrawInfo *di = (DrawInfo *)icon->drawinfo;
1444 
1445  if (di == NULL) {
1446  return NULL;
1447  }
1448 
1449  if (di->type == ICON_TYPE_PREVIEW) {
1450  PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
1451  icon->obj;
1452 
1453  if (prv) {
1454  return BKE_previewimg_copy(prv);
1455  }
1456  }
1457  else if (di->data.buffer.image) {
1458  ImBuf *bbuf;
1459 
1460  bbuf = IMB_ibImageFromMemory(di->data.buffer.image->datatoc_rect,
1461  di->data.buffer.image->datatoc_size,
1462  IB_rect,
1463  NULL,
1464  __func__);
1465  if (bbuf) {
1467 
1468  prv->rect[0] = bbuf->rect;
1469 
1470  prv->w[0] = bbuf->x;
1471  prv->h[0] = bbuf->y;
1472 
1473  bbuf->rect = NULL;
1474  IMB_freeImBuf(bbuf);
1475 
1476  return prv;
1477  }
1478  }
1479 
1480  return NULL;
1481 }
1482 
1483 static void icon_draw_rect(float x,
1484  float y,
1485  int w,
1486  int h,
1487  float UNUSED(aspect),
1488  int rw,
1489  int rh,
1490  uint *rect,
1491  float alpha,
1492  const float desaturate)
1493 {
1494  ImBuf *ima = NULL;
1495  int draw_w = w;
1496  int draw_h = h;
1497  int draw_x = x;
1498  int draw_y = y;
1499 
1500  /* sanity check */
1501  if (w <= 0 || h <= 0 || w > 2000 || h > 2000) {
1502  printf("%s: icons are %i x %i pixels?\n", __func__, w, h);
1503  BLI_assert(!"invalid icon size");
1504  return;
1505  }
1506  /* modulate color */
1507  const float col[4] = {alpha, alpha, alpha, alpha};
1508 
1509  /* rect contains image in 'rendersize', we only scale if needed */
1510  if (rw != w || rh != h) {
1511  /* preserve aspect ratio and center */
1512  if (rw > rh) {
1513  draw_w = w;
1514  draw_h = (int)(((float)rh / (float)rw) * (float)w);
1515  draw_y += (h - draw_h) / 2;
1516  }
1517  else if (rw < rh) {
1518  draw_w = (int)(((float)rw / (float)rh) * (float)h);
1519  draw_h = h;
1520  draw_x += (w - draw_w) / 2;
1521  }
1522  /* if the image is squared, the draw_ initialization values are good */
1523 
1524  /* first allocate imbuf for scaling and copy preview into it */
1525  ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
1526  memcpy(ima->rect, rect, rw * rh * sizeof(uint));
1527  IMB_scaleImBuf(ima, draw_w, draw_h); /* scale it */
1528  rect = ima->rect;
1529  }
1530 
1531  /* draw */
1533  if (desaturate != 0.0f) {
1535  }
1536  else {
1538  }
1540 
1542  immUniform1f("factor", desaturate);
1543  }
1544 
1546  &state, draw_x, draw_y, draw_w, draw_h, GPU_RGBA8, false, rect, 1.0f, 1.0f, col);
1547 
1548  if (ima) {
1549  IMB_freeImBuf(ima);
1550  }
1551 }
1552 
1553 /* High enough to make a difference, low enough so that
1554  * small draws are still efficient with the use of glUniform.
1555  * NOTE TODO: We could use UBO but we would need some triple
1556  * buffer system + persistent mapping for this to be more
1557  * efficient than simple glUniform calls. */
1558 #define ICON_DRAW_CACHE_SIZE 16
1559 
1560 typedef struct IconDrawCall {
1563  float color[4];
1565 
1566 typedef struct IconTextureDrawCall {
1568  int calls; /* Number of calls batched together */
1570 
1571 static struct {
1574  bool enabled;
1575 } g_icon_draw_cache = {{{{{0}}}}};
1576 
1578 {
1579  BLI_assert(g_icon_draw_cache.enabled == false);
1580  g_icon_draw_cache.enabled = true;
1581 }
1582 
1584  IconTextureDrawCall *texture_draw_calls)
1585 {
1586  if (texture_draw_calls->calls == 0) {
1587  return;
1588  }
1589 
1592 
1593  const int img_binding = GPU_shader_get_texture_binding(shader, "image");
1594  const int data_loc = GPU_shader_get_uniform(shader, "calls_data");
1595 
1596  GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
1598  shader, data_loc, 4, ICON_DRAW_CACHE_SIZE * 3, (float *)texture_draw_calls->drawcall_cache);
1599 
1602  GPU_batch_draw_instanced(quad, texture_draw_calls->calls);
1603 
1605 
1606  texture_draw_calls->calls = 0;
1607 }
1608 
1609 static void icon_draw_cache_flush_ex(bool only_full_caches)
1610 {
1611  bool should_draw = false;
1612  if (only_full_caches) {
1613  should_draw = g_icon_draw_cache.normal.calls == ICON_DRAW_CACHE_SIZE ||
1614  g_icon_draw_cache.border.calls == ICON_DRAW_CACHE_SIZE;
1615  }
1616  else {
1617  should_draw = g_icon_draw_cache.normal.calls || g_icon_draw_cache.border.calls;
1618  }
1619 
1620  if (should_draw) {
1621  /* We need to flush widget base first to ensure correct ordering. */
1623 
1625 
1626  if (!only_full_caches || g_icon_draw_cache.normal.calls == ICON_DRAW_CACHE_SIZE) {
1628  }
1629 
1630  if (!only_full_caches || g_icon_draw_cache.border.calls == ICON_DRAW_CACHE_SIZE) {
1632  }
1633 
1635  }
1636 }
1637 
1639 {
1640  BLI_assert(g_icon_draw_cache.enabled == true);
1641  g_icon_draw_cache.enabled = false;
1642 
1643  /* Don't change blend state if it's not needed. */
1644  if (g_icon_draw_cache.border.calls == 0 && g_icon_draw_cache.normal.calls == 0) {
1645  return;
1646  }
1647 
1649  icon_draw_cache_flush_ex(false);
1651 }
1652 
1653 static void icon_draw_texture_cached(float x,
1654  float y,
1655  float w,
1656  float h,
1657  int ix,
1658  int iy,
1659  int UNUSED(iw),
1660  int ih,
1661  float alpha,
1662  const float rgb[3],
1663  bool with_border)
1664 {
1665 
1666  float mvp[4][4];
1668 
1669  IconTextureDrawCall *texture_call = with_border ? &g_icon_draw_cache.border :
1670  &g_icon_draw_cache.normal;
1671 
1672  IconDrawCall *call = &texture_call->drawcall_cache[texture_call->calls];
1673  texture_call->calls++;
1674 
1675  /* Manual mat4*vec2 */
1676  call->pos.xmin = x * mvp[0][0] + y * mvp[1][0] + mvp[3][0];
1677  call->pos.ymin = x * mvp[0][1] + y * mvp[1][1] + mvp[3][1];
1678  call->pos.xmax = call->pos.xmin + w * mvp[0][0] + h * mvp[1][0];
1679  call->pos.ymax = call->pos.ymin + w * mvp[0][1] + h * mvp[1][1];
1680 
1681  call->tex.xmin = ix * icongltex.invw;
1682  call->tex.xmax = (ix + ih) * icongltex.invw;
1683  call->tex.ymin = iy * icongltex.invh;
1684  call->tex.ymax = (iy + ih) * icongltex.invh;
1685 
1686  if (rgb) {
1687  copy_v4_fl4(call->color, rgb[0], rgb[1], rgb[2], alpha);
1688  }
1689  else {
1690  copy_v4_fl(call->color, alpha);
1691  }
1692 
1693  if (texture_call->calls == ICON_DRAW_CACHE_SIZE) {
1695  }
1696 }
1697 
1698 static void icon_draw_texture(float x,
1699  float y,
1700  float w,
1701  float h,
1702  int ix,
1703  int iy,
1704  int iw,
1705  int ih,
1706  float alpha,
1707  const float rgb[3],
1708  bool with_border)
1709 {
1710  if (g_icon_draw_cache.enabled) {
1711  icon_draw_texture_cached(x, y, w, h, ix, iy, iw, ih, alpha, rgb, with_border);
1712  return;
1713  }
1714 
1715  /* We need to flush widget base first to ensure correct ordering. */
1717 
1719 
1720  const float x1 = ix * icongltex.invw;
1721  const float x2 = (ix + ih) * icongltex.invw;
1722  const float y1 = iy * icongltex.invh;
1723  const float y2 = (iy + ih) * icongltex.invh;
1724 
1725  GPUTexture *texture = with_border ? icongltex.tex[1] : icongltex.tex[0];
1726 
1729 
1730  const int img_binding = GPU_shader_get_texture_binding(shader, "image");
1732  const int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
1733  const int rect_geom_loc = GPU_shader_get_uniform(shader, "rect_geom");
1734 
1735  if (rgb) {
1736  GPU_shader_uniform_vector(shader, color_loc, 4, 1, (float[4]){UNPACK3(rgb), alpha});
1737  }
1738  else {
1739  GPU_shader_uniform_vector(shader, color_loc, 4, 1, (float[4]){alpha, alpha, alpha, alpha});
1740  }
1741 
1742  GPU_shader_uniform_vector(shader, rect_tex_loc, 4, 1, (float[4]){x1, y1, x2, y2});
1743  GPU_shader_uniform_vector(shader, rect_geom_loc, 4, 1, (float[4]){x, y, x + w, y + h});
1744 
1745  GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
1746 
1750 
1752 
1754 }
1755 
1756 /* Drawing size for preview images */
1758 {
1759  switch (size) {
1760  case ICON_SIZE_ICON:
1761  return ICON_DEFAULT_HEIGHT;
1762  case ICON_SIZE_PREVIEW:
1763  return PREVIEW_DEFAULT_HEIGHT;
1764  default:
1765  return 0;
1766  }
1767 }
1768 
1769 static void icon_draw_size(float x,
1770  float y,
1771  int icon_id,
1772  float aspect,
1773  float alpha,
1774  enum eIconSizes size,
1775  int draw_size,
1776  const float desaturate,
1777  const uchar mono_rgba[4],
1778  const bool mono_border)
1779 {
1780  bTheme *btheme = UI_GetTheme();
1781  const float fdraw_size = (float)draw_size;
1782 
1783  Icon *icon = BKE_icon_get(icon_id);
1784  alpha *= btheme->tui.icon_alpha;
1785 
1786  if (icon == NULL) {
1787  if (G.debug & G_DEBUG) {
1788  printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
1789  }
1790  return;
1791  }
1792 
1793  /* scale width and height according to aspect */
1794  int w = (int)(fdraw_size / aspect + 0.5f);
1795  int h = (int)(fdraw_size / aspect + 0.5f);
1796 
1797  DrawInfo *di = icon_ensure_drawinfo(icon);
1798 
1799  /* We need to flush widget base first to ensure correct ordering. */
1801 
1802  if (di->type == ICON_TYPE_IMBUF) {
1803  ImBuf *ibuf = icon->obj;
1804 
1806  icon_draw_rect(x, y, w, h, aspect, ibuf->x, ibuf->y, ibuf->rect, alpha, desaturate);
1808  }
1809  else if (di->type == ICON_TYPE_VECTOR) {
1810  /* vector icons use the uiBlock transformation, they are not drawn
1811  * with untransformed coordinates like the other icons */
1812  di->data.vector.func((int)x, (int)y, w, h, 1.0f);
1813  }
1814  else if (di->type == ICON_TYPE_GEOM) {
1815 #ifdef USE_UI_TOOLBAR_HACK
1816  /* TODO(campbell): scale icons up for toolbar,
1817  * we need a way to detect larger buttons and do this automatic. */
1818  {
1819  float scale = (float)ICON_DEFAULT_HEIGHT_TOOLBAR / (float)ICON_DEFAULT_HEIGHT;
1820  y = (y + (h / 2)) - ((h * scale) / 2);
1821  w *= scale;
1822  h *= scale;
1823  }
1824 #endif
1825 
1826  /* If the theme is light, we will adjust the icon colors. */
1827  const bool invert = (rgb_to_grayscale_byte(btheme->tui.wcol_toolbar_item.inner) > 128);
1828  const bool geom_inverted = di->data.geom.inverted;
1829 
1830  /* This could re-generate often if rendered at different sizes in the one interface.
1831  * TODO(campbell): support caching multiple sizes. */
1832  ImBuf *ibuf = di->data.geom.image_cache;
1833  if ((ibuf == NULL) || (ibuf->x != w) || (ibuf->y != h) || (invert != geom_inverted)) {
1834  if (ibuf) {
1835  IMB_freeImBuf(ibuf);
1836  }
1837  if (invert != geom_inverted) {
1839  }
1840  ibuf = BKE_icon_geom_rasterize(icon->obj, w, h);
1841  di->data.geom.image_cache = ibuf;
1842  di->data.geom.inverted = invert;
1843  }
1844 
1846  icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, desaturate);
1848  }
1849  else if (di->type == ICON_TYPE_EVENT) {
1850  const short event_type = di->data.input.event_type;
1851  const short event_value = di->data.input.event_value;
1852  icon_draw_rect_input(x, y, w, h, alpha, event_type, event_value);
1853  }
1854  else if (di->type == ICON_TYPE_COLOR_TEXTURE) {
1855  /* texture image use premul alpha for correct scaling */
1857  y,
1858  (float)w,
1859  (float)h,
1860  di->data.texture.x,
1861  di->data.texture.y,
1862  di->data.texture.w,
1863  di->data.texture.h,
1864  alpha,
1865  NULL,
1866  false);
1867  }
1868  else if (di->type == ICON_TYPE_MONO_TEXTURE) {
1869  /* Monochrome icon that uses text or theme color. */
1870  const bool with_border = mono_border && (btheme->tui.icon_border_intensity > 0.0f);
1871  float color[4];
1872  if (mono_rgba) {
1873  rgba_uchar_to_float(color, (const uchar *)mono_rgba);
1874  }
1875  else {
1876  UI_GetThemeColor4fv(TH_TEXT, color);
1877  }
1878 
1879  mul_v4_fl(color, alpha);
1880 
1881  float border_outset = 0.0;
1882  uint border_texel = 0;
1883 #ifndef WITH_HEADLESS
1884  if (with_border) {
1885  const float scale = (float)ICON_GRID_W / (float)ICON_DEFAULT_WIDTH;
1886  border_texel = ICON_MONO_BORDER_OUTSET;
1887  border_outset = ICON_MONO_BORDER_OUTSET / (scale * aspect);
1888  }
1889 #endif
1890  icon_draw_texture(x - border_outset,
1891  y - border_outset,
1892  (float)w + 2 * border_outset,
1893  (float)h + 2 * border_outset,
1894  di->data.texture.x - border_texel,
1895  di->data.texture.y - border_texel,
1896  di->data.texture.w + 2 * border_texel,
1897  di->data.texture.h + 2 * border_texel,
1898  color[3],
1899  color,
1900  with_border);
1901  }
1902 
1903  else if (di->type == ICON_TYPE_BUFFER) {
1904  /* it is a builtin icon */
1905  IconImage *iimg = di->data.buffer.image;
1906 #ifndef WITH_HEADLESS
1907  icon_verify_datatoc(iimg);
1908 #endif
1909  if (!iimg->rect) {
1910  /* something has gone wrong! */
1911  return;
1912  }
1913 
1914  icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, desaturate);
1915  }
1916  else if (di->type == ICON_TYPE_PREVIEW) {
1917  PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
1918  icon->obj;
1919 
1920  if (pi) {
1921  /* no create icon on this level in code */
1922  if (!pi->rect[size]) {
1923  /* Something has gone wrong! */
1924  return;
1925  }
1926 
1927  /* Preview images use premultiplied alpha. */
1930  x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, desaturate);
1932  }
1933  }
1934  else if (di->type == ICON_TYPE_GPLAYER) {
1935  BLI_assert(icon->obj != NULL);
1936 
1937  /* Just draw a colored rect - Like for vicon_colorset_draw() */
1938 #ifndef WITH_HEADLESS
1939  vicon_gplayer_color_draw(icon, (int)x, (int)y, w, h);
1940 #endif
1941  }
1942 }
1943 
1945  const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job)
1946 {
1947  /* changed only ever set by dynamic icons */
1948  if (((pi->flag[size] & PRV_CHANGED) || !pi->rect[size])) {
1949  /* create the rect if necessary */
1950  icon_set_image(C, scene, id, pi, size, use_job);
1951 
1952  pi->flag[size] &= ~PRV_CHANGED;
1953  }
1954 }
1955 
1960  const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job)
1961 {
1963 
1964  if (pi == NULL) {
1965  return;
1966  }
1967 
1968  ui_id_preview_image_render_size(C, scene, id, pi, size, use_job);
1969 }
1970 
1971 static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
1972 {
1974 
1975  if (!pi) {
1976  return;
1977  }
1978 
1979  for (enum eIconSizes i = 0; i < NUM_ICON_SIZES; i++) {
1980  ui_id_preview_image_render_size(C, NULL, id, pi, i, use_jobs);
1981  }
1982 }
1983 
1984 static int ui_id_brush_get_icon(const bContext *C, ID *id)
1985 {
1986  Brush *br = (Brush *)id;
1987 
1988  if (br->flag & BRUSH_CUSTOM_ICON) {
1989  BKE_icon_id_ensure(id);
1990  ui_id_icon_render(C, id, true);
1991  }
1992  else {
1994  const EnumPropertyItem *items = NULL;
1995  ePaintMode paint_mode = PAINT_MODE_INVALID;
1996  ScrArea *area = CTX_wm_area(C);
1997  char space_type = area->spacetype;
1998  /* Fallback to 3D view. */
1999  if (space_type == SPACE_PROPERTIES) {
2000  space_type = SPACE_VIEW3D;
2001  }
2002 
2003  /* XXX: this is not nice, should probably make brushes
2004  * be strictly in one paint mode only to avoid
2005  * checking various context stuff here */
2006 
2007  if ((space_type == SPACE_VIEW3D) && ob) {
2008  if (ob->mode & OB_MODE_SCULPT) {
2009  paint_mode = PAINT_MODE_SCULPT;
2010  }
2011  else if (ob->mode & OB_MODE_VERTEX_PAINT) {
2012  paint_mode = PAINT_MODE_VERTEX;
2013  }
2014  else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
2015  paint_mode = PAINT_MODE_WEIGHT;
2016  }
2017  else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
2018  paint_mode = PAINT_MODE_TEXTURE_3D;
2019  }
2020  }
2021  else if (space_type == SPACE_IMAGE) {
2022  if (area->spacetype == space_type) {
2023  const SpaceImage *sima = area->spacedata.first;
2024  if (sima->mode == SI_MODE_PAINT) {
2025  paint_mode = PAINT_MODE_TEXTURE_2D;
2026  }
2027  }
2028  }
2029 
2030  /* reset the icon */
2031  if ((ob != NULL) &&
2034  (br->gpencil_settings != NULL)) {
2035  switch (br->gpencil_settings->icon_id) {
2036  case GP_BRUSH_ICON_PENCIL:
2037  br->id.icon_id = ICON_GPBRUSH_PENCIL;
2038  break;
2039  case GP_BRUSH_ICON_PEN:
2040  br->id.icon_id = ICON_GPBRUSH_PEN;
2041  break;
2042  case GP_BRUSH_ICON_INK:
2043  br->id.icon_id = ICON_GPBRUSH_INK;
2044  break;
2046  br->id.icon_id = ICON_GPBRUSH_INKNOISE;
2047  break;
2048  case GP_BRUSH_ICON_BLOCK:
2049  br->id.icon_id = ICON_GPBRUSH_BLOCK;
2050  break;
2051  case GP_BRUSH_ICON_MARKER:
2052  br->id.icon_id = ICON_GPBRUSH_MARKER;
2053  break;
2054  case GP_BRUSH_ICON_FILL:
2055  br->id.icon_id = ICON_GPBRUSH_FILL;
2056  break;
2058  br->id.icon_id = ICON_GPBRUSH_AIRBRUSH;
2059  break;
2060  case GP_BRUSH_ICON_CHISEL:
2061  br->id.icon_id = ICON_GPBRUSH_CHISEL;
2062  break;
2064  br->id.icon_id = ICON_GPBRUSH_ERASE_SOFT;
2065  break;
2067  br->id.icon_id = ICON_GPBRUSH_ERASE_HARD;
2068  break;
2070  br->id.icon_id = ICON_GPBRUSH_ERASE_STROKE;
2071  break;
2072  case GP_BRUSH_ICON_TINT:
2073  br->id.icon_id = ICON_BRUSH_TEXDRAW;
2074  break;
2076  br->id.icon_id = ICON_BRUSH_MIX;
2077  break;
2079  br->id.icon_id = ICON_BRUSH_BLUR;
2080  break;
2082  br->id.icon_id = ICON_BRUSH_BLUR;
2083  break;
2085  br->id.icon_id = ICON_BRUSH_BLUR;
2086  break;
2088  br->id.icon_id = ICON_BRUSH_MIX;
2089  break;
2091  br->id.icon_id = ICON_GPBRUSH_SMOOTH;
2092  break;
2094  br->id.icon_id = ICON_GPBRUSH_THICKNESS;
2095  break;
2097  br->id.icon_id = ICON_GPBRUSH_STRENGTH;
2098  break;
2100  br->id.icon_id = ICON_GPBRUSH_RANDOMIZE;
2101  break;
2103  br->id.icon_id = ICON_GPBRUSH_GRAB;
2104  break;
2106  br->id.icon_id = ICON_GPBRUSH_PUSH;
2107  break;
2109  br->id.icon_id = ICON_GPBRUSH_TWIST;
2110  break;
2112  br->id.icon_id = ICON_GPBRUSH_PINCH;
2113  break;
2115  br->id.icon_id = ICON_GPBRUSH_CLONE;
2116  break;
2118  br->id.icon_id = ICON_GPBRUSH_WEIGHT;
2119  break;
2120  default:
2121  br->id.icon_id = ICON_GPBRUSH_PEN;
2122  break;
2123  }
2124  return id->icon_id;
2125  }
2126 
2127  if (paint_mode != PAINT_MODE_INVALID) {
2128  items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
2129  const uint tool_offset = BKE_paint_get_brush_tool_offset_from_paintmode(paint_mode);
2130  const int tool_type = *(char *)POINTER_OFFSET(br, tool_offset);
2131  if (!items || !RNA_enum_icon_from_value(items, tool_type, &id->icon_id)) {
2132  id->icon_id = 0;
2133  }
2134  }
2135  else {
2136  id->icon_id = 0;
2137  }
2138  }
2139 
2140  return id->icon_id;
2141 }
2142 
2143 static int ui_id_screen_get_icon(const bContext *C, ID *id)
2144 {
2145  BKE_icon_id_ensure(id);
2146  /* Don't use jobs here, offscreen rendering doesn't like this and crashes. */
2147  ui_id_icon_render(C, id, false);
2148 
2149  return id->icon_id;
2150 }
2151 
2152 int ui_id_icon_get(const bContext *C, ID *id, const bool big)
2153 {
2154  int iconid = 0;
2155 
2156  /* icon */
2157  switch (GS(id->name)) {
2158  case ID_BR:
2159  iconid = ui_id_brush_get_icon(C, id);
2160  break;
2161  case ID_MA: /* fall through */
2162  case ID_TE: /* fall through */
2163  case ID_IM: /* fall through */
2164  case ID_WO: /* fall through */
2165  case ID_LA: /* fall through */
2166  iconid = BKE_icon_id_ensure(id);
2167  /* checks if not exists, or changed */
2169  break;
2170  case ID_SCR:
2171  iconid = ui_id_screen_get_icon(C, id);
2172  break;
2173  case ID_GR:
2174  iconid = UI_icon_color_from_collection((Collection *)id);
2175  break;
2176  default:
2177  break;
2178  }
2179 
2180  return iconid;
2181 }
2182 
2183 int UI_icon_from_library(const ID *id)
2184 {
2185  if (ID_IS_LINKED(id)) {
2186  if (id->tag & LIB_TAG_MISSING) {
2187  return ICON_LIBRARY_DATA_BROKEN;
2188  }
2189  if (id->tag & LIB_TAG_INDIRECT) {
2190  return ICON_LIBRARY_DATA_INDIRECT;
2191  }
2192  return ICON_LIBRARY_DATA_DIRECT;
2193  }
2194  if (ID_IS_OVERRIDE_LIBRARY(id)) {
2195  return ICON_LIBRARY_DATA_OVERRIDE;
2196  }
2197  if (ID_IS_ASSET(id)) {
2198  return ICON_ASSET_MANAGER;
2199  }
2200 
2201  return ICON_NONE;
2202 }
2203 
2204 int UI_icon_from_rnaptr(bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
2205 {
2206  ID *id = NULL;
2207 
2208  if (!ptr->data) {
2209  return rnaicon;
2210  }
2211 
2212  /* try ID, material, texture or dynapaint slot */
2213  if (RNA_struct_is_ID(ptr->type)) {
2214  id = ptr->owner_id;
2215  }
2216  else if (RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) {
2217  id = RNA_pointer_get(ptr, "material").data;
2218  }
2219  else if (RNA_struct_is_a(ptr->type, &RNA_TextureSlot)) {
2220  id = RNA_pointer_get(ptr, "texture").data;
2221  }
2223  return RNA_int_get(ptr, "icon");
2224  }
2227 
2228  if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) {
2229  return ICON_SHADING_TEXTURE;
2230  }
2231  if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
2232  return ICON_OUTLINER_DATA_MESH;
2233  }
2234  if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
2235  return ICON_FILE_IMAGE;
2236  }
2237  }
2238  else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) {
2239  StudioLight *sl = ptr->data;
2240  switch (sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS) {
2242  return sl->icon_id_irradiance;
2244  default:
2245  return sl->icon_id_radiance;
2247  return sl->icon_id_matcap;
2248  }
2249  }
2250 
2251  /* get icon from ID */
2252  if (id) {
2253  const int icon = ui_id_icon_get(C, id, big);
2254 
2255  return icon ? icon : rnaicon;
2256  }
2257 
2258  return rnaicon;
2259 }
2260 
2261 int UI_icon_from_idcode(const int idcode)
2262 {
2263  switch ((ID_Type)idcode) {
2264  case ID_AC:
2265  return ICON_ACTION;
2266  case ID_AR:
2267  return ICON_ARMATURE_DATA;
2268  case ID_BR:
2269  return ICON_BRUSH_DATA;
2270  case ID_CA:
2271  return ICON_CAMERA_DATA;
2272  case ID_CF:
2273  return ICON_FILE;
2274  case ID_CU:
2275  return ICON_CURVE_DATA;
2276  case ID_GD:
2277  return ICON_OUTLINER_DATA_GREASEPENCIL;
2278  case ID_GR:
2279  return ICON_OUTLINER_COLLECTION;
2280  case ID_IM:
2281  return ICON_IMAGE_DATA;
2282  case ID_LA:
2283  return ICON_LIGHT_DATA;
2284  case ID_LS:
2285  return ICON_LINE_DATA;
2286  case ID_LT:
2287  return ICON_LATTICE_DATA;
2288  case ID_MA:
2289  return ICON_MATERIAL_DATA;
2290  case ID_MB:
2291  return ICON_META_DATA;
2292  case ID_MC:
2293  return ICON_TRACKER;
2294  case ID_ME:
2295  return ICON_MESH_DATA;
2296  case ID_MSK:
2297  return ICON_MOD_MASK; /* TODO! this would need its own icon! */
2298  case ID_NT:
2299  return ICON_NODETREE;
2300  case ID_OB:
2301  return ICON_OBJECT_DATA;
2302  case ID_PA:
2303  return ICON_PARTICLE_DATA;
2304  case ID_PAL:
2305  return ICON_COLOR; /* TODO! this would need its own icon! */
2306  case ID_PC:
2307  return ICON_CURVE_BEZCURVE; /* TODO! this would need its own icon! */
2308  case ID_LP:
2309  return ICON_OUTLINER_DATA_LIGHTPROBE;
2310  case ID_SCE:
2311  return ICON_SCENE_DATA;
2312  case ID_SPK:
2313  return ICON_SPEAKER;
2314  case ID_SO:
2315  return ICON_SOUND;
2316  case ID_TE:
2317  return ICON_TEXTURE_DATA;
2318  case ID_TXT:
2319  return ICON_TEXT;
2320  case ID_VF:
2321  return ICON_FONT_DATA;
2322  case ID_HA:
2323  return ICON_HAIR_DATA;
2324  case ID_PT:
2325  return ICON_POINTCLOUD_DATA;
2326  case ID_VO:
2327  return ICON_VOLUME_DATA;
2328  case ID_WO:
2329  return ICON_WORLD_DATA;
2330  case ID_WS:
2331  return ICON_WORKSPACE;
2332  case ID_SIM:
2333  /* TODO: Use correct icon. */
2334  return ICON_PHYSICS;
2335 
2336  /* No icons for these ID-types. */
2337  case ID_LI:
2338  case ID_IP:
2339  case ID_KE:
2340  case ID_SCR:
2341  case ID_WM:
2342  break;
2343  }
2344  return ICON_NONE;
2345 }
2346 
2347 int UI_icon_from_object_mode(const int mode)
2348 {
2349  switch ((eObjectMode)mode) {
2350  case OB_MODE_OBJECT:
2351  return ICON_OBJECT_DATAMODE;
2352  case OB_MODE_EDIT:
2353  case OB_MODE_EDIT_GPENCIL:
2354  return ICON_EDITMODE_HLT;
2355  case OB_MODE_SCULPT:
2357  return ICON_SCULPTMODE_HLT;
2358  case OB_MODE_VERTEX_PAINT:
2360  return ICON_VPAINT_HLT;
2361  case OB_MODE_WEIGHT_PAINT:
2363  return ICON_WPAINT_HLT;
2364  case OB_MODE_TEXTURE_PAINT:
2365  return ICON_TPAINT_HLT;
2366  case OB_MODE_PARTICLE_EDIT:
2367  return ICON_PARTICLEMODE;
2368  case OB_MODE_POSE:
2369  return ICON_POSE_HLT;
2370  case OB_MODE_PAINT_GPENCIL:
2371  return ICON_GREASEPENCIL;
2372  }
2373  return ICON_NONE;
2374 }
2375 
2377 {
2378  int icon = ICON_OUTLINER_COLLECTION;
2379 
2380  if (collection->color_tag != COLLECTION_COLOR_NONE) {
2381  icon = ICON_COLLECTION_COLOR_01 + collection->color_tag;
2382  }
2383 
2384  return icon;
2385 }
2386 
2387 /* draws icon with dpi scale factor */
2388 void UI_icon_draw(float x, float y, int icon_id)
2389 {
2390  UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, NULL, false);
2391 }
2392 
2393 void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
2394 {
2395  UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, alpha, 0.0f, NULL, false);
2396 }
2397 
2398 void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size)
2399 {
2400  icon_draw_size(x, y, icon_id, aspect, alpha, ICON_SIZE_PREVIEW, size, false, NULL, false);
2401 }
2402 
2403 void UI_icon_draw_ex(float x,
2404  float y,
2405  int icon_id,
2406  float aspect,
2407  float alpha,
2408  float desaturate,
2409  const uchar mono_color[4],
2410  const bool mono_border)
2411 {
2412  const int draw_size = get_draw_size(ICON_SIZE_ICON);
2413  icon_draw_size(x,
2414  y,
2415  icon_id,
2416  aspect,
2417  alpha,
2419  draw_size,
2420  desaturate,
2421  mono_color,
2422  mono_border);
2423 }
2424 
2425 /* ********** Alert Icons ********** */
2426 
2428 {
2429 #ifdef WITH_HEADLESS
2430  return NULL;
2431 #else
2432  const int ALERT_IMG_SIZE = 256;
2433  icon = MIN2(icon, ALERT_ICON_MAX - 1);
2434  const int left = icon * ALERT_IMG_SIZE;
2435  const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1};
2438  IB_rect,
2439  NULL,
2440  "alert_icon");
2441  IMB_rect_crop(ibuf, &crop);
2442  IMB_premultiply_alpha(ibuf);
2443  return ibuf;
2444 #endif
2445 }
typedef float(TangentPoint)[2]
void immDrawPixelsTex(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, void *rect, float xzoom, float yzoom, const float color[4])
Definition: glutil.c:298
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
Definition: glutil.c:66
@ BLENDER_DATAFILES
Definition: BKE_appdir.h:78
const char * BKE_appdir_folder_id(const int folder_id, const char *subfolder)
Definition: appdir.c:674
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
@ G_DEBUG
Definition: BKE_global.h:133
struct PreviewImage * BKE_previewimg_id_ensure(struct ID *id)
Definition: icons.cc:400
bool BKE_previewimg_id_supports_jobs(const struct ID *id)
struct PreviewImage * BKE_previewimg_create(void)
Definition: icons.cc:273
#define ICON_RENDER_DEFAULT_HEIGHT
Definition: BKE_icons.h:202
void BKE_icon_set(const int icon_id, struct Icon *icon)
Definition: icons.cc:897
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
void BKE_icons_free(void)
Definition: icons.cc:212
void BKE_icon_geom_invert_lightness(struct Icon_Geom *geom)
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
struct ImBuf * BKE_icon_geom_rasterize(const struct Icon_Geom *geom, const unsigned int size_x, const unsigned int size_y)
uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
Definition: paint.c:663
const struct EnumPropertyItem * BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
Definition: paint.c:389
ePaintMode
Definition: BKE_paint.h:78
@ PAINT_MODE_INVALID
Definition: BKE_paint.h:95
@ PAINT_MODE_TEXTURE_3D
Definition: BKE_paint.h:84
@ PAINT_MODE_SCULPT
Definition: BKE_paint.h:79
@ PAINT_MODE_WEIGHT
Definition: BKE_paint.h:82
@ PAINT_MODE_TEXTURE_2D
Definition: BKE_paint.h:86
@ PAINT_MODE_VERTEX
Definition: BKE_paint.h:81
@ STUDIOLIGHT_TYPE_MATCAP
@ STUDIOLIGHT_TYPE_WORLD
@ STUDIOLIGHT_TYPE_STUDIO
#define STUDIOLIGHT_ICON_SIZE
void BKE_studiolight_set_free_function(StudioLight *sl, StudioLightFreeFunction *free_function, void *data)
Definition: studiolight.c:1632
#define STUDIOLIGHT_FLAG_ORIENTATIONS
void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type)
Definition: studiolight.c:1515
#define BLI_assert(a)
Definition: BLI_assert.h:58
void BLI_filelist_free(struct direntry *filelist, const unsigned int nrentries)
Definition: BLI_filelist.c:467
unsigned int BLI_filelist_dir_contents(const char *dir, struct direntry **r_filelist)
Definition: BLI_filelist.c:238
Some types for dealing with directories.
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:281
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:128
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
unsigned int rgb_to_cpack(float r, float g, float b)
Definition: math_color.c:379
MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
Definition: math_color.c:414
MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
MINLINE void copy_v4_fl(float r[4], float f)
#define FILE_MAX
void BLI_join_dirfile(char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1737
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1459
#define BLI_path_cmp
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED(x)
#define UNPACK3(a)
#define MAX2(a, b)
#define ELEM(...)
#define MIN2(a, b)
#define POINTER_OFFSET(v, ofs)
@ LIB_TAG_INDIRECT
Definition: DNA_ID.h:524
@ LIB_TAG_MISSING
Definition: DNA_ID.h:537
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
#define ID_IS_ASSET(_id)
Definition: DNA_ID.h:451
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:445
@ PRV_TAG_DEFFERED
Definition: DNA_ID.h:384
@ PRV_CHANGED
Definition: DNA_ID.h:377
@ PRV_UNFINISHED
Definition: DNA_ID.h:379
@ PRV_USER_EDITED
Definition: DNA_ID.h:378
eIconSizes
Definition: DNA_ID_enums.h:28
@ ICON_SIZE_PREVIEW
Definition: DNA_ID_enums.h:30
@ ICON_SIZE_ICON
Definition: DNA_ID_enums.h:29
@ NUM_ICON_SIZES
Definition: DNA_ID_enums.h:32
ID_Type
Definition: DNA_ID_enums.h:56
@ ID_WM
Definition: DNA_ID_enums.h:84
@ ID_CA
Definition: DNA_ID_enums.h:68
@ ID_AR
Definition: DNA_ID_enums.h:78
@ ID_MC
Definition: DNA_ID_enums.h:85
@ ID_CF
Definition: DNA_ID_enums.h:90
@ ID_LI
Definition: DNA_ID_enums.h:58
@ ID_TE
Definition: DNA_ID_enums.h:64
@ ID_IM
Definition: DNA_ID_enums.h:65
@ ID_VO
Definition: DNA_ID_enums.h:95
@ ID_WS
Definition: DNA_ID_enums.h:91
@ ID_NT
Definition: DNA_ID_enums.h:80
@ ID_LA
Definition: DNA_ID_enums.h:67
@ ID_KE
Definition: DNA_ID_enums.h:70
@ ID_TXT
Definition: DNA_ID_enums.h:74
@ ID_SO
Definition: DNA_ID_enums.h:76
@ ID_SCE
Definition: DNA_ID_enums.h:57
@ ID_LS
Definition: DNA_ID_enums.h:87
@ ID_MSK
Definition: DNA_ID_enums.h:86
@ ID_GD
Definition: DNA_ID_enums.h:83
@ ID_PAL
Definition: DNA_ID_enums.h:88
@ ID_BR
Definition: DNA_ID_enums.h:81
@ ID_LP
Definition: DNA_ID_enums.h:92
@ ID_HA
Definition: DNA_ID_enums.h:93
@ ID_WO
Definition: DNA_ID_enums.h:71
@ ID_SIM
Definition: DNA_ID_enums.h:96
@ ID_MA
Definition: DNA_ID_enums.h:63
@ ID_AC
Definition: DNA_ID_enums.h:79
@ ID_SCR
Definition: DNA_ID_enums.h:72
@ ID_VF
Definition: DNA_ID_enums.h:73
@ ID_ME
Definition: DNA_ID_enums.h:60
@ ID_IP
Definition: DNA_ID_enums.h:69
@ ID_GR
Definition: DNA_ID_enums.h:77
@ ID_SPK
Definition: DNA_ID_enums.h:75
@ ID_MB
Definition: DNA_ID_enums.h:62
@ ID_LT
Definition: DNA_ID_enums.h:66
@ ID_OB
Definition: DNA_ID_enums.h:59
@ ID_PA
Definition: DNA_ID_enums.h:82
@ ID_PT
Definition: DNA_ID_enums.h:94
@ ID_CU
Definition: DNA_ID_enums.h:61
@ ID_PC
Definition: DNA_ID_enums.h:89
@ BRUSH_CUSTOM_ICON
@ GP_BRUSH_ICON_ERASE_SOFT
@ GP_BRUSH_ICON_GPBRUSH_RANDOMIZE
@ GP_BRUSH_ICON_VERTEX_BLUR
@ GP_BRUSH_ICON_TINT
@ GP_BRUSH_ICON_FILL
@ GP_BRUSH_ICON_PENCIL
@ GP_BRUSH_ICON_GPBRUSH_GRAB
@ GP_BRUSH_ICON_GPBRUSH_STRENGTH
@ GP_BRUSH_ICON_INKNOISE
@ GP_BRUSH_ICON_GPBRUSH_TWIST
@ GP_BRUSH_ICON_PEN
@ GP_BRUSH_ICON_VERTEX_REPLACE
@ GP_BRUSH_ICON_MARKER
@ GP_BRUSH_ICON_VERTEX_DRAW
@ GP_BRUSH_ICON_BLOCK
@ GP_BRUSH_ICON_GPBRUSH_WEIGHT
@ GP_BRUSH_ICON_INK
@ GP_BRUSH_ICON_GPBRUSH_PINCH
@ GP_BRUSH_ICON_VERTEX_SMEAR
@ GP_BRUSH_ICON_GPBRUSH_THICKNESS
@ GP_BRUSH_ICON_AIRBRUSH
@ GP_BRUSH_ICON_GPBRUSH_CLONE
@ GP_BRUSH_ICON_CHISEL
@ GP_BRUSH_ICON_ERASE_STROKE
@ GP_BRUSH_ICON_ERASE_HARD
@ GP_BRUSH_ICON_GPBRUSH_SMOOTH
@ GP_BRUSH_ICON_GPBRUSH_PUSH
@ GP_BRUSH_ICON_VERTEX_AVERAGE
Object groups, one object can be in many groups at once.
@ COLLECTION_COLOR_NONE
@ COLLECTION_COLOR_02
@ COLLECTION_COLOR_05
@ COLLECTION_COLOR_07
@ COLLECTION_COLOR_06
@ COLLECTION_COLOR_04
@ COLLECTION_COLOR_01
@ COLLECTION_COLOR_08
@ COLLECTION_COLOR_03
@ BEZT_KEYTYPE_EXTREME
@ BEZT_KEYTYPE_JITTER
@ BEZT_KEYTYPE_BREAKDOWN
@ BEZT_KEYTYPE_MOVEHOLD
@ BEZT_KEYTYPE_KEYFRAME
@ MOD_DPAINT_SURFACE_F_PTEX
@ MOD_DPAINT_SURFACE_F_VERTEX
@ MOD_DPAINT_SURFACE_F_IMAGESEQ
eObjectMode
@ OB_MODE_VERTEX_GPENCIL
@ OB_MODE_EDIT_GPENCIL
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_WEIGHT_GPENCIL
@ OB_MODE_SCULPT
@ OB_MODE_SCULPT_GPENCIL
@ OB_MODE_POSE
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_OBJECT
@ OB_MODE_VERTEX_PAINT
@ OB_MODE_PAINT_GPENCIL
Object is a sort of wrapper for general info.
@ RGN_TYPE_WINDOW
@ SPACE_ACTION
@ SPACE_PROPERTIES
@ SPACE_IMAGE
@ SPACE_VIEW3D
@ SI_MODE_PAINT
char datatoc_blender_icons16_png[]
int datatoc_blender_icons32_png_size
int datatoc_blender_icons16_png_size
char datatoc_alert_icons_png[]
int datatoc_alert_icons_png_size
char datatoc_blender_icons32_png[]
@ KEYFRAME_SHAPE_BOTH
@ KEYFRAME_HANDLE_VECTOR
@ KEYFRAME_HANDLE_FREE
@ KEYFRAME_HANDLE_AUTO_CLAMP
@ KEYFRAME_HANDLE_NONE
@ KEYFRAME_HANDLE_AUTO
@ KEYFRAME_HANDLE_ALIGNED
@ KEYFRAME_EXTREME_NONE
void ED_preview_icon_job(const struct bContext *C, void *owner, struct ID *id, unsigned int *rect, int sizex, int sizey, const bool delay)
void ED_preview_icon_render(const struct bContext *C, struct Scene *scene, struct ID *id, unsigned int *rect, int sizex, int sizey)
GPUBatch
Definition: GPU_batch.h:93
void GPU_batch_draw_instanced(GPUBatch *batch, int i_count)
Definition: gpu_batch.cc:247
void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader)
Definition: gpu_batch.cc:222
void GPU_batch_draw(GPUBatch *batch)
Definition: gpu_batch.cc:234
struct GPUBatch * GPU_batch_preset_quad(void)
void immVertex2iv(uint attr_id, const int data[2])
void immUniform2f(const char *name, float x, float y)
void immUniformColor4f(float r, float g, float b, float a)
void immUnbindProgram(void)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniformColor3ubv(const unsigned char rgb[3])
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat(void)
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
void immUniformColor3fv(const float rgb[3])
void immRecti(uint pos, int x1, int y1, int x2, int y2)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
#define GPU_matrix_model_view_projection_get(x)
Definition: GPU_matrix.h:228
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:35
@ GPU_PRIM_TRIS
Definition: GPU_primitive.h:37
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:551
struct GPUShader GPUShader
Definition: GPU_shader.h:33
void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, const float *value)
Definition: gpu_shader.cc:617
GPUShader * GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
void GPU_shader_bind(GPUShader *shader)
Definition: gpu_shader.cc:494
@ GPU_UNIFORM_COLOR
Definition: GPU_shader.h:106
eGPUBuiltinShader
Definition: GPU_shader.h:159
@ GPU_SHADER_2D_IMAGE_DESATURATE_COLOR
Definition: GPU_shader.h:188
@ GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR
Definition: GPU_shader.h:190
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:171
@ GPU_SHADER_2D_IMAGE_RECT_COLOR
Definition: GPU_shader.h:189
@ GPU_SHADER_KEYFRAME_DIAMOND
Definition: GPU_shader.h:162
@ GPU_SHADER_2D_IMAGE_COLOR
Definition: GPU_shader.h:187
int GPU_shader_get_texture_binding(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:585
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
Definition: gpu_shader.cc:558
void GPU_program_point_size(bool enable)
Definition: gpu_state.cc:191
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:57
@ GPU_BLEND_ALPHA_PREMULT
Definition: GPU_state.h:58
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:55
@ GPU_SAMPLER_ICON
Definition: GPU_texture.h:50
void GPU_texture_update_mipmap(GPUTexture *tex, int miplvl, eGPUDataFormat gpu_data_format, const void *pixels)
Definition: gpu_texture.cc:345
void GPU_texture_bind_ex(GPUTexture *tex, eGPUSamplerState state, int unit, const bool set_number)
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:175
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:508
void GPU_texture_unbind(GPUTexture *tex)
Definition: gpu_texture.cc:421
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
@ GPU_RGBA8
Definition: GPU_texture.h:88
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
@ GPU_FETCH_INT
@ GPU_FETCH_INT_TO_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_I32
@ GPU_COMP_U32
@ GPU_COMP_U8
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1667
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:478
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_rect_crop(struct ImBuf *ibuf, const struct rcti *crop)
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
Definition: readimage.c:224
void IMB_premultiply_alpha(struct ImBuf *ibuf)
Definition: filter.c:687
struct ImBuf * IMB_ibImageFromMemory(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
Definition: readimage.c:99
Contains defines and structs used throughout the imbuf module.
@ IB_rect
#define PREVIEW_RENDER_DEFAULT_HEIGHT
Definition: IMB_thumbs.h:54
Read Guarded memory(de)allocation.
StructRNA RNA_MaterialSlot
StructRNA RNA_StudioLight
StructRNA RNA_DynamicPaintSurface
StructRNA RNA_FileBrowserFSMenuEntry
StructRNA RNA_TextureSlot
#define C
Definition: RandGen.cpp:39
void UI_widgetbase_draw_cache_flush(void)
#define ICON_DEFAULT_HEIGHT
#define ICON_DEFAULT_HEIGHT_TOOLBAR
#define PREVIEW_DEFAULT_HEIGHT
eAlertIcon
@ ALERT_ICON_MAX
#define ICON_DEFAULT_WIDTH
@ TH_TEXT
Definition: UI_resources.h:58
#define BIFICONID_FIRST
Definition: UI_resources.h:40
void UI_Theme_Restore(struct bThemeState *theme_state)
Definition: resources.c:1098
struct bTheme * UI_GetTheme(void)
Definition: resources.c:1086
void UI_GetThemeColor4fv(int colorid, float col[4])
Definition: resources.c:1199
bool UI_GetIconThemeColor4ubv(int colorid, unsigned char col[4])
Definition: resources.c:1415
void UI_SetTheme(int spacetype, int regionid)
Definition: resources.c:1064
void UI_Theme_Store(struct bThemeState *theme_state)
Definition: resources.c:1094
@ WM_JOB_TYPE_STUDIOLIGHT
Definition: WM_api.h:753
#define NC_WINDOW
Definition: WM_types.h:277
#define KM_CLICK
Definition: WM_types.h:244
#define KM_ANY
Definition: WM_types.h:240
#define KM_CLICK_DRAG
Definition: WM_types.h:246
#define KM_PRESS
Definition: WM_types.h:242
#define KM_NOTHING
Definition: WM_types.h:241
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
Scene scene
static CCL_NAMESPACE_BEGIN const double alpha
struct @203::@204 surface
uint pos
uint col
GPUBatch * quad
static struct @395 g_icon_draw_cache
void UI_icons_free_drawinfo(void *drawinfo)
static struct ListBase iconfilelist
static void vicon_collection_color_draw(short color_tag, int x, int y, int w, int UNUSED(h), float UNUSED(alpha))
int UI_icon_from_object_mode(const int mode)
struct IconType IconType
void UI_icon_draw_cache_end(void)
static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, short key_type, short handle_type)
#define ICON_TYPE_MONO_TEXTURE
static void ui_studiolight_icon_job_exec(void *customdata, short *UNUSED(stop), short *UNUSED(do_update), float *UNUSED(progress))
static void icon_draw_cache_flush_ex(bool only_full_caches)
void UI_icons_free(void)
#define ICON_TYPE_COLOR_TEXTURE
static void ui_id_preview_image_render_size(const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job)
#define DEF_ICON_VECTOR_COLORSET_DRAW_NTH(prefix, index)
static void vicon_handletype_aligned_draw(int x, int y, int w, int h, float alpha)
#define DEF_ICON_COLLECTION_COLOR_DRAW(index, color)
struct IconImage IconImage
static DrawInfo * icon_ensure_drawinfo(Icon *icon)
static IconTexture icongltex
void(* VectorDrawFunc)(int x, int y, int w, int h, float alpha)
#define ICON_GRID_MARGIN
static void init_iconfile_list(struct ListBase *list)
static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy, int iw, int ih, float alpha, const float rgb[3], bool with_border)
static void vicon_handletype_auto_clamp_draw(int x, int y, int w, int h, float alpha)
static void vicon_keytype_keyframe_draw(int x, int y, int w, int h, float alpha)
void UI_icons_reload_internal_textures(void)
void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
static const IconType icontypes[]
int UI_icon_from_idcode(const int idcode)
void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h)
static void vicon_keytype_jitter_draw(int x, int y, int w, int h, float alpha)
void UI_icon_draw(float x, float y, int icon_id)
int UI_icon_from_rnaptr(bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
static void vicon_handletype_vector_draw(int x, int y, int w, int h, float alpha)
static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha))
#define INIT_BRUSH_ICON(icon_id, name)
static void free_icons_textures(void)
#define ICON_GRID_W
void UI_icon_draw_cache_begin(void)
static void free_iconfile_list(struct ListBase *list)
static void icon_verify_datatoc(IconImage *iimg)
IconTextureDrawCall normal
static void vicon_handletype_free_draw(int x, int y, int w, int h, float alpha)
static void ui_studiolight_icon_job_end(void *customdata)
struct IconTextureDrawCall IconTextureDrawCall
void UI_icon_render_id(const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job)
bool enabled
struct IconTexture IconTexture
PreviewImage * UI_icon_to_preview(int icon_id)
int ui_id_icon_get(const bContext *C, ID *id, const bool big)
static int ui_id_screen_get_icon(const bContext *C, ID *id)
#define ICON_TYPE_GEOM
#define ICON_TYPE_EVENT
static void init_brush_icons(void)
int UI_icon_from_keymap_item(const wmKeyMapItem *kmi, int r_icon_mod[4])
int UI_icon_get_height(int icon_id)
static void viconutil_set_point(int pt[2], int x, int y)
bool UI_icon_get_theme_color(int icon_id, uchar color[4])
static void vicon_keytype_moving_hold_draw(int x, int y, int w, int h, float alpha)
static DrawInfo * icon_create_drawinfo(Icon *icon)
ImBuf * UI_icon_alert_imbuf_get(eAlertIcon icon)
static void vicon_handletype_auto_draw(int x, int y, int w, int h, float alpha)
static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
#define ICON_TYPE_BUFFER
int UI_icon_from_library(const ID *id)
static void ui_studiolight_free_function(StudioLight *sl, void *data)
static ImBuf * create_mono_icon_with_border(ImBuf *buf, int resolution_divider, float border_intensity)
int UI_iconfile_get_index(const char *filename)
#define ICON_MONO_BORDER_OUTSET
void UI_icons_init()
#define ICON_DRAW_CACHE_SIZE
#define ICON_GRID_ROWS
int UI_icon_from_event_type(short event_type, short event_value)
int UI_icon_color_from_collection(const Collection *collection)
static DrawInfo * def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color)
ListBase * UI_iconfile_list(void)
static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, uint *rect, float alpha, const float desaturate)
void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size)
#define ICON_TYPE_GPLAYER
static void vicon_keytype_extreme_draw(int x, int y, int w, int h, float alpha)
static int ui_id_brush_get_icon(const bContext *C, ID *id)
static void init_internal_icons(void)
#define ICON_TYPE_PREVIEW
struct IconDrawCall IconDrawCall
#define ICON_TYPE_IMBUF
#define ICON_TYPE_VECTOR
static int get_draw_size(enum eIconSizes size)
int UI_icon_preview_to_render_size(enum eIconSizes size)
static DrawInfo * g_di_event_list
int UI_icon_get_width(int icon_id)
static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
static void icon_draw_texture_cached(float x, float y, float w, float h, int ix, int iy, int UNUSED(iw), int ih, float alpha, const float rgb[3], bool with_border)
static void ui_studiolight_kill_icon_preview_job(wmWindowManager *wm, int icon_id)
static void vicon_keytype_breakdown_draw(int x, int y, int w, int h, float alpha)
#define INIT_EVENT_ICON(icon_id, type, value)
static void init_event_icons(void)
#define ICON_GRID_H
void UI_icon_draw_ex(float x, float y, int icon_id, float aspect, float alpha, float desaturate, const uchar mono_color[4], const bool mono_border)
static void icon_draw_cache_texture_flush_ex(GPUTexture *texture, IconTextureDrawCall *texture_draw_calls)
struct DrawInfo DrawInfo
static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, enum eIconSizes size, int draw_size, const float desaturate, const uchar mono_rgba[4], const bool mono_border)
static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
IconTextureDrawCall border
#define ICON_GRID_COLS
static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
static void icon_set_image(const bContext *C, Scene *scene, ID *id, PreviewImage *prv_img, enum eIconSizes size, const bool use_job)
void icon_draw_rect_input(float x, float y, int w, int h, float UNUSED(alpha), short event_type, short UNUSED(event_value))
#define GS(x)
Definition: iris.c:241
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha, uint pos_id, uint size_id, uint color_id, uint outline_color_id, uint flags_id, short handle_type, short extreme_type)
format
Definition: logImageCore.h:47
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static ulong state[N]
static int left
static unsigned c
Definition: RandGen.cpp:97
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6562
bool RNA_struct_is_ID(const StructRNA *type)
Definition: rna_access.c:797
bool RNA_enum_icon_from_value(const EnumPropertyItem *item, int value, int *r_icon)
Definition: rna_access.c:6494
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
struct BrushGpencilSettings * gpencil_settings
IconImage * image
struct DrawInfo::@396::@400 texture
struct DrawInfo::@396::@397 vector
short event_type
struct DrawInfo * next
VectorDrawFunc func
struct DrawInfo::@396::@398 geom
ImBuf * image_cache
short event_value
struct DrawInfo::@396::@399 buffer
union DrawInfo::@396 data
struct DrawInfo::@396::@401 input
Definition: DNA_ID.h:273
int tag
Definition: DNA_ID.h:292
int icon_id
Definition: DNA_ID.h:294
char name[66]
Definition: DNA_ID.h:283
char filename[256]
struct IconFile * next
const uchar * datatoc_rect
IconDrawCall drawcall_cache[ICON_DRAW_CACHE_SIZE]
struct GPUTexture * tex[2]
Definition: BKE_icons.h:59
void * obj
Definition: BKE_icons.h:66
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
unsigned int * rect
void * first
Definition: DNA_listBase.h:47
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
unsigned int h[2]
Definition: DNA_ID.h:392
short changed_timestamp[2]
Definition: DNA_ID.h:394
short flag[2]
Definition: DNA_ID.h:393
unsigned int * rect[2]
Definition: DNA_ID.h:395
unsigned int w[2]
Definition: DNA_ID.h:391
int icon_id_matcap_flipped
unsigned char color[4]
float icon_border_intensity
float icon_alpha
uiWidgetColors wcol_toolbar_item
unsigned char select[4]
unsigned char solid[4]
unsigned char active[4]
float color[4]
ThemeUI tui
ThemeWireColor tarm[20]
ThemeCollectionColor collection_color[8]
const char * relname
float xmax
Definition: DNA_vec_types.h:85
float xmin
Definition: DNA_vec_types.h:85
float ymax
Definition: DNA_vec_types.h:86
float ymin
Definition: DNA_vec_types.h:86
unsigned char inner[4]
Definition: wm_jobs.c:73
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: svm_invert.h:19
#define mix(a, b, c)
Definition: util_hash.h:30
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
#define G(x, y, z)
@ RIGHTMOUSE
@ EVT_OKEY
@ EVT_EKEY
@ EVT_JKEY
@ EVT_F7KEY
@ EVT_YKEY
@ EVT_RIGHTCTRLKEY
@ EVT_SKEY
@ EVT_VKEY
@ EVT_IKEY
@ EVT_F1KEY
@ EVT_XKEY
@ EVT_F10KEY
@ EVT_FKEY
@ EVT_CKEY
@ EVT_F2KEY
@ EVT_GKEY
@ EVT_KKEY
@ EVT_TABKEY
@ EVT_UKEY
@ EVT_AKEY
@ EVT_PAGEUPKEY
@ EVT_OSKEY
@ EVT_TWEAK_M
@ EVT_F4KEY
@ EVT_PAGEDOWNKEY
@ EVT_F8KEY
@ EVT_LEFTCTRLKEY
@ EVT_F6KEY
@ EVT_F5KEY
@ EVT_SPACEKEY
@ EVT_WKEY
@ EVT_RIGHTALTKEY
@ EVT_MKEY
@ EVT_TKEY
@ EVT_HKEY
@ EVT_TWEAK_R
@ LEFTMOUSE
@ EVT_F11KEY
@ EVT_NKEY
@ EVT_QKEY
@ MIDDLEMOUSE
@ EVT_LEFTALTKEY
@ EVT_ZKEY
@ EVT_ESCKEY
@ EVT_TWEAK_L
@ EVT_F12KEY
@ EVT_DKEY
@ EVT_LKEY
@ EVT_RIGHTSHIFTKEY
@ EVT_LEFTSHIFTKEY
@ EVT_F3KEY
@ EVT_F9KEY
@ EVT_RKEY
@ EVT_BKEY
@ EVT_PKEY
@ EVT_RETKEY
PointerRNA * ptr
Definition: wm_files.c:3157
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition: wm_jobs.c:450
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
Definition: wm_jobs.c:196
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition: wm_jobs.c:372
void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
Definition: wm_jobs.c:572
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
Definition: wm_jobs.c:344
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
Definition: wm_jobs.c:360