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