diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2019-09-06 20:02:18 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2019-09-12 04:13:02 +0300 |
commit | f02e64556f3fb9126050bc91f56caebe6a473f72 (patch) | |
tree | 737eef6e02b7e999dc361389b3267529920c2bf7 | |
parent | 57ac8fed676cf50ab6453c272de22c53f436efd5 (diff) |
UI: File Browser Preview Outlines
File Browser image thumbnails get just a contrasting outline and no shadow.
Differential Revision: https://developer.blender.org/D5708
Reviewed by Brecht Van Lommel
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 3e16a8473ad..e11ca06494d 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -223,7 +223,7 @@ static void file_draw_preview(uiBlock *block, float scaledx, scaledy; float scale; int ex, ey; - bool use_dropshadow = !is_icon && + bool show_outline = !is_icon && (typeflags & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_BLENDER)); BLI_assert(imb != NULL); @@ -259,11 +259,6 @@ static void file_draw_preview(uiBlock *block, xco = sx + (int)dx; yco = sy - layout->prv_h + (int)dy; - /* shadow */ - if (use_dropshadow) { - UI_draw_box_shadow(128, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); - } - GPU_blend(true); /* the large image */ @@ -344,23 +339,21 @@ static void file_draw_preview(uiBlock *block, } } - /* border */ - if (use_dropshadow) { + /* Contrasting outline around some preview types. */ + if (show_outline) { GPUVertFormat *format = immVertexFormat(); - uint pos_attr = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uint col_attr = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GPU_PRIM_LINE_LOOP, 4); - immAttr4f(col_attr, 1.0f, 1.0f, 1.0f, 0.15f); - immVertex2f(pos_attr, (float)xco + 1, (float)(yco + ey)); - immAttr4f(col_attr, 1.0f, 1.0f, 1.0f, 0.2f); - immVertex2f(pos_attr, (float)(xco + ex), (float)(yco + ey)); - immAttr4f(col_attr, 0.0f, 0.0f, 0.0f, 0.2f); - immVertex2f(pos_attr, (float)(xco + ex), (float)yco + 1); - immAttr4f(col_attr, 0.0f, 0.0f, 0.0f, 0.3f); - immVertex2f(pos_attr, (float)xco + 1, (float)yco + 1); - immEnd(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + float border_color[4] = {1.0f, 1.0f, 1.0f, 0.4f}; + float bgcolor[4]; + UI_GetThemeColor4fv(TH_BACK, bgcolor); + if (rgb_to_grayscale(bgcolor) > 0.5f) { + border_color[0] = 0.0f; + border_color[1] = 0.0f; + border_color[2] = 0.0f; + } + immUniformColor4fv(border_color); + imm_draw_box_wire_2d(pos, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); immUnbindProgram(); } |