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
path: root/source
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2015-09-19 04:05:08 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-09-23 17:02:22 +0300
commit13589207160316d8a5d1845c0a7302f3422973d3 (patch)
tree00c1066778922d723e7fd349a98a05680f1a8f76 /source
parent42eb1cc64e6adc941ac38e939d9dca6ec3d11793 (diff)
Fix file key select using wrong file after border select in scrolled view
Basically, after border selecting, a wrong file was selected by using arrow keys if the screen was scrolled a bit vertically. Reason was that we didn't use correct view space coordinates but region space coordinates for measuring distance from mouse to first/last file in selection after border select.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_file/file_ops.c11
-rw-r--r--source/blender/editors/space_file/file_utils.c3
2 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 74070a255bd..08b6564ec97 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -276,6 +276,9 @@ static int file_border_select_find_last_selected(
FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
rcti bounds_first, bounds_last;
int dist_first, dist_last;
+ float mouseco_view[2];
+
+ UI_view2d_region_to_view(&ar->v2d, UNPACK2(mouse_xy), &mouseco_view[0], &mouseco_view[1]);
file_tile_boundbox(ar, layout, sel->first, &bounds_first);
file_tile_boundbox(ar, layout, sel->last, &bounds_last);
@@ -285,18 +288,18 @@ static int file_border_select_find_last_selected(
(layout->flag & FILE_LAYOUT_VER && bounds_first.ymin != bounds_last.ymin))
{
/* use vertical distance */
- const int my_loc = mouse_xy[1] - ar->winrct.ymin;
+ const int my_loc = (int)mouseco_view[1];
dist_first = BLI_rcti_length_y(&bounds_first, my_loc);
dist_last = BLI_rcti_length_y(&bounds_last, my_loc);
}
else {
/* use horizontal distance */
- const int mx_loc = mouse_xy[0] - ar->winrct.xmin;
+ const int mx_loc = (int)mouseco_view[0];
dist_first = BLI_rcti_length_x(&bounds_first, mx_loc);
dist_last = BLI_rcti_length_x(&bounds_last, mx_loc);
}
- return dist_first < dist_last ? sel->first : sel->last;
+ return (dist_first < dist_last) ? sel->first : sel->last;
}
static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -339,7 +342,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *
}
}
params->sel_first = sel.first; params->sel_last = sel.last;
- params->active_file = file_border_select_find_last_selected(sfile, ar, &sel, &event->x);
+ params->active_file = file_border_select_find_last_selected(sfile, ar, &sel, event->mval);
}
else {
params->highlight_file = -1;
diff --git a/source/blender/editors/space_file/file_utils.c b/source/blender/editors/space_file/file_utils.c
index 8a80e4a69ee..435c04b8ef1 100644
--- a/source/blender/editors/space_file/file_utils.c
+++ b/source/blender/editors/space_file/file_utils.c
@@ -41,6 +41,7 @@ void file_tile_boundbox(const ARegion *ar, FileLayout *layout, const int file, r
int xmin, ymax;
ED_fileselect_layout_tilepos(layout, file, &xmin, &ymax);
+ ymax = ar->v2d.tot.ymax - ymax; /* real, view space ymax */
BLI_rcti_init(r_bounds, xmin, xmin + layout->tile_w + layout->tile_border_x,
- ar->winy - ymax - layout->tile_h - layout->tile_border_y, ar->winy - ymax);
+ ymax - layout->tile_h - layout->tile_border_y, ymax);
}