Bunch of fixes for GLSL display transform
[blender.git] / source / blender / editors / space_file / file_draw.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version. 
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2008 Blender Foundation.
19  * All rights reserved.
20  *
21  * 
22  * Contributor(s): Blender Foundation
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/editors/space_file/file_draw.c
28  *  \ingroup spfile
29  */
30
31
32 #include <math.h>
33 #include <string.h>
34
35 #include "BLI_blenlib.h"
36 #include "BLI_utildefines.h"
37 #include "BLI_dynstr.h"
38 #include "BLI_fileops_types.h"
39
40 #ifdef WIN32
41 #  include "BLI_winstuff.h"
42 #endif
43
44 #include "BIF_gl.h"
45 #include "BIF_glutil.h"
46
47 #include "BKE_context.h"
48 #include "BKE_global.h"
49 #include "BKE_main.h"
50
51 #include "BLF_api.h"
52 #include "BLF_translation.h"
53
54 #include "IMB_imbuf_types.h"
55  
56 #include "MEM_guardedalloc.h"
57
58 #include "DNA_userdef_types.h"
59 #include "DNA_windowmanager_types.h"
60
61 #include "RNA_access.h"
62
63 #include "ED_fileselect.h"
64 #include "ED_screen.h"
65
66 #include "UI_interface.h"
67 #include "UI_interface_icons.h"
68 #include "UI_resources.h"
69 #include "UI_view2d.h"
70
71 #include "WM_types.h"
72
73 #include "fsmenu.h"
74 #include "filelist.h"
75
76 #include "file_intern.h"    // own include
77
78 /* button events */
79 enum {
80         B_FS_DIRNAME,
81         B_FS_FILENAME
82 } /*eFile_ButEvents*/;
83
84
85 static void do_file_buttons(bContext *C, void *UNUSED(arg), int event)
86 {
87         switch (event) {
88                 case B_FS_FILENAME:
89                         file_filename_exec(C, NULL);
90                         break;
91                 case B_FS_DIRNAME:
92                         file_directory_exec(C, NULL);
93                         break;
94         }
95 }
96
97 /* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. 
98  * The controls are laid out as follows:
99  *
100  * -------------------------------------------
101  * | Directory input               | execute |
102  * -------------------------------------------
103  * | Filename input        | + | - | cancel  |
104  * -------------------------------------------
105  *
106  * The input widgets will stretch to fill any excess space.
107  * When there isn't enough space for all controls to be shown, they are
108  * hidden in this order: x/-, execute/cancel, input widgets.
109  */
110 void file_draw_buttons(const bContext *C, ARegion *ar)
111 {
112         /* Button layout. */
113         const int max_x      = ar->winx - 10;
114         const int line1_y    = ar->winy - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN);
115         const int line2_y    = line1_y - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN);
116         const int input_minw = 20;
117         const int btn_h      = UI_UNIT_Y;
118         const int btn_fn_w   = UI_UNIT_X;
119         const int btn_minw   = 80;
120         const int btn_margin = 20;
121         const int separator  = 4;
122
123         /* Additional locals. */
124         char uiblockstr[32];
125         int loadbutton;
126         int fnumbuttons;
127         int min_x       = 10;
128         int chan_offs   = 0;
129         int available_w = max_x - min_x;
130         int line1_w     = available_w;
131         int line2_w     = available_w;
132         
133         uiBut *but;
134         uiBlock *block;
135         SpaceFile *sfile  = CTX_wm_space_file(C);
136         FileSelectParams *params = ED_fileselect_get_params(sfile);
137         ARegion *artmp;
138         
139         /* Initialize UI block. */
140         BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar);
141         block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS);
142         uiBlockSetHandleFunc(block, do_file_buttons, NULL);
143
144         /* exception to make space for collapsed region icon */
145         for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) {
146                 if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) {
147                         chan_offs = 16;
148                         min_x += chan_offs;
149                         available_w -= chan_offs;
150                 }
151         }
152         
153         /* Is there enough space for the execute / cancel buttons? */
154         loadbutton = UI_GetStringWidth(sfile->params->title) + btn_margin;
155         if (loadbutton < btn_minw) {
156                 loadbutton = MAX2(btn_minw, 
157                                   btn_margin + UI_GetStringWidth(params->title));
158         }
159         
160         if (available_w <= loadbutton + separator + input_minw || params->title[0] == 0) {
161                 loadbutton = 0;
162         }
163         else {
164                 line1_w -= (loadbutton + separator);
165                 line2_w  = line1_w;
166         }
167
168         /* Is there enough space for file number increment/decrement buttons? */
169         fnumbuttons = 2 * btn_fn_w;
170         if (!loadbutton || line2_w <= fnumbuttons + separator + input_minw) {
171                 fnumbuttons = 0;
172         }
173         else {
174                 line2_w -= (fnumbuttons + separator);
175         }
176         
177         /* Text input fields for directory and file. */
178         if (available_w > 0) {
179                 int overwrite_alert = file_draw_check_exists(sfile);
180                 /* callbacks for operator check functions */
181                 uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL);
182
183                 but = uiDefButTextO(block, TEX, "FILE_OT_directory", 0, "",
184                                     min_x, line1_y, line1_w - chan_offs, btn_h,
185                                     params->dir, 0.0, (float)FILE_MAX, 0, 0,
186                                     TIP_("File path"));
187                 uiButSetCompleteFunc(but, autocomplete_directory, NULL);
188                 uiButSetFlag(but, UI_BUT_NO_UTF8);
189
190                 if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
191                         but = uiDefBut(block, TEX, B_FS_FILENAME, "",
192                                        min_x, line2_y, line2_w - chan_offs, btn_h,
193                                        params->file, 0.0, (float)FILE_MAXFILE, 0, 0,
194                                        TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name")));
195                         uiButSetCompleteFunc(but, autocomplete_file, NULL);
196                         uiButSetFlag(but, UI_BUT_NO_UTF8);
197                         uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */
198
199                         /* check if this overrides a file and if the operator option is used */
200                         if (overwrite_alert) {
201                                 uiButSetFlag(but, UI_BUT_REDALERT);
202                         }
203                 }
204                 
205                 /* clear func */
206                 uiBlockSetFunc(block, NULL, NULL, NULL);
207         }
208         
209         /* Filename number increment / decrement buttons. */
210         if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) {
211                 uiBlockBeginAlign(block);
212                 but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMOUT,
213                                     min_x + line2_w + separator - chan_offs, line2_y,
214                                     btn_fn_w, btn_h,
215                                     TIP_("Decrement the filename number"));
216                 RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", -1);
217
218                 but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMIN,
219                                     min_x + line2_w + separator + btn_fn_w - chan_offs, line2_y,
220                                     btn_fn_w, btn_h,
221                                     TIP_("Increment the filename number"));
222                 RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", 1);
223                 uiBlockEndAlign(block);
224         }
225         
226         /* Execute / cancel buttons. */
227         if (loadbutton) {
228                 /* params->title is already translated! */
229                 uiDefButO(block, BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, params->title,
230                           max_x - loadbutton, line1_y, loadbutton, btn_h, "");
231                 uiDefButO(block, BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"),
232                           max_x - loadbutton, line2_y, loadbutton, btn_h, "");
233         }
234         
235         uiEndBlock(C, block);
236         uiDrawBlock(C, block);
237 }
238
239
240 static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade)
241 {
242         UI_ThemeColorShade(colorid, shade);
243         uiSetRoundBox(UI_CNR_ALL);
244         uiRoundBox((float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f);
245 }
246
247
248 static int get_file_icon(struct direntry *file)
249 {
250         if (file->type & S_IFDIR) {
251                 if (strcmp(file->relname, "..") == 0) {
252                         return ICON_FILE_PARENT;
253                 }
254                 if (file->flags & BLENDERFILE) {
255                         return ICON_FILE_BLEND;
256                 }
257                 return ICON_FILE_FOLDER;
258         }
259         else if (file->flags & BLENDERFILE)
260                 return ICON_FILE_BLEND;
261         else if (file->flags & BLENDERFILE_BACKUP)
262                 return ICON_FILE_BACKUP;
263         else if (file->flags & IMAGEFILE)
264                 return ICON_FILE_IMAGE;
265         else if (file->flags & MOVIEFILE)
266                 return ICON_FILE_MOVIE;
267         else if (file->flags & PYSCRIPTFILE)
268                 return ICON_FILE_SCRIPT;
269         else if (file->flags & SOUNDFILE)
270                 return ICON_FILE_SOUND;
271         else if (file->flags & FTFONTFILE)
272                 return ICON_FILE_FONT;
273         else if (file->flags & BTXFILE)
274                 return ICON_FILE_BLANK;
275         else if (file->flags & COLLADAFILE)
276                 return ICON_FILE_BLANK;
277         else if (file->flags & TEXTFILE)
278                 return ICON_FILE_TEXT;
279         else
280                 return ICON_FILE_BLANK;
281 }
282
283 static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, int width, int height)
284 {
285         uiBut *but;
286         int x, y;
287         // float alpha = 1.0f;
288         
289         x = sx;
290         y = sy - height;
291         
292         /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/
293
294         but = uiDefIconBut(block, LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, "");
295         uiButSetDragPath(but, path);
296 }
297
298
299 static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align)
300 {
301         uiStyle *style = UI_GetStyle();
302         uiFontStyle fs = style->widgetlabel;
303         rcti rect;
304         char fname[FILE_MAXFILE];
305
306         fs.align = align;
307
308         BLI_strncpy(fname, string, FILE_MAXFILE);
309         file_shorten_string(fname, width + 1.0f, 0);
310
311         /* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */
312         rect.xmin = sx;
313         rect.xmax = (int)(sx + ceil(width + 4.0f));
314         rect.ymin = sy - height;
315         rect.ymax = sy;
316         
317         uiStyleFontDraw(&fs, &rect, fname);
318 }
319
320 void file_calc_previews(const bContext *C, ARegion *ar)
321 {
322         SpaceFile *sfile = CTX_wm_space_file(C);
323         View2D *v2d = &ar->v2d;
324         
325         ED_fileselect_init_layout(sfile, ar);
326         UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height);
327 }
328
329 static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow)
330 {
331         if (imb) {
332                 uiBut *but;
333                 float fx, fy;
334                 float dx, dy;
335                 int xco, yco;
336                 float scaledx, scaledy;
337                 float scale;
338                 int ex, ey;
339                 
340                 if ((imb->x * UI_DPI_FAC > layout->prv_w) ||
341                     (imb->y * UI_DPI_FAC > layout->prv_h))
342                 {
343                         if (imb->x > imb->y) {
344                                 scaledx = (float)layout->prv_w;
345                                 scaledy =  ( (float)imb->y / (float)imb->x) * layout->prv_w;
346                                 scale = scaledx / imb->x;
347                         }
348                         else {
349                                 scaledy = (float)layout->prv_h;
350                                 scaledx =  ( (float)imb->x / (float)imb->y) * layout->prv_h;
351                                 scale = scaledy / imb->y;
352                         }
353                 }
354                 else {
355                         scaledx = (float)imb->x * UI_DPI_FAC;
356                         scaledy = (float)imb->y * UI_DPI_FAC;
357                         scale = UI_DPI_FAC;
358                 }
359
360                 ex = (int)scaledx;
361                 ey = (int)scaledy;
362                 fx = ((float)layout->prv_w - (float)ex) / 2.0f;
363                 fy = ((float)layout->prv_h - (float)ey) / 2.0f;
364                 dx = (fx + 0.5f + layout->prv_border_x);
365                 dy = (fy + 0.5f - layout->prv_border_y);
366                 xco = sx + (int)dx;
367                 yco = sy - layout->prv_h + (int)dy;
368                 
369                 glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);
370                 
371                 /* shadow */
372                 if (dropshadow)
373                         uiDrawBoxShadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
374
375                 glEnable(GL_BLEND);
376                 
377                 /* the image */
378                 glColor4f(1.0, 1.0, 1.0, 1.0);
379                 glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale);
380                 
381                 /* border */
382                 if (dropshadow) {
383                         glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
384                         fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
385                 }
386                 
387                 /* dragregion */
388                 but = uiDefBut(block, LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, "");
389                 uiButSetDragImage(but, file->path, get_file_icon(file), imb, scale);
390                 
391                 glDisable(GL_BLEND);
392                 imb = NULL;
393         }
394 }
395
396 static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
397 {
398         char newname[FILE_MAX + 12];
399         char orgname[FILE_MAX + 12];
400         char filename[FILE_MAX + 12];
401         wmWindowManager *wm = CTX_wm_manager(C);
402         SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
403         ARegion *ar = CTX_wm_region(C);
404
405         BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname);
406         BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename));
407         BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename);
408
409         if (strcmp(orgname, newname) != 0) {
410                 if (!BLI_exists(newname)) {
411                         BLI_rename(orgname, newname);
412                         /* to make sure we show what is on disk */
413                         ED_fileselect_clear(wm, sfile);
414                 }
415
416                 ED_region_tag_redraw(ar);
417         }
418 }
419
420
421 static void draw_background(FileLayout *layout, View2D *v2d)
422 {
423         int i;
424         int sy;
425
426         /* alternating flat shade background */
427         for (i = 0; (i <= layout->rows); i += 2) {
428                 sy = (int)v2d->cur.ymax - i * (layout->tile_h + 2 * layout->tile_border_y) - layout->tile_border_y;
429
430                 UI_ThemeColorShade(TH_BACK, -7);
431                 glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y));
432                 
433         }
434 }
435
436 static void draw_dividers(FileLayout *layout, View2D *v2d)
437 {
438         int sx;
439
440         /* vertical column dividers */
441         sx = (int)v2d->tot.xmin;
442         while (sx < v2d->cur.xmax) {
443                 sx += (layout->tile_w + 2 * layout->tile_border_x);
444                 
445                 UI_ThemeColorShade(TH_BACK, 30);
446                 sdrawline(sx + 1, (short)(v2d->cur.ymax - layout->tile_border_y),  sx + 1,  (short)v2d->cur.ymin);
447                 UI_ThemeColorShade(TH_BACK, -30);
448                 sdrawline(sx, (short)(v2d->cur.ymax - layout->tile_border_y),  sx,  (short)v2d->cur.ymin); 
449         }
450 }
451
452 void file_draw_list(const bContext *C, ARegion *ar)
453 {
454         SpaceFile *sfile = CTX_wm_space_file(C);
455         FileSelectParams *params = ED_fileselect_get_params(sfile);
456         FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
457         View2D *v2d = &ar->v2d;
458         struct FileList *files = sfile->files;
459         struct direntry *file;
460         ImBuf *imb;
461         uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
462         int numfiles;
463         int numfiles_layout;
464         int sx, sy;
465         int offset;
466         int textwidth, textheight;
467         int i;
468         short is_icon;
469         short align;
470         int column_space = 0.6f * UI_UNIT_X;
471
472         numfiles = filelist_numfiles(files);
473         
474         if (params->display != FILE_IMGDISPLAY) {
475
476                 draw_background(layout, v2d);
477         
478                 draw_dividers(layout, v2d);
479         }
480
481         offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax);
482         if (offset < 0) offset = 0;
483
484         numfiles_layout = ED_fileselect_layout_numfiles(layout, ar);
485
486         /* adjust, so the next row is already drawn when scrolling */
487         if (layout->flag & FILE_LAYOUT_HOR) {
488                 numfiles_layout += layout->rows;
489         }
490         else {
491                 numfiles_layout += layout->columns;
492         }
493
494         textwidth = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME];
495         textheight = (int)(layout->textheight * 3.0 / 2.0 + 0.5);
496
497         align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT;
498
499         for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) {
500                 ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
501                 sx += (int)(v2d->tot.xmin + 0.1f * UI_UNIT_X);
502                 sy = (int)(v2d->tot.ymax - sy);
503
504                 file = filelist_file(files, i);
505                 
506                 UI_ThemeColor4(TH_TEXT);
507
508
509                 if (!(file->selflag & EDITING_FILE)) {
510                         if ((params->active_file == i) || (file->selflag & HILITED_FILE) || (file->selflag & SELECTED_FILE)) {
511                                 int colorid = (file->selflag & SELECTED_FILE) ? TH_HILITE : TH_BACK;
512                                 int shade = (params->active_file == i) || (file->selflag & HILITED_FILE) ? 20 : 0;
513                                 draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade);
514                         }
515                 }
516                 uiSetRoundBox(UI_CNR_NONE);
517
518                 if (FILE_IMGDISPLAY == params->display) {
519                         is_icon = 0;
520                         imb = filelist_getimage(files, i);
521                         if (!imb) {
522                                 imb = filelist_geticon(files, i);
523                                 is_icon = 1;
524                         }
525                         
526                         file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE));
527                 }
528                 else {
529                         file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE);
530                         sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X;
531                 }
532
533                 UI_ThemeColor4(TH_TEXT);
534
535                 if (file->selflag & EDITING_FILE) {
536                         uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 0.15f * UI_UNIT_X,
537                                               textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, "");
538                         uiButSetRenameFunc(but, renamebutton_cb, file);
539                         uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */
540                         uiButClearFlag(but, UI_BUT_UNDO);
541                         if (0 == uiButActiveOnly(C, ar, block, but)) {
542                                 file->selflag &= ~EDITING_FILE;
543                         }
544                 }
545
546                 if (!(file->selflag & EDITING_FILE)) {
547                         int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy;
548                         file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align);
549                 }
550
551                 if (params->display == FILE_SHORTDISPLAY) {
552                         sx += (int)layout->column_widths[COLUMN_NAME] + column_space;
553                         if (!(file->type & S_IFDIR)) {
554                                 file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
555                                 sx += (int)layout->column_widths[COLUMN_SIZE] + column_space;
556                         }
557                 }
558                 else if (params->display == FILE_LONGDISPLAY) {
559                         sx += (int)layout->column_widths[COLUMN_NAME] + column_space;
560
561 #ifndef WIN32
562                         /* rwx rwx rwx */
563                         file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align); 
564                         sx += layout->column_widths[COLUMN_MODE1] + column_space;
565
566                         file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align);
567                         sx += layout->column_widths[COLUMN_MODE2] + column_space;
568
569                         file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align);
570                         sx += layout->column_widths[COLUMN_MODE3] + column_space;
571
572                         file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER], layout->tile_h, align);
573                         sx += layout->column_widths[COLUMN_OWNER] + column_space;
574 #endif
575
576                         file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align);
577                         sx += (int)layout->column_widths[COLUMN_DATE] + column_space;
578
579                         file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME], layout->tile_h, align);
580                         sx += (int)layout->column_widths[COLUMN_TIME] + column_space;
581
582                         if (!(file->type & S_IFDIR)) {
583                                 file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
584                                 sx += (int)layout->column_widths[COLUMN_SIZE] + column_space;
585                         }
586                 }
587         }
588
589         uiEndBlock(C, block);
590         uiDrawBlock(C, block);
591
592 }