diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_fileselect.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_header.c | 39 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 99 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 16 |
8 files changed, 83 insertions, 116 deletions
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index 7cbef4984d7..34aefa91225 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -35,7 +35,6 @@ struct SpaceFile; #define FILE_IMGDISPLAY 3 typedef struct FileSelectParams { - int type; /* the mode of the filebrowser, FILE_BLENDER, FILE_SPECIAL, FILE_MAIN or FILE_LOADLIB */ char title[24]; /* title, also used for the text of the execute button */ char dir[240]; /* directory */ char file[80]; /* file */ @@ -96,8 +95,8 @@ typedef struct FileLayout FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile); -short ED_fileselect_set_params(struct SpaceFile *sfile, int type, const char *title, const char *path, - short flag, short display, short filter); +short ED_fileselect_set_params(struct SpaceFile *sfile, const char *title, const char *path, + short flag, short display, short filter, short sort); void ED_fileselect_reset_params(struct SpaceFile *sfile); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index bbe8245a3f7..6ed8f87d987 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -444,13 +444,11 @@ void file_draw_list(const bContext *C, ARegion *ar) int colorid = 0; short sx, sy; int offset; - short type; int i; float sw, spos; numfiles = filelist_numfiles(files); - type = filelist_gettype(files); - + sx = ar->v2d.tot.xmin + layout->tile_border_x/2; sy = ar->v2d.cur.ymax - layout->tile_border_y; diff --git a/source/blender/editors/space_file/file_header.c b/source/blender/editors/space_file/file_header.c index bfa0a553334..4799003d6c7 100644 --- a/source/blender/editors/space_file/file_header.c +++ b/source/blender/editors/space_file/file_header.c @@ -63,6 +63,7 @@ #define B_SORTIMASELLIST 1 #define B_RELOADIMASELDIR 2 #define B_FILTERIMASELDIR 3 +#define B_HIDEDOTFILES 4 /* ************************ header area region *********************** */ @@ -88,6 +89,14 @@ static void do_file_header_buttons(bContext *C, void *arg, int event) } } WM_event_add_notifier(C, NC_WINDOW, NULL); + break; + case B_HIDEDOTFILES: + if(sfile->params) { + filelist_free(sfile->files); + filelist_hidedot(sfile->files, sfile->params->flag & FILE_HIDE_DOT); + WM_event_add_notifier(C, NC_WINDOW, NULL); + } + break; } } @@ -126,15 +135,14 @@ void file_header_buttons(const bContext *C, ARegion *ar) xco += 5; - if (sfile->params->type != FILE_MAIN) { - uiBlockBeginAlign(block); - uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_SHORTDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_SHORTDISPLAY, 0, 0, "Displays short file description"); - uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_LONGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_LONGDISPLAY, 0, 0, "Displays long file description"); - uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_IMGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_IMGDISPLAY, 0, 0, "Displays files as thumbnails"); - uiBlockEndAlign(block); - - xco+=XIC; - } + uiBlockBeginAlign(block); + uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_SHORTDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_SHORTDISPLAY, 0, 0, "Displays short file description"); + uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_LONGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_LONGDISPLAY, 0, 0, "Displays long file description"); + uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_IMGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_IMGDISPLAY, 0, 0, "Displays files as thumbnails"); + uiBlockEndAlign(block); + + xco+=XIC; + uiBlockBeginAlign(block); uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTALPHA, xco+=XIC, yco, XIC,YIC, ¶ms->sort, 1.0, 0.0, 0, 0, "Sorts files alphabetically"); @@ -144,17 +152,8 @@ void file_header_buttons(const bContext *C, ARegion *ar) uiBlockEndAlign(block); xco+=XIC; - - /* replace with consistent sub-region collapsing - if (sfile->params->type != FILE_MAIN) { - uiBlockBeginAlign(block); - // uiDefIconButBitS(block, TOG, FILE_BOOKMARKS, B_RELOADIMASELDIR, ICON_BOOKMARKS,xco+=XIC,0,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Toggles Bookmarks on/off"); - uiDefIconButO(block, TOG, "FILE_OT_bookmark_toggle", WM_OP_INVOKE_DEFAULT, ICON_BOOKMARKS, xco+XIC,yco,20,20, "Toggle Bookmarks"); - uiBlockEndAlign(block); - xco+=XIC; - } - */ - + uiDefIconButBitS(block, TOG, FILE_HIDE_DOT, B_HIDEDOTFILES, ICON_GHOST,xco+=XIC,yco,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Hide dot files"); + xco+=XIC; uiDefIconButBitS(block, TOG, FILE_FILTER, B_FILTERIMASELDIR, ICON_FILTER,xco+=XIC,yco,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Filter files"); if (params->flag & FILE_FILTER) { diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 01cdf559c58..f60b6f08348 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -113,7 +113,6 @@ typedef struct FileList int numfiles; int numfiltered; char dir[FILE_MAX]; - short type; int has_func; short prv_w; short prv_h; @@ -358,12 +357,6 @@ void filelist_free_icons() struct FileList* filelist_new() { FileList* p = MEM_callocN( sizeof(FileList), "filelist" ); - p->filelist = 0; - p->numfiles = 0; - p->dir[0] = '\0'; - p->type = 0; - p->has_func = 0; - p->filter = 0; return p; } @@ -373,7 +366,6 @@ struct FileList* filelist_copy(struct FileList* filelist) BLI_strncpy(p->dir, filelist->dir, FILE_MAX); p->filelist = NULL; p->fidx = NULL; - p->type = filelist->type; return p; } @@ -413,6 +405,7 @@ void filelist_free(struct FileList* filelist) filelist->filelist = 0; filelist->filter = 0; filelist->numfiltered =0; + filelist->hide_dot =0; } int filelist_numfiles(struct FileList* filelist) @@ -510,48 +503,46 @@ void filelist_loadimage(struct FileList* filelist, int index) if (!filelist->filelist[fidx].image) { - if (filelist->type != FILE_MAIN) - { - if ( (filelist->filelist[fidx].flags & IMAGEFILE) || (filelist->filelist[fidx].flags & MOVIEFILE) ) { - imb = IMB_thumb_read(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL); - } - if (imb) { - if (imb->x > imb->y) { - scaledx = (float)imgwidth; - scaledy = ( (float)imb->y/(float)imb->x )*imgwidth; - } - else { - scaledy = (float)imgheight; - scaledx = ( (float)imb->x/(float)imb->y )*imgheight; - } - ex = (short)scaledx; - ey = (short)scaledy; - - dx = imgwidth - ex; - dy = imgheight - ey; - - // IMB_scaleImBuf(imb, ex, ey); - filelist->filelist[fidx].image = imb; - } else { - /* prevent loading image twice */ - FileImage* limg = filelist->loadimages.first; - short found= 0; - while(limg) { - if (limg->index == fidx) { - found= 1; - break; - } - limg= limg->next; - } - if (!found) { - FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); - limg->index= fidx; - limg->lock= 0; - limg->filelist= filelist; - BLI_addtail(&filelist->loadimages, limg); + + if ( (filelist->filelist[fidx].flags & IMAGEFILE) || (filelist->filelist[fidx].flags & MOVIEFILE) ) { + imb = IMB_thumb_read(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL); + } + if (imb) { + if (imb->x > imb->y) { + scaledx = (float)imgwidth; + scaledy = ( (float)imb->y/(float)imb->x )*imgwidth; + } + else { + scaledy = (float)imgheight; + scaledx = ( (float)imb->x/(float)imb->y )*imgheight; + } + ex = (short)scaledx; + ey = (short)scaledy; + + dx = imgwidth - ex; + dy = imgheight - ey; + + // IMB_scaleImBuf(imb, ex, ey); + filelist->filelist[fidx].image = imb; + } else { + /* prevent loading image twice */ + FileImage* limg = filelist->loadimages.first; + short found= 0; + while(limg) { + if (limg->index == fidx) { + found= 1; + break; } - } - } + limg= limg->next; + } + if (!found) { + FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); + limg->index= fidx; + limg->lock= 0; + limg->filelist= filelist; + BLI_addtail(&filelist->loadimages, limg); + } + } } } @@ -826,16 +817,6 @@ void filelist_swapselect(struct FileList* filelist) } } -void filelist_settype(struct FileList* filelist, int type) -{ - filelist->type = type; -} - -short filelist_gettype(struct FileList* filelist) -{ - return filelist->type; -} - void filelist_sort(struct FileList* filelist, short sort) { struct direntry *file; diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index 4aa8359b068..f10c89926d6 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -70,8 +70,7 @@ void filelist_readdir(struct FileList* filelist); int filelist_empty(struct FileList* filelist); void filelist_parent(struct FileList* filelist); void filelist_setfiletypes(struct FileList* filelist, short has_quicktime); -void filelist_settype(struct FileList* filelist, int type); -short filelist_gettype(struct FileList* filelist); + #ifdef __cplusplus } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index cbd1457e562..d57fc7f90bc 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -84,13 +84,13 @@ FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile) { if (!sfile->params) { - ED_fileselect_set_params(sfile, FILE_UNIX, "", "/", 0, FILE_SHORTDISPLAY, 0); + ED_fileselect_set_params(sfile, "", "/", 0, FILE_SHORTDISPLAY, 0, FILE_SORTALPHA); } return sfile->params; } -short ED_fileselect_set_params(SpaceFile *sfile, int type, const char *title, const char *path, - short flag, short display, short filter) +short ED_fileselect_set_params(SpaceFile *sfile, const char *title, const char *path, + short flag, short display, short filter, short sort) { char name[FILE_MAX], dir[FILE_MAX], file[FILE_MAX]; FileSelectParams *params; @@ -101,39 +101,26 @@ short ED_fileselect_set_params(SpaceFile *sfile, int type, const char *title, co params = sfile->params; - params->type = type; params->flag = flag; params->display = display; params->filter = filter; + params->sort = sort; BLI_strncpy(params->title, title, sizeof(params->title)); BLI_strncpy(name, path, sizeof(name)); BLI_convertstringcode(name, G.sce); - - switch(type) { - case FILE_MAIN: - break; - case FILE_LOADLIB: - break; - case FILE_BLENDER: - case FILE_LOADFONT: - default: - { - BLI_split_dirfile(name, dir, file); - BLI_strncpy(params->file, file, sizeof(params->file)); - BLI_strncpy(params->dir, dir, sizeof(params->dir)); - BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */ - } - break; - } + + BLI_split_dirfile(name, dir, file); + BLI_strncpy(params->file, file, sizeof(params->file)); + BLI_strncpy(params->dir, dir, sizeof(params->dir)); + BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */ return 1; } void ED_fileselect_reset_params(SpaceFile *sfile) { - sfile->params->type = FILE_UNIX; sfile->params->flag = 0; sfile->params->title[0] = '\0'; } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 084fcf1e5f6..37d8f2bffa4 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -156,7 +156,6 @@ static SpaceLink *file_duplicate(SpaceLink *sl) sfilen->params= MEM_dupallocN(sfileo->params); filelist_setdir(sfilen->files, sfilen->params->dir); - filelist_settype(sfilen->files, sfilen->params->type); } if (sfileo->layout) { sfilen->layout= MEM_dupallocN(sfileo->layout); @@ -193,7 +192,6 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) if (!sfile->files) { sfile->files = filelist_new(); filelist_setdir(sfile->files, params->dir); - filelist_settype(sfile->files, params->type); params->active_file = -1; // added this so it opens nicer (ton) } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e142a5f9640..fc0f1496c6a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -773,12 +773,9 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa case EVT_FILESELECT_OPEN: case EVT_FILESELECT_FULL_OPEN: { - int filetype= FILE_BLENDER; + short flag =0; short display =FILE_SHORTDISPLAY; short filter =0; short sort =FILE_SORTALPHA; char *path= RNA_string_get_alloc(handler->op->ptr, "filename", NULL, 0); - if(RNA_struct_find_property(handler->op->ptr, "filetype")) - filetype= RNA_int_get(handler->op->ptr, "filetype"); - if(event->val==EVT_FILESELECT_OPEN) ED_area_newspace(C, handler->op_area, SPACE_FILE); else @@ -788,7 +785,16 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa sfile= (SpaceFile*)CTX_wm_space_data(C); sfile->op= handler->op; - ED_fileselect_set_params(sfile, filetype, handler->op->type->name, path, 0, FILE_SHORTDISPLAY, 0); + /* XXX for now take the settings from the existing (previous) filebrowser + should be stored in settings and passed via the operator */ + if (sfile->params) { + flag = sfile->params->flag; + filter = sfile->params->filter; + display = sfile->params->display; + sort = sfile->params->sort; + } + + ED_fileselect_set_params(sfile, handler->op->type->name, path, flag, display, filter, sort); MEM_freeN(path); action= WM_HANDLER_BREAK; |