diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-10-23 03:22:05 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-10-23 03:22:05 +0400 |
commit | 8f788c64db587e74079d812dbcea40c2bd4b91ff (patch) | |
tree | c767e8318a9e7aded16be6cab2042f3ea11e7912 /source/blender/editors/space_file | |
parent | 36bb566d4e6e06e08d782d610d60d755cbda2396 (diff) |
merge with trunk/2.5 at r23876
[[Split portion of a mixed commit.]]
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/SConscript | 7 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 84 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 110 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_panels.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 82 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 44 | ||||
-rw-r--r-- | source/blender/editors/space_file/writeimage.c | 14 |
9 files changed, 222 insertions, 143 deletions
diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index e6fba38fb8f..b22a265dcbc 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -15,4 +15,11 @@ if env['WITH_BF_OPENJPEG']: if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['OURPLATFORM'] == 'linux2': + cflags='-pthread' + incs += ' ../../../extern/binreloc/include' + +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): + incs += ' ' + env['BF_PTHREADS_INC'] + env.BlenderLib ( 'bf_editors_space_file', sources, Split(incs), defs, libtype=['core'], priority=[115] ) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 00024ffa961..77a1b671054 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -133,24 +133,24 @@ static void do_file_buttons(bContext *C, void *arg, int event) 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; @@ -189,7 +189,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) if (available_w > 0) { but = uiDefBut(block, TEX, B_FS_DIRNAME, "", min_x, line1_y, line1_w, btn_h, - params->dir, 0.0, (float)FILE_MAXDIR-1, 0, 0, + params->dir, 0.0, (float)FILE_MAX-1, 0, 0, "File path."); uiButSetCompleteFunc(but, autocomplete_directory, NULL); uiDefBut(block, TEX, B_FS_FILENAME, "", @@ -230,7 +230,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) } -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,25 +310,25 @@ static int get_file_icon(struct direntry *file) 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; + float alpha=1.0f; x = (float)(sx); y = (float)(sy-height); - if (icon == ICON_FILE_BLANK) blend = -80; + if (icon == ICON_FILE_BLANK) alpha = 0.375f; glEnable(GL_BLEND); - UI_icon_draw_aspect_blended(x, y, icon, 1.f, blend); + UI_icon_draw_aspect(x, y, icon, 1.f, alpha); } -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 @@ void file_calc_previews(const bContext *C, ARegion *ar) 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 @@ static void file_draw_preview(short sx, short sy, ImBuf *imb, FileLayout *layout 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 renamebutton_cb(bContext *C, void *arg1, char *oldname) 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_background(FileLayout *layout, View2D *v2d) static void draw_dividers(FileLayout *layout, View2D *v2d) { - short sx; + int sx; /* vertical column dividers */ sx = v2d->tot.xmin; @@ -483,7 +484,7 @@ void file_draw_list(const bContext *C, ARegion *ar) 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 @@ void file_draw_list(const bContext *C, ARegion *ar) 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 @@ void file_draw_list(const bContext *C, ARegion *ar) 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 @@ void file_draw_list(const bContext *C, ARegion *ar) 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 @@ void file_draw_list(const bContext *C, ARegion *ar) 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 @@ void file_draw_list(const bContext *C, ARegion *ar) 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; } } } diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index a99594e9575..d07ffd4b964 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -88,7 +88,7 @@ int file_hilight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my /* filesel.c */ float file_string_width(const char* str); float file_font_pointsize(); -void file_change_dir(struct SpaceFile *sfile); +void file_change_dir(struct SpaceFile *sfile, int checkdir); int file_select_match(struct SpaceFile *sfile, const char *pattern); void autocomplete_directory(struct bContext *C, char *str, void *arg_v); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 0e0ad88906e..c35ff6ed7b6 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -68,25 +68,15 @@ /* ---------- FILE SELECTION ------------ */ -static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, short x, short y, short clamp) +static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, int x, int y) { float fx,fy; int active_file = -1; - int numfiles = filelist_numfiles(sfile->files); View2D* v2d = &ar->v2d; UI_view2d_region_to_view(v2d, x, y, &fx, &fy); active_file = ED_fileselect_layout_offset(sfile->layout, v2d->tot.xmin + fx, v2d->tot.ymax - fy); - - if(active_file < 0) { - if(clamp) active_file= 0; - else active_file= -1; - } - else if(active_file >= numfiles) { - if(clamp) active_file= numfiles-1; - else active_file= -1; - } return active_file; } @@ -109,6 +99,31 @@ typedef enum FileSelect { FILE_SELECT_DIR = 1, FILE_SELECT_FILE = 2 } FileSelect; +static void clamp_to_filelist(int numfiles, int *first_file, int *last_file) +{ + /* border select before the first file */ + if ( (*first_file < 0) && (*last_file >=0 ) ) { + *first_file = 0; + } + /* don't select if everything is outside filelist */ + if ( (*first_file >= numfiles) && ((*last_file < 0) || (*last_file >= numfiles)) ) { + *first_file = -1; + *last_file = -1; + } + + /* fix if last file invalid */ + if ( (*first_file > 0) && (*last_file < 0) ) + *last_file = numfiles-1; + + /* clamp */ + if ( (*first_file >= numfiles) ) { + *first_file = numfiles-1; + } + if ( (*last_file >= numfiles) ) { + *last_file = numfiles-1; + } +} + static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, short val) { int first_file = -1; @@ -123,9 +138,11 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s int numfiles = filelist_numfiles(sfile->files); params->selstate = NOTACTIVE; - first_file = find_file_mouse(sfile, ar, rect->xmin, rect->ymax, 1); - last_file = find_file_mouse(sfile, ar, rect->xmax, rect->ymin, 1); + first_file = find_file_mouse(sfile, ar, rect->xmin, rect->ymax); + last_file = find_file_mouse(sfile, ar, rect->xmax, rect->ymin); + clamp_to_filelist(numfiles, &first_file, &last_file); + /* select all valid files between first and last indicated */ if ( (first_file >= 0) && (first_file < numfiles) && (last_file >= 0) && (last_file < numfiles) ) { for (act_file = first_file; act_file <= last_file; act_file++) { @@ -137,6 +154,9 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s } } + /* Don't act on multiple selected files */ + if (first_file != last_file) selecting= 0; + /* make the last file active */ if (selecting && (last_file >= 0 && last_file < numfiles)) { struct direntry* file = filelist_file(sfile->files, last_file); @@ -157,7 +177,7 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s BLI_add_slash(params->dir); } - file_change_dir(sfile); + file_change_dir(sfile, 0); retval = FILE_SELECT_DIR; } } @@ -168,7 +188,7 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s } } - } + } return retval; } @@ -201,6 +221,7 @@ void FILE_OT_select_border(wmOperatorType *ot) { /* identifiers */ ot->name= "Activate/Select File"; + ot->description= "Activate/select the file(s) contained in the border."; ot->idname= "FILE_OT_select_border"; /* api callbacks */ @@ -253,6 +274,7 @@ void FILE_OT_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Activate/Select File"; + ot->description= "Activate/select file."; ot->idname= "FILE_OT_select"; /* api callbacks */ @@ -297,6 +319,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name= "Select/Deselect all files"; + ot->description= "Select/deselect all files."; ot->idname= "FILE_OT_select_all_toggle"; /* api callbacks */ @@ -320,7 +343,7 @@ static int bookmark_select_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_string_get(op->ptr, "dir", entry); BLI_strncpy(params->dir, entry, sizeof(params->dir)); BLI_cleanup_dir(G.sce, params->dir); - file_change_dir(sfile); + file_change_dir(sfile, 1); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); } @@ -332,6 +355,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Directory"; + ot->description= "Select a bookmarked directory."; ot->idname= "FILE_OT_select_bookmark"; /* api callbacks */ @@ -364,6 +388,7 @@ void FILE_OT_add_bookmark(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Bookmark"; + ot->description= "Add a bookmark for the selected/active directory."; ot->idname= "FILE_OT_add_bookmark"; /* api callbacks */ @@ -396,6 +421,7 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete Bookmark"; + ot->description= "Delete selected bookmark."; ot->idname= "FILE_OT_delete_bookmark"; /* api callbacks */ @@ -425,6 +451,7 @@ void FILE_OT_loadimages(wmOperatorType *ot) /* identifiers */ ot->name= "Load Images"; + ot->description= "Load selected image(s)."; ot->idname= "FILE_OT_loadimages"; /* api callbacks */ @@ -449,7 +476,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) my -= ar->winrct.ymin; if(BLI_in_rcti(&ar->v2d.mask, mx, my)) { - actfile = find_file_mouse(sfile, ar, mx , my, 0); + actfile = find_file_mouse(sfile, ar, mx , my); if((actfile >= 0) && (actfile < numfiles)) params->active_file=actfile; @@ -479,6 +506,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Highlight File"; + ot->description= "Highlight selected file(s)."; ot->idname= "FILE_OT_highlight"; /* api callbacks */ @@ -497,6 +525,7 @@ int file_cancel_exec(bContext *C, wmOperator *unused) sfile->op = NULL; if (sfile->files) { + filelist_freelib(sfile->files); filelist_free(sfile->files); MEM_freeN(sfile->files); sfile->files= NULL; @@ -505,15 +534,26 @@ int file_cancel_exec(bContext *C, wmOperator *unused) return OPERATOR_FINISHED; } +int file_operator_poll(bContext *C) +{ + int poll = ED_operator_file_active(C); + SpaceFile *sfile= CTX_wm_space_file(C); + + if (!sfile || !sfile->op) poll= 0; + + return poll; +} + void FILE_OT_cancel(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Cancel File Load"; + ot->description= "Cancel loading of selected file."; ot->idname= "FILE_OT_cancel"; /* api callbacks */ ot->exec= file_cancel_exec; - ot->poll= ED_operator_file_active; + ot->poll= file_operator_poll; } /* sends events now, so things get handled on windowqueue level */ @@ -531,9 +571,10 @@ int file_exec(bContext *C, wmOperator *unused) RNA_string_set(op->ptr, "directory", name); strcat(name, sfile->params->file); - if ( RNA_boolean_get(op->ptr, "relative_paths") ) { - BLI_makestringcode(G.sce, name); - } + if(RNA_struct_find_property(op->ptr, "relative_paths")) + if(RNA_boolean_get(op->ptr, "relative_paths")) + BLI_makestringcode(G.sce, name); + RNA_string_set(op->ptr, "path", name); /* some ops have multiple files to select */ @@ -574,6 +615,7 @@ int file_exec(bContext *C, wmOperator *unused) fsmenu_write_file(fsmenu_get(), name); WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC); + filelist_freelib(sfile->files); filelist_free(sfile->files); MEM_freeN(sfile->files); sfile->files= NULL; @@ -586,11 +628,12 @@ void FILE_OT_execute(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Execute File Window"; + ot->description= "Execute selected file."; ot->idname= "FILE_OT_execute"; /* api callbacks */ ot->exec= file_exec; - ot->poll= ED_operator_file_active; /* <- important, handler is on window level */ + ot->poll= file_operator_poll; } @@ -602,7 +645,7 @@ int file_parent_exec(bContext *C, wmOperator *unused) if (BLI_has_parent(sfile->params->dir)) { BLI_parent_dir(sfile->params->dir); BLI_cleanup_dir(G.sce, sfile->params->dir); - file_change_dir(sfile); + file_change_dir(sfile, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); } } @@ -616,6 +659,7 @@ void FILE_OT_parent(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Parent File"; + ot->description= "Move to parent directory."; ot->idname= "FILE_OT_parent"; /* api callbacks */ @@ -628,7 +672,7 @@ int file_refresh_exec(bContext *C, wmOperator *unused) { SpaceFile *sfile= CTX_wm_space_file(C); - file_change_dir(sfile); + file_change_dir(sfile, 1); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); @@ -640,6 +684,7 @@ void FILE_OT_previous(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Previous Folder"; + ot->description= "Move to previous folder."; ot->idname= "FILE_OT_previous"; /* api callbacks */ @@ -659,7 +704,7 @@ int file_previous_exec(bContext *C, wmOperator *unused) folderlist_popdir(sfile->folders_prev, sfile->params->dir); folderlist_pushdir(sfile->folders_next, sfile->params->dir); - file_change_dir(sfile); + file_change_dir(sfile, 1); } WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); @@ -670,6 +715,7 @@ void FILE_OT_next(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Next Folder"; + ot->description= "Move to next folder."; ot->idname= "FILE_OT_next"; /* api callbacks */ @@ -690,7 +736,7 @@ int file_next_exec(bContext *C, wmOperator *unused) // update folder_prev so we can check for it in folderlist_clear_next() folderlist_pushdir(sfile->folders_prev, sfile->params->dir); - file_change_dir(sfile); + file_change_dir(sfile, 1); } WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); @@ -733,8 +779,8 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Create New Directory"; - ot->idname= "FILE_OT_directory_new"; ot->description= "Create a new directory"; + ot->idname= "FILE_OT_directory_new"; /* api callbacks */ ot->invoke= WM_operator_confirm; @@ -749,7 +795,6 @@ int file_directory_exec(bContext *C, wmOperator *unused) SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { - if ( sfile->params->dir[0] == '~' ) { if (sfile->params->dir[1] == '\0') { BLI_strncpy(sfile->params->dir, BLI_gethome(), sizeof(sfile->params->dir) ); @@ -771,7 +816,8 @@ int file_directory_exec(bContext *C, wmOperator *unused) #endif BLI_cleanup_dir(G.sce, sfile->params->dir); BLI_add_slash(sfile->params->dir); - file_change_dir(sfile); + file_change_dir(sfile, 1); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); } @@ -799,6 +845,7 @@ void FILE_OT_refresh(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Refresh Filelist"; + ot->description= "Refresh the file list."; ot->idname= "FILE_OT_refresh"; /* api callbacks */ @@ -826,6 +873,7 @@ void FILE_OT_hidedot(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Toggle Hide Dot Files"; + ot->description= "Toggle hide hidden dot files."; ot->idname= "FILE_OT_hidedot"; /* api callbacks */ @@ -875,6 +923,7 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Toggle Bookmarks"; + ot->description= "Toggle bookmarks display."; ot->idname= "FILE_OT_bookmark_toggle"; /* api callbacks */ @@ -903,6 +952,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Increment Number in Filename"; + ot->description= "Increment number in filename."; ot->idname= "FILE_OT_filenum"; /* api callbacks */ @@ -954,6 +1004,7 @@ void FILE_OT_rename(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Rename File or Directory"; + ot->description= "Rename file or file directory."; ot->idname= "FILE_OT_rename"; /* api callbacks */ @@ -1004,6 +1055,7 @@ void FILE_OT_delete(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Delete File"; + ot->description= "Delete selected file."; ot->idname= "FILE_OT_delete"; /* api callbacks */ diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 1b54277c383..afdb0d24917 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -172,16 +172,16 @@ static void file_panel_operator(const bContext *C, Panel *pa) { SpaceFile *sfile= CTX_wm_space_file(C); wmOperator *op= sfile->op; - int empty= 1; + int empty= 1, flag; if(op->type->ui) { op->type->ui((bContext*)C, op->ptr, pa->layout); } else { RNA_STRUCT_BEGIN(op->ptr, prop) { - if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "filemode") == 0) + flag= RNA_property_flag(prop); + + if(flag & PROP_HIDDEN) continue; if(strcmp(RNA_property_identifier(prop), "path") == 0) continue; @@ -189,10 +189,6 @@ static void file_panel_operator(const bContext *C, Panel *pa) 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); empty= 0; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index c0b16e639c0..94d90929d80 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -406,7 +406,7 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir) previous_folder = folderlist->last; // check if already exists - if(previous_folder){ + if(previous_folder && previous_folder->foldername){ if(! strcmp(previous_folder->foldername, dir)){ return; } @@ -592,10 +592,12 @@ void filelist_loadimage_timer(struct FileList* filelist) } if (limg->done) { FileImage *oimg = limg; - BLI_remlink(&filelist->loadimages, oimg); BLI_remove_thread(&filelist->threads, oimg); + /* brecht: keep failed images in the list, otherwise + it keeps trying to load them over and over? + BLI_remlink(&filelist->loadimages, oimg); + MEM_freeN(oimg);*/ limg = oimg->next; - MEM_freeN(oimg); refresh = 1; } else { limg= limg->next; @@ -802,6 +804,8 @@ static void filelist_read_library(struct FileList* filelist) if(!filelist->libfiledata) { int num; struct direntry *file; + + BLI_make_exist(filelist->dir); filelist_read_dir(filelist); file = filelist->filelist; for(num=0; num<filelist->numfiles; num++, file++) { diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index a0787ef989d..89678bffd01 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -117,8 +117,6 @@ short ED_fileselect_set_params(SpaceFile *sfile) BLI_strncpy(sfile->params->file, file, sizeof(sfile->params->file)); BLI_make_file_string(G.sce, sfile->params->dir, dir, ""); /* XXX needed ? - also solve G.sce */ } - - ED_fileselect_reset_params(sfile); params = sfile->params; @@ -126,7 +124,10 @@ short ED_fileselect_set_params(SpaceFile *sfile) if (op) { BLI_strncpy(params->title, op->type->name, sizeof(params->title)); - params->type = RNA_int_get(op->ptr, "filemode"); + if(RNA_struct_find_property(op->ptr, "filename")) + params->type = RNA_int_get(op->ptr, "filemode"); + else + params->type = FILE_SPECIAL; if (RNA_property_is_set(op->ptr, "path")) { RNA_string_get(op->ptr, "path", name); @@ -142,15 +143,24 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } params->filter = 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(RNA_struct_find_property(op->ptr, "filter_blender")) + params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_image")) + params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_movie")) + params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_text")) + params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_python")) + params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_font")) + params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_sound")) + params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_text")) + params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; + if(RNA_struct_find_property(op->ptr, "filter_folder")) + params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0; if (params->filter != 0) params->flag |= FILE_FILTER; @@ -191,14 +201,14 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) int numfiles; if (layout->flag & FILE_LAYOUT_HOR) { - short width = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x; + int width = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x; numfiles = width/layout->tile_w + 1; + return numfiles*layout->rows; } else { - short height = ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y; + int height = ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y; numfiles = height/layout->tile_h + 1; + return numfiles*layout->columns; } - - return layout->columns*layout->rows; } int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) @@ -222,7 +232,7 @@ int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) return active_file; } -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) { if (layout->flag == FILE_LAYOUT_HOR) { *x = layout->tile_border_x + (tile/layout->rows)*(layout->tile_w+2*layout->tile_border_x); @@ -265,7 +275,7 @@ static void column_widths(struct FileList* files, struct FileLayout* layout) if (file) { int len; len = file_string_width(file->relname); - if (len > layout->column_widths[COLUMN_NAME]) layout->column_widths[COLUMN_NAME] = len; + if (len > layout->column_widths[COLUMN_NAME]) layout->column_widths[COLUMN_NAME] = len + 20; len = file_string_width(file->date); if (len > layout->column_widths[COLUMN_DATE]) layout->column_widths[COLUMN_DATE] = len; len = file_string_width(file->time); @@ -337,18 +347,23 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) column_widths(sfile->files, layout); if (params->display == FILE_SHORTDISPLAY) { - maxlen = layout->column_widths[COLUMN_NAME] + + maxlen = layout->column_widths[COLUMN_NAME] + 12 + layout->column_widths[COLUMN_SIZE]; - maxlen += 20+2*10; // for icon and space between columns + maxlen += 20; // for icon } else { - maxlen = layout->column_widths[COLUMN_NAME] + - layout->column_widths[COLUMN_DATE] + - layout->column_widths[COLUMN_TIME] + + maxlen = layout->column_widths[COLUMN_NAME] + 12 + +#ifndef WIN32 + layout->column_widths[COLUMN_MODE1] + 12 + + layout->column_widths[COLUMN_MODE2] + 12 + + layout->column_widths[COLUMN_MODE3] + 12 + + layout->column_widths[COLUMN_OWNER] + 12 + +#endif + layout->column_widths[COLUMN_DATE] + 12 + + layout->column_widths[COLUMN_TIME] + 12 + layout->column_widths[COLUMN_SIZE]; - /* XXX add mode1, mode2, mode3, owner columns for non-windows platforms */ - maxlen += 20+4*10; // for icon and space between columns + maxlen += 20; // for icon } - layout->tile_w = maxlen + 40; + layout->tile_w = maxlen; if(layout->rows > 0) layout->columns = numfiles/layout->rows + 1; // XXX dirty, modulo is zero else { @@ -369,9 +384,15 @@ FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar return sfile->layout; } -void file_change_dir(struct SpaceFile *sfile) +void file_change_dir(struct SpaceFile *sfile, int checkdir) { - if (sfile->params) { + if (sfile->params) { + + if(checkdir && S_ISDIR(BLI_exists(sfile->params->dir)) == 0) { + BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), sizeof(sfile->params->dir)); + /* could return but just refresh the current dir */ + } + filelist_setdir(sfile->files, sfile->params->dir); if(folderlist_clear_next(sfile)) @@ -419,13 +440,16 @@ void autocomplete_directory(struct bContext *C, char *str, void *arg_v) struct direntry* file = filelist_file(sfile->files, i); const char* dir = filelist_dir(sfile->files); if (file && S_ISDIR(file->type)) { - BLI_make_file_string(G.sce, tmp, dir, file->relname); + // BLI_make_file_string(G.sce, tmp, dir, file->relname); + BLI_join_dirfile(tmp, dir, file->relname); autocomplete_do_name(autocpl,tmp); } } autocomplete_end(autocpl, str); if (BLI_exists(str)) { BLI_add_slash(str); + } else { + BLI_make_exist(str); } } } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 27948618d03..91d917acfe7 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -156,17 +156,9 @@ static void file_free(SpaceLink *sl) static void file_init(struct wmWindowManager *wm, ScrArea *sa) { SpaceFile *sfile= (SpaceFile*)sa->spacedata.first; - if(sfile->params) { - MEM_freeN(sfile->params); - sfile->params = 0; - ED_fileselect_set_params(sfile); - if (sfile->files) { - filelist_free(sfile->files); - MEM_freeN(sfile->files); - sfile->files= NULL; - } - } printf("file_init\n"); + + if(sfile->layout) sfile->layout->dirty= 1; } @@ -188,7 +180,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl) if(sfileo->params) { sfilen->params= MEM_dupallocN(sfileo->params); - file_change_dir(sfilen); + file_change_dir(sfilen, 0); } if (sfileo->layout) { sfilen->layout= MEM_dupallocN(sfileo->layout); @@ -205,7 +197,7 @@ static void file_refresh(const bContext *C, ScrArea *sa) sfile->folders_prev = folderlist_new(); if (!sfile->files) { sfile->files = filelist_new(params->type); - file_change_dir(sfile); + file_change_dir(sfile, 0); params->active_file = -1; // added this so it opens nicer (ton) } filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT); @@ -213,6 +205,7 @@ static void file_refresh(const bContext *C, ScrArea *sa) if (filelist_empty(sfile->files)) { filelist_readdir(sfile->files); + BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX); } if(params->sort!=FILE_SORT_NONE) filelist_sort(sfile->files, params->sort); @@ -255,15 +248,15 @@ static void file_listener(ScrArea *sa, wmNotifier *wmn) /* add handlers, stuff you only do once or on area/region changes */ static void file_main_area_init(wmWindowManager *wm, ARegion *ar) { - ListBase *keymap; + wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymaps */ - keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "FileMain", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -371,11 +364,11 @@ void file_operatortypes(void) } /* NOTE: do not add .blend file reading on this level */ -void file_keymap(struct wmWindowManager *wm) +void file_keymap(struct wmKeyConfig *keyconf) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* keys for all areas */ - ListBase *keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "File", SPACE_FILE, 0); WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_add_bookmark", BKEY, KM_PRESS, KM_CTRL, 0); @@ -384,9 +377,10 @@ void file_keymap(struct wmWindowManager *wm) WM_keymap_add_item(keymap, "FILE_OT_next", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "FILE_OT_directory_new", IKEY, KM_PRESS, 0, 0); /* XXX needs button */ WM_keymap_add_item(keymap, "FILE_OT_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "FILE_OT_delete", DELKEY, KM_PRESS, 0, 0); /* keys for main area */ - keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0); + keymap= WM_keymap_find(keyconf, "FileMain", SPACE_FILE, 0); WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0); @@ -407,7 +401,7 @@ void file_keymap(struct wmWindowManager *wm) RNA_int_set(kmi->ptr, "increment",-100); /* keys for button area (top) */ - keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0); + keymap= WM_keymap_find(keyconf, "FileButtons", SPACE_FILE, 0); WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "increment", 1); @@ -426,12 +420,12 @@ void file_keymap(struct wmWindowManager *wm) static void file_channel_area_init(wmWindowManager *wm, ARegion *ar) { - ListBase *keymap; + wmKeyMap *keymap; ED_region_panels_init(wm, ar); /* own keymaps */ - keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); + keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -462,15 +456,15 @@ static void file_header_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void file_ui_area_init(wmWindowManager *wm, ARegion *ar) { - ListBase *keymap; + wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); /* XXX weak? */ + keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0); /* XXX weak? */ + keymap= WM_keymap_find(wm->defaultconf, "FileButtons", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_file/writeimage.c b/source/blender/editors/space_file/writeimage.c index 994f38320f2..045c790b9cd 100644 --- a/source/blender/editors/space_file/writeimage.c +++ b/source/blender/editors/space_file/writeimage.c @@ -115,15 +115,18 @@ static void save_rendered_image_cb_real(char *name, int confirm) if(overwrite) { if(scene->r.imtype==R_MULTILAYER) { - RenderResult *rr= RE_GetResult(RE_GetRender(scene->id.name)); + Render *re= RE_GetRender(scene->id.name); + RenderResult *rr= RE_AcquireResultRead(re); if(rr) RE_WriteRenderResult(rr, str, scene->r.quality); + RE_ReleaseResult(re); } else { + Render *re= RE_GetRender(scene->id.name); RenderResult rres; ImBuf *ibuf; - RE_GetResultImage(RE_GetRender(scene->id.name), &rres); + RE_AcquireResultImage(re, &rres); waitcursor(1); /* from screen.c */ @@ -137,6 +140,8 @@ static void save_rendered_image_cb_real(char *name, int confirm) BKE_write_ibuf(scene, ibuf, str, scene->r.imtype, scene->r.subimtype, scene->r.quality); IMB_freeImBuf(ibuf); /* imbuf knows rects are not part of ibuf */ + + RE_ReleaseResultImage(re); } strcpy(G.ima, name); @@ -231,9 +236,10 @@ void BIF_save_rendered_image(char *name) /* calls fileselect */ void BIF_save_rendered_image_fs(Scene *scene) { + Render *re= RE_GetRender(scene->id.name); RenderResult rres; - RE_GetResultImage(RE_GetRender(scene->id.name), &rres); + RE_AcquireResultImage(re, &rres); if(!rres.rectf && !rres.rect32) { error("No image rendered"); @@ -250,6 +256,8 @@ void BIF_save_rendered_image_fs(Scene *scene) save_image_filesel_str(scene, str); activate_fileselect(FILE_SPECIAL, str, G.ima, save_rendered_image_cb); } + + RE_ReleaseResultImage(re); } |