Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/file_draw.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| true, (float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f, color); | true, (float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f, color); | ||||
| } | } | ||||
| static void file_draw_icon( | static void file_draw_icon( | ||||
| uiBlock *block, const char *path, int sx, int sy, int icon, int width, int height, bool drag) | uiBlock *block, const char *path, int sx, int sy, int icon, int width, int height, bool drag) | ||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| int x, y; | int x, y; | ||||
| // float alpha = 1.0f; | |||||
| x = sx; | x = sx; | ||||
| y = sy - height; | y = sy - height; | ||||
| /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ | |||||
| but = uiDefIconBut( | but = uiDefIconBut( | ||||
| block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL); | block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL); | ||||
| UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path)); | UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path)); | ||||
| if (drag) { | if (drag) { | ||||
| /* path is no more static, cannot give it directly to but... */ | /* path is no more static, cannot give it directly to but... */ | ||||
| UI_but_drag_set_path(but, BLI_strdup(path), true); | UI_but_drag_set_path(but, BLI_strdup(path), true); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
| yco = sy - layout->prv_h + (int)dy; | yco = sy - layout->prv_h + (int)dy; | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| /* the large image */ | /* the large image */ | ||||
| float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | ||||
| if (is_icon) { | if (is_icon) { | ||||
| /* File and Folder icons draw with lowered opacity until we add themes */ | if (typeflags & FILE_TYPE_DIR) { | ||||
| col[3] = 0.6f; | UI_GetThemeColor4fv(TH_ICON_FOLDER, col); | ||||
| /* Use dark images if background is light */ | } | ||||
| float bg[3]; | else { | ||||
| UI_GetThemeColor3fv(TH_BACK, bg); | UI_GetThemeColor4fv(TH_TEXT, col); | ||||
| if (rgb_to_grayscale(bg) > 0.5f) { | |||||
| col[0] = 0; | |||||
| col[1] = 0; | |||||
| col[2] = 0; | |||||
| } | } | ||||
| } | } | ||||
| else if (typeflags & FILE_TYPE_FTFONT) { | else if (typeflags & FILE_TYPE_FTFONT) { | ||||
| UI_GetThemeColor4fv(TH_TEXT, col); | UI_GetThemeColor4fv(TH_TEXT, col); | ||||
| } | } | ||||
| if (!is_icon && typeflags & FILE_TYPE_BLENDERLIB) { | if (!is_icon && typeflags & FILE_TYPE_BLENDERLIB) { | ||||
| /* Datablock preview images use premultiplied alpha. */ | /* Datablock preview images use premultiplied alpha. */ | ||||
| Show All 24 Lines | |||||
| /* size of center icon is scaled to fit container and UI scale */ | /* size of center icon is scaled to fit container and UI scale */ | ||||
| float icon_x, icon_y; | float icon_x, icon_y; | ||||
| if (is_icon) { | if (is_icon) { | ||||
| const float icon_size = 16.0f / icon_aspect * U.dpi_fac; | const float icon_size = 16.0f / icon_aspect * U.dpi_fac; | ||||
| float icon_opacity = 0.3f; | float icon_opacity = 0.3f; | ||||
| uchar icon_color[4] = {0, 0, 0, 255}; | uchar icon_color[4] = {0, 0, 0, 255}; | ||||
| float bgcolor[4]; | float bgcolor[4]; | ||||
| UI_GetThemeColor4fv(TH_TEXT, bgcolor); | UI_GetThemeColor4fv(TH_ICON_FOLDER, bgcolor); | ||||
| if (rgb_to_grayscale(bgcolor) < 0.5f) { | if (rgb_to_grayscale(bgcolor) < 0.5f) { | ||||
| icon_color[0] = 255; | icon_color[0] = 255; | ||||
| icon_color[1] = 255; | icon_color[1] = 255; | ||||
| icon_color[2] = 255; | icon_color[2] = 255; | ||||
| } | } | ||||
| icon_x = xco + (ex / 2.0f) - (icon_size / 2.0f); | icon_x = xco + (ex / 2.0f) - (icon_size / 2.0f); | ||||
| icon_y = yco + (ey / 2.0f) - (icon_size * ((typeflags & FILE_TYPE_DIR) ? 0.78f : 0.75f)); | icon_y = yco + (ey / 2.0f) - (icon_size * ((typeflags & FILE_TYPE_DIR) ? 0.78f : 0.75f)); | ||||
| UI_icon_draw_ex( | UI_icon_draw_ex( | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||