diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2015-09-19 05:24:48 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2015-09-19 05:24:48 +0300 |
commit | 36d64240e6898a5372a072f36a9ef30152e260fc (patch) | |
tree | 1418118c7ac6b1d550fcfd994c9d24069ad74fc2 /source/blender/editors/space_file/file_ops.c | |
parent | d7e88fe1fd467da17b8436fe857b79003bbb3eba (diff) |
File Browser: Scroll view on normal selection too
Adjusts view after mouse/border selection if some selected items are out of view bounds.
To get as much of the selection into view as possible, this adjusts view first for the last, then for the first element in the selection.
Also, if region is pretty small, view adjustment is skipped, as otherwise the view is focused on the first element only, which isn't really useful IMHO.
Maybe not so nice: Since we do two view alignment iterations, UI_view2d_curRect_validate, which is a rather big function *might* be called twice under certain circumstances (border select & total size of selected elements is exceeds view bounds). I think that's totally acceptable though.
Diffstat (limited to 'source/blender/editors/space_file/file_ops.c')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index eb0ad4bbff9..8347ad87258 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -305,6 +305,20 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, if (select != FILE_SEL_ADD && !file_is_any_selected(sfile->files)) { sfile->params->active_file = -1; } + else { + ARegion *ar = CTX_wm_region(C); + const FileLayout *layout = ED_fileselect_get_layout(sfile, ar); + + /* Adjust view to display selection. Doing iterations for first and last + * selected item makes view showing as much of the selection possible. + * Not really useful if tiles are (almost) bigger than viewbounds though. */ + if (((layout->flag & FILE_LAYOUT_HOR) && ar->winx > (1.2f * layout->tile_w)) || + ((layout->flag & FILE_LAYOUT_VER) && ar->winy > (2.0f * layout->tile_h))) + { + file_ensure_inside_viewbounds(ar, sfile, sel.last); + file_ensure_inside_viewbounds(ar, sfile, sel.first); + } + } /* update operator for name change event */ file_draw_check(C); |