]> O.S.I.I.S - jp/crow.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 12 Dec 2020 23:03:31 +0000 (00:03 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 12 Dec 2020 23:03:31 +0000 (00:03 +0100)
Crow/Crow.csproj
Crow/Default.style
Crow/Templates/ProgressBar.template [new file with mode: 0644]
Crow/src/Command.cs
Crow/src/Widgets/Gauge.cs
Crow/src/Widgets/NumericControl.cs
Crow/src/Widgets/ProgressBar.cs
Crow/src/Widgets/Slider.cs
Crow/src/Widgets/Widget.cs
Samples/Directory.Build.props

index 9f7349bd871bef2417d23b2eeb3ec1fadfa0e108..c053f2ba23a9c811bcaa45f77d6382327075a2d5 100644 (file)
@@ -41,7 +41,7 @@
        </ItemGroup>
        <ItemGroup>
                <PackageReference Include="FastEnum" Version="1.5.3" />
-               <PackageReference Include="glfw-sharp" Version="0.2.10-beta" />
+               <PackageReference Include="glfw-sharp" Version="0.2.11-beta" />
        </ItemGroup>
 
        <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
index 04cb01dcc9b6f3d83b1a2af512c3f39a932d9c00..ae09ec1c83d8d152f870c26863196336e4aa5a80 100644 (file)
@@ -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 (file)
index 0000000..a3516bf
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<Gauge Background="{./Background}" Foreground="{./Foreground}" CornerRadius="{./CornerRadius}"
+       Orientation="{./Orientation}" Minimum="{./Minimum}" Maximum="{./Maximum}" Value="{./Value}"/>
index b2c587f92c707da79e6373e008726a06515fd8a0..caa8a3b0ea5be5fc24773b8a0e4e324aceba68a6 100644 (file)
@@ -37,6 +37,11 @@ namespace Crow {
                                NotifyValueChanged ("Icon", icon);
                        }
                }
+
+               public CommandGroup () { }
+               public CommandGroup (params Command[] commands) {
+                       AddRange (commands);
+               }
        }
 
 
index 191a9faf27ad7d704a2f29fe8a41accfbd4b60e0..079866c25f17a25f79909c6e5d3ac519cf4cec25 100644 (file)
@@ -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);
                        }
                }
-               /// <summary>
-               /// border width in pixels
-               /// </summary>
-               [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);
                }
        }
 }
index 504c75168a7c4853652e618478ed9caf11f65124..80c685878e5649d49956601124f4edcc4955effd 100644 (file)
@@ -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 ();
        }
 }
 
index c9e40b48337236e8fb3d4ebfb1bb7c2abfb0b372..ca9a1a3dca27a05f7acf437f0fd00b30bd96966b 100644 (file)
@@ -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
+       /// <summary>
+       /// Templated numeric control for displaying a progress indicator
+       /// </summary>
        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
-    }
+       }
 }
index 314917be950165fc5f9fa705f03ce25d4856b56d..222b06043e9d73b736bf58942fca749a8284f307 100644 (file)
@@ -9,10 +9,9 @@ using System.ComponentModel;
 namespace Crow
 {
        /// <summary>
-       /// templated numeric control to select a value
-       /// by slidding a cursor
+       /// templated numeric control to select a value by slidding a cursor.
        /// </summary>
-       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;
 
index ac170479edf9486e1eec51c91bd3f4f9f6942a4f..ec21a6d642241be51edd62a3c4317e82060cac77 100644 (file)
@@ -2132,12 +2132,6 @@ namespace Crow
                /// Checks to handle when widget is removed from the visible graphic tree
                /// </summary>
                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);
+                               }
+                       }
                }
        }
 }
index 190db9dc8376826d074c71fe2ae83654fe52f3ec..c80ed43a89e8fddafe6e3bde2265ebae5468f9d5 100644 (file)
@@ -13,7 +13,7 @@
                <Authors>Jean-Philippe Bruyère</Authors>
 
                <EnableDefaultNoneItems>false</EnableDefaultNoneItems>
-               <SamplesDir>$(SolutionDir)Samples\</SamplesDir>
+               <SamplesDir>$(MSBuildThisFileDirectory)\</SamplesDir>
                <AppConfig>$(SolutionDir)Crow\App.config</AppConfig>
        </PropertyGroup>
        
@@ -29,7 +29,6 @@
                        <LogicalName>ui.%(Filename)%(Extension)</LogicalName>
                        <Link>Templates\%(Filename)%(Extension)</Link>
                </EmbeddedResource>
-               <EmbeddedResource Include="$(SamplesDir)common\samples.style" />
                <EmbeddedResource Include="$(SamplesDir)common\ui\images\**\*.*">
                        <LogicalName>images.%(Filename)%(Extension)</LogicalName>
                        <Link>Images\%(Filename)%(Extension)</Link>
                        <LogicalName>Icons.%(Filename)%(Extension)</LogicalName>
                        <Link>Icons\%(Filename)%(Extension)</Link>
                </EmbeddedResource>
-               <Compile Include="$(SamplesDir)common\SampleBase.cs"/>
+               <EmbeddedResource Include="$(SamplesDir)common\samples.style" >
+                       <Link>common\%(Filename)%(Extension)</Link>
+               </EmbeddedResource>
+               <Compile Include="$(SamplesDir)common\SampleBase.cs">
+                       <Link>common\%(Filename)%(Extension)</Link>
+               </Compile>
        </ItemGroup>
 </Project>