[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23366] trunk/blender/source/blender/ editors/space_file/file_ops.c: 2.5 filebrowser
Andrea Weikert
elubie at gmx.net
Sun Sep 20 17:02:14 CEST 2009
Revision: 23366
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23366
Author: elubie
Date: 2009-09-20 17:02:14 +0200 (Sun, 20 Sep 2009)
Log Message:
-----------
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
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_file/file_ops.c
Modified: trunk/blender/source/blender/editors/space_file/file_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_ops.c 2009-09-20 14:14:40 UTC (rev 23365)
+++ trunk/blender/source/blender/editors/space_file/file_ops.c 2009-09-20 15:02:14 UTC (rev 23366)
@@ -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 @@
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 @@
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 @@
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 @@
}
}
+ /* 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 @@
}
}
- }
+ }
return retval;
}
More information about the Bf-blender-cvs
mailing list