From: Jean-Philippe Bruyère Date: Mon, 13 Sep 2021 13:39:28 +0000 (+0000) Subject: numeric control: min/max change => actual value check X-Git-Tag: v0.9.7-beta~13 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=faff80de76b68ef19013bacb5b7e1d8a2cbb1db2;p=jp%2Fcrow.git numeric control: min/max change => actual value check --- 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