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:
authorAndrea Weikert <elubie@gmx.net>2009-09-20 19:02:14 +0400
committerAndrea Weikert <elubie@gmx.net>2009-09-20 19:02:14 +0400
commit85e529433b62b27680203221083481db04e867a1 (patch)
tree48235e8acf2b1b0a7fc263badec7119ca6edb5dd /source/blender/editors/space_file
parentec8c47f0c08bf500bbf5d5fe6a833942c7710d29 (diff)
2.5 filebrowser
* fix selection related bugs: ** selection outside filelist would select first item ** border select would enter directory even if more than one is selected
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_ops.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index faca6db75bf..5603c0bb2e4 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -68,7 +68,7 @@
/* ---------- 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, short x, short y)
{
float fx,fy;
int active_file = -1;
@@ -78,15 +78,6 @@ static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, short x, short
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 +100,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 +139,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 +155,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);
@@ -168,7 +189,7 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s
}
}
- }
+ }
return retval;
}
@@ -449,7 +470,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;