diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-28 20:46:14 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-28 20:46:14 +0400 |
commit | aa44603146e87f29f08cee2abab7e0ddd89222c5 (patch) | |
tree | df7c7a0f0ecec9317c0350584a83644d9517c40c /source/blender/editors | |
parent | 74e4ad20c9e8d19f85aaa2995652e3f65bdfc0c9 (diff) |
2.5: File browser
* Side panels now use list widgets.
* Enabled theme colors for side panel.
* Add button in bookmarks panel.
* Operator panel title now uses operator name.
* For unix, added / to system, and home and desktop to bookmarks.
* For opening fileselect with filter, cleaned up the code a bit,
adding WM_operator_properties_filesel instead of duplicating code.
* Also added filter for all operators calling fileselect, only image
and file open did it before.
* Hide . files by default, and also hide files ending with ~.
* Added back .. (but not .) in the file list, I really missed this.
* File highlight now only happens when you're actually over a file,
instead staying after you move the mouse away.
* Fix some redraw/refresh issues.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/curve/editfont.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screendump.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 119 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_panels.c | 145 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 29 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 35 | ||||
-rw-r--r-- | source/blender/editors/space_info/info_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 4 |
12 files changed, 238 insertions, 156 deletions
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 9f2bd6f26f9..46be95063ec 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -416,7 +416,7 @@ void FONT_OT_file_paste(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "File path of text file to load."); + WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE); } /******************* paste buffer operator ********************/ diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 81da74217ec..d69c6dfcdba 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -173,7 +173,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->flag= 0; - RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE); RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); } diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index f2906686db5..1074a24f9ae 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -153,7 +153,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiBut* but; uiBlock* block; - SpaceFile* sfile = (SpaceFile*) CTX_wm_space_data(C); + SpaceFile* sfile = CTX_wm_space_file(C); FileSelectParams* params = ED_fileselect_get_params(sfile); /* Initialize UI block. */ @@ -345,7 +345,7 @@ static void file_draw_string(short sx, short sy, const char* string, float width void file_calc_previews(const bContext *C, ARegion *ar) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); View2D *v2d= &ar->v2d; ED_fileselect_init_layout(sfile, ar); @@ -354,7 +354,7 @@ void file_calc_previews(const bContext *C, ARegion *ar) void file_draw_previews(const bContext *C, ARegion *ar) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); FileSelectParams* params= ED_fileselect_get_params(sfile); FileLayout* layout= ED_fileselect_get_layout(sfile, ar); View2D *v2d= &ar->v2d; @@ -517,7 +517,7 @@ static void renamebutton_cb(bContext *C, void *arg1, char *oldname) void file_draw_list(const bContext *C, ARegion *ar) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); FileSelectParams* params = ED_fileselect_get_params(sfile); FileLayout* layout= ED_fileselect_get_layout(sfile, ar); View2D *v2d= &ar->v2d; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 8e64f2a594a..c515ef6e295 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -143,14 +143,20 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s params->active_file = last_file; if(file && S_ISDIR(file->type)) { - /* the path is too long! */ - if (strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) + /* the path is too long and we are not going up! */ + if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) { // XXX error("Path too long, cannot enter this directory"); } else { - BLI_cleanup_dir(G.sce, params->dir); - strcat(params->dir, file->relname); - BLI_add_slash(params->dir); + if (strcmp(file->relname, "..")==0) { + /* avoids /../../ */ + BLI_parent_dir(params->dir); + } else { + BLI_cleanup_dir(G.sce, params->dir); + strcat(params->dir, file->relname); + BLI_add_slash(params->dir); + } + params->file[0] = '\0'; file_change_dir(sfile); retval = FILE_SELECT_DIR; @@ -172,7 +178,7 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s static int file_border_select_exec(bContext *C, wmOperator *op) { ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); short val; rcti rect; @@ -216,24 +222,31 @@ void FILE_OT_select_border(wmOperatorType *ot) static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); short val; rcti rect; + if(ar->regiontype != RGN_TYPE_WINDOW) + return OPERATOR_CANCELLED; + rect.xmin = rect.xmax = event->x - ar->winrct.xmin; rect.ymin = rect.ymax = event->y - ar->winrct.ymin; val = event->val; - if (BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) { + if(!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) + return OPERATOR_CANCELLED; + + /* single select, deselect all selected first */ + file_deselect_all(sfile); + + if (FILE_SELECT_DIR == file_select(sfile, ar, &rect, val )) + WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL); + else + WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL); + + WM_event_add_mousemove(C); /* for directory changes */ + WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL); - /* single select, deselect all selected first */ - file_deselect_all(sfile); - if (FILE_SELECT_DIR == file_select(sfile, ar, &rect, val )) { - WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL); - } else { - WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL); - } - } return OPERATOR_FINISHED; } @@ -254,7 +267,7 @@ void FILE_OT_select(wmOperatorType *ot) static int file_select_all_invoke(bContext *C, wmOperator *op, wmEvent *event) { ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); int numfiles = filelist_numfiles(sfile->files); int i; int select = 1; @@ -299,7 +312,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) static int bookmark_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(RNA_struct_find_property(op->ptr, "dir")) { char entry[256]; @@ -333,7 +346,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) static int bookmark_add_invoke(bContext *C, wmOperator *op, wmEvent *event) { ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); struct FSMenu* fsmenu = fsmenu_get(); struct FileSelectParams* params= ED_fileselect_get_params(sfile); @@ -398,7 +411,7 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) static int loadimages_invoke(bContext *C, wmOperator *op, wmEvent *event) { ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if (sfile->files) { filelist_loadimage_timer(sfile->files); if (filelist_changed(sfile->files)) { @@ -425,31 +438,41 @@ void FILE_OT_loadimages(wmOperatorType *ot) int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { FileSelectParams* params; - int numfiles, actfile; + int numfiles, actfile, origfile; if(sfile==NULL || sfile->files==NULL) return 0; - + numfiles = filelist_numfiles(sfile->files); params = ED_fileselect_get_params(sfile); - actfile = find_file_mouse(sfile, ar, mx , my, 0); - - if (params && (actfile >= 0) && (actfile < numfiles) ) { - params->active_file=actfile; - return 1; - } - params->active_file= -1; - return 0; + origfile= params->active_file; + + mx -= ar->winrct.xmin; + my -= ar->winrct.ymin; + + if(BLI_in_rcti(&ar->v2d.mask, mx, my)) { + actfile = find_file_mouse(sfile, ar, mx , my, 0); + + if((actfile >= 0) && (actfile < numfiles)) + params->active_file=actfile; + else + params->active_file= -1; + } + else + params->active_file= -1; + + return (params->active_file != origfile); } static int file_highlight_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - - if( file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { - ED_area_tag_redraw(CTX_wm_area(C)); - } + SpaceFile *sfile= CTX_wm_space_file(C); + + if(!file_hilight_set(sfile, ar, event->x, event->y)) + return OPERATOR_CANCELLED; + + ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; } @@ -467,7 +490,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot) int file_cancel_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); folderlist_free(sfile->folders_prev); folderlist_free(sfile->folders_next); @@ -492,7 +515,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot) /* sends events now, so things get handled on windowqueue level */ int file_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); char name[FILE_MAX]; if(sfile->op) { @@ -559,7 +582,7 @@ void FILE_OT_exec(struct wmOperatorType *ot) int file_parent_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { if (BLI_has_parent(sfile->params->dir)) { @@ -589,7 +612,7 @@ void FILE_OT_parent(struct wmOperatorType *ot) int file_refresh_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); file_change_dir(sfile); @@ -612,7 +635,7 @@ void FILE_OT_previous(struct wmOperatorType *ot) int file_previous_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { if (!sfile->folders_next) @@ -642,7 +665,7 @@ void FILE_OT_next(struct wmOperatorType *ot) int file_next_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -666,7 +689,7 @@ int file_directory_new_exec(bContext *C, wmOperator *unused) char tmpdir[FILE_MAXFILE]; int i = 1; - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { @@ -706,7 +729,7 @@ int file_directory_exec(bContext *C, wmOperator *unused) { char tmpstr[FILE_MAX]; - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { @@ -741,7 +764,7 @@ int file_directory_exec(bContext *C, wmOperator *unused) int file_filename_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { if (file_select_match(sfile, sfile->params->file)) @@ -768,7 +791,7 @@ void FILE_OT_refresh(struct wmOperatorType *ot) int file_hidedot_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { sfile->params->flag ^= FILE_HIDE_DOT; @@ -849,7 +872,7 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) int file_filenum_exec(bContext *C, wmOperator *op) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); int inc = RNA_int_get(op->ptr, "increment"); if(sfile->params && (inc != 0)) { @@ -909,7 +932,7 @@ void FILE_OT_rename(struct wmOperatorType *ot) int file_delete_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); struct direntry* file; if (sfile->params) { @@ -929,7 +952,7 @@ int file_delete_poll(bContext *C) int file_delete_exec(bContext *C, wmOperator *op) { char str[FILE_MAX]; - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); struct direntry* file; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 351d1619508..f3c18859fb0 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -44,97 +44,150 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "WM_api.h" +#include "WM_types.h" + #include "file_intern.h" #include "fsmenu.h" #include <string.h> -static void do_file_panel_events(bContext *C, void *arg, int event) +static void file_panel_cb(bContext *C, void *arg_entry, void *arg_unused) { + PointerRNA ptr; + char *entry= (char*)arg_entry; + WM_operator_properties_create(&ptr, "FILE_OT_select_bookmark"); + RNA_string_set(&ptr, "dir", entry); + WM_operator_name_call(C, "FILE_OT_select_bookmark", WM_OP_INVOKE_REGION_WIN, &ptr); + WM_operator_properties_free(&ptr); } -static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, int icon, int allow_delete) +static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete) { + SpaceFile *sfile= CTX_wm_space_file(C); uiBlock *block; + uiBut *but; + uiLayout *box, *col; struct FSMenu* fsmenu = fsmenu_get(); - int nentries = fsmenu_get_nentries(fsmenu, category); - int i; + char *curdir= (sfile->params)? sfile->params->dir: ""; + int i, nentries = fsmenu_get_nentries(fsmenu, category); + + /* reset each time */ + *nr= -1; + /* hide if no entries */ + if(nentries == 0) + return; + + /* layout */ uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT); - block= uiLayoutFreeBlock(pa->layout); - uiBlockSetHandleFunc(block, do_file_panel_events, NULL); - uiBlockSetEmboss(block, UI_EMBOSSP); - uiBlockBeginAlign(block); + block= uiLayoutGetBlock(pa->layout); + box= uiLayoutBox(pa->layout); + col= uiLayoutColumn(box, 1); + for (i=0; i< nentries;++i) { char dir[FILE_MAX]; char temp[FILE_MAX]; - uiLayout* layout = uiLayoutRow(pa->layout, UI_LAYOUT_ALIGN_LEFT); + uiLayout* layout = uiLayoutRow(col, 0); char *entry = fsmenu_get_entry(fsmenu, category, i); + /* set this list item as active if we have a match */ + if(strcmp(curdir, entry) == 0) + *nr= i; + /* create nice bookmark name, shows last directory in the full path currently */ BLI_strncpy(temp, entry, FILE_MAX); BLI_add_slash(temp); BLI_getlastdir(temp, dir, FILE_MAX); BLI_del_slash(dir); - /* operator shows the short bookmark name, should eventually have tooltip */ - uiItemStringO(layout, dir, icon, "FILE_OT_select_bookmark", "dir", entry); - if (allow_delete && fsmenu_can_save(fsmenu, category, i) ) + if(dir[0] == 0) + BLI_strncpy(dir, entry, FILE_MAX); + + /* create list item */ + but= uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0,0,UI_UNIT_X*10,UI_UNIT_Y, nr, 0, i, 0, 0, entry); + uiButSetFunc(but, file_panel_cb, entry, NULL); + uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); + + /* create delete button */ + if(allow_delete && fsmenu_can_save(fsmenu, category, i)) { + uiBlockSetEmboss(block, UI_EMBOSSN); uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i); + uiBlockSetEmboss(block, UI_EMBOSS); + } } - uiBlockEndAlign(block); } static void file_panel_system(const bContext *C, Panel *pa) { - file_panel_category(C, pa, FS_CATEGORY_SYSTEM, ICON_DISK_DRIVE, 0); + SpaceFile *sfile= CTX_wm_space_file(C); + + if(sfile) + file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0); } static void file_panel_bookmarks(const bContext *C, Panel *pa) { - file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, ICON_BOOKMARKS, 1); -} + SpaceFile *sfile= CTX_wm_space_file(C); + uiLayout *row; + if(sfile) { + row= uiLayoutRow(pa->layout, 0); + uiItemO(row, "Add", ICON_ZOOMIN, "file.add_bookmark"); + uiItemL(row, NULL, 0); + + file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1); + } +} static void file_panel_recent(const bContext *C, Panel *pa) { - file_panel_category(C, pa, FS_CATEGORY_RECENT, ICON_FILE_FOLDER, 0); + SpaceFile *sfile= CTX_wm_space_file(C); + + if(sfile) + file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0); +} + + +static int file_panel_operator_poll(const bContext *C, PanelType *pt) +{ + SpaceFile *sfile= CTX_wm_space_file(C); + return (sfile && sfile->op); } +static void file_panel_operator_header(const bContext *C, Panel *pa) +{ + SpaceFile *sfile= CTX_wm_space_file(C); + wmOperator *op= sfile->op; + + BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); +} static void file_panel_operator(const bContext *C, Panel *pa) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - struct wmOperator *op = sfile ? sfile->op : NULL; - uiBlock *block; - int sy; - - block= uiLayoutFreeBlock(pa->layout); - uiBlockSetHandleFunc(block, do_file_panel_events, NULL); - - sy= 0; - if (op) { - uiBlockBeginAlign(block); - RNA_STRUCT_BEGIN(op->ptr, prop) { - if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "filename") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "display") == 0) - continue; - if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) - continue; - uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0); - } - RNA_STRUCT_END; - uiBlockEndAlign(block); + SpaceFile *sfile= CTX_wm_space_file(C); + wmOperator *op= sfile->op; + int empty= 1; + + RNA_STRUCT_BEGIN(op->ptr, prop) { + if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "filename") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "display") == 0) + continue; + if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) + continue; + + uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0); + empty= 0; } - uiBlockLayoutResolve(C, block, NULL, &sy); - uiEndBlock(C, block); - uiDrawBlock(C, block); -} + RNA_STRUCT_END; + if(empty) + uiItemL(pa->layout, "No properties.", 0); +} void file_panels_register(ARegionType *art) { @@ -161,6 +214,8 @@ void file_panels_register(ARegionType *art) pt= MEM_callocN(sizeof(PanelType), "spacetype file operator properties"); strcpy(pt->idname, "FILE_PT_operator"); strcpy(pt->label, "Operator"); + pt->poll= file_panel_operator_poll; + pt->draw_header= file_panel_operator_header; pt->draw= file_panel_operator; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 6263f9fe57f..8ee7d3515b5 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -124,18 +124,24 @@ short ED_fileselect_set_params(SpaceFile *sfile) if (op) { BLI_strncpy(params->title, op->type->name, sizeof(params->title)); params->filter = 0; - params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0; params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0; params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0; + params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; + params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0; + params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0; + params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0; + params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; + params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0; if (params->filter != 0) params->flag |= FILE_FILTER; + + params->flag |= FILE_HIDE_DOT; - if (RNA_property_is_set(op->ptr, "display")) { - params->display= RNA_int_get(op->ptr, "display"); - } else { - params->display = FILE_SHORTDISPLAY; - } + if(params->filter & (IMAGEFILE|MOVIEFILE)) + params->display= FILE_IMGDISPLAY; + else + params->display= FILE_SHORTDISPLAY; /* if operator has path set, use it, otherwise keep the last */ if (RNA_property_is_set(op->ptr, "filename")) { @@ -147,12 +153,15 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } else { /* default values, if no operator */ - params->flag = 0; + params->flag |= FILE_HIDE_DOT; params->display = FILE_SHORTDISPLAY; params->filter = 0; params->sort = FILE_SORT_ALPHA; } + /* new params, refresh file list */ + if(sfile->files) filelist_free(sfile->files); + return 1; } @@ -188,8 +197,8 @@ int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) offsetx = (x)/(layout->tile_w + 2*layout->tile_border_x); offsety = (y)/(layout->tile_h + 2*layout->tile_border_y); - if (offsetx > layout->columns-1) offsetx = -1 ; - if (offsety > layout->rows-1) offsety = -1 ; + if (offsetx > layout->columns-1) return -1 ; + if (offsety > layout->rows-1) return -1 ; if (layout->flag & FILE_LAYOUT_HOR) active_file = layout->rows*offsetx + offsety; @@ -386,7 +395,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern) void autocomplete_directory(struct bContext *C, char *str, void *arg_v) { char tmp[FILE_MAX]; - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); /* search if str matches the beginning of name */ if(str[0] && sfile->files) { diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index c67a9e7a0d5..9d80dd7273a 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -34,9 +34,12 @@ #include "MEM_guardedalloc.h" +#include "DNA_space_types.h" /* FILE_MAX */ + #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_dynstr.h" +#include "BLI_string.h" #ifdef WIN32 #include <windows.h> /* need to include windows.h so _WIN32_IE is defined */ @@ -245,7 +248,7 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename) FSMenuCategory category = FS_CATEGORY_BOOKMARKS; FILE *fp; - #ifdef WIN32 +#ifdef WIN32 /* Add the drive names to the listing */ { __int64 tmp; @@ -272,8 +275,7 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename) SHGetSpecialFolderPath(0, folder, CSIDL_DESKTOPDIRECTORY, 0); fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, folder, 1, 0); } -#endif - +#else #ifdef __APPLE__ { OSErr err=noErr; @@ -293,6 +295,22 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename) fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, 1, 0); } } +#else + /* unix */ + { + char dir[FILE_MAXDIR]; + char *home= BLI_gethome(); + + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0); + + if(home) { + BLI_snprintf(dir, FILE_MAXDIR, "%s/", home); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, dir, 1, 0); + BLI_snprintf(dir, FILE_MAXDIR, "%s/Desktop/", home); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, dir, 1, 0); + } + } +#endif #endif fp = fopen(filename, "r"); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index a03026d0184..7cdd1d89041 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -184,7 +184,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl) static void file_refresh(const bContext *C, ScrArea *sa) { - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + SpaceFile *sfile= CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); if (!sfile->folders_prev) @@ -217,9 +217,11 @@ static void file_listener(ScrArea *sa, wmNotifier *wmn) case ND_FILELIST: if (sfile->files) filelist_free(sfile->files); ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); break; case ND_PARAMS: ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); break; } break; @@ -263,7 +265,7 @@ static void file_main_area_listener(ARegion *ar, wmNotifier *wmn) 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); + SpaceFile *sfile= CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); FileLayout *layout=NULL; @@ -305,7 +307,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* on first read, find active file */ if (params->active_file == -1) { wmEvent *event= CTX_wm_window(C)->eventstate; - file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin); + file_hilight_set(sfile, ar, event->x, event->y); } if (params->display == FILE_IMGDISPLAY) { diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 723d3eeaf82..d9f02a35142 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -609,10 +609,6 @@ static const EnumPropertyItem image_file_type_items[] = { static void image_filesel(bContext *C, wmOperator *op, const char *path) { RNA_string_set(op->ptr, "filename", path); - RNA_boolean_set(op->ptr, "filter_image", 1); - RNA_boolean_set(op->ptr, "filter_movie", 1); - RNA_boolean_set(op->ptr, "filter_folder", 1); - RNA_enum_set(op->ptr, "display", FILE_IMGDISPLAY); WM_event_add_fileselect(C, op); } @@ -653,14 +649,6 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *event) void IMAGE_OT_open(wmOperatorType *ot) { - PropertyRNA *prop; - - static EnumPropertyItem file_display_items[] = { - {FILE_SHORTDISPLAY, "FILE_SHORTDISPLAY", ICON_SHORTDISPLAY, "Short List", "Display files as short list"}, - {FILE_LONGDISPLAY, "FILE_LONGDISPLAY", ICON_LONGDISPLAY, "Long List", "Display files as a detailed list"}, - {FILE_IMGDISPLAY, "FILE_IMGDISPLAY", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"}, - {0, NULL, 0, NULL, NULL}}; - /* identifiers */ ot->name= "Open"; ot->idname= "IMAGE_OT_open"; @@ -674,27 +662,14 @@ void IMAGE_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to open."); - - prop= RNA_def_boolean(ot->srna, "filter_image", 0, "Show image files", ""); - RNA_def_property_boolean_sdna(prop, NULL, "filter", IMAGEFILE); - prop= RNA_def_boolean(ot->srna, "filter_movie", 0, "Show movie files", ""); - RNA_def_property_boolean_sdna(prop, NULL, "filter", MOVIEFILE); - prop= RNA_def_boolean(ot->srna, "filter_folder", 0, "Show folders", ""); - RNA_def_property_boolean_sdna(prop, NULL, "filter", FOLDERFILE); - - prop= RNA_def_property(ot->srna, "display", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "display"); - RNA_def_property_enum_items(prop, file_display_items); - RNA_def_property_ui_text(prop, "Display Mode", "Display mode for the file list"); - + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE); } /******************** replace image operator ********************/ static int replace_exec(bContext *C, wmOperator *op) { - SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + SpaceImage *sima= CTX_wm_space_image(C); char str[FILE_MAX]; if(!sima->image) @@ -740,7 +715,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to replace current image with."); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE); } /******************** save image as operator ********************/ @@ -884,15 +859,15 @@ void IMAGE_OT_save_as(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path to save image to."); RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as."); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE); } /******************** save image operator ********************/ static int save_exec(bContext *C, wmOperator *op) { - SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + SpaceImage *sima= CTX_wm_space_image(C); Image *ima = ED_space_image(sima); ImBuf *ibuf= ED_space_image_buffer(sima); Scene *scene= CTX_data_scene(C); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 56f925a2e81..640c968742c 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -330,7 +330,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to open."); + WM_operator_properties_filesel(ot, 0); } #if 0 diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index f6cf6de4b00..4a300b7390d 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -97,7 +97,6 @@ /* avoid passing multiple args and be more verbose */ #define SEQPROP_STARTFRAME 1<<0 #define SEQPROP_ENDFRAME 1<<1 -#define SEQPROP_FILENAME 1<<2 static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) { @@ -111,9 +110,6 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ); - if(flag & SEQPROP_FILENAME) - RNA_def_string(ot->srna, "filename", "", FILE_MAX, "Scene Name", "full path to load the strip data from"); - RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "replace the current selection"); } @@ -312,7 +308,8 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME); + WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "sound", FALSE, "Sound", "Load hd sound with the movie"); // XXX need to impliment this } @@ -417,7 +414,8 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "hd", FALSE, "HD Sound", "Load the sound as streaming audio"); // XXX need to impliment this } @@ -512,7 +510,8 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } @@ -646,7 +645,8 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILENAME); + WM_operator_properties_filesel(ot, 0); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME); RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type"); RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 79912d9ed0e..4c9f47ed170 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -231,7 +231,7 @@ void TEXT_OT_open(wmOperatorType *ot) ot->poll= text_new_poll; /* properties */ - RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to open."); + WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE); } /******************* reload operator *********************/ @@ -498,7 +498,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) ot->poll= text_edit_poll; /* properties */ - RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path to save image to."); + WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE); } /******************* run script operator *********************/ |