Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/file_draw.c
| Context not available. | |||||
| const bool drag) | const bool drag) | ||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| float fx, fy; | float fx, fy; | ||||
| float dx, dy; | float dx, dy; | ||||
| int xco, yco; | int xco, yco; | ||||
| float ui_imbx, ui_imby; | float ui_imbx, ui_imby; | ||||
| float scaledx, scaledy; | float scaledx, scaledy; | ||||
| float scale; | float scale; | ||||
| int ex, ey; | int ex, ey; | ||||
| bool use_dropshadow = !is_icon && (typeflags & FILE_TYPE_IMAGE); | bool use_dropshadow = !is_icon && | ||||
| (typeflags & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_BLENDER)); | |||||
| float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | ||||
| BLI_assert(imb != NULL); | BLI_assert(imb != NULL); | ||||
| ui_imbx = imb->x * UI_DPI_FAC; | ui_imbx = imb->x * UI_DPI_FAC; | ||||
| ui_imby = imb->y * UI_DPI_FAC; | ui_imby = imb->y * UI_DPI_FAC; | ||||
| /* Unlike thumbnails, icons are not scaled up. */ | /* Unlike thumbnails, icons are not scaled up. */ | ||||
| if (((ui_imbx > layout->prv_w) || (ui_imby > layout->prv_h)) || | if (((ui_imbx > layout->prv_w) || (ui_imby > layout->prv_h)) || | ||||
| (!is_icon && ((ui_imbx < layout->prv_w) || (ui_imby < layout->prv_h)))) { | (!is_icon && ((ui_imbx < layout->prv_w) || (ui_imby < layout->prv_h)))) { | ||||
| if (imb->x > imb->y) { | if (imb->x > imb->y) { | ||||
| Context not available. | |||||
| scale = UI_DPI_FAC; | scale = UI_DPI_FAC; | ||||
| } | } | ||||
| ex = (int)scaledx; | ex = (int)scaledx; | ||||
| ey = (int)scaledy; | ey = (int)scaledy; | ||||
| fx = ((float)layout->prv_w - (float)ex) / 2.0f; | fx = ((float)layout->prv_w - (float)ex) / 2.0f; | ||||
| fy = ((float)layout->prv_h - (float)ey) / 2.0f; | fy = ((float)layout->prv_h - (float)ey) / 2.0f; | ||||
| dx = (fx + 0.5f + layout->prv_border_x); | dx = (fx + 0.5f + layout->prv_border_x); | ||||
| dy = (fy + 0.5f - layout->prv_border_y); | dy = (fy + 0.5f - layout->prv_border_y); | ||||
| xco = sx + (int)dx; | xco = sx + (int)dx; | ||||
| yco = sy - layout->prv_h + (int)dy; | yco = sy - layout->prv_h; | ||||
| /* shadow */ | /* shadow */ | ||||
| if (use_dropshadow) { | if (use_dropshadow) { | ||||
| UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); | UI_draw_box_shadow(128, (float)(xco), (float)(yco), (float)(xco + ex), (float)(yco + ey)); | ||||
| } | } | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| /* the image */ | /* the image */ | ||||
| if (!is_icon && typeflags & FILE_TYPE_FTFONT) { | if (!is_icon && 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) { | ||||
| Context not available. | |||||
| imb->rect, | imb->rect, | ||||
| scale, | scale, | ||||
| scale, | scale, | ||||
| 1.0f, | 1.0f, | ||||
| 1.0f, | 1.0f, | ||||
| col); | col); | ||||
| GPU_blend_set_func_separate( | GPU_blend_set_func_separate( | ||||
| GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | ||||
| if (icon) { | if (icon && (icon != ICON_FILE_FONT)) { | ||||
| UI_icon_draw_ex((float)xco + (7 * UI_DPI_FAC), | /* size of center icon is scaled to fit container and UI scale */ | ||||
| (float)yco + (7 * UI_DPI_FAC), | float icon_x, icon_y; | ||||
| icon, | if (is_icon) { | ||||
| icon_aspect, | float icon_size = 16.0f / icon_aspect * U.dpi_fac; | ||||
| 1.0f, | icon_x = xco + (ex / 2.0f) - (icon_size / 2.0f); | ||||
| 0.0f, | if (typeflags & FILE_TYPE_DIR) { | ||||
| NULL, | icon_y = yco + (ey / 2.0f) - (icon_size * 1.52f); | ||||
| false); | } | ||||
| else { | |||||
| icon_y = yco + (ey / 2.0f) - (icon_size * 1.0f); | |||||
| } | |||||
| UI_icon_draw_ex( | |||||
| icon_x, icon_y, icon, icon_aspect / U.dpi_fac, icon_aspect, 0.0f, NULL, false); | |||||
| } | |||||
| else { | |||||
| /* Smaller, fainter icon for preview image thumbnail. */ | |||||
| icon_x = xco + (2.0f * UI_DPI_FAC); | |||||
| icon_y = yco + (2.0f * UI_DPI_FAC); | |||||
| uchar dark[4] = {0, 0, 0, 255}; | |||||
| uchar light[4] = {255, 255, 255, 255}; | |||||
| UI_icon_draw_ex(icon_x + 1, icon_y - 1, icon, 1.0f / U.dpi_fac, 0.2f, 0.0f, dark, false); | |||||
| UI_icon_draw_ex(icon_x, icon_y, icon, 1.0f / U.dpi_fac, 0.6f, 0.0f, light, false); | |||||
| } | |||||
| } | } | ||||
| /* border */ | /* border */ | ||||
| if (use_dropshadow) { | if (use_dropshadow) { | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); | ||||
| immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); | immBegin(GPU_PRIM_LINE_LOOP, 4); | ||||
| imm_draw_box_wire_2d(pos, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); | immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.07f); | ||||
| immVertex2f(pos, (float)xco, (float)(yco + ey)); | |||||
| immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.10f); | |||||
| immVertex2f(pos, (float)(xco + ex), (float)(yco + ey)); | |||||
| immAttr4f(col, 0.0f, 0.0f, 0.0f, 0.15f); | |||||
| immVertex2f(pos, (float)(xco + ex), (float)(yco)); | |||||
| immAttr4f(col, 0.0f, 0.0f, 0.0f, 0.2f); | |||||
| immVertex2f(pos, (float)(xco), (float)(yco)); | |||||
| immEnd(); | |||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, NULL); | but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, 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)); | ||||
| /* dragregion */ | /* dragregion */ | ||||
| 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_image(but, BLI_strdup(path), icon, imb, scale, true); | UI_but_drag_set_image(but, BLI_strdup(path), icon, imb, scale, true); | ||||
| Context not available. | |||||
| int offset; | int offset; | ||||
| int textwidth, textheight; | int textwidth, textheight; | ||||
| int i; | int i; | ||||
| bool is_icon; | bool is_icon; | ||||
| eFontStyle_Align align; | eFontStyle_Align align; | ||||
| bool do_drag; | bool do_drag; | ||||
| int column_space = 0.6f * UI_UNIT_X; | int column_space = 0.6f * UI_UNIT_X; | ||||
| unsigned char text_col[4]; | unsigned char text_col[4]; | ||||
| const bool small_size = SMALL_SIZE_CHECK(params->thumbnail_size); | const bool small_size = SMALL_SIZE_CHECK(params->thumbnail_size); | ||||
| const bool update_stat_strings = small_size != SMALL_SIZE_CHECK(layout->curr_size); | const bool update_stat_strings = small_size != SMALL_SIZE_CHECK(layout->curr_size); | ||||
| const float thumb_icon_aspect = sqrtf(64.0f / (float)(params->thumbnail_size)); | const float thumb_icon_aspect = MIN2(64.0f / (float)(params->thumbnail_size), 1.0f); | ||||
| numfiles = filelist_files_ensure(files); | numfiles = filelist_files_ensure(files); | ||||
| if (params->display != FILE_IMGDISPLAY) { | if (params->display != FILE_IMGDISPLAY) { | ||||
| draw_background(layout, v2d); | draw_background(layout, v2d); | ||||
| draw_dividers(layout, v2d); | draw_dividers(layout, v2d); | ||||
| } | } | ||||
| Context not available. | |||||