diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-09-13 13:39:28 +0000 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-09-13 13:39:28 +0000 |
| commit | faff80de76b68ef19013bacb5b7e1d8a2cbb1db2 (patch) | |
| tree | 329a63fb9790858ddf4f998d0e8f802d9322c1b2 | |
| parent | 3e93e1e290952df1c9ed86ffea8835e2f12679a4 (diff) | |
numeric control: min/max change => actual value check
| -rw-r--r-- | Crow/src/Widgets/NumericControl.cs | 12 | ||||
| -rw-r--r-- | Crow/src/Widgets/Slider.cs | 18 |
2 files changed, 19 insertions, 11 deletions
diff --git a/Crow/src/Widgets/NumericControl.cs b/Crow/src/Widgets/NumericControl.cs index df8fa17d..5c7c50c2 100644 --- a/Crow/src/Widgets/NumericControl.cs +++ b/Crow/src/Widgets/NumericControl.cs @@ -55,6 +55,10 @@ namespace Crow { maxValue = value; NotifyValueChangedAuto (maxValue); + + if (Value > maxValue) + Value = maxValue; + registerUpdate (); } } @@ -68,6 +72,10 @@ namespace Crow { smallStep = value; NotifyValueChangedAuto (smallStep); + + if (Value < minValue) + Value = minValue; + registerUpdate (); } } @@ -97,7 +105,7 @@ namespace Crow { actualValue = minValue; else if (value > maxValue) actualValue = maxValue; - else + else actualValue = value; actualValue = Math.Round (actualValue, decimals); @@ -110,7 +118,7 @@ namespace Crow { protected virtual void registerUpdate () => RegisterForRedraw (); - + protected virtual void onUp (object sender, MouseButtonEventArgs e) { if (IFace.Ctrl) diff --git a/Crow/src/Widgets/Slider.cs b/Crow/src/Widgets/Slider.cs index 8e197fda..e1e8d90e 100644 --- a/Crow/src/Widgets/Slider.cs +++ b/Crow/src/Widgets/Slider.cs @@ -56,10 +56,10 @@ namespace Crow public virtual Orientation Orientation { get { return _orientation; } - set { + set { if (_orientation == value) return; - _orientation = value; + _orientation = value; RegisterForLayouting (LayoutingType.All); NotifyValueChangedAuto (_orientation); @@ -110,9 +110,9 @@ namespace Crow public override bool ArrangeChildren => true; public override bool UpdateLayout (LayoutingType layoutType) { - if (layoutType == LayoutingType.ArrangeChildren) + if (layoutType == LayoutingType.ArrangeChildren) computeCursorPosition (); - + return base.UpdateLayout (layoutType); } @@ -192,13 +192,13 @@ namespace Crow } public override void onMouseMove (object sender, MouseMoveEventArgs e) { - if (holdCursor) { + if (holdCursor) { Point m = ScreenPointToLocal (e.Position) - mouseDownInit; Rectangle r = cursor.Parent.ClientRectangle; if (_orientation == Orientation.Horizontal) { if (r.Width - cursorSize == 0) - return; + return; double unit = (Maximum - Minimum) / (double)(r.Width - cursorSize); if (inverted) unit = -unit; @@ -207,17 +207,17 @@ namespace Crow Value = tmp; } else { if (r.Height - cursorSize == 0) - return; + return; double unit = (Maximum - Minimum) / (double)(r.Height - cursorSize); if (inverted) unit = -unit; double tmp = mouseDownInitValue + (double)m.Y * unit; tmp -= tmp % SmallIncrement; Value = tmp; - } + } } e.Handled = true; - + base.onMouseMove (sender, e); } #endregion |