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 | |||||
| { | { | ||||
| float color[4]; | float color[4]; | ||||
| UI_GetThemeColorShade4fv(colorid, shade, color); | UI_GetThemeColorShade4fv(colorid, shade, color); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_aa( | UI_draw_roundbox_aa( | ||||
| 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, | ||||
| uiBlock *block, const char *path, int sx, int sy, int icon, int width, int height, bool drag) | const char *path, | ||||
| int sx, | |||||
| int sy, | |||||
| int icon, | |||||
| int width, | |||||
| int height, | |||||
| bool drag, | |||||
| bool dimmed) | |||||
JacquesLucke: I find the name `is_hidden` a bit confusing. It can mean that the file is hidden inside of… | |||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| int x, y; | int x, y; | ||||
| x = sx; | x = sx; | ||||
| y = sy - height; | y = sy - height; | ||||
| /* For uiDefIconBut(), if a1==1.0 then a2 is alpha 0.0 - 1.0 */ | |||||
| const float a1 = dimmed ? 1.0f : 0.0f; | |||||
| const float a2 = dimmed ? 0.3f : 0.0f; | |||||
| 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, a1, a2, 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); | ||||
| } | } | ||||
| } | } | ||||
| static void file_draw_string(int sx, | static void file_draw_string(int sx, | ||||
| int sy, | int sy, | ||||
| const char *string, | const char *string, | ||||
Not Done Inline ActionsCan you add a comment that explains what these values mean? Does not seem very obvious to me. JacquesLucke: Can you add a comment that explains what these values mean? Does not seem very obvious to me. | |||||
| float width, | float width, | ||||
| int height, | int height, | ||||
| eFontStyle_Align align, | eFontStyle_Align align, | ||||
| const uchar col[4]) | const uchar col[4]) | ||||
| { | { | ||||
| uiStyle *style; | uiStyle *style; | ||||
| uiFontStyle fs; | uiFontStyle fs; | ||||
| rcti rect; | rcti rect; | ||||
| Show All 39 Lines | |||||
| int sx, | int sx, | ||||
| int sy, | int sy, | ||||
| const float icon_aspect, | const float icon_aspect, | ||||
| ImBuf *imb, | ImBuf *imb, | ||||
| const int icon, | const int icon, | ||||
| FileLayout *layout, | FileLayout *layout, | ||||
| const bool is_icon, | const bool is_icon, | ||||
| const int typeflags, | const int typeflags, | ||||
| const bool drag) | const bool drag, | ||||
| const bool dimmed) | |||||
| { | { | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| else { | else { | ||||
| UI_GetThemeColor4fv(TH_TEXT, col); | UI_GetThemeColor4fv(TH_TEXT, col); | ||||
| } | } | ||||
| } | } | ||||
| else if (typeflags & FILE_TYPE_FTFONT) { | else if (typeflags & FILE_TYPE_FTFONT) { | ||||
| UI_GetThemeColor4fv(TH_TEXT, col); | UI_GetThemeColor4fv(TH_TEXT, col); | ||||
| } | } | ||||
| if (dimmed) { | |||||
| col[3] *= 0.3f; | |||||
| } | |||||
| 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. */ | ||||
| GPU_blend_set_func_separate( | GPU_blend_set_func_separate( | ||||
| GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | ||||
| } | } | ||||
| IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); | IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); | ||||
| immDrawPixelsTexScaled(&state, | immDrawPixelsTexScaled(&state, | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| draw_tile( | draw_tile( | ||||
| sx, sy - 1, width, sfile->layout->tile_h + layout->tile_border_y, colorid, shade); | sx, sy - 1, width, sfile->layout->tile_h + layout->tile_border_y, colorid, shade); | ||||
| } | } | ||||
| } | } | ||||
| UI_draw_roundbox_corner_set(UI_CNR_NONE); | UI_draw_roundbox_corner_set(UI_CNR_NONE); | ||||
| /* don't drag parent or refresh items */ | /* don't drag parent or refresh items */ | ||||
| do_drag = !(FILENAME_IS_CURRPAR(file->relpath)); | do_drag = !(FILENAME_IS_CURRPAR(file->relpath)); | ||||
| bool is_hidden = (file->attributes & FILE_ATTR_HIDDEN); | |||||
Not Done Inline Actionsconst bool ;) mont29: `const bool` ;) | |||||
| if (FILE_IMGDISPLAY == params->display) { | if (FILE_IMGDISPLAY == params->display) { | ||||
| const int icon = filelist_geticon(files, i, false); | const int icon = filelist_geticon(files, i, false); | ||||
| is_icon = 0; | is_icon = 0; | ||||
| imb = filelist_getimage(files, i); | imb = filelist_getimage(files, i); | ||||
| if (!imb) { | if (!imb) { | ||||
| imb = filelist_geticon_image(files, i); | imb = filelist_geticon_image(files, i); | ||||
| is_icon = 1; | is_icon = 1; | ||||
| } | } | ||||
| file_draw_preview(block, | file_draw_preview(block, | ||||
| path, | path, | ||||
| sx, | sx, | ||||
| sy, | sy, | ||||
| thumb_icon_aspect, | thumb_icon_aspect, | ||||
| imb, | imb, | ||||
| icon, | icon, | ||||
| layout, | layout, | ||||
| is_icon, | is_icon, | ||||
| file->typeflag, | file->typeflag, | ||||
| do_drag); | do_drag, | ||||
| is_hidden); | |||||
| } | } | ||||
| else { | else { | ||||
| file_draw_icon(block, | file_draw_icon(block, | ||||
| path, | path, | ||||
| sx, | sx, | ||||
| sy - layout->tile_border_y, | sy - layout->tile_border_y, | ||||
| filelist_geticon(files, i, true), | filelist_geticon(files, i, true), | ||||
| ICON_DEFAULT_WIDTH_SCALE, | ICON_DEFAULT_WIDTH_SCALE, | ||||
| ICON_DEFAULT_HEIGHT_SCALE, | ICON_DEFAULT_HEIGHT_SCALE, | ||||
| do_drag); | do_drag, | ||||
| is_hidden); | |||||
| icon_ofs += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X; | icon_ofs += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X; | ||||
| } | } | ||||
| if (file_selflag & FILE_SEL_EDITING) { | if (file_selflag & FILE_SEL_EDITING) { | ||||
| uiBut *but; | uiBut *but; | ||||
| const short width = (params->display == FILE_IMGDISPLAY) ? | const short width = (params->display == FILE_IMGDISPLAY) ? | ||||
| textwidth : | textwidth : | ||||
| layout->attribute_columns[COLUMN_NAME].width - | layout->attribute_columns[COLUMN_NAME].width - | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||
I find the name is_hidden a bit confusing. It can mean that the file is hidden inside of Blender or "in the OS". Usually it means something is hidden in Blender, so it does not make sense to draw it. However, I couldn't come up with a better name right now, so it's probably fine.