Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_icons.c
| Show First 20 Lines • Show All 824 Lines • ▼ Show 20 Lines | for (int i = 0; i < 2; i++) { | ||||
| GPU_texture_free(icongltex.tex[i]); | GPU_texture_free(icongltex.tex[i]); | ||||
| icongltex.tex[i] = NULL; | icongltex.tex[i] = NULL; | ||||
| } | } | ||||
| } | } | ||||
| icongltex.num_textures = 0; | icongltex.num_textures = 0; | ||||
| } | } | ||||
| } | } | ||||
| /* Reload the textures for internal icons. | |||||
| * This function will release the previous textures. */ | |||||
| void UI_icons_reload_internal_textures(void) | void UI_icons_reload_internal_textures(void) | ||||
| { | { | ||||
| bTheme *btheme = UI_GetTheme(); | bTheme *btheme = UI_GetTheme(); | ||||
| ImBuf *b16buf = NULL, *b32buf = NULL, *b16buf_border = NULL, *b32buf_border = NULL; | ImBuf *b16buf = NULL, *b32buf = NULL, *b16buf_border = NULL, *b32buf_border = NULL; | ||||
| const float icon_border_intensity = btheme->tui.icon_border_intensity; | const float icon_border_intensity = btheme->tui.icon_border_intensity; | ||||
| const bool need_icons_with_border = icon_border_intensity > 0.0f; | const bool need_icons_with_border = icon_border_intensity > 0.0f; | ||||
| if (b16buf == NULL) { | if (b16buf == NULL) { | ||||
| ▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | if (icon->drawinfo) { | ||||
| return icon->drawinfo; | return icon->drawinfo; | ||||
| } | } | ||||
| DrawInfo *di = icon_create_drawinfo(icon); | DrawInfo *di = icon_create_drawinfo(icon); | ||||
| icon->drawinfo = di; | icon->drawinfo = di; | ||||
| icon->drawinfo_free = UI_icons_free_drawinfo; | icon->drawinfo_free = UI_icons_free_drawinfo; | ||||
| return di; | return di; | ||||
| } | } | ||||
| /* NOTE:, returns unscaled by DPI. */ | |||||
| int UI_icon_get_width(int icon_id) | int UI_icon_get_width(int icon_id) | ||||
| { | { | ||||
| Icon *icon = BKE_icon_get(icon_id); | Icon *icon = BKE_icon_get(icon_id); | ||||
| if (icon == NULL) { | if (icon == NULL) { | ||||
| if (G.debug & G_DEBUG) { | if (G.debug & G_DEBUG) { | ||||
| printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id); | printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | #ifndef WITH_HEADLESS | ||||
| init_iconfile_list(&iconfilelist); | init_iconfile_list(&iconfilelist); | ||||
| UI_icons_reload_internal_textures(); | UI_icons_reload_internal_textures(); | ||||
| init_internal_icons(); | init_internal_icons(); | ||||
| init_brush_icons(); | init_brush_icons(); | ||||
| init_event_icons(); | init_event_icons(); | ||||
| #endif | #endif | ||||
| } | } | ||||
| /* Render size for preview images and icons | |||||
| */ | |||||
| int UI_icon_preview_to_render_size(enum eIconSizes size) | int UI_icon_preview_to_render_size(enum eIconSizes size) | ||||
| { | { | ||||
| switch (size) { | switch (size) { | ||||
| case ICON_SIZE_ICON: | case ICON_SIZE_ICON: | ||||
| return ICON_RENDER_DEFAULT_HEIGHT; | return ICON_RENDER_DEFAULT_HEIGHT; | ||||
| case ICON_SIZE_PREVIEW: | case ICON_SIZE_PREVIEW: | ||||
| return PREVIEW_RENDER_DEFAULT_HEIGHT; | return PREVIEW_RENDER_DEFAULT_HEIGHT; | ||||
| default: | default: | ||||
| ▲ Show 20 Lines • Show All 771 Lines • ▼ Show 20 Lines | static void ui_id_preview_image_render_size( | ||||
| 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, size, use_job); | ||||
| pi->flag[size] &= ~PRV_CHANGED; | pi->flag[size] &= ~PRV_CHANGED; | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Note that if an ID doesn't support jobs for preview creation, \a use_job will be ignored. | |||||
| */ | |||||
| void UI_icon_render_id( | void UI_icon_render_id( | ||||
| const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job) | const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job) | ||||
| { | { | ||||
| PreviewImage *pi = BKE_previewimg_id_ensure(id); | PreviewImage *pi = BKE_previewimg_id_ensure(id); | ||||
| if (pi == NULL) { | if (pi == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 423 Lines • ▼ Show 20 Lines | int UI_icon_color_from_collection(const Collection *collection) | ||||
| if (collection->color_tag != COLLECTION_COLOR_NONE) { | if (collection->color_tag != COLLECTION_COLOR_NONE) { | ||||
| icon = ICON_COLLECTION_COLOR_01 + collection->color_tag; | icon = ICON_COLLECTION_COLOR_01 + collection->color_tag; | ||||
| } | } | ||||
| return icon; | return icon; | ||||
| } | } | ||||
| /* draws icon with dpi scale factor */ | |||||
| void UI_icon_draw(float x, float y, int icon_id) | void UI_icon_draw(float x, float y, int icon_id) | ||||
| { | { | ||||
| UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, NULL, false); | UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, NULL, false); | ||||
| } | } | ||||
| void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha) | void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha) | ||||
| { | { | ||||
| UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, alpha, 0.0f, NULL, false); | UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, alpha, 0.0f, NULL, false); | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||