diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 54 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.h | 15 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 39 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 8 |
6 files changed, 101 insertions, 74 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index bf71f2294c0..971a0b3ad06 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -450,19 +450,21 @@ void file_draw_list(const bContext *C, ARegion *ar) if (offset<0) offset=0; /* alternating flat shade background */ - for (i=offset; (i <= numfiles); ++i) + for (i=0; (i <= layout->rows); ++i) { - ED_fileselect_layout_tilepos(layout, i, &sx, &sy); - sx = v2d->tot.xmin; - sy = v2d->tot.ymax - (sy + layout->tile_border_y); - //sy = v2d->tot.ymax - sy; + sx = v2d->cur.xmin; + sy = v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; - if (i % 2) UI_ThemeColor(TH_BACK); - else UI_ThemeColorShade(TH_BACK, -7); - glRectf(v2d->tot.xmin, sy, v2d->tot.xmax, sy+layout->tile_h+2*layout->tile_border_y); + if (i % 2) { + UI_ThemeColor(TH_BACK); + } else { + UI_ThemeColorShade(TH_BACK, -7); + } + glRectf(v2d->cur.xmin, sy, v2d->cur.xmax, sy+layout->tile_h+2*layout->tile_border_y); } /* vertical column dividers */ + sx = v2d->tot.xmin; while (sx < ar->v2d.cur.xmax) { sx += (sfile->layout->tile_w+2*sfile->layout->tile_border_x); @@ -490,12 +492,7 @@ void file_draw_list(const bContext *C, ARegion *ar) } else if (file->flags & ACTIVE) { colorid = TH_HILITE; draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,0); - } else { - /* - colorid = TH_PANEL; - draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid); - */ - } + } spos = sx; file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH); @@ -503,14 +500,16 @@ void file_draw_list(const bContext *C, ARegion *ar) UI_ThemeColor4(TH_TEXT); - // sw = shorten_filesize(file->size, FILE_SHORTEN_FSIZE_WIDTHONLY); - sw = UI_GetStringWidth(G.font, file->size, 0); - file_draw_string(spos, sy, file->relname, layout->tile_w - sw - 5, layout->tile_h, FILE_SHORTEN_END); - spos += filelist_maxnamelen(sfile->files); + sw = UI_GetStringWidth(G.font, file->relname, 0); + file_draw_string(spos, sy, file->relname, sw, layout->tile_h, FILE_SHORTEN_END); + spos += filelist_column_len(sfile->files, COLUMN_NAME) + 10; if (params->display == FILE_SHOWSHORT) { - if (!(file->type & S_IFDIR)) - file_draw_string(sx + layout->tile_w - layout->tile_border_x - sw, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END); + if (!(file->type & S_IFDIR)) { + sw = UI_GetStringWidth(G.font, file->size, 0); + spos += filelist_column_len(sfile->files, COLUMN_SIZE) + 10 - sw; + file_draw_string(spos, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END); + } } else { #if 0 // XXX TODO: add this for non-windows systems /* rwx rwx rwx */ @@ -531,17 +530,18 @@ void file_draw_list(const bContext *C, ARegion *ar) file_draw_string(spos, sy, file->owner, sw, layout->tile_h); #endif - spos += 50; + sw = UI_GetStringWidth(G.font, file->date, 0); file_draw_string(spos, sy, file->date, sw, layout->tile_h, FILE_SHORTEN_END); + spos += filelist_column_len(sfile->files, COLUMN_DATE) + 10; - spos += 100; sw = UI_GetStringWidth(G.font, file->time, 0); file_draw_string(spos, sy, file->time, sw, layout->tile_h, FILE_SHORTEN_END); - + spos += filelist_column_len(sfile->files, COLUMN_TIME) + 10; + if (!(file->type & S_IFDIR)) { sw = UI_GetStringWidth(G.font, file->size, 0); - spos += 200-sw; + spos += filelist_column_len(sfile->files, COLUMN_SIZE) + 10 - sw; file_draw_string(spos, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END); } } @@ -583,9 +583,9 @@ static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, FSMenuCate } if (fsmenu_is_selected(fsmenu, category, i) ) { UI_ThemeColor(TH_HILITE); - /* uiSetRoundBox(15); - * uiRoundBox(sx, sy - linestep, sx + bmwidth, sy, 4.0f); */ - glRectf(ar->v2d.cur.xmin, sy-linestep, ar->v2d.cur.xmax + 2*TILE_BORDER_X, sy); + //uiSetRoundBox(15); + uiRoundBox(sx, sy - linestep, ar->v2d.cur.xmax - TILE_BORDER_X, sy, 4.0f); + // glRectf(ar->v2d.cur.xmin, sy-linestep, ar->v2d.cur.xmax + 2*TILE_BORDER_X, sy); UI_ThemeColor(TH_TEXT); } else { UI_ThemeColor(TH_TEXT_HI); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 20e6b9b16a8..bafd81ae73e 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -117,17 +117,19 @@ static void file_deselect_all(SpaceFile* sfile) } } -static void file_select(SpaceFile* sfile, FileSelectParams* params, ARegion* ar, const rcti* rect, short val) +static void file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, short val) { int first_file = -1; int last_file = -1; int act_file; short selecting = (val == LEFTMOUSE); + FileSelectParams *params = ED_fileselect_get_params(sfile); + FileLayout *layout = ED_fileselect_get_layout(sfile, ar); int numfiles = filelist_numfiles(sfile->files); params->selstate = NOTACTIVE; - if ( (params->display == FILE_IMGDISPLAY) || (params->display == FILE_LONGDISPLAY) ) { + if ( (layout->flag == FILE_LAYOUT_HOR) ) { first_file = find_file_mouse_hor(sfile, ar, rect->xmin, rect->ymax); last_file = find_file_mouse_hor(sfile, ar, rect->xmax, rect->ymin); } else { @@ -209,7 +211,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) rect.xmax= RNA_int_get(op->ptr, "xmax"); rect.ymax= RNA_int_get(op->ptr, "ymax"); - file_select(sfile, sfile->params, ar, &rect, val ); + file_select(sfile, ar, &rect, val ); WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_FINISHED; } @@ -250,7 +252,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) /* single select, deselect all selected first */ file_deselect_all(sfile); - file_select(sfile, sfile->params, ar, &rect, val ); + file_select(sfile, ar, &rect, val ); WM_event_add_notifier(C, NC_WINDOW, NULL); } return OPERATOR_FINISHED; @@ -446,20 +448,22 @@ void FILE_OT_loadimages(wmOperatorType *ot) int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { FileSelectParams* params; + FileLayout* layout; int numfiles, actfile; if(sfile==NULL || sfile->files==NULL) return 0; numfiles = filelist_numfiles(sfile->files); params = ED_fileselect_get_params(sfile); - - if ( (params->display == FILE_IMGDISPLAY) || (params->display == FILE_LONGDISPLAY)) { + layout = ED_fileselect_get_layout(sfile, ar); + + if ( (layout->flag == FILE_LAYOUT_HOR)) { actfile = find_file_mouse_hor(sfile, ar, mx , my); } else { actfile = find_file_mouse_vert(sfile, ar, mx, my); } - if (actfile >= 0 && actfile < numfiles ) { + if (params && (actfile >= 0) && (actfile < numfiles) ) { params->active_file=actfile; return 1; } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 2a2aa610f96..e38aed07577 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -120,7 +120,7 @@ typedef struct FileList short hide_dot; unsigned int filter; short changed; - int maxnamelen; + int columns[MAX_FILE_COLUMN]; ListBase loadimages; ListBase threads; } FileList; @@ -659,9 +659,9 @@ void filelist_setfilter(struct FileList* filelist, unsigned int filter) filelist->filter = filter; } -int filelist_maxnamelen(struct FileList* filelist) +int filelist_column_len(struct FileList* filelist, FileListColumns column) { - return filelist->maxnamelen; + return filelist->columns[column]; } void filelist_readdir(struct FileList* filelist) @@ -688,13 +688,31 @@ void filelist_readdir(struct FileList* filelist) BLI_init_threads(&filelist->threads, exec_loadimages, 2); } - filelist->maxnamelen = 0; + for (i=0; i<MAX_FILE_COLUMN; ++i) { + filelist->columns[i] = 0; + } + for (i=0; (i < filelist->numfiles); ++i) { struct direntry* file = filelist_file(filelist, i); if (file) { - int len = UI_GetStringWidth(G.font, file->relname,0)+UI_GetStringWidth(G.font, file->size,0); - if (len > filelist->maxnamelen) filelist->maxnamelen = len; + int len; + len = UI_GetStringWidth(G.font, file->relname,0); + if (len > filelist->columns[COLUMN_NAME]) filelist->columns[COLUMN_NAME] = len; + len = UI_GetStringWidth(G.font, file->date,0); + if (len > filelist->columns[COLUMN_DATE]) filelist->columns[COLUMN_DATE] = len; + len = UI_GetStringWidth(G.font, file->time,0); + if (len > filelist->columns[COLUMN_TIME]) filelist->columns[COLUMN_TIME] = len; + len = UI_GetStringWidth(G.font, file->size,0); + if (len > filelist->columns[COLUMN_SIZE]) filelist->columns[COLUMN_SIZE] = len; + len = UI_GetStringWidth(G.font, file->mode1,0); + if (len > filelist->columns[COLUMN_MODE1]) filelist->columns[COLUMN_MODE1] = len; + len = UI_GetStringWidth(G.font, file->mode2,0); + if (len > filelist->columns[COLUMN_MODE2]) filelist->columns[COLUMN_MODE2] = len; + len = UI_GetStringWidth(G.font, file->mode3,0); + if (len > filelist->columns[COLUMN_MODE3]) filelist->columns[COLUMN_MODE3] = len; + len = UI_GetStringWidth(G.font, file->owner,0); + if (len > filelist->columns[COLUMN_OWNER]) filelist->columns[COLUMN_OWNER] = len; } } } @@ -730,17 +748,6 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) if(BLO_has_bfile_extension(file->relname)) { file->flags |= BLENDERFILE; - if(filelist->type==FILE_LOADLIB) { - char name[FILE_MAXDIR+FILE_MAXFILE]; - BLI_strncpy(name, filelist->dir, sizeof(name)); - strcat(name, file->relname); - - /* prevent current file being used as acceptable dir */ - if (BLI_streq(G.main->name, name)==0) { - file->type &= ~S_IFMT; - file->type |= S_IFDIR; - } - } } else if(BLI_testextensie(file->relname, ".py")) { file->flags |= PYSCRIPTFILE; } else if(BLI_testextensie(file->relname, ".txt")) { diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index 62fa05d94d3..26a2d46f5a7 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -42,6 +42,19 @@ struct direntry; struct BlendHandle; struct Scene; +#define MAX_FILE_COLUMN 8 + +typedef enum FileListColumns { + COLUMN_NAME = 0, + COLUMN_DATE, + COLUMN_TIME, + COLUMN_SIZE, + COLUMN_MODE1, + COLUMN_MODE2, + COLUMN_MODE3, + COLUMN_OWNER +} FileListColumns; + struct FileList * filelist_new(); void filelist_init_icons(); void filelist_free_icons(); @@ -65,7 +78,7 @@ struct ImBuf * filelist_getimage(struct FileList* filelist, int index); struct ImBuf * filelist_geticon(struct FileList* filelist, int index); short filelist_changed(struct FileList* filelist); void filelist_readdir(struct FileList* filelist); -int filelist_maxnamelen(struct FileList* filelist); +int filelist_column_len(struct FileList* filelist, FileListColumns column); int filelist_empty(struct FileList* filelist); void filelist_parent(struct FileList* filelist); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 9eef35d47a5..a422bda9503 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -197,20 +197,33 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) } sfile->layout->height= sfile->layout->rows*(sfile->layout->tile_h+2*sfile->layout->tile_border_y) + sfile->layout->tile_border_y*2; sfile->layout->flag = FILE_LAYOUT_VER; - } else if (params->display == FILE_SHORTDISPLAY) { + } else { sfile->layout->prv_w = 0; sfile->layout->prv_h = 0; sfile->layout->tile_border_x = 8; sfile->layout->tile_border_y = 2; sfile->layout->prv_border_x = 0; sfile->layout->prv_border_y = 0; - sfile->layout->tile_w = 240; sfile->layout->tile_h = U.fontsize*3/2; sfile->layout->height= v2d->cur.ymax - v2d->cur.ymin; sfile->layout->rows = sfile->layout->height / (sfile->layout->tile_h + 2*sfile->layout->tile_border_y);; - - maxlen = filelist_maxnamelen(sfile->files); - sfile->layout->tile_w = maxlen + 100; + + if (params->display == FILE_SHORTDISPLAY) { + maxlen = filelist_column_len(sfile->files, COLUMN_NAME) + + filelist_column_len(sfile->files, COLUMN_SIZE); + maxlen += 20+2*10; // for icon and space between columns + } else { + maxlen = filelist_column_len(sfile->files, COLUMN_NAME) + + filelist_column_len(sfile->files, COLUMN_DATE) + + filelist_column_len(sfile->files, COLUMN_TIME) + + filelist_column_len(sfile->files, COLUMN_SIZE) /* + + filelist_column_len(sfile->files, COLUMN_MODE1) + + filelist_column_len(sfile->files, COLUMN_MODE2) + + filelist_column_len(sfile->files, COLUMN_MODE3) + + filelist_column_len(sfile->files, COLUMN_OWNER) */ ; + maxlen += 20+4*10; // for icon and space between columns + } + sfile->layout->tile_w = maxlen + 40; if(sfile->layout->rows > 0) sfile->layout->columns = numfiles/sfile->layout->rows + 1; // XXX dirty, modulo is zero else { @@ -219,21 +232,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) } sfile->layout->width = sfile->layout->columns * (sfile->layout->tile_w + 2*sfile->layout->tile_border_x) + sfile->layout->tile_border_x*2; sfile->layout->flag = FILE_LAYOUT_HOR; - } else { - sfile->layout->prv_w = 0; - sfile->layout->prv_h = 0; - sfile->layout->tile_border_x = 8; - sfile->layout->tile_border_y = 2; - sfile->layout->prv_border_x = 0; - sfile->layout->prv_border_y = 0; - sfile->layout->tile_w = v2d->cur.xmax - v2d->cur.xmin - 2*sfile->layout->tile_border_x; - sfile->layout->tile_h = U.fontsize*3/2; - sfile->layout->width= (v2d->cur.xmax - v2d->cur.xmin + 2*sfile->layout->tile_border_x); - sfile->layout->rows= numfiles+1; - sfile->layout->columns= 1; - sfile->layout->height= sfile->layout->rows*(sfile->layout->tile_h+2*sfile->layout->tile_border_y) + sfile->layout->tile_border_y*2; - sfile->layout->flag = FILE_LAYOUT_VER; - } + } } FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index b19245cba06..b2fad2a387c 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -183,7 +183,9 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - FileSelectParams* params = sfile->params; + FileSelectParams *params = ED_fileselect_get_params(sfile); + FileLayout *layout=NULL; + View2D *v2d= &ar->v2d; View2DScrollers *scrollers; float col[3]; @@ -195,6 +197,8 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) params->active_file = -1; // added this so it opens nicer (ton) } + layout = ED_fileselect_get_layout(sfile, ar); + if (filelist_empty(sfile->files)) { unsigned int filter = 0; @@ -217,7 +221,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); /* Allow dynamically sliders to be set, saves notifiers etc. */ - if (sfile->params && ( (sfile->params->display == FILE_IMGDISPLAY) || (sfile->params->display == FILE_LONGDISPLAY)) ) { + if (layout && (layout->flag == FILE_LAYOUT_VER)) { v2d->scroll = V2D_SCROLL_RIGHT; v2d->keepofs &= ~V2D_LOCKOFS_Y; v2d->keepofs |= V2D_LOCKOFS_X; |