From: Jean-Philippe Bruyère Date: Wed, 14 Mar 2018 13:00:47 +0000 (+0100) Subject: slider small increment accuracy X-Git-Tag: 0.7.3~4^2~8 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=3afeacbe13680d45b3bd041378bc5366c99e5758;p=jp%2Fcrow.git slider small increment accuracy --- diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 59eb99ec..4492c406 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -215,11 +215,27 @@ namespace Crow } public override void onMouseMove (object sender, MouseMoveEventArgs e) { - if (holdCursor) { - if (_orientation == Orientation.Horizontal) - Value += (double)e.XDelta / unity; - else - Value += (double)e.YDelta / unity; + if (holdCursor) { + Point m = ScreenPointToLocal (e.Position); + Rectangle r = ClientRectangle; + + if (_orientation == Orientation.Horizontal) { + if (r.Width - _cursorSize == 0) + return; + double unit = (Maximum - Minimum) / (double)(r.Width - _cursorSize); + double tmp = (double)m.X * unit; + tmp -= tmp % SmallIncrement; + Value = tmp; + } else { + if (r.Height - _cursorSize == 0) + return; + double unit = (Maximum - Minimum) / (double)(r.Height - _cursorSize); + double tmp = (double)m.Y * unit; + tmp -= tmp % SmallIncrement; + Value = tmp; + } + + } base.onMouseMove (sender, e);