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