From 24e9552f57ba4b10f6859acaa9a0218caf9cadf8 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 5 Nov 2012 06:01:20 +0000 Subject: base selection scroll speed on distance from viewport I played around with different speed algorithms, without anything seeming _obviously_ best, so here's something to start with, anyway... --- dw/fltkviewport.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'dw/fltkviewport.cc') diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index 2dcc199b..748262d8 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -435,16 +435,18 @@ void FltkViewport::scroll (core::ScrollCommand cmd) */ void FltkViewport::selectionScroll () { + int distance; int dx = 0, dy = 0; - if (mouse_x < x()) - dx = -hscrollbar->linesize (); - else if (mouse_x >= x() + w()) - dx = hscrollbar->linesize (); - if (mouse_y < y()) - dy = -vscrollbar->linesize (); - else if (mouse_y >= y() + h()) - dy = vscrollbar->linesize (); + if ((distance = x() - mouse_x) > 0) + dx = -distance * hscrollbar->linesize () / 48 - 1; + else if ((distance = mouse_x - (x() + w())) > 0) + dx = distance * hscrollbar->linesize () / 48 + 1; + if ((distance = y() - mouse_y) > 0) + dy = -distance * vscrollbar->linesize () / 48 - 1; + else if ((distance = mouse_y - (y() + h())) > 0) + dy = distance * vscrollbar->linesize () / 48 + 1; + scroll (dx, dy); } -- cgit v1.2.3