diff options
author | corvid <corvid@lavabit.com> | 2012-11-05 06:01:20 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2012-11-05 06:01:20 +0000 |
commit | 24e9552f57ba4b10f6859acaa9a0218caf9cadf8 (patch) | |
tree | ca03ec2db72a18f260e4dc4447ea0b4fd1385886 /dw/fltkviewport.cc | |
parent | 953f81e651465603f537270859732ccee038ea52 (diff) |
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...
Diffstat (limited to 'dw/fltkviewport.cc')
-rw-r--r-- | dw/fltkviewport.cc | 18 |
1 files changed, 10 insertions, 8 deletions
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); } |