Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/CMakeLists.txt67
-rw-r--r--source/blender/editors/space_file/Makefile13
-rw-r--r--source/blender/editors/space_file/SConscript4
-rw-r--r--source/blender/editors/space_file/file_draw.c61
-rw-r--r--source/blender/editors/space_file/file_intern.h2
-rw-r--r--source/blender/editors/space_file/file_ops.c195
-rw-r--r--source/blender/editors/space_file/file_panels.c2
-rw-r--r--source/blender/editors/space_file/filelist.c183
-rw-r--r--source/blender/editors/space_file/filelist.h1
-rw-r--r--source/blender/editors/space_file/filesel.c149
-rw-r--r--source/blender/editors/space_file/fsmenu.c78
-rw-r--r--source/blender/editors/space_file/fsmenu.h5
-rw-r--r--source/blender/editors/space_file/space_file.c54
-rw-r--r--source/blender/editors/space_file/writeimage.c21
14 files changed, 514 insertions, 321 deletions
diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt
new file mode 100644
index 00000000000..5cbe9bbe0ba
--- /dev/null
+++ b/source/blender/editors/space_file/CMakeLists.txt
@@ -0,0 +1,67 @@
+# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+FILE(GLOB SRC *.c)
+
+SET(INC
+ ../../blenfont
+ ../../blenkernel
+ ../../blenlib
+ ../../blenloader
+ ../../imbuf
+ ../include
+ ../../../../intern/audaspace/intern
+ ../../../../intern/guardedalloc
+ ../../makesdna
+ ../../makesrna
+ ../../render/extern/include
+ ../../windowmanager
+)
+
+IF(WITH_IMAGE_OPENEXR)
+ ADD_DEFINITIONS(-DWITH_OPENEXR)
+ENDIF(WITH_IMAGE_OPENEXR)
+
+IF(WITH_IMAGE_TIFF)
+ ADD_DEFINITIONS(-DWITH_TIFF)
+ENDIF(WITH_IMAGE_TIFF)
+
+IF(WITH_IMAGE_OPENJPEG)
+ ADD_DEFINITIONS(-DWITH_OPENJPEG)
+ENDIF(WITH_IMAGE_OPENJPEG)
+
+IF(WITH_IMAGE_DDS)
+ ADD_DEFINITIONS(-DWITH_DDS)
+ENDIF(WITH_IMAGE_DDS)
+
+IF(WITH_IMAGE_CINEON)
+ ADD_DEFINITIONS(-DWITH_CINEON)
+ENDIF(WITH_IMAGE_CINEON)
+
+IF(WITH_IMAGE_HDR)
+ ADD_DEFINITIONS(-DWITH_HDR)
+ENDIF(WITH_IMAGE_HDR)
+
+IF(WIN32)
+ SET(INC ${INC} ${PTHREADS_INC})
+ENDIF(WIN32)
+
+BLENDERLIB(bf_editor_space_file "${SRC}" "${INC}")
diff --git a/source/blender/editors/space_file/Makefile b/source/blender/editors/space_file/Makefile
index 43b2f09ed2d..1fc27795f08 100644
--- a/source/blender/editors/space_file/Makefile
+++ b/source/blender/editors/space_file/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2007 Blender Foundation
# All rights reserved.
@@ -63,3 +63,14 @@ ifeq ($(WITH_OPENEXR), true)
CPPFLAGS += -DWITH_OPENEXR
endif
+ifeq ($(WITH_TIFF), true)
+ CPPFLAGS += -DWITH_TIFF
+endif
+
+ifeq ($(WITH_CINEON), true)
+ CPPFLAGS += -DWITH_CINEON
+endif
+
+ifeq ($(WITH_HDR), true)
+ CPPFLAGS += -DWITH_HDR
+endif \ No newline at end of file
diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript
index b22a265dcbc..9de705e99d3 100644
--- a/source/blender/editors/space_file/SConscript
+++ b/source/blender/editors/space_file/SConscript
@@ -12,9 +12,13 @@ defs = []
if env['WITH_BF_OPENJPEG']:
defs.append('WITH_OPENJPEG')
+
if env['WITH_BF_OPENEXR']:
defs.append('WITH_OPENEXR')
+if env['WITH_BF_TIFF']:
+ defs.append('WITH_TIFF')
+
if env['OURPLATFORM'] == 'linux2':
cflags='-pthread'
incs += ' ../../../extern/binreloc/include'
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index bfc17261fa6..3368ce636e1 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -38,20 +38,16 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
-#include "BKE_colortools.h"
#include "BKE_context.h"
-#include "BKE_screen.h"
#include "BKE_global.h"
-#include "BKE_utildefines.h"
#include "BLF_api.h"
-
-
#include "IMB_imbuf_types.h"
#include "MEM_guardedalloc.h"
+#include "DNA_userdef_types.h"
#include "RNA_access.h"
@@ -78,10 +74,6 @@
/* button events */
enum {
- B_REDR = 0,
- B_FS_EXEC,
- B_FS_CANCEL,
- B_FS_PARENT,
B_FS_DIRNAME,
B_FS_FILENAME
} eFile_ButEvents;
@@ -90,9 +82,6 @@ enum {
static void do_file_buttons(bContext *C, void *arg, int event)
{
switch(event) {
- case B_FS_PARENT:
- file_parent_exec(C, NULL); /* file_ops.c */
- break;
case B_FS_FILENAME:
file_filename_exec(C, NULL);
break;
@@ -129,10 +118,11 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
const int separator = 4;
/* Additional locals. */
- char name[20];
+ char name[32];
int loadbutton;
int fnumbuttons;
int min_x = 10;
+ int chan_offs = 0;
int available_w = max_x - min_x;
int line1_w = available_w;
int line2_w = available_w;
@@ -151,8 +141,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
/* exception to make space for collapsed region icon */
for (artmp=CTX_wm_area(C)->regionbase.first; artmp; artmp=artmp->next) {
if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) {
- min_x += 16;
- available_w -= 16;
+ chan_offs = 16;
+ min_x += chan_offs;
+ available_w -= chan_offs;
}
}
@@ -182,27 +173,28 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
/* Text input fields for directory and file. */
if (available_w > 0) {
but = uiDefBut(block, TEX, B_FS_DIRNAME, "",
- min_x, line1_y, line1_w, btn_h,
+ min_x, line1_y, line1_w-chan_offs, btn_h,
params->dir, 0.0, (float)FILE_MAX-1, 0, 0,
"File path.");
uiButSetCompleteFunc(but, autocomplete_directory, NULL);
- uiDefBut(block, TEX, B_FS_FILENAME, "",
- min_x, line2_y, line2_w, btn_h,
+ but = uiDefBut(block, TEX, B_FS_FILENAME, "",
+ min_x, line2_y, line2_w-chan_offs, btn_h,
params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0,
"File name.");
+ uiButSetCompleteFunc(but, autocomplete_file, NULL);
}
/* Filename number increment / decrement buttons. */
if (fnumbuttons) {
uiBlockBeginAlign(block);
but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMOUT,
- min_x + line2_w + separator, line2_y,
+ min_x + line2_w + separator - chan_offs, line2_y,
btn_fn_w, btn_h,
"Decrement the filename number");
RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", -1);
but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMIN,
- min_x + line2_w + separator + btn_fn_w, line2_y,
+ min_x + line2_w + separator + btn_fn_w - chan_offs, line2_y,
btn_fn_w, btn_h,
"Increment the filename number");
RNA_int_set(uiButGetOperatorPtrRNA(but), "increment", 1);
@@ -334,11 +326,13 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon,
static void file_draw_string(int sx, int sy, const char* string, float width, int height, int flag)
{
+ uiStyle *style= U.uistyles.first;
int soffs;
char fname[FILE_MAXFILE];
float sw;
float x,y;
+
BLI_strncpy(fname,string, FILE_MAXFILE);
sw = shorten_string(fname, width, flag );
@@ -346,8 +340,9 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in
x = (float)(sx);
y = (float)(sy-height);
- BLF_position(x, y, 0);
- BLF_draw(fname);
+ uiStyleFontSet(&style->widget);
+ BLF_position(style->widget.uifont_id, x, y, 0);
+ BLF_draw(style->widget.uifont_id, fname);
}
void file_calc_previews(const bContext *C, ARegion *ar)
@@ -431,21 +426,25 @@ static void renamebutton_cb(bContext *C, void *arg1, char *oldname)
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
ARegion* ar = CTX_wm_region(C);
+#if 0
struct direntry *file = (struct direntry *)arg1;
+#endif
BLI_make_file_string(G.sce, orgname, sfile->params->dir, oldname);
- BLI_strncpy(filename, file->relname, sizeof(filename));
+ BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename));
BLI_make_file_string(G.sce, newname, sfile->params->dir, filename);
if( strcmp(orgname, newname) != 0 ) {
if (!BLI_exists(newname)) {
BLI_rename(orgname, newname);
/* to make sure we show what is on disk */
+#if 0 /* this is cleared anyway, no need */
+ MEM_freeN(file->relname);
+ file->relname= BLI_strdup(sfile->params->renameedit);
+#endif
ED_fileselect_clear(C, sfile);
- } else {
- BLI_strncpy(file->relname, oldname, strlen(oldname)+1);
}
-
+
ED_region_tag_redraw(ar);
}
}
@@ -516,6 +515,13 @@ void file_draw_list(const bContext *C, ARegion *ar)
numfiles_layout = ED_fileselect_layout_numfiles(layout, ar);
+ /* adjust, so the next row is already drawn when scrolling */
+ if (layout->flag & FILE_LAYOUT_HOR) {
+ numfiles_layout += layout->rows;
+ } else {
+ numfiles_layout += layout->columns;
+ }
+
for (i=offset; (i < numfiles) && (i<offset+numfiles_layout); ++i)
{
ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
@@ -533,7 +539,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
int but_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : layout->column_widths[COLUMN_NAME];
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,"");
+ but_width, layout->textheight*2, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit),0,0,"");
uiButSetRenameFunc(but, renamebutton_cb, file);
if ( 0 == uiButActiveOnly(C, block, but)) {
file->flags &= ~EDITING;
@@ -622,4 +628,3 @@ void file_draw_list(const bContext *C, ARegion *ar)
}
-
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index a7aeaa1d365..c77379b39a0 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -70,6 +70,7 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot);
void FILE_OT_filenum(struct wmOperatorType *ot);
void FILE_OT_delete(struct wmOperatorType *ot);
void FILE_OT_rename(struct wmOperatorType *ot);
+void FILE_OT_smoothscroll(struct wmOperatorType *ot);
int file_exec(bContext *C, struct wmOperator *exec_op);
int file_cancel_exec(bContext *C, struct wmOperator *unused);
@@ -90,6 +91,7 @@ float file_font_pointsize();
void file_change_dir(bContext *C, int checkdir);
int file_select_match(struct SpaceFile *sfile, const char *pattern);
void autocomplete_directory(struct bContext *C, char *str, void *arg_v);
+void autocomplete_file(struct bContext *C, char *str, void *arg_v);
/* file_panels.c */
void file_panels_register(struct ARegionType *art);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index f1d3702160f..2a50b505c57 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -121,7 +121,7 @@ static void clamp_to_filelist(int numfiles, int *first_file, int *last_file)
}
}
-static FileSelect file_select(bContext* C, const rcti* rect, short selecting, short toggle_one)
+static FileSelect file_select(bContext* C, const rcti* rect, short selecting, short toggle_one, short fill)
{
ARegion *ar= CTX_wm_region(C);
SpaceFile *sfile= CTX_wm_space_file(C);
@@ -141,6 +141,19 @@ static FileSelect file_select(bContext* C, const rcti* rect, short selecting, sh
clamp_to_filelist(numfiles, &first_file, &last_file);
+ if (fill && (last_file >= 0) && (last_file < numfiles) ) {
+ int f= last_file;
+ while (f >= 0) {
+ struct direntry* file = filelist_file(sfile->files, f);
+ if (file->flags & ACTIVEFILE)
+ break;
+ f--;
+ }
+ if (f >= 0) {
+ first_file = f+1;
+ }
+ }
+
/* 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++) {
@@ -213,7 +226,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op)
BLI_isect_rcti(&(ar->v2d.mask), &rect, &rect);
- if (FILE_SELECT_DIR == file_select(C, &rect, selecting, 0)) {
+ if (FILE_SELECT_DIR == file_select(C, &rect, selecting, 0, 0)) {
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
} else {
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
@@ -245,6 +258,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
short val;
rcti rect;
int extend = RNA_boolean_get(op->ptr, "extend");
+ int fill = RNA_boolean_get(op->ptr, "fill");
if(ar->regiontype != RGN_TYPE_WINDOW)
return OPERATOR_CANCELLED;
@@ -259,7 +273,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* single select, deselect all selected first */
if (!extend) file_deselect_all(sfile);
- if (FILE_SELECT_DIR == file_select(C, &rect, 1, extend ))
+ if (FILE_SELECT_DIR == file_select(C, &rect, 1, extend, fill ))
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
else
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
@@ -283,6 +297,7 @@ void FILE_OT_select(wmOperatorType *ot)
/* rna */
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first.");
+ RNA_def_boolean(ot->srna, "fill", 0, "Fill", "Select everything beginning with the last selection.");
}
static int file_select_all_exec(bContext *C, wmOperator *op)
@@ -318,7 +333,7 @@ static int file_select_all_exec(bContext *C, wmOperator *op)
void FILE_OT_select_all_toggle(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select/Deselect all files";
+ ot->name= "Select/Deselect All Files";
ot->description= "Select/deselect all files";
ot->idname= "FILE_OT_select_all_toggle";
@@ -376,7 +391,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *op)
char name[FILE_MAX];
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1);
- BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+ BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
}
@@ -408,7 +423,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op)
char name[FILE_MAX];
fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index);
- BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+ BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
ED_area_tag_redraw(sa);
}
@@ -530,7 +545,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot)
int file_exec(bContext *C, wmOperator *exec_op)
{
SpaceFile *sfile= CTX_wm_space_file(C);
- char name[FILE_MAX];
+ char filepath[FILE_MAX];
if(sfile->op) {
wmOperator *op= sfile->op;
@@ -552,16 +567,23 @@ int file_exec(bContext *C, wmOperator *exec_op)
}
sfile->op = NULL;
- RNA_string_set(op->ptr, "filename", sfile->params->file);
- BLI_strncpy(name, sfile->params->dir, sizeof(name));
- RNA_string_set(op->ptr, "directory", name);
- strcat(name, sfile->params->file); // XXX unsafe
- if(RNA_struct_find_property(op->ptr, "relative_path"))
- if(RNA_boolean_get(op->ptr, "relative_path"))
- BLI_path_rel(name, G.sce);
+ BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
+ if(RNA_struct_find_property(op->ptr, "relative_path")) {
+ if(RNA_boolean_get(op->ptr, "relative_path")) {
+ BLI_path_rel(filepath, G.sce);
+ }
+ }
- RNA_string_set(op->ptr, "path", name);
+ if(RNA_struct_find_property(op->ptr, "filename")) {
+ RNA_string_set(op->ptr, "filename", sfile->params->file);
+ }
+ if(RNA_struct_find_property(op->ptr, "directory")) {
+ RNA_string_set(op->ptr, "directory", sfile->params->dir);
+ }
+ if(RNA_struct_find_property(op->ptr, "filepath")) {
+ RNA_string_set(op->ptr, "filepath", filepath);
+ }
/* some ops have multiple files to select */
{
@@ -597,8 +619,8 @@ int file_exec(bContext *C, wmOperator *exec_op)
folderlist_free(sfile->folders_next);
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1);
- BLI_make_file_string(G.sce, name, BLI_gethome(), ".Bfs");
- fsmenu_write_file(fsmenu_get(), name);
+ BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
+ fsmenu_write_file(fsmenu_get(), filepath);
WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
ED_fileselect_clear(C, sfile);
@@ -657,7 +679,9 @@ void FILE_OT_parent(struct wmOperatorType *ot)
int file_refresh_exec(bContext *C, wmOperator *unused)
{
- file_change_dir(C, 1);
+ SpaceFile *sfile= CTX_wm_space_file(C);
+
+ ED_fileselect_clear(C, sfile);
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
@@ -728,6 +752,116 @@ int file_next_exec(bContext *C, wmOperator *unused)
return OPERATOR_FINISHED;
}
+
+/* only meant for timer usage */
+static int file_smoothscroll_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ SpaceFile *sfile= CTX_wm_space_file(C);
+ ARegion *ar, *oldar= CTX_wm_region(C);
+ int numfiles, offset;
+ int edit_idx = 0;
+ int numfiles_layout;
+ int i;
+
+ /* escape if not our timer */
+ if(sfile->smoothscroll_timer==NULL || sfile->smoothscroll_timer!=event->customdata)
+ return OPERATOR_PASS_THROUGH;
+
+ numfiles = filelist_numfiles(sfile->files);
+
+ /* check if we are editing a name */
+ for (i=0; i < numfiles; ++i)
+ {
+ struct direntry *file = filelist_file(sfile->files, i);
+ if (file->flags & EDITING) {
+ edit_idx=i;
+ break;
+ }
+ }
+
+ /* if we are not editing, we are done */
+ if (0==edit_idx) {
+ WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
+ sfile->smoothscroll_timer=NULL;
+ return OPERATOR_PASS_THROUGH;
+ }
+
+ /* we need the correct area for scrolling */
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (!ar || ar->regiontype != RGN_TYPE_WINDOW) {
+ WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
+ sfile->smoothscroll_timer=NULL;
+ return OPERATOR_PASS_THROUGH;
+ }
+
+ offset = ED_fileselect_layout_offset(sfile->layout, 0, ar->v2d.cur.xmin, -ar->v2d.cur.ymax);
+ if (offset<0) offset=0;
+
+ /* scroll offset is the first file in the row/column we are editing in */
+ if (sfile->scroll_offset == 0) {
+ if (sfile->layout->flag & FILE_LAYOUT_HOR) {
+ sfile->scroll_offset = (edit_idx/sfile->layout->rows)*sfile->layout->rows;
+ if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->rows;
+ } else {
+ sfile->scroll_offset = (edit_idx/sfile->layout->columns)*sfile->layout->columns;
+ if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns;
+ }
+ }
+
+ numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar);
+
+ /* check if we have reached our final scroll position */
+ if ( (sfile->scroll_offset >= offset) && (sfile->scroll_offset < offset + numfiles_layout) ) {
+ WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
+ sfile->smoothscroll_timer=NULL;
+ return OPERATOR_FINISHED;
+ }
+
+ /* temporarily set context to the main window region,
+ * so the scroll operators work */
+ CTX_wm_region_set(C, ar);
+
+ /* scroll one step in the desired direction */
+ if (sfile->scroll_offset < offset) {
+ if (sfile->layout->flag & FILE_LAYOUT_HOR) {
+ WM_operator_name_call(C, "VIEW2D_OT_scroll_left", 0, NULL);
+ } else {
+ WM_operator_name_call(C, "VIEW2D_OT_scroll_up", 0, NULL);
+ }
+
+ } else {
+ if (sfile->layout->flag & FILE_LAYOUT_HOR) {
+ WM_operator_name_call(C, "VIEW2D_OT_scroll_right", 0, NULL);
+ } else {
+ WM_operator_name_call(C, "VIEW2D_OT_scroll_down", 0, NULL);
+ }
+ }
+
+ ED_region_tag_redraw(CTX_wm_region(C));
+
+ /* and restore context */
+ CTX_wm_region_set(C, oldar);
+
+ return OPERATOR_FINISHED;
+}
+
+
+void FILE_OT_smoothscroll(wmOperatorType *ot)
+{
+
+ /* identifiers */
+ ot->name= "Smooth Scroll";
+ ot->idname= "FILE_OT_smoothscroll";
+ ot->description="Smooth scroll to make editable file visible.";
+
+ /* api callbacks */
+ ot->invoke= file_smoothscroll_invoke;
+
+ ot->poll= ED_operator_file_active;
+}
+
+
/* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created.
The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name.
*/
@@ -777,6 +911,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
/* now remember file to jump into editing */
BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE);
+
+ /* set timer to smoothly view newly generated file */
+ sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/1000.0); /* max 30 frs/sec */
+ sfile->scroll_offset=0;
+
+ /* reload dir to make sure we're seeing what's in the directory */
ED_fileselect_clear(C, sfile);
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
@@ -799,26 +939,15 @@ void FILE_OT_directory_new(struct wmOperatorType *ot)
int file_directory_exec(bContext *C, wmOperator *unused)
{
- char tmpstr[FILE_MAX];
-
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) );
- } else {
- /* replace ~ with home */
- char homestr[FILE_MAX];
- char *d = &sfile->params->dir[1];
-
- while ( (*d == '\\') || (*d == '/') )
- d++;
- BLI_strncpy(homestr, BLI_gethome(), FILE_MAX);
- BLI_join_dirfile(tmpstr, homestr, d);
- BLI_strncpy(sfile->params->dir, tmpstr, sizeof(sfile->params->dir));
- }
+ char tmpstr[sizeof(sfile->params->dir)-1];
+ strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr));
+ BLI_join_dirfile(sfile->params->dir, BLI_getDefaultDocumentFolder(), tmpstr);
}
+
#ifdef WIN32
if (sfile->params->dir[0] == '\0')
get_default_root(sfile->params->dir);
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 637e56459d7..4a505bc022f 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -182,7 +182,7 @@ static void file_panel_operator(const bContext *C, Panel *pa)
if(flag & PROP_HIDDEN)
continue;
- if(strcmp(RNA_property_identifier(prop), "path") == 0)
+ if(strcmp(RNA_property_identifier(prop), "filepath") == 0)
continue;
if(strcmp(RNA_property_identifier(prop), "directory") == 0)
continue;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 9dd16586946..c3bea2a5bea 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -34,10 +34,6 @@
#include <math.h>
#include <string.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifndef WIN32
#include <unistd.h>
#else
@@ -56,25 +52,14 @@
#endif
#include "BKE_context.h"
-#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BKE_library.h"
-#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BLO_readfile.h"
+#include "BKE_idcode.h"
#include "DNA_space_types.h"
-#include "DNA_ipo_types.h"
-#include "DNA_ID.h"
-#include "DNA_object_types.h"
-#include "DNA_listBase.h"
-#include "DNA_lamp_types.h"
-#include "DNA_material_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_world_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_userdef_types.h"
#include "ED_datafiles.h"
@@ -165,7 +150,7 @@ static int compare_name(const void *a1, const void *a2)
{
const struct direntry *entry1=a1, *entry2=a2;
- /* type is is equal to stat.st_mode */
+ /* type is equal to stat.st_mode */
if (S_ISDIR(entry1->type)){
if (S_ISDIR(entry2->type)==0) return (-1);
@@ -262,7 +247,7 @@ static int compare_extension(const void *a1, const void *a2) {
if (!sufix1) sufix1= nil;
if (!sufix2) sufix2= nil;
- /* type is is equal to stat.st_mode */
+ /* type is equal to stat.st_mode */
if (S_ISDIR(entry1->type)){
if (S_ISDIR(entry2->type)==0) return (-1);
@@ -379,7 +364,7 @@ void filelist_init_icons()
short x, y, k;
ImBuf *bbuf;
ImBuf *ibuf;
- bbuf = IMB_ibImageFromMemory((int *)datatoc_prvicons, datatoc_prvicons_size, IB_rect);
+ bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_prvicons, datatoc_prvicons_size, IB_rect);
if (bbuf) {
for (y=0; y<SPECIAL_IMG_ROWS; y++) {
for (x=0; x<SPECIAL_IMG_COLS; x++) {
@@ -617,9 +602,7 @@ struct ImBuf * filelist_loadimage(struct FileList* filelist, int index)
if (!imb)
{
if ( (filelist->filelist[fidx].flags & IMAGEFILE) || (filelist->filelist[fidx].flags & MOVIEFILE) ) {
- char path[FILE_MAX];
- BLI_join_dirfile(path, filelist->dir, filelist->filelist[fidx].relname);
- imb = IMB_thumb_read(path, THB_NORMAL);
+ imb = IMB_thumb_read(filelist->filelist[fidx].path, THB_NORMAL);
}
if (imb) {
filelist->filelist[fidx].image = imb;
@@ -743,7 +726,7 @@ static void filelist_read_dir(struct FileList* filelist)
BLI_cleanup_dir(G.sce, filelist->dir);
filelist->numfiles = BLI_getdir(filelist->dir, &(filelist->filelist));
- if(!chdir(wdir)) /* fix warning about not checking return value */;
+ if(!chdir(wdir)) {} /* fix warning about not checking return value */
filelist_setfiletypes(filelist, G.have_quicktime);
filelist_filter(filelist);
}
@@ -813,9 +796,6 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime)
/* Don't check extensions for directories */
if (file->type & S_IFDIR) {
- if(BLO_has_bfile_extension(file->relname)) {
- file->flags |= BLENDERFILE;
- }
continue;
}
@@ -837,129 +817,13 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime)
file->flags |= BTXFILE;
} else if(BLI_testextensie(file->relname, ".dae")) {
file->flags |= COLLADAFILE;
- } else if (has_quicktime){
- if( BLI_testextensie(file->relname, ".int")
- || BLI_testextensie(file->relname, ".inta")
- || BLI_testextensie(file->relname, ".jpg")
-#ifdef WITH_OPENJPEG
- || BLI_testextensie(file->relname, ".jp2")
-#endif
- || BLI_testextensie(file->relname, ".jpeg")
- || BLI_testextensie(file->relname, ".tga")
- || BLI_testextensie(file->relname, ".rgb")
- || BLI_testextensie(file->relname, ".rgba")
- || BLI_testextensie(file->relname, ".bmp")
- || BLI_testextensie(file->relname, ".png")
- || BLI_testextensie(file->relname, ".iff")
- || BLI_testextensie(file->relname, ".lbm")
- || BLI_testextensie(file->relname, ".gif")
- || BLI_testextensie(file->relname, ".psd")
- || BLI_testextensie(file->relname, ".tif")
- || BLI_testextensie(file->relname, ".tiff")
- || BLI_testextensie(file->relname, ".pct")
- || BLI_testextensie(file->relname, ".pict")
- || BLI_testextensie(file->relname, ".pntg") //macpaint
- || BLI_testextensie(file->relname, ".qtif")
- || BLI_testextensie(file->relname, ".sgi")
- || BLI_testextensie(file->relname, ".hdr")
-#ifdef WITH_DDS
- || BLI_testextensie(file->relname, ".dds")
-#endif
-#ifdef WITH_OPENEXR
- || BLI_testextensie(file->relname, ".exr")
-#endif
- ) {
+ } else if(BLI_testextensie_array(file->relname, imb_ext_image)
+ || (has_quicktime && BLI_testextensie_array(file->relname, imb_ext_image_qt))) {
file->flags |= IMAGEFILE;
- }
- else if(BLI_testextensie(file->relname, ".avi")
- || BLI_testextensie(file->relname, ".flc")
- || BLI_testextensie(file->relname, ".mov")
- || BLI_testextensie(file->relname, ".movie")
- || BLI_testextensie(file->relname, ".mp4")
- || BLI_testextensie(file->relname, ".m4v")
- || BLI_testextensie(file->relname, ".mv")
- || BLI_testextensie(file->relname, ".wmv")
- || BLI_testextensie(file->relname, ".ogv")
- || BLI_testextensie(file->relname, ".mpeg")
- || BLI_testextensie(file->relname, ".mpg")
- || BLI_testextensie(file->relname, ".mpg2")
- || BLI_testextensie(file->relname, ".vob")
- || BLI_testextensie(file->relname, ".mkv")
- || BLI_testextensie(file->relname, ".flv")
- || BLI_testextensie(file->relname, ".divx")
- || BLI_testextensie(file->relname, ".xvid")) {
- file->flags |= MOVIEFILE;
- }
- else if(BLI_testextensie(file->relname, ".wav")
- || BLI_testextensie(file->relname, ".ogg")
- || BLI_testextensie(file->relname, ".oga")
- || BLI_testextensie(file->relname, ".mp3")
- || BLI_testextensie(file->relname, ".mp2")
- || BLI_testextensie(file->relname, ".ac3")
- || BLI_testextensie(file->relname, ".aac")
- || BLI_testextensie(file->relname, ".flac")
- || BLI_testextensie(file->relname, ".wma")
- || BLI_testextensie(file->relname, ".eac3")) {
- file->flags |= SOUNDFILE;
- }
- } else { // no quicktime
- if(BLI_testextensie(file->relname, ".int")
- || BLI_testextensie(file->relname, ".inta")
- || BLI_testextensie(file->relname, ".jpg")
- || BLI_testextensie(file->relname, ".jpeg")
-#ifdef WITH_OPENJPEG
- || BLI_testextensie(file->relname, ".jp2")
-#endif
- || BLI_testextensie(file->relname, ".tga")
- || BLI_testextensie(file->relname, ".rgb")
- || BLI_testextensie(file->relname, ".rgba")
- || BLI_testextensie(file->relname, ".bmp")
- || BLI_testextensie(file->relname, ".png")
- || BLI_testextensie(file->relname, ".iff")
- || BLI_testextensie(file->relname, ".tif")
- || BLI_testextensie(file->relname, ".tiff")
- || BLI_testextensie(file->relname, ".hdr")
-#ifdef WITH_DDS
- || BLI_testextensie(file->relname, ".dds")
-#endif
-#ifdef WITH_OPENEXR
- || BLI_testextensie(file->relname, ".exr")
-#endif
- || BLI_testextensie(file->relname, ".lbm")
- || BLI_testextensie(file->relname, ".sgi")) {
- file->flags |= IMAGEFILE;
- }
- else if(BLI_testextensie(file->relname, ".avi")
- || BLI_testextensie(file->relname, ".flc")
- || BLI_testextensie(file->relname, ".mov")
- || BLI_testextensie(file->relname, ".movie")
- || BLI_testextensie(file->relname, ".mp4")
- || BLI_testextensie(file->relname, ".m4v")
- || BLI_testextensie(file->relname, ".mv")
- || BLI_testextensie(file->relname, ".wmv")
- || BLI_testextensie(file->relname, ".ogv")
- || BLI_testextensie(file->relname, ".mpeg")
- || BLI_testextensie(file->relname, ".mpg")
- || BLI_testextensie(file->relname, ".mpg2")
- || BLI_testextensie(file->relname, ".vob")
- || BLI_testextensie(file->relname, ".mkv")
- || BLI_testextensie(file->relname, ".flv")
- || BLI_testextensie(file->relname, ".divx")
- || BLI_testextensie(file->relname, ".xvid")) {
- file->flags |= MOVIEFILE;
- }
- else if(BLI_testextensie(file->relname, ".wav")
- || BLI_testextensie(file->relname, ".ogg")
- || BLI_testextensie(file->relname, ".oga")
- || BLI_testextensie(file->relname, ".mp3")
- || BLI_testextensie(file->relname, ".mp2")
- || BLI_testextensie(file->relname, ".ac3")
- || BLI_testextensie(file->relname, ".aac")
- || BLI_testextensie(file->relname, ".flac")
- || BLI_testextensie(file->relname, ".wma")
- || BLI_testextensie(file->relname, ".eac3")) {
- file->flags |= SOUNDFILE;
- }
+ } else if(BLI_testextensie_array(file->relname, imb_ext_movie)) {
+ file->flags |= MOVIEFILE;
+ } else if(BLI_testextensie_array(file->relname, imb_ext_audio)) {
+ file->flags |= SOUNDFILE;
}
}
}
@@ -1018,7 +882,7 @@ static int groupname_to_code(char *group)
if (lslash)
lslash[0]= '\0';
- return BLO_idcode_from_name(buf);
+ return BKE_idcode_from_name(buf);
}
void filelist_from_library(struct FileList* filelist)
@@ -1271,7 +1135,7 @@ static void thumbnail_joblist_free(ThumbnailJob *tj)
BLI_freelistN(&tj->loadimages);
}
-static void thumbnails_startjob(void *tjv, short *stop, short *do_update)
+static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float *progress)
{
ThumbnailJob *tj= tjv;
FileImage* limg = tj->loadimages.first;
@@ -1282,7 +1146,9 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update)
while ( (*stop==0) && (limg) ) {
if ( limg->flags & IMAGEFILE ) {
limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_IMAGE);
- } else if ( limg->flags & MOVIEFILE ) {
+ } else if ( limg->flags & BLENDERFILE ) {
+ limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_BLEND);
+ } else if ( limg->flags & MOVIEFILE ) {
limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_MOVIE);
if (!limg->img) {
/* remember that file can't be loaded via IMB_open_anim */
@@ -1336,9 +1202,9 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C)
tj->filelist = filelist;
for (idx = 0; idx < filelist->numfiles;idx++) {
if (!filelist->filelist[idx].image) {
- if ( (filelist->filelist[idx].flags & IMAGEFILE) || (filelist->filelist[idx].flags & MOVIEFILE) ) {
+ if ( (filelist->filelist[idx].flags & (IMAGEFILE|MOVIEFILE|BLENDERFILE)) ) {
FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage");
- BLI_join_dirfile(limg->path, filelist->dir, filelist->filelist[idx].relname);
+ BLI_strncpy(limg->path, filelist->filelist[idx].path, FILE_MAX);
limg->index= idx;
limg->flags= filelist->filelist[idx].flags;
BLI_addtail(&tj->loadimages, limg);
@@ -1349,10 +1215,10 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C)
BKE_reports_init(&tj->reports, RPT_PRINT);
/* setup job */
- steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, 0);
+ steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0);
WM_jobs_customdata(steve, tj, thumbnails_free);
WM_jobs_timer(steve, 0.5, NC_WINDOW, NC_WINDOW);
- WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update);
+ WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update, NULL);
/* start the job */
WM_jobs_start(CTX_wm_manager(C), steve);
@@ -1360,5 +1226,10 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C)
void thumbnails_stop(struct FileList* filelist, const struct bContext* C)
{
- WM_jobs_kill(CTX_wm_manager(C), filelist);
+ WM_jobs_kill(CTX_wm_manager(C), filelist, NULL);
+}
+
+int thumbnails_running(struct FileList* filelist, const struct bContext* C)
+{
+ return WM_jobs_test(CTX_wm_manager(C), filelist);
}
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index e75a3143817..b2a86b9c764 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -86,6 +86,7 @@ int folderlist_clear_next(struct SpaceFile* sfile);
void thumbnails_stop(struct FileList* filelist, const struct bContext* C);
void thumbnails_start(struct FileList* filelist, const struct bContext* C);
+int thumbnails_running(struct FileList* filelist, const struct bContext* C);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 7aed890e9ba..52d59270663 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -42,6 +42,15 @@
#include <sys/times.h>
#endif
+/* path/file handeling stuff */
+#ifndef WIN32
+ #include <dirent.h>
+ #include <unistd.h>
+#else
+ #include <io.h>
+ #include "BLI_winstuff.h"
+#endif
+
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
@@ -53,10 +62,7 @@
#include "BLI_storage_types.h"
#include "BLI_dynstr.h"
-#include "BLO_readfile.h"
-
#include "BKE_context.h"
-#include "BKE_screen.h"
#include "BKE_global.h"
#include "BLF_api.h"
@@ -67,8 +73,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "RNA_access.h"
@@ -77,16 +81,10 @@
#include "file_intern.h"
#include "filelist.h"
-#if defined __BeOS
-static int fnmatch(const char *pattern, const char *string, int flags)
-{
- return 0;
-}
-#elif defined WIN32 && !defined _LIBC
- /* use fnmatch included in blenlib */
- #include "BLI_fnmatch.h"
+#if defined WIN32 && !defined _LIBC
+# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */
#else
- #include <fnmatch.h>
+# include <fnmatch.h>
#endif
FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile)
@@ -99,7 +97,6 @@ FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile)
short ED_fileselect_set_params(SpaceFile *sfile)
{
- char name[FILE_MAX], dir[FILE_MAX], file[FILE_MAX];
FileSelectParams *params;
wmOperator *op = sfile->op;
@@ -107,10 +104,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
if (!sfile->params) {
sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams");
/* set path to most recently opened .blend */
- BLI_strncpy(sfile->params->dir, G.sce, sizeof(sfile->params->dir));
- BLI_split_dirfile(G.sce, dir, file);
- 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 */
+ BLI_split_dirfile(G.sce, sfile->params->dir, sfile->params->file);
}
params = sfile->params;
@@ -124,19 +118,33 @@ short ED_fileselect_set_params(SpaceFile *sfile)
else
params->type = FILE_SPECIAL;
- if (RNA_property_is_set(op->ptr, "path")) {
- RNA_string_get(op->ptr, "path", name);
+ if (RNA_struct_find_property(op->ptr, "filepath") && RNA_property_is_set(op->ptr, "filepath")) {
+ char name[FILE_MAX];
+ RNA_string_get(op->ptr, "filepath", name);
if (params->type == FILE_LOADLIB) {
BLI_strncpy(params->dir, name, sizeof(params->dir));
- BLI_cleanup_dir(G.sce, params->dir);
- } else {
- /* if operator has path set, use it, otherwise keep the last */
- BLI_path_abs(name, G.sce);
- BLI_split_dirfile(name, dir, file);
- BLI_strncpy(params->file, file, sizeof(params->file));
- BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */
+ sfile->params->file[0]= '\0';
+ }
+ else {
+ BLI_split_dirfile(name, sfile->params->dir, sfile->params->file);
}
}
+ else {
+ if (RNA_struct_find_property(op->ptr, "directory") && RNA_property_is_set(op->ptr, "directory")) {
+ RNA_string_get(op->ptr, "directory", params->dir);
+ sfile->params->file[0]= '\0';
+ }
+
+ if (RNA_struct_find_property(op->ptr, "filename") && RNA_property_is_set(op->ptr, "filename")) {
+ RNA_string_get(op->ptr, "filename", params->file);
+ }
+ }
+
+ if(params->dir[0]) {
+ BLI_cleanup_dir(G.sce, params->dir);
+ BLI_path_abs(params->dir, G.sce);
+ }
+
params->filter = 0;
if(RNA_struct_find_property(op->ptr, "filter_blender"))
params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;
@@ -160,8 +168,13 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->filter |= RNA_boolean_get(op->ptr, "filter_btx") ? BTXFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_collada"))
params->filter |= RNA_boolean_get(op->ptr, "filter_collada") ? COLLADAFILE : 0;
- if (params->filter != 0)
- params->flag |= FILE_FILTER;
+ if (params->filter != 0) {
+ if (U.uiflag & USER_FILTERFILEEXTS) {
+ params->flag |= FILE_FILTER;
+ } else {
+ params->flag &= ~FILE_FILTER;
+ }
+ }
if (U.uiflag & USER_HIDE_DOT) {
params->flag |= FILE_HIDE_DOT;
@@ -189,6 +202,13 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->filter = 0;
params->sort = FILE_SORT_ALPHA;
}
+
+
+ /* initialize the list with previous folders */
+ if (!sfile->folders_prev)
+ sfile->folders_prev = folderlist_new();
+ folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
+
return 1;
}
@@ -205,11 +225,11 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar)
if (layout->flag & FILE_LAYOUT_HOR) {
int width = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x;
- numfiles = width/layout->tile_w + 1;
+ numfiles = (float)width/(float)layout->tile_w+0.5;
return numfiles*layout->rows;
} else {
int height = ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y;
- numfiles = height/layout->tile_h + 1;
+ numfiles = (float)height/(float)layout->tile_h+0.5;
return numfiles*layout->columns;
}
}
@@ -255,7 +275,7 @@ float file_string_width(const char* str)
{
uiStyle *style= U.uistyles.first;
uiStyleFontSet(&style->widget);
- return BLF_width((char *)str);
+ return BLF_width(style->widget.uifont_id, (char *)str);
}
float file_font_pointsize()
@@ -264,7 +284,7 @@ float file_font_pointsize()
char tmp[2] = "X";
uiStyle *style= U.uistyles.first;
uiStyleFontSet(&style->widget);
- s = BLF_height(tmp);
+ s = BLF_height(style->widget.uifont_id, tmp);
return style->widget.points;
}
@@ -433,10 +453,55 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern)
return match;
}
-
void autocomplete_directory(struct bContext *C, char *str, void *arg_v)
{
- char tmp[FILE_MAX];
+ SpaceFile *sfile= CTX_wm_space_file(C);
+
+ /* search if str matches the beginning of name */
+ if(str[0] && sfile->files) {
+ char dirname[FILE_MAX];
+
+ DIR *dir;
+ struct dirent *de;
+
+ BLI_split_dirfile(str, dirname, NULL);
+
+ dir = opendir(dirname);
+
+ if(dir) {
+ AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX);
+
+ while ((de = readdir(dir)) != NULL) {
+ if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) {
+ /* pass */
+ }
+ else {
+ char path[FILE_MAX];
+ struct stat status;
+
+ BLI_join_dirfile(path, dirname, de->d_name);
+
+ if (stat(path, &status) == 0) {
+ if (S_ISDIR(status.st_mode)) { /* is subdir */
+ autocomplete_do_name(autocpl, path);
+ }
+ }
+ }
+ }
+ closedir(dir);
+
+ autocomplete_end(autocpl, str);
+ if (BLI_exists(str)) {
+ BLI_add_slash(str);
+ } else {
+ BLI_strncpy(sfile->params->dir, str, sizeof(sfile->params->dir));
+ }
+ }
+ }
+}
+
+void autocomplete_file(struct bContext *C, char *str, void *arg_v)
+{
SpaceFile *sfile= CTX_wm_space_file(C);
/* search if str matches the beginning of name */
@@ -447,19 +512,11 @@ void autocomplete_directory(struct bContext *C, char *str, void *arg_v)
for(i= 0; i<nentries; ++i) {
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_join_dirfile(tmp, dir, file->relname);
- autocomplete_do_name(autocpl,tmp);
+ if (file && S_ISREG(file->type)) {
+ autocomplete_do_name(autocpl, file->relname);
}
}
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/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index d3e859602d7..8211257da02 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -55,7 +55,6 @@
#define ID ID_
#include <CoreServices/CoreServices.h>
-#include "BKE_utildefines.h"
#endif
#ifdef __linux__
@@ -248,12 +247,41 @@ void fsmenu_write_file(struct FSMenu* fsmenu, const char *filename)
fclose(fp);
}
-void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
+void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
{
char line[256];
FSMenuCategory category = FS_CATEGORY_BOOKMARKS;
FILE *fp;
+ fp = fopen(filename, "r");
+ if (!fp) return;
+
+ while ( fgets ( line, 256, fp ) != NULL ) /* read a line */
+ {
+ if (strncmp(line, "[Bookmarks]", 11)==0){
+ category = FS_CATEGORY_BOOKMARKS;
+ } else if (strncmp(line, "[Recent]", 8)==0){
+ category = FS_CATEGORY_RECENT;
+ } else {
+ int len = strlen(line);
+ if (len>0) {
+ if (line[len-1] == '\n') {
+ line[len-1] = '\0';
+ }
+ if (BLI_exist(line)) {
+ fsmenu_insert_entry(fsmenu, category, line, 0, 1);
+ }
+ }
+ }
+ }
+ fclose(fp);
+}
+
+void fsmenu_read_system(struct FSMenu* fsmenu)
+{
+ char line[256];
+ FILE *fp;
+
#ifdef WIN32
/* Add the drive names to the listing */
{
@@ -266,7 +294,7 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
for (i=2; i < 26; i++) {
if ((tmp>>i) & 1) {
- tmps[0]='a'+i;
+ tmps[0]='A'+i;
tmps[1]=':';
tmps[2]='\\';
tmps[3]=0;
@@ -309,7 +337,7 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
/* As 10.4 doesn't provide proper API to retrieve the favorite places,
assume they are the standard ones
TODO : replace hardcoded paths with proper BLI_get_folder calls */
- home = BLI_gethome();
+ home = getenv("HOME");
if(home) {
BLI_snprintf(line, 256, "%s/", home);
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
@@ -429,15 +457,14 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
#else
/* unix */
{
- char dir[FILE_MAXDIR];
- char *home= BLI_gethome();
+ char *home= getenv("HOME");
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);
- if (BLI_exists(dir)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, dir, 1, 0);
+ BLI_snprintf(line, FILE_MAXDIR, "%s/", home);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home);
+ if (BLI_exists(line)) {
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
}
}
@@ -446,7 +473,6 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
#ifdef __linux__
/* loop over mount points */
struct mntent *mnt;
- FILE *fp;
int len;
fp = setmntent (MOUNTED, "r");
@@ -461,8 +487,8 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
len= strlen(mnt->mnt_dir);
if(len && mnt->mnt_dir[len-1] != '/') {
- BLI_snprintf(dir, FILE_MAXDIR, "%s/", mnt->mnt_dir);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, dir, 1, 0);
+ BLI_snprintf(line, FILE_MAXDIR, "%s/", mnt->mnt_dir);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0);
}
else
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0);
@@ -482,31 +508,9 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
}
#endif
#endif
-
- fp = fopen(filename, "r");
- if (!fp) return;
-
- while ( fgets ( line, 256, fp ) != NULL ) /* read a line */
- {
- if (strncmp(line, "[Bookmarks]", 11)==0){
- category = FS_CATEGORY_BOOKMARKS;
- } else if (strncmp(line, "[Recent]", 8)==0){
- category = FS_CATEGORY_RECENT;
- } else {
- int len = strlen(line);
- if (len>0) {
- if (line[len-1] == '\n') {
- line[len-1] = '\0';
- }
- if (BLI_exist(line)) {
- fsmenu_insert_entry(fsmenu, category, line, 0, 1);
- }
- }
- }
- }
- fclose(fp);
}
+
static void fsmenu_free_category(struct FSMenu* fsmenu, FSMenuCategory category)
{
FSMenuEntry *fsme= fsmenu_get_category(fsmenu, category);
diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h
index 8304b104a4f..dcf8d3eb632 100644
--- a/source/blender/editors/space_file/fsmenu.h
+++ b/source/blender/editors/space_file/fsmenu.h
@@ -68,7 +68,10 @@ void fsmenu_remove_entry (struct FSMenu* fsmenu, FSMenuCategory category, int i
void fsmenu_write_file (struct FSMenu* fsmenu, const char *filename);
/** reads the 'bookmarks' from the specified file */
-void fsmenu_read_file (struct FSMenu* fsmenu, const char *filename);
+void fsmenu_read_bookmarks (struct FSMenu* fsmenu, const char *filename);
+
+ /** adds system specific directories */
+void fsmenu_read_system (struct FSMenu* fsmenu);
/** Free's all the memory associated with the fsmenu */
void fsmenu_free (struct FSMenu* fsmenu);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 6cef78d4bee..7b9423332f2 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -43,7 +43,6 @@
#include "BLI_rand.h"
#include "BLI_storage_types.h"
-#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -195,13 +194,35 @@ static void file_refresh(const bContext *C, ScrArea *sa)
filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0);
if (filelist_empty(sfile->files))
{
+ thumbnails_stop(sfile->files, C);
filelist_readdir(sfile->files);
- thumbnails_start(sfile->files, C);
+ if(params->sort!=FILE_SORT_NONE) {
+ filelist_sort(sfile->files, params->sort);
+ }
BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX);
+ if(params->display == FILE_IMGDISPLAY) {
+ thumbnails_start(sfile->files, C);
+ }
} else {
- filelist_filter(sfile->files);
+ if(params->sort!=FILE_SORT_NONE) {
+ thumbnails_stop(sfile->files, C);
+ filelist_sort(sfile->files, params->sort);
+ if(params->display == FILE_IMGDISPLAY) {
+ thumbnails_start(sfile->files, C);
+ }
+ } else {
+ if(params->display == FILE_IMGDISPLAY) {
+ if (!thumbnails_running(sfile->files,C)) {
+ thumbnails_start(sfile->files, C);
+ }
+ } else {
+ /* stop any running thumbnail jobs if we're not
+ displaying them - speedup for NFS */
+ thumbnails_stop(sfile->files, C);
+ }
+ filelist_filter(sfile->files);
+ }
}
- if(params->sort!=FILE_SORT_NONE) filelist_sort(sfile->files, params->sort);
if (params->renamefile[0] != '\0') {
int idx = filelist_find(sfile->files, params->renamefile);
@@ -211,6 +232,7 @@ static void file_refresh(const bContext *C, ScrArea *sa)
file->flags |= EDITING;
}
}
+ BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit));
params->renamefile[0] = '\0';
}
if (sfile->layout) sfile->layout->dirty= 1;
@@ -353,6 +375,7 @@ void file_operatortypes(void)
WM_operatortype_append(FILE_OT_directory_new);
WM_operatortype_append(FILE_OT_delete);
WM_operatortype_append(FILE_OT_rename);
+ WM_operatortype_append(FILE_OT_smoothscroll);
}
/* NOTE: do not add .blend file reading on this level */
@@ -370,6 +393,7 @@ void file_keymap(struct wmKeyConfig *keyconf)
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);
+ WM_keymap_verify_item(keymap, "FILE_OT_smoothscroll", TIMER1, KM_ANY, KM_ANY, 0);
/* keys for main area */
keymap= WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0);
@@ -377,6 +401,9 @@ void file_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, 0, 0);
kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", 1);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_ALT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", 1);
+ RNA_boolean_set(kmi->ptr, "fill", 1);
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);
WM_keymap_add_item(keymap, "FILE_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0);
@@ -395,6 +422,7 @@ void file_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0);
RNA_int_set(kmi->ptr, "increment",-100);
+
/* keys for button area (top) */
keymap= WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0);
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
@@ -439,7 +467,12 @@ static void file_channel_area_listener(ARegion *ar, wmNotifier *wmn)
/* add handlers, stuff you only do once or on area/region changes */
static void file_header_area_init(wmWindowManager *wm, ARegion *ar)
{
+ wmKeyMap *keymap;
+
ED_region_header_init(ar);
+
+ keymap= WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void file_header_area_draw(const bContext *C, ARegion *ar)
@@ -556,9 +589,16 @@ void ED_spacetype_file(void)
void ED_file_init(void)
{
- char name[FILE_MAX];
- BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
- fsmenu_read_file(fsmenu_get(), name);
+ char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL);
+
+ fsmenu_read_system(fsmenu_get());
+
+ if (cfgdir) {
+ char name[FILE_MAX];
+ BLI_make_file_string("/", name, cfgdir, BLENDER_BOOKMARK_FILE);
+ fsmenu_read_bookmarks(fsmenu_get(), name);
+ }
+
filelist_init_icons();
IMB_thumb_makedirs();
}
diff --git a/source/blender/editors/space_file/writeimage.c b/source/blender/editors/space_file/writeimage.c
index ade0b7db0ca..b69bfdc0231 100644
--- a/source/blender/editors/space_file/writeimage.c
+++ b/source/blender/editors/space_file/writeimage.c
@@ -29,7 +29,6 @@
#include <string.h>
-#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -43,17 +42,16 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_image.h"
-#include "BKE_utildefines.h"
#include "RE_pipeline.h"
#include "file_intern.h"
/* XXX */
-static void error() {}
+static void error(const char *dummy) {}
static void waitcursor(int val) {}
-static void activate_fileselect() {}
-static int saveover() {return 0;}
+static void activate_fileselect(int d1, char *d2, char *d3, void *d4) {}
+static int saveover(const char *dummy) {return 0;}
/* XXX */
@@ -125,9 +123,11 @@ static void save_rendered_image_cb_real(char *name, int confirm)
void save_image_filesel_str(Scene *scene, char *str)
{
switch(scene->r.imtype) {
+#ifdef WITH_HDR
case R_RADHDR:
strcpy(str, "Save Radiance HDR");
break;
+#endif
case R_FFMPEG:
case R_H264:
case R_XVID:
@@ -143,21 +143,24 @@ void save_image_filesel_str(Scene *scene, char *str)
case R_BMP:
strcpy(str, "Save BMP");
break;
+#ifdef WITH_TIFF
case R_TIFF:
- if (G.have_libtiff)
- strcpy(str, "Save TIFF");
+ strcpy(str, "Save TIFF");
break;
+#endif
#ifdef WITH_OPENEXR
case R_OPENEXR:
strcpy(str, "Save OpenEXR");
break;
#endif
+#ifdef WITH_CINEON
case R_CINEON:
strcpy(str, "Save Cineon");
break;
case R_DPX:
strcpy(str, "Save DPX");
break;
+#endif
case R_RAWTGA:
strcpy(str, "Save Raw Targa");
break;
@@ -167,9 +170,6 @@ void save_image_filesel_str(Scene *scene, char *str)
case R_IRIZ:
strcpy(str, "Save IRIS");
break;
- case R_HAMX:
- strcpy(str, "Save HAMX");
- break;
case R_TARGA:
strcpy(str, "Save Targa");
break;
@@ -183,7 +183,6 @@ void save_image_filesel_str(Scene *scene, char *str)
#endif
/* default we save jpeg, also for all movie formats */
case R_JPEG90:
- case R_MOVIE:
case R_AVICODEC:
case R_AVIRAW:
case R_AVIJPEG: