svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22075:22099
[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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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_colortools.h"
42 #include "BKE_context.h"
43 #include "BKE_screen.h"
44 #include "BKE_global.h"
45 #include "BKE_utildefines.h"
46
47 #include "BLF_api.h"
48
49 #include "DNA_space_types.h"
50 #include "DNA_scene_types.h"
51 #include "DNA_screen_types.h"
52 #include "DNA_userdef_types.h"
53 #include "DNA_windowmanager_types.h"
54
55 #include "ED_datafiles.h"
56
57 #include "IMB_imbuf_types.h"
58 #include "IMB_imbuf.h"
59  
60 #include "MEM_guardedalloc.h"
61
62 #include "PIL_time.h"
63
64 #include "RNA_access.h"
65
66 #include "ED_fileselect.h"
67 #include "ED_screen.h"
68
69 #include "UI_interface.h"
70 #include "UI_interface_icons.h"
71 #include "UI_resources.h"
72 #include "UI_view2d.h"
73
74 #include "WM_api.h"
75 #include "WM_types.h"
76
77 #include "fsmenu.h"
78 #include "filelist.h"
79
80 #include "file_intern.h"        // own include
81
82 /* ui geometry */
83 #define IMASEL_BUTTONS_HEIGHT 40
84 #define IMASEL_BUTTONS_MARGIN 6
85 #define TILE_BORDER_X 8
86 #define TILE_BORDER_Y 8
87
88 /* button events */
89 enum {
90         B_REDR  = 0,
91         B_FS_EXEC,
92         B_FS_CANCEL,
93         B_FS_PARENT,
94         B_FS_DIRNAME,
95         B_FS_FILENAME
96 } eFile_ButEvents;
97
98
99 static void do_file_buttons(bContext *C, void *arg, int event)
100 {
101         switch(event) {
102                 case B_FS_EXEC:
103                         file_exec(C, NULL);     /* file_ops.c */
104                         break;
105                 case B_FS_CANCEL:
106                         file_cancel_exec(C, NULL); /* file_ops.c */
107                         break;
108                 case B_FS_PARENT:
109                         file_parent_exec(C, NULL); /* file_ops.c */
110                         break;
111                 case B_FS_FILENAME:
112                         file_filename_exec(C, NULL);
113                         break;
114                 case B_FS_DIRNAME:
115                         file_directory_exec(C, NULL);
116                         break;
117         }
118 }
119
120 /* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. 
121  * The controls are laid out as follows:
122  *
123  * -------------------------------------------
124  * | Directory input               | execute |
125  * -------------------------------------------
126  * | Filename input        | + | - | cancel  |
127  * -------------------------------------------
128  *
129  * The input widgets will stretch to fill any excess space.
130  * When there isn't enough space for all controls to be shown, they are
131  * hidden in this order: x/-, execute/cancel, input widgets.
132  */
133 void file_draw_buttons(const bContext *C, ARegion *ar)
134 {
135         /* Button layout. */
136         const short min_x      = 10;
137         const short max_x      = ar->winx - 10;
138         const short line1_y    = IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN*2;
139         const short line2_y    = IMASEL_BUTTONS_MARGIN;
140         const short input_minw = 20;
141         const short btn_h      = UI_UNIT_Y;
142         const short btn_fn_w   = UI_UNIT_X;
143         const short btn_minw   = 80;
144         const short btn_margin = 20;
145         const short separator  = 4;
146
147         /* Additional locals. */
148         char  name[20];
149         short loadbutton;
150         short fnumbuttons;
151         short available_w = max_x - min_x;
152         short line1_w     = available_w;
153         short line2_w     = available_w;
154         
155         uiBut*            but;
156         uiBlock*          block;
157         SpaceFile*        sfile  = CTX_wm_space_file(C);
158         FileSelectParams* params = ED_fileselect_get_params(sfile);
159         
160         /* Initialize UI block. */
161         sprintf(name, "win %p", ar);
162         block = uiBeginBlock(C, ar, name, UI_EMBOSS);
163         uiBlockSetHandleFunc(block, do_file_buttons, NULL);
164         
165         /* Is there enough space for the execute / cancel buttons? */
166         loadbutton = UI_GetStringWidth(sfile->params->title) + btn_margin;
167         if (loadbutton < btn_minw) {
168                 loadbutton = MAX2(btn_minw, 
169                                   btn_margin + UI_GetStringWidth(params->title));
170         }
171         
172         if (available_w <= loadbutton + separator + input_minw 
173          || params->title[0] == 0) {
174                 loadbutton = 0;
175         } else {
176                 line1_w -= (loadbutton + separator);
177                 line2_w  = line1_w;
178         }
179
180         /* Is there enough space for file number increment/decrement buttons? */
181         fnumbuttons = 2 * btn_fn_w;
182         if (!loadbutton || line2_w <= fnumbuttons + separator + input_minw) {
183                 fnumbuttons = 0;
184         } else {
185                 line2_w -= (fnumbuttons + separator);
186         }
187         
188         /* Text input fields for directory and file. */
189         if (available_w > 0) {
190                 but = uiDefBut(block, TEX, B_FS_DIRNAME, "",
191                          min_x, line1_y, line1_w, btn_h, 
192                          params->dir, 0.0, (float)FILE_MAXDIR-1, 0, 0, 
193                          "File path.");
194                 uiButSetCompleteFunc(but, autocomplete_directory, NULL);
195                 uiDefBut(block, TEX, B_FS_FILENAME, "",
196                          min_x, line2_y, line2_w, btn_h,
197                          params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, 
198                          "File name.");
199         }
200         
201         /* Filename number increment / decrement buttons. */
202         if (fnumbuttons) {
203                 uiBlockBeginAlign(block);
204                 but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMOUT,
205                         min_x + line2_w + separator, line2_y, 
206                         btn_fn_w, btn_h, 
207                         "Decrement the filename number.");    
208                 RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", -1); 
209         
210                 but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMIN, 
211                         min_x + line2_w + separator + btn_fn_w, line2_y, 
212                         btn_fn_w, btn_h, 
213                         "Increment the filename number.");    
214                 RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", 1); 
215                 uiBlockEndAlign(block);
216         }
217         
218         /* Execute / cancel buttons. */
219         if(loadbutton) {
220                 uiDefBut(block, BUT, B_FS_EXEC, params->title, 
221                   max_x - loadbutton, line1_y, loadbutton, btn_h, 
222                   params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, params->title);
223                 uiDefBut(block, BUT, B_FS_CANCEL, "Cancel", 
224                   max_x - loadbutton, line2_y, loadbutton, btn_h, 
225                   params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "Cancel.");
226         }
227         
228         uiEndBlock(C, block);
229         uiDrawBlock(C, block);
230 }
231
232
233 static void draw_tile(short sx, short sy, short width, short height, int colorid, int shade)
234 {       
235         UI_ThemeColorShade(colorid, shade);
236         uiSetRoundBox(15);      
237         uiRoundBox(sx, sy - height, sx + width, sy, 6);
238 }
239
240 #define FILE_SHORTEN_END                                0
241 #define FILE_SHORTEN_FRONT                              1
242
243 static float shorten_string(char* string, float w, int flag)
244 {       
245         char temp[FILE_MAX];
246         short shortened = 0;
247         float sw = 0;
248         float pad = 0;
249
250         if (w <= 0) {
251                 *string = '\0';
252                 return 0.0;
253         }
254
255         sw = file_string_width(string);
256         if (flag == FILE_SHORTEN_FRONT) {
257                 char *s = string;
258                 BLI_strncpy(temp, "...", 4);
259                 pad = file_string_width(temp);
260                 while ((*s) && (sw+pad>w)) {
261                         s++;
262                         sw = file_string_width(s);
263                         shortened = 1;
264                 }
265                 if (shortened) {
266                         int slen = strlen(s);                   
267                         BLI_strncpy(temp+3, s, slen+1);
268                         temp[slen+4] = '\0';
269                         BLI_strncpy(string, temp, slen+4);
270                 }
271         } else {
272                 char *s = string;
273                 while (sw>w) {
274                         int slen = strlen(string);
275                         string[slen-1] = '\0';
276                         sw = file_string_width(s);
277                         shortened = 1;
278                 }
279
280                 if (shortened) {
281                         int slen = strlen(string);
282                         if (slen > 3) {
283                                 BLI_strncpy(string+slen-3, "...", 4);                           
284                         }
285                 }
286         }
287         
288         return sw;
289 }
290
291 static int get_file_icon(struct direntry *file)
292 {
293         if (file->type & S_IFDIR)
294                 return ICON_FILE_FOLDER;
295         else if (file->flags & BLENDERFILE)
296                 return ICON_FILE_BLEND;
297         else if (file->flags & IMAGEFILE)
298                 return ICON_FILE_IMAGE;
299         else if (file->flags & MOVIEFILE)
300                 return ICON_FILE_MOVIE;
301         else if (file->flags & PYSCRIPTFILE)
302                 return ICON_FILE_SCRIPT;
303         else if (file->flags & PYSCRIPTFILE)
304                 return ICON_FILE_SCRIPT;
305         else if (file->flags & SOUNDFILE) 
306                 return ICON_FILE_SOUND;
307         else if (file->flags & FTFONTFILE) 
308                 return ICON_FILE_FONT;
309         else
310                 return ICON_FILE_BLANK;
311 }
312
313 static void file_draw_icon(short sx, short sy, int icon, short width, short height)
314 {
315         float x,y;
316         int blend=0;
317         
318         x = (float)(sx);
319         y = (float)(sy-height);
320         
321         if (icon == ICON_FILE_BLANK) blend = -80;
322         
323         glEnable(GL_BLEND);
324         
325         UI_icon_draw_aspect_blended(x, y, icon, 1.f, blend);
326 }
327
328
329 static void file_draw_string(short sx, short sy, const char* string, float width, short height, int flag)
330 {
331         short soffs;
332         char fname[FILE_MAXFILE];
333         float sw;
334         float x,y;
335
336         BLI_strncpy(fname,string, FILE_MAXFILE);
337         sw = shorten_string(fname, width, flag );
338
339         soffs = (width - sw) / 2;
340         x = (float)(sx);
341         y = (float)(sy-height);
342
343         BLF_position(x, y, 0);
344         BLF_draw(fname);
345 }
346
347 void file_calc_previews(const bContext *C, ARegion *ar)
348 {
349         SpaceFile *sfile= CTX_wm_space_file(C);
350         View2D *v2d= &ar->v2d;
351         
352         ED_fileselect_init_layout(sfile, ar);
353         UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height);
354 }
355
356 void file_draw_previews(const bContext *C, ARegion *ar)
357 {
358         SpaceFile *sfile= CTX_wm_space_file(C);
359         FileSelectParams* params= ED_fileselect_get_params(sfile);
360         FileLayout* layout= ED_fileselect_get_layout(sfile, ar);
361         View2D *v2d= &ar->v2d;
362         struct FileList* files = sfile->files;
363         int numfiles;
364         struct direntry *file;
365         short sx, sy;
366         ImBuf* imb=0;
367         int i;
368         int colorid = 0;
369         int offset;
370         int is_icon;
371
372         if (!files) return;
373
374         filelist_imgsize(files,sfile->layout->prv_w,sfile->layout->prv_h);
375         numfiles = filelist_numfiles(files);
376
377         sx = v2d->cur.xmin + layout->tile_border_x;
378         sy = v2d->cur.ymax - layout->tile_border_y;
379         
380         offset = ED_fileselect_layout_offset(layout, 0, 0);
381         if (offset<0) offset=0;
382         for (i=offset; (i < numfiles) && (i < (offset+(layout->rows+2)*layout->columns)); ++i)
383         {
384                 ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
385                 sx += v2d->tot.xmin+2;
386                 sy = v2d->tot.ymax - sy;
387                 file = filelist_file(files, i); 
388
389                 if (file->flags & ACTIVE) {
390                         colorid = TH_HILITE;
391                         draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0);
392                 } else if (params->active_file == i) {
393                         colorid = TH_ACTIVE;
394                         draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0);
395                 }
396                 
397                 if ( (file->flags & IMAGEFILE) /* || (file->flags & MOVIEFILE) */)
398                 {                       
399                         filelist_loadimage(files, i);
400                 }
401                 is_icon = 0;
402                 imb = filelist_getimage(files, i);
403                 if (!imb) {
404                         imb = filelist_geticon(files,i);
405                         is_icon = 1;
406                 }
407
408                 if (imb) {
409                         float fx, fy;
410                         float dx, dy;
411                         short xco, yco;
412                         float scaledx, scaledy;
413                         float scale;
414                         short ex, ey;
415
416                         if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) {
417                                 if (imb->x > imb->y) {
418                                         scaledx = (float)layout->prv_w;
419                                         scaledy =  ( (float)imb->y/(float)imb->x )*layout->prv_w;
420                                         scale = scaledx/imb->x;
421                                 }
422                                 else {
423                                         scaledy = (float)layout->prv_h;
424                                         scaledx =  ( (float)imb->x/(float)imb->y )*layout->prv_h;
425                                         scale = scaledy/imb->y;
426                                 }
427                         } else {
428                                 scaledx = (float)imb->x;
429                                 scaledy = (float)imb->y;
430                                 scale = 1.0;
431                         }
432                         ex = (short)scaledx;
433                         ey = (short)scaledy;
434                         fx = ((float)layout->prv_w - (float)ex)/2.0f;
435                         fy = ((float)layout->prv_h - (float)ey)/2.0f;
436                         dx = (fx + 0.5f + sfile->layout->prv_border_x);
437                         dy = (fy + 0.5f - sfile->layout->prv_border_y);
438                         xco = (float)sx + dx;
439                         yco = (float)sy - sfile->layout->prv_h + dy;
440
441                         glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);
442                         
443                         /* shadow */
444                         if (!is_icon && (file->flags & IMAGEFILE))
445                                 uiDrawBoxShadow(220, xco, yco, xco + ex, yco + ey);
446                         
447                         glEnable(GL_BLEND);
448                         
449                         /* the image */
450                         glColor4f(1.0, 1.0, 1.0, 1.0);
451                         glaDrawPixelsTexScaled(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale);
452                         
453                         /* border */
454                         if (!is_icon && (file->flags & IMAGEFILE)) {
455                                 glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
456                                 fdrawbox(xco, yco, xco + ex, yco + ey);
457                         }
458                         
459                         glDisable(GL_BLEND);
460                         imb = 0;
461                 }
462
463                 /* shadow */
464                 UI_ThemeColorShade(TH_BACK, -20);
465                 
466                 
467                 if (S_ISDIR(file->type)) {
468                         glColor4f(1.0f, 1.0f, 0.9f, 1.0f);
469                 }
470                 else if (file->flags & IMAGEFILE) {
471                         UI_ThemeColor(TH_SEQ_IMAGE);
472                 }
473                 else if (file->flags & MOVIEFILE) {
474                         UI_ThemeColor(TH_SEQ_MOVIE);
475                 }
476                 else if (file->flags & BLENDERFILE) {
477                         UI_ThemeColor(TH_SEQ_SCENE);
478                 }
479                 else {
480                         if (params->active_file == i) {
481                                 UI_ThemeColor(TH_GRID); /* grid used for active text */
482                         } else if (file->flags & ACTIVE) {
483                                 UI_ThemeColor(TH_TEXT_HI);                      
484                         } else {
485                                 UI_ThemeColor(TH_TEXT);
486                         }
487                 }
488
489                 file_draw_string(sx + layout->prv_border_x, sy+4, file->relname, layout->tile_w, layout->tile_h, FILE_SHORTEN_END);
490
491                 if (!sfile->loadimage_timer)
492                         sfile->loadimage_timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER1, 1.0/30.0);  /* max 30 frames/sec. */
493
494         }
495
496         uiSetRoundBox(0);
497 }
498
499 static void renamebutton_cb(bContext *C, void *arg1, char *oldname)
500 {
501         char newname[FILE_MAX+12];
502         char orgname[FILE_MAX+12];
503         char filename[FILE_MAX+12];
504         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
505         ARegion* ar = CTX_wm_region(C);
506
507         struct direntry *file = (struct direntry *)arg1;
508
509         BLI_make_file_string(G.sce, orgname, sfile->params->dir, oldname);
510         BLI_strncpy(filename, file->relname, sizeof(filename));
511         BLI_make_file_string(G.sce, newname, sfile->params->dir, filename);
512
513         if( strcmp(orgname, newname) != 0 ) {
514                 if (!BLI_exists(newname)) {
515                         BLI_rename(orgname, newname);
516                         /* to make sure we show what is on disk */
517                         filelist_free(sfile->files);
518                 } else {
519                         BLI_strncpy(file->relname, oldname, strlen(oldname)+1);
520                 }
521                 
522                 ED_region_tag_redraw(ar);
523         }
524 }
525
526 void file_draw_list(const bContext *C, ARegion *ar)
527 {
528         SpaceFile *sfile= CTX_wm_space_file(C);
529         FileSelectParams* params = ED_fileselect_get_params(sfile);
530         FileLayout* layout= ED_fileselect_get_layout(sfile, ar);
531         View2D *v2d= &ar->v2d;
532         struct FileList* files = sfile->files;
533         struct direntry *file;
534         int numfiles;
535         int numfiles_layout;
536         int colorid = 0;
537         short sx, sy;
538         int offset;
539         int i;
540         float sw, spos;
541
542         numfiles = filelist_numfiles(files);
543         
544         sx = ar->v2d.tot.xmin + layout->tile_border_x/2;
545         sy = ar->v2d.cur.ymax - layout->tile_border_y;
546
547         offset = ED_fileselect_layout_offset(layout, 0, 0);
548         if (offset<0) offset=0;
549
550         /* alternating flat shade background */
551         for (i=0; (i <= layout->rows); i+=2)
552         {
553                 sx = v2d->cur.xmin;
554                 sy = v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y;
555
556                 UI_ThemeColorShade(TH_BACK, -7);
557                 glRectf(v2d->cur.xmin, sy, v2d->cur.xmax, sy+layout->tile_h+2*layout->tile_border_y);
558                 
559         }
560         
561         /* vertical column dividers */
562         sx = v2d->tot.xmin;
563         while (sx < ar->v2d.cur.xmax) {
564                 sx += (sfile->layout->tile_w+2*sfile->layout->tile_border_x);
565                 
566                 UI_ThemeColorShade(TH_BACK, 30);
567                 sdrawline(sx+1,  ar->v2d.cur.ymax - layout->tile_border_y ,  sx+1,  ar->v2d.cur.ymin); 
568                 UI_ThemeColorShade(TH_BACK, -30);
569                 sdrawline(sx,  ar->v2d.cur.ymax - layout->tile_border_y ,  sx,  ar->v2d.cur.ymin); 
570         }
571
572         sx = ar->v2d.cur.xmin + layout->tile_border_x;
573         sy = ar->v2d.cur.ymax - layout->tile_border_y;
574         
575         numfiles_layout = ED_fileselect_layout_numfiles(layout, ar);
576
577         for (i=offset; (i < numfiles) && (i<offset+numfiles_layout); ++i)
578         {
579                 ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
580                 sx += v2d->tot.xmin+2;
581                 sy = v2d->tot.ymax - sy;
582
583                 file = filelist_file(files, i); 
584                 
585                 if (!(file->flags & EDITING)) {
586                         if (params->active_file == i) {
587                                 if (file->flags & ACTIVE) colorid= TH_HILITE;
588                                 else colorid = TH_BACK;
589                                 draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,20);
590                         } else if (file->flags & ACTIVE) {
591                                 colorid = TH_HILITE;
592                                 draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,0);
593                         } 
594                 }
595
596                 spos = sx;
597                 file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH);
598                 spos += ICON_DEFAULT_WIDTH + 4;
599                 
600                 UI_ThemeColor4(TH_TEXT);
601                 
602                 sw = file_string_width(file->relname);
603                 if (file->flags & EDITING) {
604                         uiBlock *block = uiBeginBlock(C, ar, "FileName", UI_EMBOSS);
605                         uiBut *but = uiDefBut(block, TEX, 1, "", spos, sy-layout->tile_h-3, 
606                                 layout->column_widths[COLUMN_NAME], layout->tile_h, file->relname, 1.0f, (float)FILE_MAX,0,0,"");
607                         uiButSetRenameFunc(but, renamebutton_cb, file);
608                         if ( 0 == uiButActiveOnly(C, block, but)) {
609                                 file->flags &= ~EDITING;
610                         }
611                         uiEndBlock(C, block);
612                         uiDrawBlock(C, block);
613                 } else {
614                         file_draw_string(spos, sy, file->relname, sw, layout->tile_h, FILE_SHORTEN_END);
615                 }
616                 spos += layout->column_widths[COLUMN_NAME] + 12;
617                 if (params->display == FILE_SHOWSHORT) {
618                         if (!(file->type & S_IFDIR)) {
619                                 sw = file_string_width(file->size);
620                                 spos += layout->column_widths[COLUMN_SIZE] + 12 - sw;
621                                 file_draw_string(spos, sy, file->size, sw+1, layout->tile_h, FILE_SHORTEN_END); 
622                         }
623                 } else {
624 #if 0 // XXX TODO: add this for non-windows systems
625                         /* rwx rwx rwx */
626                         spos += 20;
627                         sw = UI_GetStringWidth(file->mode1);
628                         file_draw_string(spos, sy, file->mode1, sw, layout->tile_h); 
629                         
630                         spos += 30;
631                         sw = UI_GetStringWidth(file->mode2);
632                         file_draw_string(spos, sy, file->mode2, sw, layout->tile_h);
633
634                         spos += 30;
635                         sw = UI_GetStringWidth(file->mode3);
636                         file_draw_string(spos, sy, file->mode3, sw, layout->tile_h);
637                         
638                         spos += 30;
639                         sw = UI_GetStringWidth(file->owner);
640                         file_draw_string(spos, sy, file->owner, sw, layout->tile_h);
641 #endif
642
643                         
644                         sw = file_string_width(file->date);
645                         file_draw_string(spos, sy, file->date, sw, layout->tile_h, FILE_SHORTEN_END);
646                         spos += layout->column_widths[COLUMN_DATE] + 12;
647
648                         sw = file_string_width(file->time);
649                         file_draw_string(spos, sy, file->time, sw, layout->tile_h, FILE_SHORTEN_END); 
650                         spos += layout->column_widths[COLUMN_TIME] + 12;
651
652                         if (!(file->type & S_IFDIR)) {
653                                 sw = file_string_width(file->size);
654                                 spos += layout->column_widths[COLUMN_SIZE] + 12 - sw;
655                                 file_draw_string(spos, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END);
656                         }
657                 }
658         }
659 }
660
661