2.5 filebrowser
[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
40 #include "BKE_colortools.h"
41 #include "BKE_context.h"
42 #include "BKE_screen.h"
43 #include "BKE_global.h"
44 #include "BKE_utildefines.h"
45
46 #include "DNA_space_types.h"
47 #include "DNA_scene_types.h"
48 #include "DNA_screen_types.h"
49 #include "DNA_userdef_types.h"
50 #include "DNA_windowmanager_types.h"
51
52 #include "ED_fileselect.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 "UI_interface.h"
64 #include "UI_interface_icons.h"
65 #include "UI_resources.h"
66 #include "UI_text.h"
67 #include "UI_view2d.h"
68
69 #include "WM_api.h"
70 #include "WM_types.h"
71
72 #include "fsmenu.h"
73 #include "filelist.h"
74
75 #include "file_intern.h"        // own include
76
77 /* ui geometry */
78 #define IMASEL_BUTTONS_HEIGHT 60
79 #define TILE_BORDER_X 8
80 #define TILE_BORDER_Y 8
81
82 /* button events */
83 enum {
84         B_REDR  = 0,
85         B_FS_LOAD,
86         B_FS_CANCEL,
87 } eFile_ButEvents;
88
89 // XXX for Ton: bad level, maybe needs export in ED_screen?
90 extern void area_prevspace(bContext *C);
91
92 static void do_file_buttons(bContext *C, void *arg, int event)
93 {
94         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
95         switch(event) {
96                 case B_FS_LOAD:
97                         {
98                                 char name[FILE_MAX];
99
100                                 area_prevspace(C);
101                                 BLI_strncpy(name, sfile->params->dir, sizeof(name));
102                                 strcat(name, sfile->params->file);
103                                 RNA_string_set(sfile->op->ptr, "filename", name);
104                                 sfile->op->type->exec(C, sfile->op);
105                                 /* XXX for Ton: the call to WM_operator_free crashes
106                                    WM_operator_free(sfile->op);
107                                    sfile->op = NULL;
108                                 */
109                         }
110                         break;
111                 case B_FS_CANCEL:
112                         /* XXX for Ton: the call to area_prevspace crashes
113                                    area_prevspace(C);
114                         */
115                         break;
116         }
117 }
118
119 void file_draw_buttons(const bContext *C, ARegion *ar)
120 {
121         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
122         FileSelectParams* params = sfile->params;
123         uiBlock *block;
124         int loadbutton;
125         char name[20];
126         char *menu;
127         float slen;
128         float parentbut_width = 20;
129         float bookmarkbut_width = 0.0f;
130         float file_start_width = 0.0f;
131
132         int filebuty1, filebuty2;
133
134         float xmin = ar->v2d.mask.xmin + 10;
135         float xmax = ar->v2d.mask.xmax - 10;
136
137         filebuty1= ar->v2d.mask.ymax - IMASEL_BUTTONS_HEIGHT;
138         filebuty2= filebuty1+IMASEL_BUTTONS_HEIGHT/2 -6;
139
140         /* HEADER */
141         sprintf(name, "win %d", 1); // XXX sa-win???
142         block = uiBeginBlock(C, ar, name, UI_EMBOSS, UI_HELV);
143         uiBlockSetHandleFunc(block, do_file_buttons, NULL);
144
145         /* XXXX
146         uiSetButLock( filelist_gettype(simasel->files)==FILE_MAIN && simasel->returnfunc, NULL); 
147         */
148
149         /* space available for load/save buttons? */
150         slen = UI_GetStringWidth(G.font, sfile->params->title, 0);
151         loadbutton= slen > 60 ? slen + 20 : MAX2(80, 20+UI_GetStringWidth(G.font, params->title, 0));
152         if(ar->v2d.mask.xmax-ar->v2d.mask.xmin > loadbutton+20) {
153                 /* XXX
154                 if(simasel->title[0]==0) {
155                         loadbutton= 0;
156                 }
157                 */
158         }
159         else {
160                 loadbutton= 0;
161         }
162
163         /* XXX to channel region */
164         menu= fsmenu_build_menu();
165
166         if (menu[0]&& (params->type != FILE_MAIN)) {
167                 bookmarkbut_width = parentbut_width;
168                 file_start_width = parentbut_width;
169         }
170
171         uiDefBut(block, TEX, 0 /* XXX B_FS_FILENAME */,"",      xmin+file_start_width+bookmarkbut_width+2, filebuty1, xmax-xmin-loadbutton-file_start_width-bookmarkbut_width, 21, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
172         uiDefBut(block, TEX, 0 /* XXX B_FS_DIRNAME */,"",       xmin+parentbut_width, filebuty2, xmax-xmin-loadbutton-parentbut_width, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
173
174         if(loadbutton) {
175                 uiSetCurFont(block, UI_HELV);
176                 uiDefBut(block, BUT, B_FS_LOAD, params->title,  xmax-loadbutton, filebuty2, loadbutton, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
177                 uiDefBut(block, BUT, B_FS_CANCEL, "Cancel",             xmax-loadbutton, filebuty1, loadbutton, 21, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
178         }
179
180         /* menu[0] = NULL happens when no .Bfs is there, and first time browse
181            disallow external directory browsing for databrowse */
182
183         if(menu[0] && (params->type != FILE_MAIN))      { 
184                 uiDefButS(block, MENU, 0 /* B_FS_DIR_MENU */, menu, xmin, filebuty1, parentbut_width, 21, &params->menu, 0, 0, 0, 0, "");
185                 uiDefBut(block, BUT, 0 /* B_FS_BOOKMARK */, "B", xmin+22, filebuty1, bookmarkbut_width, 21, 0, 0, 0, 0, 0, "Bookmark current directory");
186         }
187
188         MEM_freeN(menu);
189
190         uiDefBut(block, BUT, 0 /* XXX B_FS_PARDIR */, "P", xmin, filebuty2, parentbut_width, 21, 0, 0, 0, 0, 0, "Move to the parent directory (PKEY)"); 
191         uiEndBlock(C, block);
192         uiDrawBlock(C, block);
193 }
194
195
196 static void draw_tile(short sx, short sy, short width, short height, int colorid)
197 {
198         /* TODO: BIF_ThemeColor seems to need this to show the color, not sure why? - elubie */
199         glEnable(GL_BLEND);
200         glColor4ub(0, 0, 0, 100);
201         glDisable(GL_BLEND);
202         
203         UI_ThemeColor4(colorid);
204         uiSetRoundBox(15);      
205         glRecti(sx, sy - height, sx + width, sy);
206
207         // uiRoundBox(sx+TILE_BORDER_X, sy - sfile->prv_h - TILE_BORDER_Y*3 - U.fontsize, sx + sfile->prv_w + TILE_BORDER_X*3, sy, 6);
208 }
209
210 static float shorten_string(char* string, float w)
211 {       
212         short shortened = 0;
213         float sw = 0;
214         
215         sw = UI_GetStringWidth(G.font, string,0);
216         while (sw>w) {
217                 int slen = strlen(string);
218                 string[slen-1] = '\0';
219                 sw = UI_GetStringWidth(G.font, string,0);
220                 shortened = 1;
221         }
222         if (shortened) {
223                 int slen = strlen(string);
224                 if (slen > 3) {
225                         BLI_strncpy(string+slen-3, "...", 4);                           
226                 }
227         }
228         return sw;
229 }
230
231 static void file_draw_string(short sx, short sy, char* string, short width, short height)
232 {
233         short soffs;
234         char fname[FILE_MAXFILE];
235         float sw;
236         float x,y;
237
238         BLI_strncpy(fname,string, FILE_MAXFILE);
239         sw = shorten_string(fname, width );
240         soffs = (width - sw) / 2;
241         x = (float)(sx);
242         y = (float)(sy-height);
243
244         // XXX was using ui_rasterpos_safe
245         glRasterPos2f(x, y);
246         UI_RasterPos(x, y);
247
248         /* XXX TODO: handling of international fonts.
249             TODO: proper support for utf8 in languages different from ja_JP abd zh_CH
250             needs update of iconv in lib/windows to support getting the system language string
251         */
252         UI_DrawString(G.font, fname, 0);
253
254 }
255
256 /* returns max number of rows in view */
257 static int file_view_rows(SpaceFile* sfile, View2D *v2d)
258 {
259         int height= (v2d->cur.ymax - v2d->cur.ymin - 2*sfile->tile_border_y);
260         return height / (sfile->tile_h + sfile->tile_border_y);
261 }
262
263 /* returns max number of columns in view */
264 static int file_view_columns(SpaceFile* sfile, View2D *v2d)
265 {
266         int width= (v2d->cur.xmax - v2d->cur.xmin - 2*sfile->tile_border_x);
267         return width / (sfile->tile_w + sfile->tile_border_x);
268 }
269
270 void file_calc_previews(const bContext *C, ARegion *ar)
271 {
272         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
273         FileSelectParams* params = sfile->params;
274         View2D *v2d= &ar->v2d;
275         int width=0, height=0;
276         int rows, columns;
277
278         if (params->display) {
279                 sfile->prv_w = 96;
280                 sfile->prv_h = 96;
281                 sfile->tile_border_x = 8;
282                 sfile->tile_border_y = 8;
283                 sfile->prv_border_x = 4;
284                 sfile->prv_border_y = 4;
285                 sfile->tile_w = sfile->prv_w + 2*sfile->prv_border_x;
286                 sfile->tile_h = sfile->prv_h + 2*sfile->prv_border_y + U.fontsize*3/2;
287                 width= (v2d->cur.xmax - v2d->cur.xmin - 2*sfile->tile_border_x);
288                 columns= file_view_columns(sfile, v2d);
289                 rows= filelist_numfiles(params->files)/columns + 1; // XXX dirty, modulo is zero
290                 height= rows*(sfile->tile_h+sfile->tile_border_y) + sfile->tile_border_y*2;
291         } else {
292                 sfile->prv_w = 0;
293                 sfile->prv_h = 0;
294                 sfile->tile_border_x = 8;
295                 sfile->tile_border_y = 2;
296                 sfile->prv_border_x = 0;
297                 sfile->prv_border_y = 0;
298                 sfile->tile_w = 240;
299                 sfile->tile_h = U.fontsize*3/2;
300                 height= v2d->cur.ymax - v2d->cur.ymin;
301                 rows = file_view_rows(sfile, v2d);
302                 columns = filelist_numfiles(params->files)/rows + 1; // XXX dirty, modulo is zero
303                 width = columns * (sfile->tile_w + sfile->tile_border_x) + sfile->tile_border_x*2;
304         }
305
306         UI_view2d_totRect_set(v2d, width, height);
307 }
308
309 void file_draw_previews(const bContext *C, ARegion *ar)
310 {
311         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
312         FileSelectParams* params=sfile->params;
313         View2D *v2d= &ar->v2d;
314         static double lasttime= 0;
315         struct FileList* files = params->files;
316         int numfiles;
317         struct direntry *file;
318
319         short sx, sy;
320         int do_load = 1;
321         
322         ImBuf* imb=0;
323         int i;
324         short type;
325         int colorid = 0;
326         int todo;
327         int offset;
328         int columns;
329         
330         if (!files) return;
331         /* Reload directory */
332         BLI_strncpy(params->dir, filelist_dir(files), FILE_MAX);        
333         
334         type = filelist_gettype(files); 
335
336         filelist_imgsize(files,sfile->prv_w,sfile->prv_h);
337
338         numfiles = filelist_numfiles(files);
339         
340         todo = 0;
341         if (lasttime < 0.001) lasttime = PIL_check_seconds_timer();
342
343         sx = v2d->cur.xmin + sfile->tile_border_x;
344         sy = v2d->cur.ymax - sfile->tile_border_y;
345         columns = file_view_columns(sfile, v2d);
346         offset = columns*(-v2d->cur.ymax+sfile->tile_border_y)/sfile->tile_h;
347         offset = (offset/columns-1)*columns;
348         if (offset<0) offset=0;
349         for (i=offset; (i < numfiles); ++i)
350         {
351                 sx = v2d->tot.xmin + sfile->tile_border_x + ((i)%columns)*(sfile->tile_w+sfile->tile_border_x);
352                 sy = v2d->tot.ymax - sfile->tile_border_y - ((i)/columns)*(sfile->tile_h+sfile->tile_border_y);
353                 file = filelist_file(files, i);                         
354
355                 if (params->active_file == i) {
356                         colorid = TH_ACTIVE;
357                         draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
358                 } else if (file->flags & ACTIVE) {
359                         colorid = TH_HILITE;
360                         draw_tile(sx, sy+sfile->tile_border_y, sfile->tile_w, sfile->tile_h-sfile->tile_border_y, colorid);
361                 } else {
362                         /*
363                         colorid = TH_PANEL;
364                         draw_tile(simasel, sx, sy, tilewidth, tileheight, colorid);
365                         */
366                 }
367
368 #if 0
369                 if ( type == FILE_MAIN) {
370                         ID *id;
371                         int icon_id = 0;
372                         int idcode;
373                         idcode= groupname_to_code(sfile->dir);
374                         if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) {
375                                 id = (ID *)file->poin;
376                                 icon_id = BKE_icon_getid(id);
377                         }               
378                         if (icon_id) {
379                                 glEnable(GL_BLEND);
380                                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
381                                 if (do_load) {
382                                         UI_icon_draw_preview(sx+2*TILE_BORDER_X, sy-simasel->prv_w-TILE_BORDER_X, icon_id, 0);                  
383                                 } else {
384                                         UI_icon_draw_preview(sx+2*TILE_BORDER_X, sy-simasel->prv_w-TILE_BORDER_X, icon_id, 1);
385                                         todo++;
386                                 }
387                                 
388                                 glDisable(GL_BLEND);
389                         }               
390                 }
391                 else {
392 #endif
393                         if ( (file->flags & IMAGEFILE) /* || (file->flags & MOVIEFILE) */)
394                         {
395                                 if (do_load) {                                  
396                                         filelist_loadimage(files, i);                           
397                                 } else {
398                                         todo++;
399                                 }
400                                 imb = filelist_getimage(files, i);
401                         } else {
402                                 imb = filelist_getimage(files, i);
403                         }
404
405                         if (imb) {              
406                                 float fx = ((float)sfile->prv_w - (float)imb->x)/2.0f;
407                                 float fy = ((float)sfile->prv_h - (float)imb->y)/2.0f;
408                                 short dx = (short)(fx + 0.5f + sfile->prv_border_x);
409                                 short dy = (short)(fy + 0.5f + sfile->prv_border_y);
410                                 
411                                 glEnable(GL_BLEND);
412                                 glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);                                                                                                     
413                                 // glaDrawPixelsSafe((float)sx+8 + dx, (float)sy - imgwidth + dy - 8, imb->x, imb->y, imb->x, GL_RGBA, GL_UNSIGNED_BYTE, imb->rect);
414                                 glColor4f(1.0, 1.0, 1.0, 1.0);
415                                 glaDrawPixelsTex((float)sx + dx, (float)sy - sfile->prv_h + dy, imb->x, imb->y,GL_UNSIGNED_BYTE, imb->rect);
416                                 // glDisable(GL_BLEND);
417                                 imb = 0;
418                         }
419 #if 0
420                 }               
421 #endif
422                 if (type == FILE_MAIN) {
423                         glColor3f(1.0f, 1.0f, 1.0f);                    
424                 }
425                 else {
426                         if (S_ISDIR(file->type)) {
427                                 glColor3f(1.0f, 1.0f, 0.9f);
428                         }
429                         else if (file->flags & IMAGEFILE) {
430                                 UI_ThemeColor(TH_SEQ_IMAGE);
431                         }
432                         else if (file->flags & MOVIEFILE) {
433                                 UI_ThemeColor(TH_SEQ_MOVIE);
434                         }
435                         else if (file->flags & BLENDERFILE) {
436                                 UI_ThemeColor(TH_SEQ_SCENE);
437                         }
438                         else {
439                                 if (params->active_file == i) {
440                                         UI_ThemeColor(TH_GRID); /* grid used for active text */
441                                 } else if (file->flags & ACTIVE) {
442                                         UI_ThemeColor(TH_TEXT_HI);                      
443                                 } else {
444                                         UI_ThemeColor(TH_TEXT);
445                                 }
446                         }
447                 }
448                         
449                 file_draw_string(sx + sfile->prv_border_x, sy, file->relname, sfile->tile_w, sfile->tile_h);
450 #if 0
451                 if(do_load && (PIL_check_seconds_timer() - lasttime > 0.3)) {
452                         lasttime= PIL_check_seconds_timer();
453                         do_load = 0;
454                 }
455 #endif
456         }
457 #if 0 // XXX solve with threads or add notifier ??
458         if (!do_load && todo > 0) /* we broke off loading */
459                 addafterqueue(sa->win, RENDERPREVIEW, 1);
460 #endif
461 }
462
463
464 void file_draw_list(const bContext *C, ARegion *ar)
465 {
466         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
467         FileSelectParams* params = sfile->params;
468         struct FileList* files = params->files;
469         struct direntry *file;
470         int numfiles;
471         int colorid = 0;
472         short sx, sy;
473         int offset;
474         short type;
475         int i;
476         int rows;
477
478         numfiles = filelist_numfiles(files);
479         type = filelist_gettype(files); 
480
481         sx = ar->v2d.tot.xmin + sfile->tile_border_x/2;
482         sy = ar->v2d.cur.ymax - sfile->tile_border_y;
483
484         rows = (ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*sfile->tile_border_y) / (sfile->tile_h+sfile->tile_border_y);
485         offset = rows*(sx - sfile->tile_border_x)/(sfile->tile_w+sfile->tile_border_x);
486         offset = (offset/rows-1)*rows;
487
488         while (sx < ar->v2d.cur.xmax) {
489                 sx += (sfile->tile_w+sfile->tile_border_x);
490                 glColor4ub(0xB0,0xB0,0xB0, 0xFF);
491                 sdrawline(sx+1,  ar->v2d.cur.ymax - sfile->tile_border_y ,  sx+1,  ar->v2d.cur.ymin + sfile->tile_border_y); 
492                 glColor4ub(0x30,0x30,0x30, 0xFF);
493                 sdrawline(sx,  ar->v2d.cur.ymax - sfile->tile_border_y ,  sx,  ar->v2d.cur.ymin + sfile->tile_border_y); 
494         }
495
496         sx = ar->v2d.cur.xmin + sfile->tile_border_x;
497         sy = ar->v2d.cur.ymax - sfile->tile_border_y;
498         if (offset<0) offset=0;
499         for (i=offset; (i < numfiles); ++i)
500         {
501                 sy = ar->v2d.tot.ymax-sfile->tile_border_y - (i%rows)*(sfile->tile_h+sfile->tile_border_y);
502                 sx = ar->v2d.tot.xmin +sfile->tile_border_x + (i/rows)*(sfile->tile_w+sfile->tile_border_x);
503
504                 file = filelist_file(files, i); 
505
506                 if (params->active_file == i) {
507                         colorid = TH_ACTIVE;
508                         draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
509                 } else if (file->flags & ACTIVE) {
510                         colorid = TH_HILITE;
511                         draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
512                 } else {
513                         /*
514                         colorid = TH_PANEL;
515                         draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
516                         */
517                 }
518                 if (type == FILE_MAIN) {
519                         glColor3f(1.0f, 1.0f, 1.0f);                    
520                 }
521                 else {
522                         if (S_ISDIR(file->type)) {
523                                 glColor3f(1.0f, 1.0f, 0.9f);
524                         }
525                         else if (file->flags & IMAGEFILE) {
526                                 UI_ThemeColor(TH_SEQ_IMAGE);
527                         }
528                         else if (file->flags & MOVIEFILE) {
529                                 UI_ThemeColor(TH_SEQ_MOVIE);
530                         }
531                         else if (file->flags & BLENDERFILE) {
532                                 UI_ThemeColor(TH_SEQ_SCENE);
533                         }
534                         else {
535                                 if (params->active_file == i) {
536                                         UI_ThemeColor(TH_GRID); /* grid used for active text */
537                                 } else if (file->flags & ACTIVE) {
538                                         UI_ThemeColor(TH_TEXT_HI);                      
539                                 } else {
540                                         UI_ThemeColor(TH_TEXT);
541                                 }
542                         }
543                 }
544
545                 file_draw_string(sx, sy, file->relname, sfile->tile_w, sfile->tile_h);
546                 file_draw_string(sx + sfile->tile_w - UI_GetStringWidth(G.font, file->size, 0), sy,
547                         file->size, sfile->tile_w - UI_GetStringWidth(G.font, file->size, 0), sfile->tile_h);
548         }
549 }
550
551 void file_draw_fsmenu(const bContext *C, ARegion *ar)
552 {
553         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
554         FileSelectParams* params = sfile->params;
555         char bookmark[FILE_MAX];
556         int nentries = fsmenu_get_nentries();
557         int linestep = U.fontsize*3/2;
558         int i;
559         short sx, sy;
560         int bmwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*TILE_BORDER_X;
561         int fontsize = U.fontsize;
562
563         sx = ar->v2d.cur.xmin + TILE_BORDER_X;
564         sy = -2*TILE_BORDER_Y;
565         for (i=0; i< nentries && (sy > ar->v2d.cur.ymin) ;++i) {
566                 char *fname = fsmenu_get_entry(i);
567
568                 if (fname) {
569                         int sl;
570                         BLI_strncpy(bookmark, fname, FILE_MAX);
571                 
572                         sl = strlen(bookmark)-1;
573                         while (bookmark[sl] == '\\' || bookmark[sl] == '/') {
574                                 bookmark[sl] = '\0';
575                                 sl--;
576                         }
577                         if (params->active_bookmark == i ) {
578                                 glColor4ub(0, 0, 0, 100);
579                                 UI_ThemeColor(TH_HILITE);
580                                 // uiSetRoundBox(15);   
581                                 // uiRoundBox(simasel->bookmarkrect.xmin + TILE_BORDER_X - 1, sy - linestep*0.25, simasel->bookmarkrect.xmax - TILE_BORDER_X + 1, sy + linestep*0.75, 6);
582                                 glRecti(sx, sy - linestep, sx + bmwidth, sy);
583                                 UI_ThemeColor(TH_TEXT_HI);
584                         } else {
585                                 UI_ThemeColor(TH_TEXT);
586                         }
587
588                         file_draw_string(sx, sy, bookmark, bmwidth, fontsize);
589                         sy -= linestep;
590                 } else {
591                         glColor4ub(0xB0,0xB0,0xB0, 0xFF);
592                         sdrawline(sx,  sy-1-fontsize/2 ,  sx + bmwidth,  sy-1-fontsize/2); 
593                         glColor4ub(0x30,0x30,0x30, 0xFF);
594                         sdrawline(sx,  sy-fontsize/2 ,  sx + bmwidth,  sy - fontsize/2);
595                         sy -= linestep;
596                 }
597         }
598 }