diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_fileselect.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 13 |
4 files changed, 18 insertions, 16 deletions
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index 52d6fe479fa..8d7184902eb 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -83,7 +83,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar); FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar); int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar); -int ED_fileselect_layout_offset(FileLayout* layout, int x, int y); +int ED_fileselect_layout_offset(FileLayout* layout, int clamp_bounds, int x, int y); void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 63729f03e58..6259199d317 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -518,7 +518,7 @@ void file_draw_list(const bContext *C, ARegion *ar) draw_dividers(layout, v2d); } - offset = ED_fileselect_layout_offset(layout, ar->v2d.cur.xmin, -ar->v2d.cur.ymax); + offset = ED_fileselect_layout_offset(layout, 0, ar->v2d.cur.xmin, -ar->v2d.cur.ymax); if (offset<0) offset=0; numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index ab259f1e1cb..baf7e42bb63 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -69,7 +69,7 @@ /* ---------- FILE SELECTION ------------ */ -static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, int x, int y) +static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, int clamp_bounds, int x, int y) { float fx,fy; int active_file = -1; @@ -77,7 +77,7 @@ static int find_file_mouse(SpaceFile *sfile, struct ARegion* ar, int x, int y) 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); + active_file = ED_fileselect_layout_offset(sfile->layout, clamp_bounds, v2d->tot.xmin + fx, v2d->tot.ymax - fy); return active_file; } @@ -138,10 +138,10 @@ static FileSelect file_select(bContext* C, const rcti* rect, short selecting, sh // FileLayout *layout = ED_fileselect_get_layout(sfile, ar); int numfiles = filelist_numfiles(sfile->files); - + params->selstate = NOTACTIVE; - first_file = find_file_mouse(sfile, ar, rect->xmin, rect->ymax); - last_file = find_file_mouse(sfile, ar, rect->xmax, rect->ymin); + first_file = find_file_mouse(sfile, ar, 1, rect->xmin, rect->ymax); + last_file = find_file_mouse(sfile, ar, 1, rect->xmax, rect->ymin); clamp_to_filelist(numfiles, &first_file, &last_file); @@ -206,10 +206,9 @@ static FileSelect file_select(bContext* C, const rcti* rect, short selecting, sh static int file_border_select_exec(bContext *C, wmOperator *op) { ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); short selecting; rcti rect; - + selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); rect.xmin= RNA_int_get(op->ptr, "xmin"); rect.ymin= RNA_int_get(op->ptr, "ymin"); @@ -452,7 +451,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); + actfile = find_file_mouse(sfile, ar, 0, mx , my); if((actfile >= 0) && (actfile < numfiles)) params->active_file=actfile; @@ -662,8 +661,6 @@ void FILE_OT_parent(struct wmOperatorType *ot) int file_refresh_exec(bContext *C, wmOperator *unused) { - SpaceFile *sfile= CTX_wm_space_file(C); - file_change_dir(C, 1); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 6945e8c959a..da8dc4b654c 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -220,7 +220,7 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) } } -int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) +int ED_fileselect_layout_offset(FileLayout* layout, int clamp_bounds, int x, int y) { int offsetx, offsety; int active_file; @@ -231,9 +231,14 @@ int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) offsetx = (x)/(layout->tile_w + 2*layout->tile_border_x); offsety = (y)/(layout->tile_h + 2*layout->tile_border_y); - if (offsetx > layout->columns-1) return -1 ; - if (offsety > layout->rows-1) return -1 ; - + if (clamp_bounds) { + CLAMP(offsetx, 0, layout->columns-1); + CLAMP(offsety, 0, layout->rows-1); + } else { + if (offsetx > layout->columns-1) return -1 ; + if (offsety > layout->rows-1) return -1 ; + } + if (layout->flag & FILE_LAYOUT_HOR) active_file = layout->rows*offsetx + offsety; else |