[Bf-blender-cvs] [36d6424] master: File Browser: Scroll view on normal selection too

Julian Eisel noreply at git.blender.org
Sat Sep 19 04:39:20 CEST 2015


Commit: 36d64240e6898a5372a072f36a9ef30152e260fc
Author: Julian Eisel
Date:   Sat Sep 19 04:24:48 2015 +0200
Branches: master
https://developer.blender.org/rB36d64240e6898a5372a072f36a9ef30152e260fc

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.

===================================================================

M	source/blender/editors/space_file/file_ops.c

===================================================================

diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index eb0ad4b..8347ad8 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);




More information about the Bf-blender-cvs mailing list