2.5 filebrowser
[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 #include "BMF_Api.h"
41
42 #include "BKE_colortools.h"
43 #include "BKE_context.h"
44 #include "BKE_screen.h"
45 #include "BKE_global.h"
46 #include "BKE_utildefines.h"
47
48 #include "DNA_space_types.h"
49 #include "DNA_scene_types.h"
50 #include "DNA_screen_types.h"
51 #include "DNA_userdef_types.h"
52 #include "DNA_windowmanager_types.h"
53
54 #include "IMB_imbuf_types.h"
55 #include "IMB_imbuf.h"
56  
57 #include "MEM_guardedalloc.h"
58
59 #include "PIL_time.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_text.h"
70 #include "UI_view2d.h"
71
72 #include "WM_api.h"
73 #include "WM_types.h"
74
75 #include "fsmenu.h"
76 #include "filelist.h"
77
78 #include "file_intern.h"        // own include
79
80 /* ui geometry */
81 #define IMASEL_BUTTONS_HEIGHT 40
82 #define TILE_BORDER_X 8
83 #define TILE_BORDER_Y 8
84
85 /* button events */
86 enum {
87         B_REDR  = 0,
88         B_FS_EXEC,
89         B_FS_CANCEL,
90         B_FS_PARENT,
91 } eFile_ButEvents;
92
93 /* XXX very bad, need to check font code */
94 static int gFontsize=12;
95
96 static void do_file_buttons(bContext *C, void *arg, int event)
97 {
98         switch(event) {
99                 case B_FS_EXEC:
100                         file_exec(C, NULL);     /* file_ops.c */
101                         break;
102                 case B_FS_CANCEL:
103                         file_cancel_exec(C, NULL); /* file_ops.c */
104                         break;
105                 case B_FS_PARENT:
106                         file_parent_exec(C, NULL); /* file_ops.c */
107                         break;
108         }
109 }
110
111 /* note; this function uses pixelspace (0, 0, winx, winy), not view2d */
112 void file_draw_buttons(const bContext *C, ARegion *ar)
113 {
114         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
115         FileSelectParams* params = ED_fileselect_get_params(sfile);
116         uiBlock *block;
117         int loadbutton;
118         char name[20];
119         float slen;
120         int filebuty1, filebuty2;
121
122         float xmin = 8;
123         float xmax = ar->winx - 10;
124
125         filebuty1= ar->winy - IMASEL_BUTTONS_HEIGHT - 12;
126         filebuty2= filebuty1 + IMASEL_BUTTONS_HEIGHT/2 + 4;
127
128         /* HEADER */
129         sprintf(name, "win %p", ar);
130         block = uiBeginBlock(C, ar, name, UI_EMBOSS, UI_HELV);
131         uiBlockSetHandleFunc(block, do_file_buttons, NULL);
132
133         /* XXXX
134         uiSetButLock( filelist_gettype(simasel->files)==FILE_MAIN && simasel->returnfunc, NULL); 
135         */
136
137         /* space available for load/save buttons? */
138         slen = UI_GetStringWidth(G.font, sfile->params->title, 0);
139         loadbutton= slen > 60 ? slen + 20 : MAX2(80, 20+UI_GetStringWidth(G.font, params->title, 0));
140         if(ar->winx > loadbutton+20) {
141                 if(params->title[0]==0) {
142                         loadbutton= 0;
143                 }
144         }
145         else {
146                 loadbutton= 0;
147         }
148
149         uiDefBut(block, TEX, 0 /* XXX B_FS_FILENAME */,"",      xmin+2, filebuty1, xmax-xmin-loadbutton-4, 21, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
150         uiDefBut(block, TEX, 0 /* XXX B_FS_DIRNAME */,"",       xmin+2, filebuty2, xmax-xmin-loadbutton-4, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
151         
152         if(loadbutton) {
153                 uiSetCurFont(block, UI_HELV);
154                 uiDefBut(block, BUT, B_FS_EXEC, params->title,  xmax-loadbutton, filebuty2, loadbutton, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
155                 uiDefBut(block, BUT, B_FS_CANCEL, "Cancel",             xmax-loadbutton, filebuty1, loadbutton, 21, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
156         }
157
158 #if 0
159         /* menu[0] = NULL happens when no .Bfs is there, and first time browse
160            disallow external directory browsing for databrowse */
161
162         if(menu[0] && (params->type != FILE_MAIN))      { 
163                 uiDefButS(block, MENU, 0 /* B_FS_DIR_MENU */, menu, xmin, filebuty2, fsmenubut_width, 21, &params->menu, 0, 0, 0, 0, "");
164                 uiDefBut(block, BUT, 0 /* B_FS_BOOKMARK */, "B", xmin, filebuty1, bookmarkbut_width, 21, 0, 0, 0, 0, 0, "Bookmark current directory");
165         }
166
167         MEM_freeN(menu);
168 #endif
169
170
171         uiEndBlock(C, block);
172         uiDrawBlock(C, block);
173 }
174
175
176 static void draw_tile(short sx, short sy, short width, short height, int colorid, int shade)
177 {
178         /* TODO: BIF_ThemeColor seems to need this to show the color, not sure why? - elubie */
179         //glEnable(GL_BLEND);
180         //glColor4ub(0, 0, 0, 100);
181         //glDisable(GL_BLEND);
182         /* I think it was a missing glDisable() - ton */
183         
184         UI_ThemeColorShade(colorid, shade);
185         uiSetRoundBox(15);      
186         // glRecti(sx, sy - height, sx + width, sy);
187
188         uiRoundBox(sx, sy - height, sx + width, sy, 6);
189 }
190
191 #define FILE_SHORTEN_END                                0
192 #define FILE_SHORTEN_FRONT                              1
193
194 static float shorten_string(char* string, float w, int flag)
195 {       
196         char temp[FILE_MAX];
197         short shortened = 0;
198         float sw = 0;
199         float pad = 0;
200
201         sw = UI_GetStringWidth(G.font, string,0);
202         if (flag == FILE_SHORTEN_FRONT) {
203                 char *s = string;
204                 BLI_strncpy(temp, "...", 4);
205                 pad = UI_GetStringWidth(G.font, temp,0);
206                 while (s && (sw+pad>w)) {
207                         s++;
208                         sw = UI_GetStringWidth(G.font, s,0);
209                         shortened = 1;
210                 }
211                 if (shortened) {
212                         int slen = strlen(s);                   
213                         BLI_strncpy(temp+3, s, slen+1);
214                         temp[slen+4] = '\0';
215                         BLI_strncpy(string, temp, slen+4);
216                 }
217         } else {
218                 char *s = string;
219                 while (sw>w) {
220                         int slen = strlen(string);
221                         string[slen-1] = '\0';
222                         sw = UI_GetStringWidth(G.font, s,0);
223                         shortened = 1;
224                 }
225                 if (shortened) {
226                         int slen = strlen(string);
227                         if (slen > 3) {
228                                 BLI_strncpy(string+slen-3, "...", 4);                           
229                         }
230                 }
231         }
232         
233         return sw;
234 }
235
236 static int get_file_icon(struct direntry *file)
237 {
238         if (file->type & S_IFDIR)
239                 return ICON_FILE_FOLDER;
240         else if (file->flags & BLENDERFILE)
241                 return ICON_FILE_BLEND;
242         else if (file->flags & IMAGEFILE)
243                 return ICON_FILE_IMAGE;
244         else if (file->flags & MOVIEFILE)
245                 return ICON_FILE_MOVIE;
246         else if (file->flags & PYSCRIPTFILE)
247                 return ICON_FILE_SCRIPT;
248         else if (file->flags & PYSCRIPTFILE)
249                 return ICON_FILE_SCRIPT;
250         else if (file->flags & SOUNDFILE) 
251                 return ICON_FILE_SOUND;
252         else if (file->flags & FTFONTFILE) 
253                 return ICON_FILE_FONT;
254         else
255                 return ICON_FILE_BLANK;
256 }
257
258 static void file_draw_icon(short sx, short sy, int icon, short width, short height)
259 {
260         float x,y;
261         int blend=0;
262         
263         x = (float)(sx);
264         y = (float)(sy-height);
265         
266         if (icon == ICON_FILE_BLANK) blend = -80;
267         
268         glEnable(GL_BLEND);
269         
270         UI_icon_draw_aspect_blended(x, y, icon, 1.f, blend);
271 }
272
273 static void file_draw_string(short sx, short sy, const char* string, short width, short height, int flag)
274 {
275         short soffs;
276         char fname[FILE_MAXFILE];
277         float sw;
278         float x,y;
279
280         BLI_strncpy(fname,string, FILE_MAXFILE);
281         sw = shorten_string(fname, width, flag );
282
283         soffs = (width - sw) / 2;
284         x = (float)(sx);
285         y = (float)(sy-height);
286
287         // XXX was using ui_rasterpos_safe
288         glRasterPos2f(x, y);
289         UI_RasterPos(x, y);
290
291         /* XXX TODO: handling of international fonts.
292             TODO: proper support for utf8 in languages different from ja_JP abd zh_CH
293             needs update of iconv in lib/windows to support getting the system language string
294         */
295         UI_DrawString(G.font, fname, 0);
296
297 }
298
299 void file_calc_previews(const bContext *C, ARegion *ar)
300 {
301         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
302         View2D *v2d= &ar->v2d;
303         
304         ED_fileselect_init_layout(sfile, ar);
305         UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height);
306 }
307
308 void file_draw_previews(const bContext *C, ARegion *ar)
309 {
310         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
311         FileSelectParams* params= ED_fileselect_get_params(sfile);
312         FileLayout* layout= ED_fileselect_get_layout(sfile, ar);
313         View2D *v2d= &ar->v2d;
314         struct FileList* files = sfile->files;
315         int numfiles;
316         struct direntry *file;
317         short sx, sy;
318         ImBuf* imb=0;
319         int i;
320         int colorid = 0;
321         int offset;
322         int is_icon;
323
324         if (!files) return;
325
326         filelist_imgsize(files,sfile->layout->prv_w,sfile->layout->prv_h);
327         numfiles = filelist_numfiles(files);
328
329         sx = v2d->cur.xmin + layout->tile_border_x;
330         sy = v2d->cur.ymax - layout->tile_border_y;
331         
332         offset = ED_fileselect_layout_offset(layout, 0, 0);
333         if (offset<0) offset=0;
334         for (i=offset; (i < numfiles) && (i < (offset+(layout->rows+2)*layout->columns)); ++i)
335         {
336                 ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
337                 sx += v2d->tot.xmin+2;
338                 sy = v2d->tot.ymax - sy;
339                 file = filelist_file(files, i);                         
340
341                 if (file->flags & ACTIVE) {
342                         colorid = TH_HILITE;
343                         draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0);
344                 } else if (params->active_file == i) {
345                         colorid = TH_ACTIVE;
346                         draw_tile(sx - 1, sy, sfile->layout->tile_w + 1, sfile->layout->tile_h, colorid,0);
347                 }
348                 
349                 if ( (file->flags & IMAGEFILE) /* || (file->flags & MOVIEFILE) */)
350                 {                       
351                         filelist_loadimage(files, i);
352                 }
353                 is_icon = 0;
354                 imb = filelist_getimage(files, i);
355                 if (!imb) {
356                         imb = filelist_geticon(files,i);
357                         is_icon = 1;
358                 }
359
360                 if (imb) {
361                         float fx = ((float)layout->prv_w - (float)imb->x)/2.0f;
362                         float fy = ((float)layout->prv_h - (float)imb->y)/2.0f;
363                         float dx = (fx + 0.5f + sfile->layout->prv_border_x);
364                         float dy = (fy + 0.5f - sfile->layout->prv_border_y);
365                         short xco = (float)sx + dx;
366                         short yco = (float)sy - sfile->layout->prv_h + dy;
367                         
368                         glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);
369                         
370                         /* shadow */
371                         if (!is_icon && (file->flags & IMAGEFILE))
372                                 uiDrawBoxShadow(220, xco, yco, xco + imb->x, yco + imb->y);
373                         
374                         glEnable(GL_BLEND);
375                         
376                         /* the image */
377                         glColor4f(1.0, 1.0, 1.0, 1.0);
378                         glaDrawPixelsTex(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect);
379                         
380                         /* border */
381                         if (!is_icon && (file->flags & IMAGEFILE)) {
382                                 glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
383                                 fdrawbox(xco, yco, xco + imb->x, yco + imb->y);
384                         }
385                         
386                         glDisable(GL_BLEND);
387                         imb = 0;
388                 }
389
390                 /* shadow */
391                 UI_ThemeColorShade(TH_BACK, -20);
392                 
393                 
394                 if (S_ISDIR(file->type)) {
395                         glColor4f(1.0f, 1.0f, 0.9f, 1.0f);
396                 }
397                 else if (file->flags & IMAGEFILE) {
398                         UI_ThemeColor(TH_SEQ_IMAGE);
399                 }
400                 else if (file->flags & MOVIEFILE) {
401                         UI_ThemeColor(TH_SEQ_MOVIE);
402                 }
403                 else if (file->flags & BLENDERFILE) {
404                         UI_ThemeColor(TH_SEQ_SCENE);
405                 }
406                 else {
407                         if (params->active_file == i) {
408                                 UI_ThemeColor(TH_GRID); /* grid used for active text */
409                         } else if (file->flags & ACTIVE) {
410                                 UI_ThemeColor(TH_TEXT_HI);                      
411                         } else {
412                                 UI_ThemeColor(TH_TEXT);
413                         }
414                 }
415
416                 file_draw_string(sx + layout->prv_border_x, sy+4, file->relname, layout->tile_w, layout->tile_h, FILE_SHORTEN_END);
417
418                 if (!sfile->loadimage_timer)
419                         sfile->loadimage_timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER1, 1.0/30.0);  /* max 30 frames/sec. */
420
421         }
422
423         uiSetRoundBox(0);
424 }
425
426
427 void file_draw_list(const bContext *C, ARegion *ar)
428 {
429         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
430         FileSelectParams* params = ED_fileselect_get_params(sfile);
431         FileLayout* layout= ED_fileselect_get_layout(sfile, ar);
432         View2D *v2d= &ar->v2d;
433         struct FileList* files = sfile->files;
434         struct direntry *file;
435         int numfiles;
436         int colorid = 0;
437         short sx, sy;
438         int offset;
439         short type;
440         int i;
441         float sw, spos;
442
443         numfiles = filelist_numfiles(files);
444         type = filelist_gettype(files); 
445
446         sx = ar->v2d.tot.xmin + layout->tile_border_x/2;
447         sy = ar->v2d.cur.ymax - layout->tile_border_y;
448
449         offset = ED_fileselect_layout_offset(layout, 0, 0);
450         if (offset<0) offset=0;
451
452         /* alternating flat shade background */
453         for (i=offset; (i <= numfiles); ++i)
454         {
455                 ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
456                 sx = v2d->tot.xmin;
457                 sy = v2d->tot.ymax - (sy + layout->tile_border_y);
458                 //sy = v2d->tot.ymax - sy;
459                 
460                 if (i % 2) UI_ThemeColor(TH_BACK);
461                 else UI_ThemeColorShade(TH_BACK, -7);
462                 glRectf(v2d->tot.xmin, sy, v2d->tot.xmax, sy+layout->tile_h+2*layout->tile_border_y);
463         }
464         
465         /* vertical column dividers */
466         while (sx < ar->v2d.cur.xmax) {
467                 sx += (sfile->layout->tile_w+2*sfile->layout->tile_border_x);
468                 
469                 UI_ThemeColorShade(TH_BACK, 30);
470                 sdrawline(sx+1,  ar->v2d.cur.ymax - layout->tile_border_y ,  sx+1,  ar->v2d.cur.ymin); 
471                 UI_ThemeColorShade(TH_BACK, -30);
472                 sdrawline(sx,  ar->v2d.cur.ymax - layout->tile_border_y ,  sx,  ar->v2d.cur.ymin); 
473         }
474
475         sx = ar->v2d.cur.xmin + layout->tile_border_x;
476         sy = ar->v2d.cur.ymax - layout->tile_border_y;
477
478         for (i=offset; (i < numfiles); ++i)
479         {
480                 ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
481                 sx += v2d->tot.xmin+2;
482                 sy = v2d->tot.ymax - sy;
483
484                 file = filelist_file(files, i); 
485
486                 if (params->active_file == i) {
487                         if (file->flags & ACTIVE) colorid= TH_HILITE;
488                         else colorid = TH_BACK;
489                         draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,20);
490                 } else if (file->flags & ACTIVE) {
491                         colorid = TH_HILITE;
492                         draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,0);
493                 } else {
494                         /*
495                         colorid = TH_PANEL;
496                         draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
497                         */
498                 }
499
500                 spos = sx;
501                 file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH);
502                 spos += ICON_DEFAULT_WIDTH + 4;
503                 
504                 UI_ThemeColor4(TH_TEXT);
505                 
506                 // sw = shorten_filesize(file->size, FILE_SHORTEN_FSIZE_WIDTHONLY);
507                 sw = UI_GetStringWidth(G.font, file->size, 0);
508                 file_draw_string(spos, sy, file->relname, layout->tile_w - sw - 5, layout->tile_h, FILE_SHORTEN_END);
509                 
510                 spos += filelist_maxnamelen(sfile->files);
511                 if (params->display == FILE_SHOWSHORT) {
512                         if (!(file->type & S_IFDIR))
513                                 file_draw_string(sx + layout->tile_w - layout->tile_border_x - sw, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END);
514                 } else {
515 #if 0 // XXX TODO: add this for non-windows systems
516                         /* rwx rwx rwx */
517                         spos += 20;
518                         sw = UI_GetStringWidth(G.font, file->mode1, 0);
519                         file_draw_string(spos, sy, file->mode1, sw, layout->tile_h); 
520                         
521                         spos += 30;
522                         sw = UI_GetStringWidth(G.font, file->mode2, 0);
523                         file_draw_string(spos, sy, file->mode2, sw, layout->tile_h);
524
525                         spos += 30;
526                         sw = UI_GetStringWidth(G.font, file->mode3, 0);
527                         file_draw_string(spos, sy, file->mode3, sw, layout->tile_h);
528                         
529                         spos += 30;
530                         sw = UI_GetStringWidth(G.font, file->owner, 0);
531                         file_draw_string(spos, sy, file->owner, sw, layout->tile_h);
532 #endif
533
534                         spos += 50;
535                         sw = UI_GetStringWidth(G.font, file->date, 0);
536                         file_draw_string(spos, sy, file->date, sw, layout->tile_h, FILE_SHORTEN_END);
537
538                         spos += 100;
539                         sw = UI_GetStringWidth(G.font, file->time, 0);
540                         file_draw_string(spos, sy, file->time, sw, layout->tile_h, FILE_SHORTEN_END); 
541                         
542                         if (!(file->type & S_IFDIR)) {
543                                 sw = UI_GetStringWidth(G.font, file->size, 0);
544                                 spos += 200-sw;
545                                 file_draw_string(spos, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END);
546                         }
547                 }
548         }
549 }
550
551 static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, FSMenuCategory category, const char* category_name, short *starty)
552 {
553         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
554         struct FSMenu* fsmenu = fsmenu_get();
555         char bookmark[FILE_MAX];
556         int nentries = fsmenu_get_nentries(fsmenu, category);
557         int linestep = gFontsize*2.0f;
558         short sx, sy, xpos, ypos;
559         int bmwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*TILE_BORDER_X - ICON_DEFAULT_WIDTH - 4;
560         int fontsize = gFontsize;
561         int i;
562
563         
564         sx = ar->v2d.cur.xmin + TILE_BORDER_X;
565         sy = *starty;
566
567         UI_ThemeColor(TH_TEXT_HI);
568         file_draw_string(sx, sy, category_name, bmwidth, fontsize, FILE_SHORTEN_END);
569         
570         sy -= linestep;
571
572         for (i=0; i< nentries && (sy > ar->v2d.cur.ymin) ;++i) {
573                 char *fname = fsmenu_get_entry(fsmenu, category, i);
574
575                 if (fname) {
576                         int sl;
577                         BLI_strncpy(bookmark, fname, FILE_MAX);
578                 
579                         sl = strlen(bookmark)-1;
580                         while (bookmark[sl] == '\\' || bookmark[sl] == '/') {
581                                 bookmark[sl] = '\0';
582                                 sl--;
583                         }
584                         if (fsmenu_is_selected(fsmenu, category, i) ) {
585                                 UI_ThemeColor(TH_HILITE);
586                                 /* uiSetRoundBox(15);   
587                                  * uiRoundBox(sx, sy - linestep, sx + bmwidth, sy, 4.0f); */
588                                 glRectf(ar->v2d.cur.xmin, sy-linestep, ar->v2d.cur.xmax + 2*TILE_BORDER_X, sy);
589                                 UI_ThemeColor(TH_TEXT);
590                         } else {
591                                 UI_ThemeColor(TH_TEXT_HI);
592                         }
593
594                         xpos = sx;
595                         ypos = sy - (TILE_BORDER_Y * 0.5);
596                         
597                         file_draw_icon(xpos, ypos, ICON_FILE_FOLDER, ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH);
598                         xpos += ICON_DEFAULT_WIDTH + 4;
599                         file_draw_string(xpos, ypos, bookmark, bmwidth, fontsize, FILE_SHORTEN_FRONT);
600                         sy -= linestep;
601                         fsmenu_set_pos(fsmenu, category, i, xpos, ypos);
602                 }
603         }
604
605         *starty = sy;
606 }
607
608 void file_draw_fsmenu(const bContext *C, ARegion *ar)
609 {
610         int linestep = gFontsize*2.0f;
611         short sy= ar->v2d.cur.ymax-2*TILE_BORDER_Y;
612         
613         file_draw_fsmenu_category(C, ar, FS_CATEGORY_SYSTEM, "SYSTEM", &sy);
614         sy -= linestep;
615         file_draw_fsmenu_category(C, ar, FS_CATEGORY_BOOKMARKS, "BOOKMARKS", &sy);
616         sy -= linestep;
617         file_draw_fsmenu_category(C, ar, FS_CATEGORY_RECENT, "RECENT", &sy);
618         
619 }