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