Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_icons.c
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "IMB_thumbs.h" | #include "IMB_thumbs.h" | ||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| #include "ED_datafiles.h" | #include "ED_datafiles.h" | ||||
| #include "ED_keyframes_draw.h" | #include "ED_keyframes_draw.h" | ||||
| #include "ED_keyframes_keylist.h" | |||||
| #include "ED_render.h" | #include "ED_render.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_interface_icons.h" | #include "UI_interface_icons.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| ▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha) | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| static void vicon_keytype_draw_wrapper( | static void vicon_keytype_draw_wrapper( | ||||
| int x, int y, int w, int h, float alpha, short key_type, short handle_type) | int x, int y, int w, int h, float alpha, short key_type, short handle_type) | ||||
| { | { | ||||
| /* init 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 offscreen, free from any particular space_id) | * (since we're doing this off-screen, free from any particular space_id). */ | ||||
| */ | |||||
| struct bThemeState theme_state; | struct 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); | ||||
| /* the "x" and "y" given are the bottom-left coordinates of the icon, | /* The "x" and "y" given are the bottom-left coordinates of the icon, | ||||
| * while the draw_keyframe_shape() function needs the midpoint for | * while the #draw_keyframe_shape() function needs the midpoint for the keyframe. */ | ||||
| * the keyframe | |||||
| */ | |||||
| const float xco = x + w / 2 + 0.5f; | const float xco = x + w / 2 + 0.5f; | ||||
| const float yco = y + h / 2 + 0.5f; | const float yco = y + h / 2 + 0.5f; | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| const uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); | const uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); | ||||
| uint color_id = GPU_vertformat_attr_add( | uint color_id = GPU_vertformat_attr_add( | ||||
| format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | ||||
| ▲ Show 20 Lines • Show All 1,033 Lines • ▼ Show 20 Lines | void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big) | ||||
| if (di == NULL) { | if (di == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| 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) ? icon->obj : NULL; | ||||
| PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj; | PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj; | ||||
| /* Using jobs for screen previews crashes due to offscreen 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); | ||||
| if (prv) { | if (prv) { | ||||
| const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON; | const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON; | ||||
| if (id || (prv->tag & PRV_TAG_DEFFERED) != 0) { | if (id || (prv->tag & PRV_TAG_DEFFERED) != 0) { | ||||
| ui_id_preview_image_render_size(C, NULL, id, prv, size, use_jobs); | ui_id_preview_image_render_size(C, NULL, id, prv, size, use_jobs); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | static void icon_draw_rect(float x, | ||||
| int draw_w = w; | int draw_w = w; | ||||
| int draw_h = h; | int draw_h = h; | ||||
| int draw_x = x; | int draw_x = x; | ||||
| int draw_y = y; | int draw_y = y; | ||||
| /* sanity check */ | /* sanity check */ | ||||
| if (w <= 0 || h <= 0 || w > 2000 || h > 2000) { | if (w <= 0 || h <= 0 || w > 2000 || h > 2000) { | ||||
| printf("%s: icons are %i x %i pixels?\n", __func__, w, h); | printf("%s: icons are %i x %i pixels?\n", __func__, w, h); | ||||
| BLI_assert(!"invalid icon size"); | BLI_assert_msg(0, "invalid icon size"); | ||||
| return; | return; | ||||
| } | } | ||||
| /* modulate color */ | /* modulate color */ | ||||
| const float col[4] = {alpha, alpha, alpha, alpha}; | const float col[4] = {alpha, alpha, alpha, alpha}; | ||||
| /* rect contains image in 'rendersize', we only scale if needed */ | /* rect contains image in 'rendersize', we only scale if needed */ | ||||
| if (rw != w || rh != h) { | if (rw != w || rh != h) { | ||||
| /* preserve aspect ratio and center */ | /* preserve aspect ratio and center */ | ||||
| ▲ Show 20 Lines • Show All 626 Lines • ▼ Show 20 Lines | static int ui_id_brush_get_icon(const bContext *C, ID *id) | ||||
| } | } | ||||
| return id->icon_id; | return id->icon_id; | ||||
| } | } | ||||
| static int ui_id_screen_get_icon(const bContext *C, ID *id) | static int ui_id_screen_get_icon(const bContext *C, ID *id) | ||||
| { | { | ||||
| BKE_icon_id_ensure(id); | BKE_icon_id_ensure(id); | ||||
| /* Don't use jobs here, offscreen rendering doesn't like this and crashes. */ | /* Don't use jobs here, off-screen rendering doesn't like this and crashes. */ | ||||
| ui_id_icon_render(C, id, false); | ui_id_icon_render(C, id, false); | ||||
| return id->icon_id; | return id->icon_id; | ||||
| } | } | ||||
| int ui_id_icon_get(const bContext *C, ID *id, const bool big) | int ui_id_icon_get(const bContext *C, ID *id, const bool big) | ||||
| { | { | ||||
| int iconid = 0; | int iconid = 0; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | int UI_icon_from_library(const ID *id) | ||||
| } | } | ||||
| if (ID_IS_ASSET(id)) { | if (ID_IS_ASSET(id)) { | ||||
| return ICON_ASSET_MANAGER; | return ICON_ASSET_MANAGER; | ||||
| } | } | ||||
| return ICON_NONE; | return ICON_NONE; | ||||
| } | } | ||||
| int UI_icon_from_rnaptr(bContext *C, PointerRNA *ptr, int rnaicon, const bool big) | int UI_icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, const bool big) | ||||
| { | { | ||||
| ID *id = NULL; | ID *id = NULL; | ||||
| if (!ptr->data) { | if (!ptr->data) { | ||||
| return rnaicon; | return rnaicon; | ||||
| } | } | ||||
| /* try ID, material, texture or dynapaint slot */ | /* try ID, material, texture or dynapaint slot */ | ||||
| ▲ Show 20 Lines • Show All 233 Lines • Show Last 20 Lines | |||||