Revision: 23527 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23527 Author: blendix Date: 2009-09-28 14:10:23 +0200 (Mon, 28 Sep 2009)
Log Message: ----------- File Browser fixes: * The code to draw only visible items was not working, giving slow performance with many files (bug #19469). * Fix detailed list display on non-windows, would give overlapping text. * Fix folders with many files not displaying all items, changed short to int in various places, was overflowing. * Recreate layout on area resizes, file view gets out of sync otherwise. * Workaround for v2d height not being correct with image display due to scrollers. * Fix view2d code to compute minimum scroller size, this would make the scroller go outside of its bounds. Modified Paths: -------------- trunk/blender/source/blender/editors/include/ED_fileselect.h trunk/blender/source/blender/editors/interface/view2d.c trunk/blender/source/blender/editors/space_file/file_draw.c trunk/blender/source/blender/editors/space_file/file_ops.c trunk/blender/source/blender/editors/space_file/filesel.c trunk/blender/source/blender/editors/space_file/space_file.c Modified: trunk/blender/source/blender/editors/include/ED_fileselect.h =================================================================== --- trunk/blender/source/blender/editors/include/ED_fileselect.h 2009-09-28 12:10:13 UTC (rev 23526) +++ trunk/blender/source/blender/editors/include/ED_fileselect.h 2009-09-28 12:10:23 UTC (rev 23527) @@ -51,21 +51,21 @@ typedef struct FileLayout { /* view settings - XXX - move into own struct */ - short prv_w; - short prv_h; - short tile_w; - short tile_h; - short tile_border_x; - short tile_border_y; - short prv_border_x; - short prv_border_y; - short rows; - short columns; - short width; - short height; - short flag; - short dirty; - short textheight; + int prv_w; + int prv_h; + int tile_w; + int tile_h; + int tile_border_x; + int tile_border_y; + int prv_border_x; + int prv_border_y; + int rows; + int columns; + int width; + int height; + int flag; + int dirty; + int textheight; float column_widths[MAX_FILE_COLUMN]; } FileLayout; @@ -84,7 +84,7 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar); int ED_fileselect_layout_offset(FileLayout* layout, int x, int y); -void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, short *x, short *y); +void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y); #endif /* ED_FILES_H */ Modified: trunk/blender/source/blender/editors/interface/view2d.c =================================================================== --- trunk/blender/source/blender/editors/interface/view2d.c 2009-09-28 12:10:13 UTC (rev 23526) +++ trunk/blender/source/blender/editors/interface/view2d.c 2009-09-28 12:10:23 UTC (rev 23527) @@ -831,6 +831,7 @@ height= abs(height); /* hrumf! */ + /* XXX: there are work arounds for this in the panel and file browse code. */ if(scroll & V2D_SCROLL_HORIZONTAL) width -= V2D_SCROLL_WIDTH; if(scroll & V2D_SCROLL_VERTICAL) @@ -1397,8 +1398,14 @@ if (scrollers->hor_min > scrollers->hor_max) scrollers->hor_min= scrollers->hor_max; /* prevent sliders from being too small, and disappearing */ - if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) - scrollers->hor_max+= V2D_SCROLLER_HANDLE_SIZE; + if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) { + scrollers->hor_max= scrollers->hor_min + V2D_SCROLLER_HANDLE_SIZE; + + if(scrollers->hor_max > hor.xmax) { + scrollers->hor_max= hor.xmax; + scrollers->hor_min= MAX2(scrollers->hor_max - V2D_SCROLLER_HANDLE_SIZE, hor.xmin); + } + } /* check whether sliders can disappear */ if(v2d->keeptot) { @@ -1429,8 +1436,14 @@ if (scrollers->vert_min > scrollers->vert_max) scrollers->vert_min= scrollers->vert_max; /* prevent sliders from being too small, and disappearing */ - if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) - scrollers->vert_max+= V2D_SCROLLER_HANDLE_SIZE; + if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) { + scrollers->vert_max= scrollers->vert_min + V2D_SCROLLER_HANDLE_SIZE; + + if(scrollers->vert_max > vert.ymax) { + scrollers->vert_max= vert.ymax; + scrollers->vert_min= MAX2(scrollers->vert_max - V2D_SCROLLER_HANDLE_SIZE, vert.ymin); + } + } /* check whether sliders can disappear */ if(v2d->keeptot) { Modified: trunk/blender/source/blender/editors/space_file/file_draw.c =================================================================== --- trunk/blender/source/blender/editors/space_file/file_draw.c 2009-09-28 12:10:13 UTC (rev 23526) +++ trunk/blender/source/blender/editors/space_file/file_draw.c 2009-09-28 12:10:23 UTC (rev 23527) @@ -133,24 +133,24 @@ void file_draw_buttons(const bContext *C, ARegion *ar) { /* Button layout. */ - const short min_x = 10; - const short max_x = ar->winx - 10; - const short line1_y = IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN*2; - const short line2_y = IMASEL_BUTTONS_MARGIN; - const short input_minw = 20; - const short btn_h = UI_UNIT_Y; - const short btn_fn_w = UI_UNIT_X; - const short btn_minw = 80; - const short btn_margin = 20; - const short separator = 4; + const int min_x = 10; + const int max_x = ar->winx - 10; + const int line1_y = IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN*2; + const int line2_y = IMASEL_BUTTONS_MARGIN; + const int input_minw = 20; + const int btn_h = UI_UNIT_Y; + const int btn_fn_w = UI_UNIT_X; + const int btn_minw = 80; + const int btn_margin = 20; + const int separator = 4; /* Additional locals. */ char name[20]; - short loadbutton; - short fnumbuttons; - short available_w = max_x - min_x; - short line1_w = available_w; - short line2_w = available_w; + int loadbutton; + int fnumbuttons; + int available_w = max_x - min_x; + int line1_w = available_w; + int line2_w = available_w; uiBut* but; uiBlock* block; @@ -230,7 +230,7 @@ } -static void draw_tile(short sx, short sy, short width, short height, int colorid, int shade) +static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade) { UI_ThemeColorShade(colorid, shade); uiSetRoundBox(15); @@ -310,7 +310,7 @@ return ICON_FILE_BLANK; } -static void file_draw_icon(short sx, short sy, int icon, short width, short height) +static void file_draw_icon(int sx, int sy, int icon, int width, int height) { float x,y; int blend=0; @@ -326,9 +326,9 @@ } -static void file_draw_string(short sx, short sy, const char* string, float width, short height, int flag) +static void file_draw_string(int sx, int sy, const char* string, float width, int height, int flag) { - short soffs; + int soffs; char fname[FILE_MAXFILE]; float sw; float x,y; @@ -350,18 +350,19 @@ View2D *v2d= &ar->v2d; ED_fileselect_init_layout(sfile, ar); - UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); + /* +SCROLL_HEIGHT is bad hack to work around issue in UI_view2d_totRect_set */ + UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height+V2D_SCROLL_HEIGHT); } -static void file_draw_preview(short sx, short sy, ImBuf *imb, FileLayout *layout, short dropshadow) +static void file_draw_preview(int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow) { if (imb) { float fx, fy; float dx, dy; - short xco, yco; + int xco, yco; float scaledx, scaledy; float scale; - short ex, ey; + int ex, ey; if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) { if (imb->x > imb->y) { @@ -379,8 +380,8 @@ scaledy = (float)imb->y; scale = 1.0; } - ex = (short)scaledx; - ey = (short)scaledy; + ex = (int)scaledx; + ey = (int)scaledy; fx = ((float)layout->prv_w - (float)ex)/2.0f; fy = ((float)layout->prv_h - (float)ey)/2.0f; dx = (fx + 0.5f + layout->prv_border_x); @@ -442,7 +443,7 @@ static void draw_background(FileLayout *layout, View2D *v2d) { int i; - short sy; + int sy; /* alternating flat shade background */ for (i=0; (i <= layout->rows); i+=2) @@ -457,7 +458,7 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) { - short sx; + int sx; /* vertical column dividers */ sx = v2d->tot.xmin; @@ -483,7 +484,7 @@ int numfiles; int numfiles_layout; int colorid = 0; - short sx, sy; + int sx, sy; int offset; int i; float sw, spos; @@ -491,12 +492,6 @@ numfiles = filelist_numfiles(files); - sx = ar->v2d.tot.xmin + layout->tile_border_x/2; - sy = ar->v2d.cur.ymax - layout->tile_border_y; - - offset = ED_fileselect_layout_offset(layout, 0, 0); - if (offset<0) offset=0; - if (params->display != FILE_IMGDISPLAY) { draw_background(layout, v2d); @@ -504,9 +499,9 @@ draw_dividers(layout, v2d); } - sx = ar->v2d.cur.xmin + layout->tile_border_x; - sy = ar->v2d.cur.ymax - layout->tile_border_y; - + offset = ED_fileselect_layout_offset(layout, ar->v2d.cur.xmin, -ar->v2d.cur.ymax); + if (offset<0) offset=0; + numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); for (i=offset; (i < numfiles) && (i<offset+numfiles_layout); ++i) @@ -552,7 +547,7 @@ sw = file_string_width(file->relname); if (file->flags & EDITING) { - short but_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : layout->column_widths[COLUMN_NAME]; + int but_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : layout->column_widths[COLUMN_NAME]; uiBlock *block = uiBeginBlock(C, ar, "FileName", UI_EMBOSS); uiBut *but = uiDefBut(block, TEX, 1, "", spos, sy-layout->tile_h-3, but_width, layout->textheight*2, file->relname, 1.0f, (float)FILE_MAX,0,0,""); @@ -573,15 +568,14 @@ spos += layout->column_widths[COLUMN_NAME] + 12; if (!(file->type & S_IFDIR)) { sw = file_string_width(file->size); - spos += layout->column_widths[COLUMN_SIZE] + 12 - sw; file_draw_string(spos, sy, file->size, sw+1, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_SIZE] + 12; } } else if (params->display == FILE_LONGDISPLAY) { spos += layout->column_widths[COLUMN_NAME] + 12; #ifndef WIN32 /* rwx rwx rwx */ - spos += 20; sw = file_string_width(file->mode1); file_draw_string(spos, sy, file->mode1, sw, layout->tile_h, FILE_SHORTEN_END); spos += layout->column_widths[COLUMN_MODE1] + 12; @@ -609,8 +603,8 @@ if (!(file->type & S_IFDIR)) { sw = file_string_width(file->size); - spos += layout->column_widths[COLUMN_SIZE] + 12 - sw; file_draw_string(spos, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END); + spos += layout->column_widths[COLUMN_SIZE] + 12; } } } Modified: trunk/blender/source/blender/editors/space_file/file_ops.c =================================================================== --- trunk/blender/source/blender/editors/space_file/file_ops.c 2009-09-28 12:10:13 UTC (rev 23526) +++ trunk/blender/source/blender/editors/space_file/file_ops.c 2009-09-28 12:10:23 UTC (rev 23527) @@ -68,7 +68,7 @@ /* ---------- FILE SELECTION ------------ */ -static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, short x, short y) +static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, int x, int y) { float fx,fy; int active_file = -1; Modified: trunk/blender/source/blender/editors/space_file/filesel.c =================================================================== @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs