Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_icons.cc
- This file was moved from source/blender/editors/interface/interface_icons.c.
| Context not available. | |||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| */ | */ | ||||
| #include <math.h> | #include <cmath> | ||||
| #include <stdlib.h> | #include <cstdlib> | ||||
| #include <string.h> | #include <cstring> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Context not available. | |||||
| # define ICON_GRID_H 32 | # define ICON_GRID_H 32 | ||||
| #endif /* WITH_HEADLESS */ | #endif /* WITH_HEADLESS */ | ||||
| typedef struct IconImage { | struct IconImage { | ||||
| int w; | int w; | ||||
| int h; | int h; | ||||
| uint *rect; | uint *rect; | ||||
| const uchar *datatoc_rect; | const uchar *datatoc_rect; | ||||
| int datatoc_size; | int datatoc_size; | ||||
| } IconImage; | }; | ||||
| typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); | using VectorDrawFunc = void (*)(int x, int y, int w, int h, float alpha); | ||||
| #define ICON_TYPE_PREVIEW 0 | #define ICON_TYPE_PREVIEW 0 | ||||
| #define ICON_TYPE_COLOR_TEXTURE 1 | #define ICON_TYPE_COLOR_TEXTURE 1 | ||||
| Context not available. | |||||
| #define ICON_TYPE_GPLAYER 8 | #define ICON_TYPE_GPLAYER 8 | ||||
| #define ICON_TYPE_BLANK 9 | #define ICON_TYPE_BLANK 9 | ||||
| typedef struct DrawInfo { | struct DrawInfo { | ||||
| int type; | int type; | ||||
| union { | union { | ||||
| Context not available. | |||||
| struct DrawInfo *next; | struct DrawInfo *next; | ||||
| } input; | } input; | ||||
| } data; | } data; | ||||
| } DrawInfo; | }; | ||||
| typedef struct IconTexture { | struct IconTexture { | ||||
| struct GPUTexture *tex[2]; | GPUTexture *tex[2]; | ||||
| int num_textures; | int num_textures; | ||||
| int w; | int w; | ||||
| int h; | int h; | ||||
| float invw; | float invw; | ||||
| float invh; | float invh; | ||||
| } IconTexture; | }; | ||||
| typedef struct IconType { | struct IconType { | ||||
| int type; | int type; | ||||
| int theme_color; | int theme_color; | ||||
| } IconType; | }; | ||||
| /* ******************* STATIC LOCAL VARS ******************* */ | /* ******************* STATIC LOCAL VARS ******************* */ | ||||
| /* Static here to cache results of icon directory scan, so it's not | /* Static here to cache results of icon directory scan, so it's not | ||||
| * scanning the file-system each time the menu is drawn. */ | * scanning the file-system each time the menu is drawn. */ | ||||
| static struct ListBase iconfilelist = {NULL, NULL}; | static ListBase iconfilelist = {NULL, NULL}; | ||||
| static IconTexture icongltex = {{NULL, NULL}, 0, 0, 0, 0.0f, 0.0f}; | static IconTexture icongltex = {{NULL, NULL}, 0, 0, 0, 0.0f, 0.0f}; | ||||
| #ifndef WITH_HEADLESS | #ifndef WITH_HEADLESS | ||||
| Context not available. | |||||
| static DrawInfo *def_internal_icon( | static DrawInfo *def_internal_icon( | ||||
| ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color) | ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color) | ||||
| { | { | ||||
| Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon"); | Icon *new_icon = MEM_cnew<Icon>(__func__); | ||||
| new_icon->obj = NULL; /* icon is not for library object */ | new_icon->obj = NULL; /* icon is not for library object */ | ||||
| new_icon->id_type = 0; | new_icon->id_type = 0; | ||||
| DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); | DrawInfo *di = MEM_cnew<DrawInfo>(__func__); | ||||
| di->type = type; | di->type = type; | ||||
| if (ELEM(type, ICON_TYPE_COLOR_TEXTURE, ICON_TYPE_MONO_TEXTURE)) { | if (ELEM(type, ICON_TYPE_COLOR_TEXTURE, ICON_TYPE_MONO_TEXTURE)) { | ||||
| Context not available. | |||||
| di->data.texture.h = size; | di->data.texture.h = size; | ||||
| } | } | ||||
| else if (type == ICON_TYPE_BUFFER) { | else if (type == ICON_TYPE_BUFFER) { | ||||
| IconImage *iimg = MEM_callocN(sizeof(IconImage), "icon_img"); | IconImage *iimg = MEM_cnew<IconImage>(__func__); | ||||
| iimg->w = size; | iimg->w = size; | ||||
| iimg->h = size; | iimg->h = size; | ||||
| Context not available. | |||||
| if (bbuf) { | if (bbuf) { | ||||
| int y, imgsize; | int y, imgsize; | ||||
| iimg->rect = MEM_mallocN(size * size * sizeof(uint), "icon_rect"); | iimg->rect = static_cast<uint *>(MEM_mallocN(size * size * sizeof(uint), __func__)); | ||||
| /* Here we store the rect in the icon - same as before */ | /* Here we store the rect in the icon - same as before */ | ||||
| if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) { | if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) { | ||||
| Context not available. | |||||
| static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc) | static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc) | ||||
| { | { | ||||
| Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon"); | Icon *new_icon = MEM_cnew<Icon>("texicon"); | ||||
| new_icon->obj = NULL; /* icon is not for library object */ | new_icon->obj = NULL; /* icon is not for library object */ | ||||
| new_icon->id_type = 0; | new_icon->id_type = 0; | ||||
| DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); | DrawInfo *di = MEM_cnew<DrawInfo>("drawinfo"); | ||||
| di->type = ICON_TYPE_VECTOR; | di->type = ICON_TYPE_VECTOR; | ||||
| di->data.vector.func = drawFunc; | di->data.vector.func = drawFunc; | ||||
| Context not available. | |||||
| { | { | ||||
| /* Initialize dummy theme state for Action Editor - where these colors are defined | /* Initialize dummy theme state for Action Editor - where these colors are defined | ||||
| * (since we're doing this off-screen, free from any particular space_id). */ | * (since we're doing this off-screen, free from any particular space_id). */ | ||||
| struct bThemeState theme_state; | bThemeState theme_state; | ||||
| UI_Theme_Store(&theme_state); | UI_Theme_Store(&theme_state); | ||||
| UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW); | UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW); | ||||
| Context not available. | |||||
| vicon_strip_color_draw_library_data_override_noneditable); | vicon_strip_color_draw_library_data_override_noneditable); | ||||
| } | } | ||||
| static void init_iconfile_list(struct ListBase *list) | static void init_iconfile_list(ListBase *list) | ||||
| { | { | ||||
| BLI_listbase_clear(list); | BLI_listbase_clear(list); | ||||
| const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons"); | const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons"); | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| struct direntry *dir; | direntry *dir; | ||||
| const int totfile = BLI_filelist_dir_contents(icondir, &dir); | const int totfile = BLI_filelist_dir_contents(icondir, &dir); | ||||
| int index = 1; | int index = 1; | ||||
| Context not available. | |||||
| # endif /* removed */ | # endif /* removed */ | ||||
| /* found a potential icon file, so make an entry for it in the cache list */ | /* found a potential icon file, so make an entry for it in the cache list */ | ||||
| IconFile *ifile = MEM_callocN(sizeof(IconFile), "IconFile"); | IconFile *ifile = MEM_cnew<IconFile>(__func__); | ||||
| BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename)); | BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename)); | ||||
| ifile->index = index; | ifile->index = index; | ||||
| Context not available. | |||||
| dir = NULL; | dir = NULL; | ||||
| } | } | ||||
| static void free_iconfile_list(struct ListBase *list) | static void free_iconfile_list(ListBase *list) | ||||
| { | { | ||||
| IconFile *ifile = NULL, *next_ifile = NULL; | LISTBASE_FOREACH_MUTABLE (IconFile *, ifile, &iconfilelist) { | ||||
| for (ifile = list->first; ifile; ifile = next_ifile) { | |||||
| next_ifile = ifile->next; | |||||
| BLI_freelinkN(list, ifile); | BLI_freelinkN(list, ifile); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| int UI_iconfile_get_index(const char *filename) | int UI_iconfile_get_index(const char *filename) | ||||
| { | { | ||||
| IconFile *ifile; | LISTBASE_FOREACH (const IconFile *, ifile, &iconfilelist) { | ||||
| ListBase *list = &(iconfilelist); | |||||
| for (ifile = list->first; ifile; ifile = ifile->next) { | |||||
| if (BLI_path_cmp(filename, ifile->filename) == 0) { | if (BLI_path_cmp(filename, ifile->filename) == 0) { | ||||
| return ifile->index; | return ifile->index; | ||||
| } | } | ||||
| Context not available. | |||||
| void UI_icons_free_drawinfo(void *drawinfo) | void UI_icons_free_drawinfo(void *drawinfo) | ||||
| { | { | ||||
| DrawInfo *di = drawinfo; | DrawInfo *di = static_cast<DrawInfo *>(drawinfo); | ||||
| if (di == NULL) { | if (di == NULL) { | ||||
| return; | return; | ||||
| Context not available. | |||||
| { | { | ||||
| const int icon_data_type = icon->obj_type; | const int icon_data_type = icon->obj_type; | ||||
| DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "di_icon"); | DrawInfo *di = MEM_cnew<DrawInfo>("di_icon"); | ||||
| if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) { | if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) { | ||||
| di->type = ICON_TYPE_PREVIEW; | di->type = ICON_TYPE_PREVIEW; | ||||
| Context not available. | |||||
| static DrawInfo *icon_ensure_drawinfo(Icon *icon) | static DrawInfo *icon_ensure_drawinfo(Icon *icon) | ||||
| { | { | ||||
| if (icon->drawinfo) { | if (icon->drawinfo) { | ||||
| return icon->drawinfo; | return static_cast<DrawInfo *>(icon->drawinfo); | ||||
| } | } | ||||
| DrawInfo *di = icon_create_drawinfo(icon); | DrawInfo *di = icon_create_drawinfo(icon); | ||||
| icon->drawinfo = di; | icon->drawinfo = di; | ||||
| Context not available. | |||||
| /* Create rect for the icon | /* Create rect for the icon | ||||
| */ | */ | ||||
| static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size) | static void icon_create_rect(PreviewImage *prv_img, enum eIconSizes size) | ||||
| { | { | ||||
| const uint render_size = UI_icon_preview_to_render_size(size); | const uint render_size = UI_icon_preview_to_render_size(size); | ||||
| Context not available. | |||||
| prv_img->h[size] = render_size; | prv_img->h[size] = render_size; | ||||
| prv_img->flag[size] |= PRV_CHANGED; | prv_img->flag[size] |= PRV_CHANGED; | ||||
| prv_img->changed_timestamp[size] = 0; | prv_img->changed_timestamp[size] = 0; | ||||
| prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(uint), "prv_rect"); | prv_img->rect[size] = static_cast<uint *>( | ||||
| MEM_callocN(render_size * render_size * sizeof(uint), "prv_rect")); | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| Icon **tmp = (Icon **)customdata; | Icon **tmp = (Icon **)customdata; | ||||
| Icon *icon = *tmp; | Icon *icon = *tmp; | ||||
| DrawInfo *di = icon_ensure_drawinfo(icon); | DrawInfo *di = icon_ensure_drawinfo(icon); | ||||
| StudioLight *sl = icon->obj; | StudioLight *sl = static_cast<StudioLight *>(icon->obj); | ||||
| BKE_studiolight_preview(di->data.buffer.image->rect, sl, icon->id_type); | BKE_studiolight_preview(di->data.buffer.image->rect, sl, icon->id_type); | ||||
| } | } | ||||
| Context not available. | |||||
| static void ui_studiolight_free_function(StudioLight *sl, void *data) | static void ui_studiolight_free_function(StudioLight *sl, void *data) | ||||
| { | { | ||||
| wmWindowManager *wm = data; | wmWindowManager *wm = static_cast<wmWindowManager *>(data); | ||||
| /* Happens if job was canceled or already finished. */ | /* Happens if job was canceled or already finished. */ | ||||
| if (wm == NULL) { | if (wm == NULL) { | ||||
| Context not available. | |||||
| { | { | ||||
| Icon **tmp = (Icon **)customdata; | Icon **tmp = (Icon **)customdata; | ||||
| Icon *icon = *tmp; | Icon *icon = *tmp; | ||||
| StudioLight *sl = icon->obj; | StudioLight *sl = static_cast<StudioLight *>(icon->obj); | ||||
| BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, NULL); | BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, NULL); | ||||
| } | } | ||||
| Context not available. | |||||
| switch (di->type) { | switch (di->type) { | ||||
| case ICON_TYPE_PREVIEW: { | case ICON_TYPE_PREVIEW: { | ||||
| ID *id = (icon->id_type != 0) ? icon->obj : NULL; | ID *id = (icon->id_type != 0) ? static_cast<ID *>(icon->obj) : NULL; | ||||
| PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj; | PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : | ||||
| static_cast<PreviewImage *>(icon->obj); | |||||
| /* Using jobs for screen previews crashes due to off-screen rendering. | /* Using jobs for screen previews crashes due to off-screen rendering. | ||||
| * XXX: would be nicer if #PreviewImage could store if it supports jobs. */ | * XXX: would be nicer if #PreviewImage could store if it supports jobs. */ | ||||
| const bool use_jobs = !id || (GS(id->name) != ID_SCR); | const bool use_jobs = !id || (GS(id->name) != ID_SCR); | ||||
| Context not available. | |||||
| if (icon->obj_type == ICON_DATA_STUDIOLIGHT) { | if (icon->obj_type == ICON_DATA_STUDIOLIGHT) { | ||||
| if (di->data.buffer.image == NULL) { | if (di->data.buffer.image == NULL) { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| StudioLight *sl = icon->obj; | StudioLight *sl = static_cast<StudioLight *>(icon->obj); | ||||
| BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, wm); | BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, wm); | ||||
| IconImage *img = MEM_mallocN(sizeof(IconImage), __func__); | IconImage *img = MEM_cnew<IconImage>(__func__); | ||||
| img->w = STUDIOLIGHT_ICON_SIZE; | img->w = STUDIOLIGHT_ICON_SIZE; | ||||
| img->h = STUDIOLIGHT_ICON_SIZE; | img->h = STUDIOLIGHT_ICON_SIZE; | ||||
| const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint); | const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint); | ||||
| img->rect = MEM_mallocN(size, __func__); | img->rect = static_cast<uint *>(MEM_mallocN(size, __func__)); | ||||
| memset(img->rect, 0, size); | memset(img->rect, 0, size); | ||||
| di->data.buffer.image = img; | di->data.buffer.image = img; | ||||
| wmJob *wm_job = WM_jobs_get( | wmJob *wm_job = WM_jobs_get(wm, | ||||
| wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT); | CTX_wm_window(C), | ||||
| Icon **tmp = MEM_callocN(sizeof(Icon *), __func__); | icon, | ||||
| "StudioLight Icon", | |||||
| eWM_JobFlag(0), | |||||
| WM_JOB_TYPE_STUDIOLIGHT); | |||||
| Icon **tmp = MEM_cnew<Icon *>(__func__); | |||||
| *tmp = icon; | *tmp = icon; | ||||
| WM_jobs_customdata_set(wm_job, tmp, MEM_freeN); | WM_jobs_customdata_set(wm_job, tmp, MEM_freeN); | ||||
| WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW); | WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW); | ||||
| Context not available. | |||||
| if (di->type == ICON_TYPE_PREVIEW) { | if (di->type == ICON_TYPE_PREVIEW) { | ||||
| PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : | PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : | ||||
| icon->obj; | static_cast<PreviewImage *>(icon->obj); | ||||
| if (prv) { | if (prv) { | ||||
| return BKE_previewimg_copy(prv); | return BKE_previewimg_copy(prv); | ||||
| Context not available. | |||||
| * efficient than simple glUniform calls. */ | * efficient than simple glUniform calls. */ | ||||
| #define ICON_DRAW_CACHE_SIZE 16 | #define ICON_DRAW_CACHE_SIZE 16 | ||||
| typedef struct IconDrawCall { | struct IconDrawCall { | ||||
| rctf pos; | rctf pos; | ||||
| rctf tex; | rctf tex; | ||||
| float color[4]; | float color[4]; | ||||
| } IconDrawCall; | }; | ||||
| typedef struct IconTextureDrawCall { | struct IconTextureDrawCall { | ||||
| IconDrawCall drawcall_cache[ICON_DRAW_CACHE_SIZE]; | IconDrawCall drawcall_cache[ICON_DRAW_CACHE_SIZE]; | ||||
| int calls; /* Number of calls batched together */ | int calls; /* Number of calls batched together */ | ||||
| } IconTextureDrawCall; | }; | ||||
| static struct { | static struct { | ||||
| IconTextureDrawCall normal; | IconTextureDrawCall normal; | ||||
| Context not available. | |||||
| const int data_binding = GPU_shader_get_uniform_block_binding(shader, "multi_rect_data"); | const int data_binding = GPU_shader_get_uniform_block_binding(shader, "multi_rect_data"); | ||||
| GPUUniformBuf *ubo = GPU_uniformbuf_create_ex( | GPUUniformBuf *ubo = GPU_uniformbuf_create_ex( | ||||
| sizeof(struct MultiRectCallData), texture_draw_calls->drawcall_cache, __func__); | sizeof(MultiRectCallData), texture_draw_calls->drawcall_cache, __func__); | ||||
| GPU_uniformbuf_bind(ubo, data_binding); | GPU_uniformbuf_bind(ubo, data_binding); | ||||
| const int img_binding = GPU_shader_get_texture_binding(shader, "image"); | const int img_binding = GPU_shader_get_texture_binding(shader, "image"); | ||||
| Context not available. | |||||
| fstyle_small.points *= zoom_factor; | fstyle_small.points *= zoom_factor; | ||||
| fstyle_small.points *= 0.8f; | fstyle_small.points *= 0.8f; | ||||
| rcti text_rect = { | rcti text_rect{}; | ||||
| .xmax = x + UI_UNIT_X * zoom_factor, | text_rect.xmax = x + UI_UNIT_X * zoom_factor; | ||||
| .xmin = x, | text_rect.xmin = x; | ||||
| .ymax = y, | text_rect.ymax = y; | ||||
| .ymin = y, | text_rect.ymin = y; | ||||
| }; | |||||
| uiFontStyleDraw_Params params{}; | |||||
| params.align = UI_STYLE_TEXT_RIGHT; | |||||
| UI_fontstyle_draw(&fstyle_small, | UI_fontstyle_draw(&fstyle_small, | ||||
| &text_rect, | &text_rect, | ||||
| text_overlay->text, | text_overlay->text, | ||||
| sizeof(text_overlay->text), | sizeof(text_overlay->text), | ||||
| text_color, | text_color, | ||||
| &(struct uiFontStyleDraw_Params){ | ¶ms); | ||||
| .align = UI_STYLE_TEXT_RIGHT, | |||||
| }); | |||||
| text_width = (float)UI_fontstyle_string_width(&fstyle_small, text_overlay->text) / UI_UNIT_X / | text_width = (float)UI_fontstyle_string_width(&fstyle_small, text_overlay->text) / UI_UNIT_X / | ||||
| zoom_factor; | zoom_factor; | ||||
| } | } | ||||
| Context not available. | |||||
| UI_widgetbase_draw_cache_flush(); | UI_widgetbase_draw_cache_flush(); | ||||
| if (di->type == ICON_TYPE_IMBUF) { | if (di->type == ICON_TYPE_IMBUF) { | ||||
| ImBuf *ibuf = icon->obj; | ImBuf *ibuf = static_cast<ImBuf *>(icon->obj); | ||||
| GPU_blend(GPU_BLEND_ALPHA_PREMULT); | GPU_blend(GPU_BLEND_ALPHA_PREMULT); | ||||
| icon_draw_rect(x, y, w, h, aspect, ibuf->x, ibuf->y, ibuf->rect, alpha, desaturate); | icon_draw_rect(x, y, w, h, aspect, ibuf->x, ibuf->y, ibuf->rect, alpha, desaturate); | ||||
| Context not available. | |||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| } | } | ||||
| if (invert != geom_inverted) { | if (invert != geom_inverted) { | ||||
| BKE_icon_geom_invert_lightness(icon->obj); | BKE_icon_geom_invert_lightness(static_cast<Icon_Geom *>(icon->obj)); | ||||
| } | } | ||||
| ibuf = BKE_icon_geom_rasterize(icon->obj, w, h); | ibuf = BKE_icon_geom_rasterize(static_cast<Icon_Geom *>(icon->obj), w, h); | ||||
| di->data.geom.image_cache = ibuf; | di->data.geom.image_cache = ibuf; | ||||
| di->data.geom.inverted = invert; | di->data.geom.inverted = invert; | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| else if (di->type == ICON_TYPE_PREVIEW) { | else if (di->type == ICON_TYPE_PREVIEW) { | ||||
| PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : | PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : | ||||
| icon->obj; | static_cast<PreviewImage *>(icon->obj); | ||||
| if (pi) { | if (pi) { | ||||
| /* no create icon on this level in code */ | /* no create icon on this level in code */ | ||||
| Context not available. | |||||
| /* changed only ever set by dynamic icons */ | /* changed only ever set by dynamic icons */ | ||||
| if ((pi->flag[size] & PRV_CHANGED) || !pi->rect[size]) { | if ((pi->flag[size] & PRV_CHANGED) || !pi->rect[size]) { | ||||
| /* create the rect if necessary */ | /* create the rect if necessary */ | ||||
| icon_set_image(C, scene, id, pi, size, use_job); | icon_set_image(C, scene, id, pi, eIconSizes(size), use_job); | ||||
| pi->flag[size] &= ~PRV_CHANGED; | pi->flag[size] &= ~PRV_CHANGED; | ||||
| } | } | ||||
| Context not available. | |||||
| /* For objects, first try if a preview can created via the object data. */ | /* For objects, first try if a preview can created via the object data. */ | ||||
| if (GS(id->name) == ID_OB) { | if (GS(id->name) == ID_OB) { | ||||
| Object *ob = (Object *)id; | Object *ob = (Object *)id; | ||||
| if (ED_preview_id_is_supported(ob->data)) { | if (ED_preview_id_is_supported(static_cast<const ID *>(ob->data))) { | ||||
| id_to_render = ob->data; | id_to_render = static_cast<ID *>(ob->data); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| for (enum eIconSizes i = 0; i < NUM_ICON_SIZES; i++) { | for (int i = 0; i < NUM_ICON_SIZES; i++) { | ||||
| ui_id_preview_image_render_size(C, NULL, id, pi, i, use_jobs); | ui_id_preview_image_render_size(C, NULL, id, pi, i, use_jobs); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| else if (space_type == SPACE_IMAGE) { | else if (space_type == SPACE_IMAGE) { | ||||
| if (area->spacetype == space_type) { | if (area->spacetype == space_type) { | ||||
| const SpaceImage *sima = area->spacedata.first; | const SpaceImage *sima = static_cast<const SpaceImage *>(area->spacedata.first); | ||||
| if (sima->mode == SI_MODE_PAINT) { | if (sima->mode == SI_MODE_PAINT) { | ||||
| paint_mode = PAINT_MODE_TEXTURE_2D; | paint_mode = PAINT_MODE_TEXTURE_2D; | ||||
| } | } | ||||
| Context not available. | |||||
| id = ptr->owner_id; | id = ptr->owner_id; | ||||
| } | } | ||||
| else if (RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) { | else if (RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) { | ||||
| id = RNA_pointer_get(ptr, "material").data; | id = static_cast<ID *>(RNA_pointer_get(ptr, "material").data); | ||||
| } | } | ||||
| else if (RNA_struct_is_a(ptr->type, &RNA_TextureSlot)) { | else if (RNA_struct_is_a(ptr->type, &RNA_TextureSlot)) { | ||||
| id = RNA_pointer_get(ptr, "texture").data; | id = static_cast<ID *>(RNA_pointer_get(ptr, "texture").data); | ||||
| } | } | ||||
| else if (RNA_struct_is_a(ptr->type, &RNA_FileBrowserFSMenuEntry)) { | else if (RNA_struct_is_a(ptr->type, &RNA_FileBrowserFSMenuEntry)) { | ||||
| return RNA_int_get(ptr, "icon"); | return RNA_int_get(ptr, "icon"); | ||||
| } | } | ||||
| else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) { | else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) { | ||||
| DynamicPaintSurface *surface = ptr->data; | DynamicPaintSurface *surface = static_cast<DynamicPaintSurface *>(ptr->data); | ||||
| if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) { | if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) { | ||||
| return ICON_SHADING_TEXTURE; | return ICON_SHADING_TEXTURE; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) { | else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) { | ||||
| StudioLight *sl = ptr->data; | StudioLight *sl = static_cast<StudioLight *>(ptr->data); | ||||
| switch (sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS) { | switch (sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS) { | ||||
| case STUDIOLIGHT_TYPE_STUDIO: | case STUDIOLIGHT_TYPE_STUDIO: | ||||
| return sl->icon_id_irradiance; | return sl->icon_id_irradiance; | ||||
| Context not available. | |||||
| return NULL; | return NULL; | ||||
| #else | #else | ||||
| const int ALERT_IMG_SIZE = 256; | const int ALERT_IMG_SIZE = 256; | ||||
| icon = MIN2(icon, ALERT_ICON_MAX - 1); | icon = eAlertIcon(MIN2(icon, ALERT_ICON_MAX - 1)); | ||||
| const int left = icon * ALERT_IMG_SIZE; | const int left = icon * ALERT_IMG_SIZE; | ||||
| const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1}; | const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1}; | ||||
| ImBuf *ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png, | ImBuf *ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png, | ||||
| Context not available. | |||||