diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-04-08 03:10:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-08 03:38:19 +0300 |
commit | 8c539b0ab521d442d88c70243c04cbb9e40fe412 (patch) | |
tree | 58b1ffb19b1117404698a6705a87406722400b01 /source/blender/editors/space_file/file_draw.c | |
parent | c56c493cf403b63ec46b90023cdc8137275a310f (diff) |
Font preview for file browser
D1002 by @plasmasolutions, with own refactoring.
Note, needed to do a bad-level call here (IMB -> BLF)
Also can't use the BLF API directly because its not thread-safe.
So keep the function isolated (blf_thumbs.c).
Diffstat (limited to 'source/blender/editors/space_file/file_draw.c')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 98c7ddeff77..a6f3a73841e 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -323,7 +323,7 @@ void file_calc_previews(const bContext *C, ARegion *ar) UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); } -static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, bool dropshadow, bool drag) +static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, bool is_icon, bool drag) { uiBut *but; float fx, fy; @@ -332,6 +332,7 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int float scaledx, scaledy; float scale; int ex, ey; + bool use_dropshadow = !is_icon && (file->flags & FILE_TYPE_IMAGE); BLI_assert(imb != NULL); @@ -367,17 +368,23 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* shadow */ - if (dropshadow) + if (use_dropshadow) { UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); + } glEnable(GL_BLEND); /* the image */ - glColor4f(1.0, 1.0, 1.0, 1.0); + if (!is_icon && file->flags & FILE_TYPE_FTFONT) { + UI_ThemeColor(TH_TEXT); + } + else { + glColor4f(1.0, 1.0, 1.0, 1.0); + } glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale); /* border */ - if (dropshadow) { + if (use_dropshadow) { glColor4f(0.0f, 0.0f, 0.0f, 0.4f); fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); } @@ -549,7 +556,7 @@ void file_draw_list(const bContext *C, ARegion *ar) is_icon = 1; } - file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & FILE_TYPE_IMAGE), do_drag); + file_draw_preview(block, file, sx, sy, imb, layout, is_icon, do_drag); } else { file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE, do_drag); |