style cleanup: follow style guide for formatting of if/for/while loops, and else...
[blender.git] / source / blender / editors / space_file / file_draw.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version. 
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2008 Blender Foundation.
19  * All rights reserved.
20  *
21  * 
22  * Contributor(s): Blender Foundation
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/editors/space_file/file_draw.c
28  *  \ingroup spfile
29  */
30
31
32 #include <math.h>
33 #include <string.h>
34
35 #include "BLI_blenlib.h"
36 #include "BLI_utildefines.h"
37 #include "BLI_dynstr.h"
38 #ifdef WIN32
39 #include "BLI_winstuff.h"
40 #endif
41
42 #include "BIF_gl.h"
43 #include "BIF_glutil.h"
44
45 #include "BKE_context.h"
46 #include "BKE_global.h"
47 #include "BKE_main.h"
48
49 #include "BLF_api.h"
50 #include "BLF_translation.h"
51
52 #include "IMB_imbuf_types.h"
53  
54 #include "MEM_guardedalloc.h"
55
56 #include "DNA_userdef_types.h"
57
58 #include "RNA_access.h"
59
60 #include "ED_fileselect.h"
61 #include "ED_screen.h"
62
63 #include "UI_interface.h"
64 #include "UI_interface_icons.h"
65 #include "UI_resources.h"
66 #include "UI_view2d.h"
67
68 #include "WM_types.h"
69
70 #include "fsmenu.h"
71 #include "filelist.h"
72
73 #include "file_intern.h"        // own include
74
75 /* button events */
76 enum {
77         B_FS_DIRNAME,
78         B_FS_FILENAME
79 } /*eFile_ButEvents*/;
80
81
82 static void do_file_buttons(bContext *C, void *UNUSED(arg), int event)
83 {
84         switch(event) {
85                 case B_FS_FILENAME:
86                         file_filename_exec(C, NULL);
87                         break;
88                 case B_FS_DIRNAME:
89                         file_directory_exec(C, NULL);
90                         break;
91         }
92 }
93
94 /* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. 
95  * The controls are laid out as follows:
96  *
97  * -------------------------------------------
98  * | Directory input               | execute |
99  * -------------------------------------------
100  * | Filename input        | + | - | cancel  |
101  * -------------------------------------------
102  *
103  * The input widgets will stretch to fill any excess space.
104  * When there isn't enough space for all controls to be shown, they are
105  * hidden in this order: x/-, execute/cancel, input widgets.
106  */
107 void file_draw_buttons(const bContext *C, ARegion *ar)
108 {
109         /* Button layout. */
110         const int max_x      = ar->winx - 10;
111         const int line1_y    = ar->winy - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN);
112         const int line2_y    = line1_y - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN);
113         const int input_minw = 20;
114         const int btn_h      = UI_UNIT_Y;
115         const int btn_fn_w   = UI_UNIT_X;
116         const int btn_minw   = 80;
117         const int btn_margin = 20;
118         const int separator  = 4;
119
120         /* Additional locals. */
121         char uiblockstr[32];
122         int loadbutton;
123         int fnumbuttons;
124         int min_x       = 10;
125         int chan_offs   = 0;
126         int available_w = max_x - min_x;
127         int line1_w     = available_w;
128         int line2_w     = available_w;
129         
130         uiBut*            but;
131         uiBlock*          block;
132         SpaceFile*        sfile  = CTX_wm_space_file(C);
133         FileSelectParams* params = ED_fileselect_get_params(sfile);
134         ARegion*                  artmp;
135         
136         /* Initialize UI block. */
137         BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar);
138         block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS);
139         uiBlockSetHandleFunc(block, do_file_buttons, NULL);
140
141         /* exception to make space for collapsed region icon */
142         for (artmp=CTX_wm_area(C)->regionbase.first; artmp; artmp=artmp->next) {
143                 if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) {
144                         chan_offs = 16;
145                         min_x += chan_offs;
146                         available_w -= chan_offs;
147                 }
148         }
149         
150         /* Is there enough space for the execute / cancel buttons? */
151         loadbutton = UI_GetStringWidth(sfile->params->title) + btn_margin;
152         if (loadbutton < btn_minw) {
153                 loadbutton = MAX2(btn_minw, 
154                                                   btn_margin + UI_GetStringWidth(params->title));
155         }
156         
157         if (available_w <= loadbutton + separator + input_minw 
158          || params->title[0] == 0) {
159                 loadbutton = 0;
160         }
161         else {
162                 line1_w -= (loadbutton + separator);
163                 line2_w  = line1_w;
164         }
165
166         /* Is there enough space for file number increment/decrement buttons? */
167         fnumbuttons = 2 * btn_fn_w;
168         if (!loadbutton || line2_w <= fnumbuttons + separator + input_minw) {
169                 fnumbuttons = 0;
170         }
171         else {
172                 line2_w -= (fnumbuttons + separator);
173         }
174         
175         /* Text input fields for directory and file. */
176         if (available_w > 0) {
177                 int overwrite_alert= file_draw_check_exists(sfile);
178                 /* callbacks for operator check functions */
179                 uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL);
180
181                 but = uiDefButTextO(block, TEX, "FILE_OT_directory", 0, "",
182                                     min_x, line1_y, line1_w-chan_offs, btn_h,
183                                     params->dir, 0.0, (float)FILE_MAX, 0, 0,
184                                     TIP_("File path"));
185                 uiButSetCompleteFunc(but, autocomplete_directory, NULL);
186                 uiButSetFlag(but, UI_BUT_NO_UTF8);
187
188                 if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
189                         but = uiDefBut(block, TEX, B_FS_FILENAME, "",
190                                        min_x, line2_y, line2_w-chan_offs, btn_h,
191                                        params->file, 0.0, (float)FILE_MAXFILE, 0, 0,
192                                        TIP_(overwrite_alert ?N_("File name, overwrite existing") : N_("File name")));
193                         uiButSetCompleteFunc(but, autocomplete_file, NULL);
194                         uiButSetFlag(but, UI_BUT_NO_UTF8);
195                         uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */
196
197                         /* check if this overrides a file and if the operator option is used */
198                         if (overwrite_alert) {
199                                 uiButSetFlag(but, UI_BUT_REDALERT);
200                         }
201                 }
202                 
203                 /* clear func */
204                 uiBlockSetFunc(block, NULL, NULL, NULL);
205         }
206         
207         /* Filename number increment / decrement buttons. */
208         if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) {
209                 uiBlockBeginAlign(block);
210                 but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMOUT,
211                                     min_x + line2_w + separator - chan_offs, line2_y,
212                                     btn_fn_w, btn_h,
213                                     TIP_("Decrement the filename number"));
214                 RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", -1);
215
216                 but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMIN,
217                                     min_x + line2_w + separator + btn_fn_w - chan_offs, line2_y,
218                                     btn_fn_w, btn_h,
219                                     TIP_("Increment the filename number"));
220                 RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", 1);
221                 uiBlockEndAlign(block);
222         }
223         
224         /* Execute / cancel buttons. */
225         if (loadbutton) {
226                 
227                 uiDefButO(block, BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, IFACE_(params->title),
228                         max_x - loadbutton, line1_y, loadbutton, btn_h, TIP_(params->title));
229                 uiDefButO(block, BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"),
230                         max_x - loadbutton, line2_y, loadbutton, btn_h, TIP_("Cancel"));
231         }
232         
233         uiEndBlock(C, block);
234         uiDrawBlock(C, block);
235 }
236
237
238 static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade)
239 {
240         UI_ThemeColorShade(colorid, shade);
241         uiSetRoundBox(UI_CNR_ALL);
242         uiRoundBox((float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f);
243 }
244
245
246 static int get_file_icon(struct direntry *file)
247 {
248         if (file->type & S_IFDIR) {
249                 if ( strcmp(file->relname, "..") == 0) {
250                                 return  ICON_FILE_PARENT;
251                 }
252                 if (file->flags & BLENDERFILE) {
253                         return ICON_FILE_BLEND;
254                 }
255                 return ICON_FILE_FOLDER;
256         }
257         else if (file->flags & BLENDERFILE)
258                 return ICON_FILE_BLEND;
259         else if (file->flags & BLENDERFILE_BACKUP)
260                 return ICON_FILE_BLEND;
261         else if (file->flags & IMAGEFILE)
262                 return ICON_FILE_IMAGE;
263         else if (file->flags & MOVIEFILE)
264                 return ICON_FILE_MOVIE;
265         else if (file->flags & PYSCRIPTFILE)
266                 return ICON_FILE_SCRIPT;
267         else if (file->flags & SOUNDFILE) 
268                 return ICON_FILE_SOUND;
269         else if (file->flags & FTFONTFILE) 
270                 return ICON_FILE_FONT;
271         else if (file->flags & BTXFILE) 
272                 return ICON_FILE_BLANK;
273         else if (file->flags & COLLADAFILE) 
274                 return ICON_FILE_BLANK;
275         else
276                 return ICON_FILE_BLANK;
277 }
278
279 static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, int width, int height)
280 {
281         uiBut *but;
282         int x,y;
283         /*float alpha=1.0f;*/
284         
285         x = sx;
286         y = sy-height;
287         
288         /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/
289
290         but = uiDefIconBut(block, LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, "");
291         uiButSetDragPath(but, path);
292 }
293
294
295 static void file_draw_string(int sx, int sy, const char* string, float width, int height, short align)
296 {
297         uiStyle *style= UI_GetStyle();
298         uiFontStyle fs = style->widgetlabel;
299         rcti rect;
300         char fname[FILE_MAXFILE];
301
302         fs.align = align;
303
304         BLI_strncpy(fname,string, FILE_MAXFILE);
305         file_shorten_string(fname, width + 1.0f, 0);
306
307         /* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */
308         rect.xmin = sx;
309         rect.xmax = (int)(sx + ceil(width+4.0f));
310         rect.ymin = sy - height;
311         rect.ymax = sy;
312         
313         uiStyleFontDraw(&fs, &rect, fname);
314 }
315
316 void file_calc_previews(const bContext *C, ARegion *ar)
317 {
318         SpaceFile *sfile= CTX_wm_space_file(C);
319         View2D *v2d= &ar->v2d;
320         
321         ED_fileselect_init_layout(sfile, ar);
322         /* +SCROLL_HEIGHT is bad hack to work around issue in UI_view2d_totRect_set */
323         UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height+V2D_SCROLL_HEIGHT);
324 }
325
326 static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow)
327 {
328         if (imb) {
329                 uiBut *but;
330                 float fx, fy;
331                 float dx, dy;
332                 int xco, yco;
333                 float scaledx, scaledy;
334                 float scale;
335                 int ex, ey;
336                 
337                 if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) {
338                         if (imb->x > imb->y) {
339                                 scaledx = (float)layout->prv_w;
340                                 scaledy =  ( (float)imb->y/(float)imb->x )*layout->prv_w;
341                                 scale = scaledx/imb->x;
342                         }
343                         else {
344                                 scaledy = (float)layout->prv_h;
345                                 scaledx =  ( (float)imb->x/(float)imb->y )*layout->prv_h;
346                                 scale = scaledy/imb->y;
347                         }
348                 }
349                 else {
350                         scaledx = (float)imb->x;
351                         scaledy = (float)imb->y;
352                         scale = 1.0;
353                 }
354                 ex = (int)scaledx;
355                 ey = (int)scaledy;
356                 fx = ((float)layout->prv_w - (float)ex)/2.0f;
357                 fy = ((float)layout->prv_h - (float)ey)/2.0f;
358                 dx = (fx + 0.5f + layout->prv_border_x);
359                 dy = (fy + 0.5f - layout->prv_border_y);
360                 xco = sx + (int)dx;
361                 yco = sy - layout->prv_h + (int)dy;
362                 
363                 glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);
364                 
365                 /* shadow */
366                 if (dropshadow)
367                         uiDrawBoxShadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
368
369                 glEnable(GL_BLEND);
370                 
371                 /* the image */
372                 glColor4f(1.0, 1.0, 1.0, 1.0);
373                 glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale);
374                 
375                 /* border */
376                 if (dropshadow) {
377                         glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
378                         fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
379                 }
380                 
381                 /* dragregion */
382                 but = uiDefBut(block, LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, "");
383                 uiButSetDragImage(but, file->path, get_file_icon(file), imb, scale);
384                 
385                 glDisable(GL_BLEND);
386                 imb = NULL;
387         }
388 }
389
390 static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
391 {
392         char newname[FILE_MAX+12];
393         char orgname[FILE_MAX+12];
394         char filename[FILE_MAX+12];
395         SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
396         ARegion* ar = CTX_wm_region(C);
397
398         BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname);
399         BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename));
400         BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename);
401
402         if ( strcmp(orgname, newname) != 0 ) {
403                 if (!BLI_exists(newname)) {
404                         BLI_rename(orgname, newname);
405                         /* to make sure we show what is on disk */
406                         ED_fileselect_clear(C, sfile);
407                 }
408
409                 ED_region_tag_redraw(ar);
410         }
411 }
412
413
414 static void draw_background(FileLayout *layout, View2D *v2d)
415 {
416         int i;
417         int sy;
418
419         /* alternating flat shade background */
420         for (i=0; (i <= layout->rows); i+=2)
421         {
422                 sy = (int)v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y;
423
424                 UI_ThemeColorShade(TH_BACK, -7);
425                 glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy+layout->tile_h+2*layout->tile_border_y));
426                 
427         }
428 }
429
430 static void draw_dividers(FileLayout *layout, View2D *v2d)
431 {
432         int sx;
433
434         /* vertical column dividers */
435         sx = (int)v2d->tot.xmin;
436         while (sx < v2d->cur.xmax) {
437                 sx += (layout->tile_w+2*layout->tile_border_x);
438                 
439                 UI_ThemeColorShade(TH_BACK, 30);
440                 sdrawline(sx+1, (short)(v2d->cur.ymax - layout->tile_border_y),  sx+1,  (short)v2d->cur.ymin); 
441                 UI_ThemeColorShade(TH_BACK, -30);
442                 sdrawline(sx, (short)(v2d->cur.ymax - layout->tile_border_y),  sx,  (short)v2d->cur.ymin); 
443         }
444 }
445
446 void file_draw_list(const bContext *C, ARegion *ar)
447 {
448         SpaceFile *sfile= CTX_wm_space_file(C);
449         FileSelectParams* params = ED_fileselect_get_params(sfile);
450         FileLayout* layout= ED_fileselect_get_layout(sfile, ar);
451         View2D *v2d= &ar->v2d;
452         struct FileList* files = sfile->files;
453         struct direntry *file;
454         ImBuf *imb;
455         uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
456         int numfiles;
457         int numfiles_layout;
458         int sx, sy;
459         int offset;
460         int textwidth, textheight;
461         int i;
462         short is_icon;
463         short align;
464
465
466         numfiles = filelist_numfiles(files);
467         
468         if (params->display != FILE_IMGDISPLAY) {
469
470                 draw_background(layout, v2d);
471         
472                 draw_dividers(layout, v2d);
473         }
474
475         offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax);
476         if (offset<0) offset=0;
477
478         numfiles_layout = ED_fileselect_layout_numfiles(layout, ar);
479
480         /* adjust, so the next row is already drawn when scrolling */
481         if (layout->flag & FILE_LAYOUT_HOR) {
482                 numfiles_layout += layout->rows;
483         }
484         else {
485                 numfiles_layout += layout->columns;
486         }
487
488         textwidth =( FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME];
489         textheight = (int)(layout->textheight*3.0/2.0 + 0.5);
490
491         align = ( FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT;
492
493         for (i=offset; (i < numfiles) && (i<offset+numfiles_layout); ++i)
494         {
495                 ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
496                 sx += (int)(v2d->tot.xmin+2.0f);
497                 sy = (int)(v2d->tot.ymax - sy);
498
499                 file = filelist_file(files, i); 
500                 
501                 UI_ThemeColor4(TH_TEXT);
502
503
504                 if (!(file->selflag & EDITING_FILE)) {
505                         if  ((params->active_file == i) || (file->selflag & HILITED_FILE) || (file->selflag & SELECTED_FILE) ) {
506                                 int colorid = (file->selflag & SELECTED_FILE) ? TH_HILITE : TH_BACK;
507                                 int shade = (params->active_file == i) || (file->selflag & HILITED_FILE) ? 20 : 0;
508                                 draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid, shade);
509                         }
510                 }
511                 uiSetRoundBox(UI_CNR_NONE);
512
513                 if ( FILE_IMGDISPLAY == params->display ) {
514                         is_icon = 0;
515                         imb = filelist_getimage(files, i);
516                         if (!imb) {
517                                 imb = filelist_geticon(files,i);
518                                 is_icon = 1;
519                         }
520                         
521                         file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE));
522                 }
523                 else {
524                         file_draw_icon(block, file->path, sx, sy-(UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE);
525                         sx += ICON_DEFAULT_WIDTH_SCALE + 4;
526                 }
527
528                 UI_ThemeColor4(TH_TEXT);
529
530                 if (file->selflag & EDITING_FILE) {
531                         uiBut *but = uiDefBut(block, TEX, 1, "", sx , sy-layout->tile_h-3, 
532                                 textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit),0,0,"");
533                         uiButSetRenameFunc(but, renamebutton_cb, file);
534                         uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */
535                         uiButClearFlag(but, UI_BUT_UNDO);
536                         if ( 0 == uiButActiveOnly(C, block, but)) {
537                                 file->selflag &= ~EDITING_FILE;
538                         }
539                 }
540
541                 if (!(file->selflag & EDITING_FILE)) {
542                         int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy;
543                         file_draw_string(sx+1, tpos, file->relname, (float)textwidth, textheight, align);
544                 }
545
546                 if (params->display == FILE_SHORTDISPLAY) {
547                         sx += (int)layout->column_widths[COLUMN_NAME] + 12;
548                         if (!(file->type & S_IFDIR)) {
549                                 file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);        
550                                 sx += (int)layout->column_widths[COLUMN_SIZE] + 12;
551                         }
552                 }
553                 else if (params->display == FILE_LONGDISPLAY) {
554                         sx += (int)layout->column_widths[COLUMN_NAME] + 12;
555
556 #ifndef WIN32
557                         /* rwx rwx rwx */
558                         file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align); 
559                         sx += layout->column_widths[COLUMN_MODE1] + 12;
560
561                         file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align);
562                         sx += layout->column_widths[COLUMN_MODE2] + 12;
563
564                         file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align);
565                         sx += layout->column_widths[COLUMN_MODE3] + 12;
566
567                         file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER] , layout->tile_h, align);
568                         sx += layout->column_widths[COLUMN_OWNER] + 12;
569 #endif
570
571                         file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align);
572                         sx += (int)layout->column_widths[COLUMN_DATE] + 12;
573
574                         file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME] , layout->tile_h, align); 
575                         sx += (int)layout->column_widths[COLUMN_TIME] + 12;
576
577                         if (!(file->type & S_IFDIR)) {
578                                 file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
579                                 sx += (int)layout->column_widths[COLUMN_SIZE] + 12;
580                         }
581                 }
582         }
583
584         uiEndBlock(C, block);
585         uiDrawBlock(C, block);
586
587 }