Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_file/file_draw.c')
-rw-r--r--source/blender/editors/space_file/file_draw.c54
1 files changed, 36 insertions, 18 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 98c7ddeff77..6347ce7c4e8 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -295,22 +295,29 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon,
static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align)
{
- uiStyle *style = UI_style_get();
- uiFontStyle fs = style->widgetlabel;
+ uiStyle *style;
+ uiFontStyle fs;
rcti rect;
char fname[FILE_MAXFILE];
+ if (string[0] == '\0') {
+ return;
+ }
+
+ style = UI_style_get();
+ fs = style->widgetlabel;
+
fs.align = align;
BLI_strncpy(fname, string, FILE_MAXFILE);
- file_shorten_string(fname, width + 1.0f, 0);
+ UI_text_clip_middle_ex(&fs, fname, width, UI_DPI_ICON_SIZE, sizeof(fname), '\0');
/* no text clipping needed, UI_fontstyle_draw does it but is a bit too strict (for buttons it works) */
rect.xmin = sx;
- rect.xmax = (int)(sx + ceil(width + 4.0f));
+ rect.xmax = (int)(sx + ceil(width + 5.0f / UI_DPI_FAC));
rect.ymin = sy - height;
rect.ymax = sy;
-
+
UI_fontstyle_draw(&fs, &rect, fname);
}
@@ -323,35 +330,40 @@ 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;
float dx, dy;
int xco, yco;
+ float ui_imbx, ui_imby;
float scaledx, scaledy;
float scale;
int ex, ey;
+ bool use_dropshadow = !is_icon && (file->flags & FILE_TYPE_IMAGE);
BLI_assert(imb != NULL);
- if ((imb->x * UI_DPI_FAC > layout->prv_w) ||
- (imb->y * UI_DPI_FAC > layout->prv_h))
+ ui_imbx = imb->x * UI_DPI_FAC;
+ ui_imby = imb->y * UI_DPI_FAC;
+ /* Unlike thumbnails, icons are not scaled up. */
+ if (((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) {
scaledx = (float)layout->prv_w;
- scaledy = ( (float)imb->y / (float)imb->x) * layout->prv_w;
+ scaledy = ((float)imb->y / (float)imb->x) * layout->prv_w;
scale = scaledx / imb->x;
}
else {
scaledy = (float)layout->prv_h;
- scaledx = ( (float)imb->x / (float)imb->y) * layout->prv_h;
+ scaledx = ((float)imb->x / (float)imb->y) * layout->prv_h;
scale = scaledy / imb->y;
}
}
else {
- scaledx = (float)imb->x * UI_DPI_FAC;
- scaledy = (float)imb->y * UI_DPI_FAC;
+ scaledx = ui_imbx;
+ scaledy = ui_imby;
scale = UI_DPI_FAC;
}
@@ -367,17 +379,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));
}
@@ -525,9 +543,9 @@ void file_draw_list(const bContext *C, ARegion *ar)
if (!(file->selflag & FILE_SEL_EDITING)) {
- if ((params->active_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) || (file->selflag & FILE_SEL_SELECTED)) {
+ if ((params->highlight_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) || (file->selflag & FILE_SEL_SELECTED)) {
int colorid = (file->selflag & FILE_SEL_SELECTED) ? TH_HILITE : TH_BACK;
- int shade = (params->active_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) ? 20 : 0;
+ int shade = (params->highlight_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) ? 35 : 0;
/* readonly files (".." and ".") must not be drawn as selected - set color back to normal */
if (FILENAME_IS_CURRPAR(file->relname)) {
@@ -549,7 +567,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);