diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-14 14:00:47 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-14 14:00:47 +0100 |
| commit | 296348b5bc983112e2d4399c73d5f64e4e736dae (patch) | |
| tree | a4cb3eacaab35989122f3081a0854d639adecfa6 | |
| parent | 2c8ebf731af0a626c5d684efc5c2853edd8c3c2d (diff) | |
slider small increment accuracy
| -rw-r--r-- | src/GraphicObjects/Slider.cs | 26 |
1 files 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); |