From: Jean-Philippe Bruyère Date: Sat, 12 Dec 2020 23:03:31 +0000 (+0100) Subject: wip X-Git-Tag: v0.9.5-beta~111 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=035ef61b3233c0a85caf42260f3cd1c1e1a01d54;p=jp%2Fcrow.git wip --- diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 9f7349bd..c053f2ba 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -41,7 +41,7 @@ - + diff --git a/Crow/Default.style b/Crow/Default.style index 04cb01dc..ae09ec1c 100644 --- a/Crow/Default.style +++ b/Crow/Default.style @@ -204,7 +204,10 @@ FileDialog { Height = "300"; } ProgressBar { - Foreground = "vgradient|0:DarkBlue|0.5:SkyBlue|1:DarkBlue"; + Background = "Jet"; + Foreground = "RoyalBlue"; + Orientation = "Horizontal"; + Height = "10"; } Scroller { CacheEnabled = "false"; diff --git a/Crow/Templates/ProgressBar.template b/Crow/Templates/ProgressBar.template new file mode 100644 index 00000000..a3516bfa --- /dev/null +++ b/Crow/Templates/ProgressBar.template @@ -0,0 +1,3 @@ + + diff --git a/Crow/src/Command.cs b/Crow/src/Command.cs index b2c587f9..caa8a3b0 100644 --- a/Crow/src/Command.cs +++ b/Crow/src/Command.cs @@ -37,6 +37,11 @@ namespace Crow { NotifyValueChanged ("Icon", icon); } } + + public CommandGroup () { } + public CommandGroup (params Command[] commands) { + AddRange (commands); + } } diff --git a/Crow/src/Widgets/Gauge.cs b/Crow/src/Widgets/Gauge.cs index 191a9faf..079866c2 100644 --- a/Crow/src/Widgets/Gauge.cs +++ b/Crow/src/Widgets/Gauge.cs @@ -17,9 +17,7 @@ namespace Crow { #region protected fields protected double actualValue, minValue, maxValue; - CursorType cursorType; Orientation orientation; - int borderWidth; #endregion #region public properties @@ -68,17 +66,6 @@ namespace Crow { RegisterForGraphicUpdate(); } } - [DefaultValue (CursorType.Pentagone)] - public CursorType CursorType { - get => cursorType; - set { - if (cursorType == value) - return; - cursorType = value; - NotifyValueChangedAuto (cursorType); - RegisterForRedraw (); - } - } [DefaultValue (Orientation.Horizontal)] public virtual Orientation Orientation { get => orientation; @@ -90,23 +77,11 @@ namespace Crow { RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); } } - /// - /// border width in pixels - /// - [DefaultValue (0)] - public virtual int BorderWidth { - get { return borderWidth; } - set { - if (borderWidth == value) - return; - borderWidth = value; - NotifyValueChangedAuto (borderWidth); - RegisterForGraphicUpdate (); - } - } #endregion protected override void onDraw (Context gr) { + base.onDraw (gr); + Rectangle cb = ClientRectangle; if (orientation == Orientation.Horizontal) @@ -114,12 +89,10 @@ namespace Crow { else cb.Height = (int)(cb.Height / Maximum * Value); - Background.SetAsSource (IFace, gr, cb); + + Foreground.SetAsSource (IFace, gr, cb); CairoHelpers.CairoRectangle (gr, cb, CornerRadius); gr.Fill (); - Foreground.SetAsSource (IFace, gr, cb); - if (borderWidth > 0) - CairoHelpers.CairoRectangle (gr, cb, CornerRadius, borderWidth); } } } diff --git a/Crow/src/Widgets/NumericControl.cs b/Crow/src/Widgets/NumericControl.cs index 504c7516..80c68587 100644 --- a/Crow/src/Widgets/NumericControl.cs +++ b/Crow/src/Widgets/NumericControl.cs @@ -30,7 +30,7 @@ namespace Crow { return; decimals = value; NotifyValueChangedAuto (decimals); - RegisterForGraphicUpdate(); + registerUpdate (); } } [DefaultValue(0.0)] @@ -42,7 +42,7 @@ namespace Crow { minValue = value; NotifyValueChangedAuto (minValue); - RegisterForRedraw (); + registerUpdate (); } } [DefaultValue(100.0)] @@ -55,7 +55,7 @@ namespace Crow { maxValue = value; NotifyValueChangedAuto (maxValue); - RegisterForRedraw (); + registerUpdate (); } } [DefaultValue(1.0)] @@ -68,7 +68,7 @@ namespace Crow { smallStep = value; NotifyValueChangedAuto (smallStep); - RegisterForRedraw (); + registerUpdate (); } } [DefaultValue(5.0)] @@ -81,7 +81,7 @@ namespace Crow { bigStep = value; NotifyValueChangedAuto (bigStep); - RegisterForRedraw (); + registerUpdate (); } } [DefaultValue(0.0)] @@ -103,11 +103,13 @@ namespace Crow { actualValue = Math.Round (actualValue, decimals); NotifyValueChangedAuto (actualValue); - RegisterForGraphicUpdate(); + registerUpdate (); } } #endregion + protected virtual void registerUpdate () + => RegisterForRedraw (); } } diff --git a/Crow/src/Widgets/ProgressBar.cs b/Crow/src/Widgets/ProgressBar.cs index c9e40b48..ca9a1a3d 100644 --- a/Crow/src/Widgets/ProgressBar.cs +++ b/Crow/src/Widgets/ProgressBar.cs @@ -2,11 +2,14 @@ // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +using System.ComponentModel; using Crow.Cairo; namespace Crow { - //TODO:to be removed, numeric control with template having Gauge child is enough + /// + /// Templated numeric control for displaying a progress indicator + /// public class ProgressBar : NumericControl { #region CTOR @@ -14,25 +17,18 @@ namespace Crow public ProgressBar(Interface iface, string style = null) : base (iface, style) { } #endregion - protected override void loadTemplate (Widget template) - { - } - - #region GraphicObject overrides - protected override void onDraw (Context gr) - { - base.onDraw (gr); - - if (Maximum == 0) - return; + Orientation orientation; - Rectangle rBack = ClientRectangle; - rBack.Width = (int)((double)rBack.Width / Maximum * Value); - Foreground.SetAsSource (IFace, gr, rBack); - - CairoHelpers.CairoRectangle(gr,rBack,CornerRadius); - gr.Fill(); + [DefaultValue (Orientation.Horizontal)] + public virtual Orientation Orientation { + get => orientation; + set { + if (orientation == value) + return; + orientation = value; + NotifyValueChangedAuto (orientation); + RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); + } } - #endregion - } + } } diff --git a/Crow/src/Widgets/Slider.cs b/Crow/src/Widgets/Slider.cs index 314917be..222b0604 100644 --- a/Crow/src/Widgets/Slider.cs +++ b/Crow/src/Widgets/Slider.cs @@ -9,10 +9,9 @@ using System.ComponentModel; namespace Crow { /// - /// templated numeric control to select a value - /// by slidding a cursor + /// templated numeric control to select a value by slidding a cursor. /// - public class Slider : TemplatedControl + public class Slider : NumericControl { #region CTOR protected Slider() {} @@ -37,103 +36,18 @@ namespace Crow } #endregion - #region protected fields - protected double actualValue, minValue, maxValue, smallStep, bigStep; - protected int decimals; - #endregion - - #region public properties - [DefaultValue (2)] - public int Decimals { - get { return decimals; } - set { - if (value == decimals) - return; - decimals = value; - NotifyValueChangedAuto (decimals); - RegisterForGraphicUpdate (); - } - } - [DefaultValue (0.0)] - public virtual double Minimum { - get { return minValue; } - set { - if (minValue == value) - return; - - minValue = value; - NotifyValueChangedAuto (minValue); - RegisterForLayouting (LayoutingType.ArrangeChildren); - } - } - [DefaultValue (100.0)] - public virtual double Maximum { - get { return maxValue; } - set { - if (maxValue == value) - return; - - maxValue = value; - NotifyValueChangedAuto (maxValue); - RegisterForLayouting (LayoutingType.ArrangeChildren); - } - } - [DefaultValue (1.0)] - public virtual double SmallIncrement { - get { return smallStep; } - set { - if (smallStep == value) - return; - - smallStep = value; - NotifyValueChangedAuto (smallStep); - RegisterForLayouting (LayoutingType.ArrangeChildren); - } - } - [DefaultValue (5.0)] - public virtual double LargeIncrement { - get { return bigStep; } - set { - if (bigStep == value) - return; - - bigStep = value; - NotifyValueChangedAuto (bigStep); - RegisterForLayouting (LayoutingType.ArrangeChildren); - } - } - [DefaultValue (0.0)] - public virtual double Value { - get { return actualValue; } - set { - if (value == actualValue) - return; - if (value < minValue) - actualValue = minValue; - else if (value > maxValue) - actualValue = maxValue; - else - actualValue = value; - actualValue = Math.Round (actualValue, decimals); - - NotifyValueChangedAuto (actualValue); - RegisterForLayouting (LayoutingType.ArrangeChildren); - } - } - #endregion + protected override void registerUpdate () + => RegisterForLayouting (LayoutingType.ArrangeChildren); #region private fields - //Rectangle cursor; int cursorSize; - //Fill _cursorColor; Orientation _orientation; - //CursorType cursorType; bool holdCursor = false; - #endregion Widget cursor; + #endregion protected double unity; diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index ac170479..ec21a6d6 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -2132,12 +2132,6 @@ namespace Crow /// Checks to handle when widget is removed from the visible graphic tree /// void unshownPostActions () { - if (IFace.HoverWidget != null) { - if (IFace.HoverWidget.IsOrIsInside (this)) { - IFace.HoverWidget = null; - IFace.OnMouseMove (IFace.MousePosition.X, IFace.MousePosition.Y); - } - } if (IFace.ActiveWidget != null) { if (IFace.ActiveWidget.IsOrIsInside (this)) IFace.ActiveWidget = null; @@ -2145,7 +2139,13 @@ namespace Crow if (IFace.FocusedWidget != null) { if (IFace.FocusedWidget.IsOrIsInside (this)) IFace.FocusedWidget = null; - } + } + if (IFace.HoverWidget != null) { + if (IFace.HoverWidget.IsOrIsInside (this)) { + IFace.HoverWidget = null; + IFace.OnMouseMove (IFace.MousePosition.X, IFace.MousePosition.Y); + } + } } } } diff --git a/Samples/Directory.Build.props b/Samples/Directory.Build.props index 190db9dc..c80ed43a 100644 --- a/Samples/Directory.Build.props +++ b/Samples/Directory.Build.props @@ -13,7 +13,7 @@ Jean-Philippe Bruyère false - $(SolutionDir)Samples\ + $(MSBuildThisFileDirectory)\ $(SolutionDir)Crow\App.config @@ -29,7 +29,6 @@ ui.%(Filename)%(Extension) Templates\%(Filename)%(Extension) - images.%(Filename)%(Extension) Images\%(Filename)%(Extension) @@ -38,6 +37,11 @@ Icons.%(Filename)%(Extension) Icons\%(Filename)%(Extension) - + + common\%(Filename)%(Extension) + + + common\%(Filename)%(Extension) +