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