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