]> O.S.I.I.S - jp/crow.git/commitdiff
slider small increment accuracy
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 14 Mar 2018 13:00:47 +0000 (14:00 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 14 Mar 2018 13:00:47 +0000 (14:00 +0100)
src/GraphicObjects/Slider.cs

index 59eb99ece0b24ae2bd7729c9d0eddf28529768e9..4492c40676e50d2b64f6783eeef6f0d310423760 100644 (file)
@@ -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);