From 3afeacbe13680d45b3bd041378bc5366c99e5758 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 14 Mar 2018 14:00:47 +0100 Subject: [PATCH] slider small increment accuracy --- src/GraphicObjects/Slider.cs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) 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); -- 2.47.3