Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r--source/blender/editors/interface/interface_icons.c367
1 files changed, 208 insertions, 159 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index c91b4d826a7..fbe61a23d11 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -41,6 +41,7 @@
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
+#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_gpencil_types.h"
@@ -178,16 +179,12 @@ static const IconType icontypes[] = {
static DrawInfo *def_internal_icon(
ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color)
{
- Icon *new_icon = NULL;
- IconImage *iimg = NULL;
- DrawInfo *di;
-
- new_icon = MEM_callocN(sizeof(Icon), "texicon");
+ Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
new_icon->obj = NULL; /* icon is not for library object */
new_icon->id_type = 0;
- di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
+ DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
di->type = type;
if (ELEM(type, ICON_TYPE_COLOR_TEXTURE, ICON_TYPE_MONO_TEXTURE)) {
@@ -198,7 +195,7 @@ static DrawInfo *def_internal_icon(
di->data.texture.h = size;
}
else if (type == ICON_TYPE_BUFFER) {
- iimg = MEM_callocN(sizeof(IconImage), "icon_img");
+ IconImage *iimg = MEM_callocN(sizeof(IconImage), "icon_img");
iimg->w = size;
iimg->h = size;
@@ -234,15 +231,12 @@ static DrawInfo *def_internal_icon(
static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
{
- Icon *new_icon = NULL;
- DrawInfo *di;
-
- new_icon = MEM_callocN(sizeof(Icon), "texicon");
+ Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
new_icon->obj = NULL; /* icon is not for library object */
new_icon->id_type = 0;
- di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
+ DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
di->type = ICON_TYPE_VECTOR;
di->data.vector.func = drawFunc;
@@ -256,7 +250,7 @@ static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
/* Utilities */
-static void viconutil_set_point(GLint pt[2], int x, int y)
+static void viconutil_set_point(int pt[2], int x, int y)
{
pt[0] = x;
pt[1] = y;
@@ -264,7 +258,7 @@ static void viconutil_set_point(GLint pt[2], int x, int y)
static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
- GLint pts[3][2];
+ int pts[3][2];
const int cx = x + w / 2 - 4;
const int cy = y + w / 2;
const int d = w / 5, d2 = w / 7;
@@ -461,6 +455,33 @@ DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19)
# undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH
+static void vicon_collection_color_draw(
+ short color_tag, int x, int y, int UNUSED(w), int UNUSED(h), float UNUSED(alpha))
+{
+ bTheme *btheme = UI_GetTheme();
+ const ThemeCollectionColor *collection_color = &btheme->collection_color[color_tag];
+
+ UI_icon_draw_ex(
+ x, y, ICON_OUTLINER_COLLECTION, U.inv_dpi_fac, 1.0f, 0.0f, collection_color->color, true);
+}
+
+# define DEF_ICON_COLLECTION_COLOR_DRAW(index, color) \
+ static void vicon_collection_color_draw_##index(int x, int y, int w, int h, float alpha) \
+ { \
+ vicon_collection_color_draw(color, x, y, w, h, alpha); \
+ }
+
+DEF_ICON_COLLECTION_COLOR_DRAW(01, COLLECTION_COLOR_01);
+DEF_ICON_COLLECTION_COLOR_DRAW(02, COLLECTION_COLOR_02);
+DEF_ICON_COLLECTION_COLOR_DRAW(03, COLLECTION_COLOR_03);
+DEF_ICON_COLLECTION_COLOR_DRAW(04, COLLECTION_COLOR_04);
+DEF_ICON_COLLECTION_COLOR_DRAW(05, COLLECTION_COLOR_05);
+DEF_ICON_COLLECTION_COLOR_DRAW(06, COLLECTION_COLOR_06);
+DEF_ICON_COLLECTION_COLOR_DRAW(07, COLLECTION_COLOR_07);
+DEF_ICON_COLLECTION_COLOR_DRAW(08, COLLECTION_COLOR_08);
+
+# undef DEF_ICON_COLLECTION_COLOR_DRAW
+
/* Dynamically render icon instead of rendering a plain color to a texture/buffer
* This is not strictly a "vicon", as it needs access to icon->obj to get the color info,
* but it works in a very similar way.
@@ -750,7 +771,7 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
const int asy = MAX2(by - blur_size, 0);
const int aey = MIN2(by + blur_size + 1, icon_height);
- // blur alpha channel
+ /* blur alpha channel */
const int write_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx;
float alpha_accum = 0.0;
uint alpha_samples = 0;
@@ -887,9 +908,7 @@ void UI_icons_reload_internal_textures(void)
static void init_internal_icons(void)
{
- int x, y;
-
-# if 0 // temp disabled
+# if 0 /* temp disabled */
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
char iconfilestr[FILE_MAX];
@@ -917,9 +936,9 @@ static void init_internal_icons(void)
# endif
/* Define icons. */
- for (y = 0; y < ICON_GRID_ROWS; y++) {
+ for (int y = 0; y < ICON_GRID_ROWS; y++) {
/* Row W has monochrome icons. */
- for (x = 0; x < ICON_GRID_COLS; x++) {
+ for (int x = 0; x < ICON_GRID_COLS; x++) {
const IconType icontype = icontypes[y * ICON_GRID_COLS + x];
if (!ELEM(icontype.type, ICON_TYPE_COLOR_TEXTURE, ICON_TYPE_MONO_TEXTURE)) {
continue;
@@ -969,24 +988,30 @@ static void init_internal_icons(void)
def_internal_vicon(ICON_COLORSET_18_VEC, vicon_colorset_draw_18);
def_internal_vicon(ICON_COLORSET_19_VEC, vicon_colorset_draw_19);
def_internal_vicon(ICON_COLORSET_20_VEC, vicon_colorset_draw_20);
+
+ def_internal_vicon(ICON_COLLECTION_COLOR_01, vicon_collection_color_draw_01);
+ def_internal_vicon(ICON_COLLECTION_COLOR_02, vicon_collection_color_draw_02);
+ def_internal_vicon(ICON_COLLECTION_COLOR_03, vicon_collection_color_draw_03);
+ def_internal_vicon(ICON_COLLECTION_COLOR_04, vicon_collection_color_draw_04);
+ def_internal_vicon(ICON_COLLECTION_COLOR_05, vicon_collection_color_draw_05);
+ def_internal_vicon(ICON_COLLECTION_COLOR_06, vicon_collection_color_draw_06);
+ def_internal_vicon(ICON_COLLECTION_COLOR_07, vicon_collection_color_draw_07);
+ def_internal_vicon(ICON_COLLECTION_COLOR_08, vicon_collection_color_draw_08);
}
static void init_iconfile_list(struct ListBase *list)
{
- IconFile *ifile;
- struct direntry *dir;
- int index = 1;
- const char *icondir;
-
BLI_listbase_clear(list);
- icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
+ const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
if (icondir == NULL) {
return;
}
+ struct direntry *dir;
int totfile = BLI_filelist_dir_contents(icondir, &dir);
+ int index = 1;
for (int i = 0; i < totfile; i++) {
if ((dir[i].type & S_IFREG)) {
const char *filename = dir[i].relname;
@@ -1021,7 +1046,7 @@ static void init_iconfile_list(struct ListBase *list)
# endif /* removed */
/* found a potential icon file, so make an entry for it in the cache list */
- ifile = MEM_callocN(sizeof(IconFile), "IconFile");
+ IconFile *ifile = MEM_callocN(sizeof(IconFile), "IconFile");
BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
ifile->index = index;
@@ -1089,23 +1114,25 @@ void UI_icons_free_drawinfo(void *drawinfo)
{
DrawInfo *di = drawinfo;
- if (di) {
- if (di->type == ICON_TYPE_BUFFER) {
- if (di->data.buffer.image) {
- if (di->data.buffer.image->rect) {
- MEM_freeN(di->data.buffer.image->rect);
- }
- MEM_freeN(di->data.buffer.image);
+ if (di == NULL) {
+ return;
+ }
+
+ if (di->type == ICON_TYPE_BUFFER) {
+ if (di->data.buffer.image) {
+ if (di->data.buffer.image->rect) {
+ MEM_freeN(di->data.buffer.image->rect);
}
+ MEM_freeN(di->data.buffer.image);
}
- else if (di->type == ICON_TYPE_GEOM) {
- if (di->data.geom.image_cache) {
- IMB_freeImBuf(di->data.geom.image_cache);
- }
+ }
+ else if (di->type == ICON_TYPE_GEOM) {
+ if (di->data.geom.image_cache) {
+ IMB_freeImBuf(di->data.geom.image_cache);
}
-
- MEM_freeN(di);
}
+
+ MEM_freeN(di);
}
/**
@@ -1114,9 +1141,8 @@ void UI_icons_free_drawinfo(void *drawinfo)
static DrawInfo *icon_create_drawinfo(Icon *icon)
{
const int icon_data_type = icon->obj_type;
- DrawInfo *di = NULL;
- di = MEM_callocN(sizeof(DrawInfo), "di_icon");
+ DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "di_icon");
if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) {
di->type = ICON_TYPE_PREVIEW;
@@ -1151,10 +1177,7 @@ static DrawInfo *icon_ensure_drawinfo(Icon *icon)
/* note!, returns unscaled by DPI */
int UI_icon_get_width(int icon_id)
{
- Icon *icon = NULL;
- DrawInfo *di = NULL;
-
- icon = BKE_icon_get(icon_id);
+ Icon *icon = BKE_icon_get(icon_id);
if (icon == NULL) {
if (G.debug & G_DEBUG) {
@@ -1163,7 +1186,7 @@ int UI_icon_get_width(int icon_id)
return 0;
}
- di = icon_ensure_drawinfo(icon);
+ DrawInfo *di = icon_ensure_drawinfo(icon);
if (di) {
return ICON_DEFAULT_WIDTH;
}
@@ -1213,7 +1236,7 @@ void UI_icons_init()
/* Render size for preview images and icons
*/
-int UI_preview_render_size(enum eIconSizes size)
+int UI_icon_preview_to_render_size(enum eIconSizes size)
{
switch (size) {
case ICON_SIZE_ICON:
@@ -1229,7 +1252,7 @@ int UI_preview_render_size(enum eIconSizes size)
*/
static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
{
- const uint render_size = UI_preview_render_size(size);
+ const uint render_size = UI_icon_preview_to_render_size(size);
if (!prv_img) {
if (G.debug & G_DEBUG) {
@@ -1276,7 +1299,7 @@ static void ui_studiolight_free_function(StudioLight *sl, void *data)
return;
}
- // get icons_id, get icons and kill wm jobs
+ /* get icons_id, get icons and kill wm jobs */
if (sl->icon_id_radiance) {
ui_studiolight_kill_icon_preview_job(wm, sl->icon_id_radiance);
}
@@ -1303,56 +1326,60 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi
{
Icon *icon = BKE_icon_get(icon_id);
- if (icon) {
- DrawInfo *di = icon_ensure_drawinfo(icon);
+ if (icon == NULL) {
+ return;
+ }
+
+ DrawInfo *di = icon_ensure_drawinfo(icon);
+
+ if (di == NULL) {
+ return;
+ }
- if (di) {
- switch (di->type) {
- case ICON_TYPE_PREVIEW: {
- ID *id = (icon->id_type != 0) ? icon->obj : NULL;
- PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
- /* Using jobs for screen previews crashes due to offscreen rendering.
- * XXX would be nicer if PreviewImage could store if it supports jobs */
- const bool use_jobs = !id || (GS(id->name) != ID_SCR);
+ switch (di->type) {
+ case ICON_TYPE_PREVIEW: {
+ ID *id = (icon->id_type != 0) ? icon->obj : NULL;
+ PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
+ /* Using jobs for screen previews crashes due to offscreen rendering.
+ * XXX would be nicer if PreviewImage could store if it supports jobs */
+ const bool use_jobs = !id || (GS(id->name) != ID_SCR);
- if (prv) {
- const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON;
+ if (prv) {
+ const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON;
- if (id || (prv->tag & PRV_TAG_DEFFERED) != 0) {
- ui_id_preview_image_render_size(C, NULL, id, prv, size, use_jobs);
- }
- }
- break;
+ if (id || (prv->tag & PRV_TAG_DEFFERED) != 0) {
+ ui_id_preview_image_render_size(C, NULL, id, prv, size, use_jobs);
}
- case ICON_TYPE_BUFFER: {
- if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
- if (di->data.buffer.image == NULL) {
- wmWindowManager *wm = CTX_wm_manager(C);
- StudioLight *sl = icon->obj;
- BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, wm);
- IconImage *img = MEM_mallocN(sizeof(IconImage), __func__);
-
- img->w = STUDIOLIGHT_ICON_SIZE;
- img->h = STUDIOLIGHT_ICON_SIZE;
- const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint);
- img->rect = MEM_mallocN(size, __func__);
- memset(img->rect, 0, size);
- di->data.buffer.image = img;
-
- wmJob *wm_job = WM_jobs_get(
- wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT);
- Icon **tmp = MEM_callocN(sizeof(Icon *), __func__);
- *tmp = icon;
- WM_jobs_customdata_set(wm_job, tmp, MEM_freeN);
- WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW);
- WM_jobs_callbacks(
- wm_job, ui_studiolight_icon_job_exec, NULL, NULL, ui_studiolight_icon_job_end);
- WM_jobs_start(CTX_wm_manager(C), wm_job);
- }
- }
- break;
+ }
+ break;
+ }
+ case ICON_TYPE_BUFFER: {
+ if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
+ if (di->data.buffer.image == NULL) {
+ wmWindowManager *wm = CTX_wm_manager(C);
+ StudioLight *sl = icon->obj;
+ BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, wm);
+ IconImage *img = MEM_mallocN(sizeof(IconImage), __func__);
+
+ img->w = STUDIOLIGHT_ICON_SIZE;
+ img->h = STUDIOLIGHT_ICON_SIZE;
+ const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint);
+ img->rect = MEM_mallocN(size, __func__);
+ memset(img->rect, 0, size);
+ di->data.buffer.image = img;
+
+ wmJob *wm_job = WM_jobs_get(
+ wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT);
+ Icon **tmp = MEM_callocN(sizeof(Icon *), __func__);
+ *tmp = icon;
+ WM_jobs_customdata_set(wm_job, tmp, MEM_freeN);
+ WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW);
+ WM_jobs_callbacks(
+ wm_job, ui_studiolight_icon_job_exec, NULL, NULL, ui_studiolight_icon_job_end);
+ WM_jobs_start(CTX_wm_manager(C), wm_job);
}
}
+ break;
}
}
}
@@ -1400,41 +1427,47 @@ PreviewImage *UI_icon_to_preview(int icon_id)
{
Icon *icon = BKE_icon_get(icon_id);
- if (icon) {
- DrawInfo *di = (DrawInfo *)icon->drawinfo;
- if (di) {
- if (di->type == ICON_TYPE_PREVIEW) {
- PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
- icon->obj;
+ if (icon == NULL) {
+ return NULL;
+ }
- if (prv) {
- return BKE_previewimg_copy(prv);
- }
- }
- else if (di->data.buffer.image) {
- ImBuf *bbuf;
-
- bbuf = IMB_ibImageFromMemory(di->data.buffer.image->datatoc_rect,
- di->data.buffer.image->datatoc_size,
- IB_rect,
- NULL,
- __func__);
- if (bbuf) {
- PreviewImage *prv = BKE_previewimg_create();
+ DrawInfo *di = (DrawInfo *)icon->drawinfo;
- prv->rect[0] = bbuf->rect;
+ if (di == NULL) {
+ return NULL;
+ }
- prv->w[0] = bbuf->x;
- prv->h[0] = bbuf->y;
+ if (di->type == ICON_TYPE_PREVIEW) {
+ PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
+ icon->obj;
- bbuf->rect = NULL;
- IMB_freeImBuf(bbuf);
+ if (prv) {
+ return BKE_previewimg_copy(prv);
+ }
+ }
+ else if (di->data.buffer.image) {
+ ImBuf *bbuf;
- return prv;
- }
- }
+ bbuf = IMB_ibImageFromMemory(di->data.buffer.image->datatoc_rect,
+ di->data.buffer.image->datatoc_size,
+ IB_rect,
+ NULL,
+ __func__);
+ if (bbuf) {
+ PreviewImage *prv = BKE_previewimg_create();
+
+ prv->rect[0] = bbuf->rect;
+
+ prv->w[0] = bbuf->x;
+ prv->h[0] = bbuf->y;
+
+ bbuf->rect = NULL;
+ IMB_freeImBuf(bbuf);
+
+ return prv;
}
}
+
return NULL;
}
@@ -1675,12 +1708,10 @@ static void icon_draw_texture(float x,
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
- float x1, x2, y1, y2;
-
- x1 = ix * icongltex.invw;
- x2 = (ix + ih) * icongltex.invw;
- y1 = iy * icongltex.invh;
- y2 = (iy + ih) * icongltex.invh;
+ float x1 = ix * icongltex.invw;
+ float x2 = (ix + ih) * icongltex.invw;
+ float y1 = iy * icongltex.invh;
+ float y2 = (iy + ih) * icongltex.invh;
GPUTexture *texture = with_border ? icongltex.tex[1] : icongltex.tex[0];
@@ -1738,12 +1769,9 @@ static void icon_draw_size(float x,
const bool mono_border)
{
bTheme *btheme = UI_GetTheme();
- Icon *icon = NULL;
- IconImage *iimg;
const float fdraw_size = (float)draw_size;
- int w, h;
- icon = BKE_icon_get(icon_id);
+ Icon *icon = BKE_icon_get(icon_id);
alpha *= btheme->tui.icon_alpha;
if (icon == NULL) {
@@ -1754,8 +1782,8 @@ static void icon_draw_size(float x,
}
/* scale width and height according to aspect */
- w = (int)(fdraw_size / aspect + 0.5f);
- h = (int)(fdraw_size / aspect + 0.5f);
+ int w = (int)(fdraw_size / aspect + 0.5f);
+ int h = (int)(fdraw_size / aspect + 0.5f);
DrawInfo *di = icon_ensure_drawinfo(icon);
@@ -1858,7 +1886,7 @@ static void icon_draw_size(float x,
else if (di->type == ICON_TYPE_BUFFER) {
/* it is a builtin icon */
- iimg = di->data.buffer.image;
+ IconImage *iimg = di->data.buffer.image;
#ifndef WITH_HEADLESS
icon_verify_datatoc(iimg);
#endif
@@ -1909,32 +1937,33 @@ static void ui_id_preview_image_render_size(
}
}
-void UI_id_icon_render(const bContext *C, Scene *scene, ID *id, const bool big, const bool use_job)
+void UI_icon_render_id(const bContext *C, Scene *scene, ID *id, const bool big, const bool use_job)
{
PreviewImage *pi = BKE_previewimg_id_ensure(id);
- if (pi) {
- if (big) {
- /* bigger preview size */
- ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_PREVIEW, use_job);
- }
- else {
- /* icon size */
- ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_ICON, use_job);
- }
+ if (pi == NULL) {
+ return;
+ }
+
+ if (big) {
+ /* bigger preview size */
+ ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_PREVIEW, use_job);
+ }
+ else {
+ /* icon size */
+ ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_ICON, use_job);
}
}
static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
{
PreviewImage *pi = BKE_previewimg_id_ensure(id);
- enum eIconSizes i;
if (!pi) {
return;
}
- for (i = 0; i < NUM_ICON_SIZES; i++) {
+ for (enum eIconSizes i = 0; i < NUM_ICON_SIZES; i++) {
/* check if rect needs to be created; changed
* only set by dynamic icons */
if (((pi->flag[i] & PRV_CHANGED) || !pi->rect[i])) {
@@ -2128,11 +2157,14 @@ int ui_id_icon_get(const bContext *C, ID *id, const bool big)
case ID_LA: /* fall through */
iconid = BKE_icon_id_ensure(id);
/* checks if not exists, or changed */
- UI_id_icon_render(C, NULL, id, big, true);
+ UI_icon_render_id(C, NULL, id, big, true);
break;
case ID_SCR:
iconid = ui_id_screen_get_icon(C, id);
break;
+ case ID_GR:
+ iconid = UI_icon_color_from_collection((Collection *)id);
+ break;
default:
break;
}
@@ -2140,7 +2172,7 @@ int ui_id_icon_get(const bContext *C, ID *id, const bool big)
return iconid;
}
-int UI_library_icon_get(const ID *id)
+int UI_icon_from_library(const ID *id)
{
if (ID_IS_LINKED(id)) {
if (id->tag & LIB_TAG_MISSING) {
@@ -2158,7 +2190,7 @@ int UI_library_icon_get(const ID *id)
return ICON_NONE;
}
-int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
+int UI_icon_from_rnaptr(bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
{
ID *id = NULL;
@@ -2215,9 +2247,9 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big
return rnaicon;
}
-int UI_idcode_icon_get(const int idcode)
+int UI_icon_from_idcode(const int idcode)
{
- switch (idcode) {
+ switch ((ID_Type)idcode) {
case ID_AC:
return ICON_ACTION;
case ID_AR:
@@ -2289,14 +2321,21 @@ int UI_idcode_icon_get(const int idcode)
case ID_SIM:
/* TODO: Use correct icon. */
return ICON_PHYSICS;
- default:
- return ICON_NONE;
+
+ /* No icons for these ID-types. */
+ case ID_LI:
+ case ID_IP:
+ case ID_KE:
+ case ID_SCR:
+ case ID_WM:
+ break;
}
+ return ICON_NONE;
}
-int UI_mode_icon_get(const int mode)
+int UI_icon_from_object_mode(const int mode)
{
- switch (mode) {
+ switch ((eObjectMode)mode) {
case OB_MODE_OBJECT:
return ICON_OBJECT_DATAMODE;
case OB_MODE_EDIT:
@@ -2319,9 +2358,19 @@ int UI_mode_icon_get(const int mode)
return ICON_POSE_HLT;
case OB_MODE_PAINT_GPENCIL:
return ICON_GREASEPENCIL;
- default:
- return ICON_NONE;
}
+ return ICON_NONE;
+}
+
+int UI_icon_color_from_collection(const Collection *collection)
+{
+ int icon = ICON_OUTLINER_COLLECTION;
+
+ if (collection->color_tag != COLLECTION_COLOR_NONE) {
+ icon = ICON_COLLECTION_COLOR_01 + collection->color_tag;
+ }
+
+ return icon;
}
/* draws icon with dpi scale factor */
@@ -2364,7 +2413,7 @@ void UI_icon_draw_ex(float x,
/* ********** Alert Icons ********** */
-ImBuf *UI_alert_image(eAlertIcon icon)
+ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon)
{
#ifdef WITH_HEADLESS
return NULL;