From: Jean-Philippe Bruyère Date: Tue, 21 Apr 2020 13:45:23 +0000 (+0200) Subject: add facilities for using icons for EnumSelector + path parsing documentation and... X-Git-Tag: v0.9.5-beta~123 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=df2ad1e48d1aba38e93834bc89566761d56d35ff;p=jp%2Fcrow.git add facilities for using icons for EnumSelector + path parsing documentation and test --- diff --git a/Crow.sln b/Crow.sln index 18b3f358..20fc3366 100644 --- a/Crow.sln +++ b/Crow.sln @@ -64,7 +64,7 @@ Global GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 $0.StandardHeader = $1 - $1.Text = @Copyright (c) ${Year} ${AuthorName} <${AuthorEmail}>\n\nThis code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + $1.Text = @Copyright (c) 2013-${Year} ${AuthorName} <${AuthorEmail}>\n\nThis code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) $0.DotNetNamingPolicy = $2 $0.TextStylePolicy = $3 $3.EolMarker = Unix diff --git a/Crow/Default.style b/Crow/Default.style index ba59c54f..666bfd81 100644 --- a/Crow/Default.style +++ b/Crow/Default.style @@ -206,7 +206,7 @@ ArrowBut { } HArrowBut { MouseRepeat="true"; - Focusable="true"; + Focusable="true"; Foreground="Onyx"; Background="vgradient|0:Grey|1:DimGrey"; MouseDown="{Background=vgradient|0:White|0.4:DarkBlue|1:Jet}"; @@ -232,9 +232,8 @@ HScrollBar { Orientation = "Horizontal"; } EnumSelector { - Orientation = "Vertical"; - Height = "Fit"; - Spacing = "0"; + Width = "Fit"; + Height = "Fit"; } labColor { Margin="2"; diff --git a/Crow/Templates/HScrollBar.template b/Crow/Templates/HScrollBar.template index a4ab6416..23a56cd9 100644 --- a/Crow/Templates/HScrollBar.template +++ b/Crow/Templates/HScrollBar.template @@ -2,7 +2,7 @@ + Margin="1" Width="6" Size="10,10" Path="M 0.5,4.5 L 9.5,0.5 L 9.5,9.5 Z G"/> + Margin="1" Width="6" Size="10,10" Path="M 0.5,0.5 L 9.5,4.5 L 0.5,9.5 Z G"/> \ No newline at end of file diff --git a/Crow/Templates/ScrollBar.template b/Crow/Templates/ScrollBar.template index 158671e5..27047829 100644 --- a/Crow/Templates/ScrollBar.template +++ b/Crow/Templates/ScrollBar.template @@ -2,7 +2,7 @@ + Margin="1" Height="6" Size="10,10" Path="M 4.5,0.5 L 9.5,9.5 L 0.5,9.5 Z G"/> + Margin="1" Height="6" Size="10,10" Path="M 0.5,0.5 L 9.5,0.5 L 4.5,9.5 Z G"/> \ No newline at end of file diff --git a/Crow/Templates/Spinner.template b/Crow/Templates/Spinner.template index 1bac0d1d..f81a128a 100644 --- a/Crow/Templates/Spinner.template +++ b/Crow/Templates/Spinner.template @@ -6,7 +6,7 @@ Text="{²./Value}" TextAlignment="Right" Margin="0"/> - - + + diff --git a/Crow/src/Enums.cs b/Crow/src/Enums.cs index 4c55d451..df741d50 100644 --- a/Crow/src/Enums.cs +++ b/Crow/src/Enums.cs @@ -1,37 +1,10 @@ -// -// Enums.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) namespace Crow { - public enum Orientation + public enum Orientation { Horizontal, Vertical diff --git a/Crow/src/Widgets/Container.cs b/Crow/src/Widgets/Container.cs index ce54514e..07ccfa9b 100644 --- a/Crow/src/Widgets/Container.cs +++ b/Crow/src/Widgets/Container.cs @@ -1,28 +1,6 @@ +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// Container.cs -// -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.Xml.Serialization; diff --git a/Crow/src/Widgets/EnumSelector.cs b/Crow/src/Widgets/EnumSelector.cs index fa43e3b3..bac4f5f6 100644 --- a/Crow/src/Widgets/EnumSelector.cs +++ b/Crow/src/Widgets/EnumSelector.cs @@ -11,6 +11,11 @@ namespace Crow /// Convenient widget for selecting value among enum values. This is a templated control /// expecting a 'Group' widget named 'Content' inside the template to handle the enum values display. /// + /// + /// Instanced RadioButton's names are set to enum values, and Tags are populated with a string build with + /// 'IconsPrefix+EnumValueName+IconsExtension to ease associating icons with values. + /// There's many other way to use this control, for examples see 'testEnumSelector.crow' in the samples directory. + /// public class EnumSelector : TemplatedControl { #region CTOR @@ -31,11 +36,33 @@ namespace Crow #region private fields Enum enumValue; Type enumType; - string rbStyle; + string rbStyle, iconsPrefix, iconsExtension; IML.Instantiator radioButtonITor; #endregion #region public properties + [DefaultValue ("#Icons.")] + public string IconsPrefix { + get => iconsPrefix; + set { + if (iconsPrefix == value) + return; + iconsPrefix = value; + forceRefresh (); + NotifyValueChanged ("IconsPrefix", iconsPrefix); + } + } + [DefaultValue (".svg")] + public string IconsExtension { + get => iconsExtension; + set { + if (iconsExtension == value) + return; + iconsExtension = value; + forceRefresh (); + NotifyValueChanged ("IconsExtension", iconsExtension); + } + } /// /// Enum values are presented with RadioButton controls. Here you may specify a template to use /// for the radio buttons. @@ -48,12 +75,7 @@ namespace Crow return; rbStyle = value; radioButtonITor = null; - //force refresh to use new template if values are already displayed - if (enumValue != null) { - Enum tmp = enumValue; - enumValue = null; - EnumValue = tmp; - } + forceRefresh (); NotifyValueChanged ("RadioButtonStyle", rbStyle); } } @@ -80,12 +102,20 @@ namespace Crow RadioButton rb = radioButtonITor.CreateInstance (); rb.Caption = en; rb.LogicalParent = this; + rb.Tag = $"{iconsPrefix}{en}{IconsExtension}"; if (enumValue.ToString () == en) rb.IsChecked = true; rb.Checked += (sender, e) => (((RadioButton)sender).LogicalParent as EnumSelector).EnumValue = (Enum)Enum.Parse (enumType, (sender as RadioButton).Caption); enumValueContainer.AddChild (rb); } - + + } else { + foreach (RadioButton rb in enumValueContainer.Children) { + if (rb.Caption == enumValue.ToString ()) + rb.IsChecked = true; + else if (rb.IsChecked) + rb.IsChecked = false; + } } } else enumValueContainer.ClearChildren (); @@ -96,6 +126,15 @@ namespace Crow } #endregion + //force refresh to use new template if values are already displayed + void forceRefresh () + { + if (enumValue != null) { + Enum tmp = enumValue; + enumValue = null; + EnumValue = tmp; + } + } } } diff --git a/Crow/src/Widgets/GroupBox.cs b/Crow/src/Widgets/GroupBox.cs index 2e32ddd5..0ec191ad 100644 --- a/Crow/src/Widgets/GroupBox.cs +++ b/Crow/src/Widgets/GroupBox.cs @@ -1,28 +1,6 @@ -// -// GroupBox.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.Xml.Serialization; diff --git a/Crow/src/Widgets/ScrollBar.cs b/Crow/src/Widgets/ScrollBar.cs index cf6201e4..08ee5e09 100644 --- a/Crow/src/Widgets/ScrollBar.cs +++ b/Crow/src/Widgets/ScrollBar.cs @@ -55,9 +55,9 @@ namespace Crow _orientation = value; NotifyValueChanged ("Orientation", _orientation); if (_orientation == Orientation.Horizontal) - NotifyValueChanged ("ScrollBackShape", "M 1.5,3.5 L 6.5,0.5 L 6.5,6.5 Z"); + NotifyValueChanged ("ScrollBackShape", "M 1.5,3.5 L 6.5,0.5 L 6.5,6.5 Z G"); else - NotifyValueChanged ("ScrollBackShape", "M 4.5,0.5 L 9.5,9.5 L 0.5,9.5 Z"); + NotifyValueChanged ("ScrollBackShape", "M 4.5,0.5 L 9.5,9.5 L 0.5,9.5 Z G"); RegisterForGraphicUpdate (); } diff --git a/Crow/src/Widgets/Shape.cs b/Crow/src/Widgets/Shape.cs index 952c3738..ac006b82 100644 --- a/Crow/src/Widgets/Shape.cs +++ b/Crow/src/Widgets/Shape.cs @@ -10,76 +10,143 @@ using Crow.Cairo; namespace Crow { + /// + /// String Parser for drawing shape + /// + /// + /// All fields are separated by one or more space. Each statement is composed of one letter followed by 0 to n + /// double parameters. The following list enumerate available instructions: + /// - M x y: Move to (x,y) absolute coordinate. + /// - m x y: Relative move to by x in the horizontal direction and y in the vertical. + /// - L x y: Line to (x,y) + /// - l x y: trace line from current point by moving pen by x and y in each direction. + /// - R x y w h: draw rectangle at (x,y) with width and height equal to w and h. + /// - C x1 y1 x2 y2 x3 y3: draw bezier curve with current point as first control point, and parameters as others. + /// - c x1 y1 x2 y2 x3 y3: draw bezier curve with control points relative to current position. + /// - A x y r a1 a2: draw positive arc at (x,y) with radius r from angle a1 to angle a2. + /// - N x y r a1 a2: draw negative arc at (x,y) with radius r from angle a1 to angle a2. + /// - Z: close path + /// - F: fill path. + /// - f: fill preserve. + /// - G: stroke path. + /// - g: stroke preserve. + /// - S x: set line width to x. + /// - O r g b a: set solid color as source with rgba values. + /// public class PathParser : StringReader { - public PathParser (string str) : base (str) {} + public PathParser (string str) : base (str) { } - double readDouble () { - StringBuilder tmp = new StringBuilder(); + double readDouble () + { + StringBuilder tmp = new StringBuilder (); - while (Peek () >= 0) { - char c = (char)Read(); - if (c.IsWhiteSpaceOrNewLine()) { + while (Peek () >= 0) { + char c = (char)Read (); + if (c.IsWhiteSpaceOrNewLine ()) { if (tmp.Length == 0) continue; else break; } else if (c == ',') - break; + break; tmp.Append (c); } return double.Parse (tmp.ToString ()); } - public void Draw (Context gr) { - while (Peek () >= 0) { - char c = (char)Read (); - if (c.IsWhiteSpaceOrNewLine ()) - continue; - switch (c) { - case 'M': - gr.MoveTo (readDouble (), readDouble ()); - break; - case 'm': - gr.RelMoveTo (readDouble (), readDouble ()); - break; - case 'L': - gr.LineTo (readDouble (), readDouble ()); - break; - case 'l': - gr.RelLineTo (readDouble (), readDouble ()); - break; - case 'C': - gr.CurveTo (readDouble (), readDouble (), readDouble (), readDouble (), readDouble (), readDouble ()); - break; - case 'c': - gr.RelCurveTo (readDouble (), readDouble (), readDouble (), readDouble (), readDouble (), readDouble ()); - break; - case 'Z': - gr.ClosePath (); - break; - case 'F': - gr.Fill (); - break; - case 'G': - gr.Stroke (); - break; - default: - throw new Exception ("Invalid character in path string of Shape control"); + public void Draw (Context gr, bool measure = false) + { + try { + while (Peek () >= 0) { + char c = (char)Read (); + if (c.IsWhiteSpaceOrNewLine ()) + continue; + switch (c) { + case 'M': + gr.MoveTo (readDouble (), readDouble ()); + break; + case 'm': + gr.RelMoveTo (readDouble (), readDouble ()); + break; + case 'L': + gr.LineTo (readDouble (), readDouble ()); + break; + case 'l': + gr.RelLineTo (readDouble (), readDouble ()); + break; + case 'R': + gr.Rectangle (readDouble (), readDouble (), readDouble (), readDouble ()); + break; + case 'C': + gr.CurveTo (readDouble (), readDouble (), readDouble (), readDouble (), readDouble (), readDouble ()); + break; + case 'c': + gr.RelCurveTo (readDouble (), readDouble (), readDouble (), readDouble (), readDouble (), readDouble ()); + break; + case 'A': + gr.Arc (readDouble (), readDouble (), readDouble (), readDouble (), readDouble ()); + break; + case 'N': + gr.ArcNegative (readDouble (), readDouble (), readDouble (), readDouble (), readDouble ()); + break; + case 'Z': + gr.ClosePath (); + break; + case 'f': + if (measure) + continue; + gr.FillPreserve (); + break; + case 'g': + if (measure) + break; + gr.StrokePreserve (); + break; + case 'F': + if (measure) + break; + gr.Fill (); + break; + case 'G': + if (measure) + break; + gr.Stroke (); + break; + case 'S': + gr.LineWidth = readDouble (); + break; + case 'O': + if (measure) { + readDouble (); readDouble (); readDouble (); readDouble (); + break; + } + gr.SetSourceRGBA (readDouble (), readDouble (), readDouble (), readDouble ()); + break; + default: + throw new Exception ("Invalid character in path string of Shape control"); + } } - } + } catch (Exception ex) { + System.Diagnostics.Debug.WriteLine ($"Error parsing path: {ex.Message}"); + } } } + /// + /// Widget for drawing a shape define with a path expression as defined in the PathParser. + /// public class Shape : Widget { #region CTOR - protected Shape () : base() {} - public Shape (Interface iface) : base (iface) {} + protected Shape () : base () { } + public Shape (Interface iface) : base (iface) { } #endregion string path; double strokeWidth; - Size size; - + Size size; + /// + /// Path expression, for syntax see 'PathParser'. + /// public string Path { get { return path; } set { @@ -91,7 +158,11 @@ namespace Crow RegisterForGraphicUpdate (); } } - [DefaultValue(1.0)] + /// + /// Default stroke width, may be overriden by a 'S' command in the path string. + /// + /// The width of the stoke. + [DefaultValue (1.0)] public double StokeWidth { get { return strokeWidth; } set { @@ -103,70 +174,66 @@ namespace Crow RegisterForGraphicUpdate (); } } - [DefaultValue("0,0")] - public Size Size - { - get { return size; } - set - { - if (size == value) - return; - size = value; - contentSize = default(Size); - NotifyValueChanged("Size", size); - RegisterForLayouting(LayoutingType.Sizing); - } - } - protected override void onDraw(Context gr) - { + /// + /// View box + /// + /// The size. + [DefaultValue ("0,0")] + public Size Size { + get { return size; } + set { + if (size == value) + return; + size = value; + contentSize = default (Size); + NotifyValueChanged ("Size", size); + RegisterForLayouting (LayoutingType.Sizing); + } + } + protected override void onDraw (Context gr) + { + base.onDraw (gr); - if (string.IsNullOrEmpty(path)) - return; + if (string.IsNullOrEmpty (path)) + return; - gr.Save(); + gr.Save (); - Rectangle r = ClientRectangle; + Rectangle r = ClientRectangle; - double sx = (double)r.Width / (double)(contentSize.Width == 0? size.Width : contentSize.Width); - double sy = (double)r.Height / (double)(contentSize.Height == 0 ? size.Height : contentSize.Height); + double sx = (double)r.Width / (double)(contentSize.Width == 0 ? size.Width : contentSize.Width); + double sy = (double)r.Height / (double)(contentSize.Height == 0 ? size.Height : contentSize.Height); - gr.Translate(r.Left, r.Top); - gr.Scale (sx,sy); + gr.Translate (r.Left, r.Top); + gr.Scale (sx, sy); - using (PathParser parser = new PathParser (path)) - parser.Draw (gr); - - Background.SetAsSource (gr, r); - gr.FillPreserve (); gr.LineWidth = strokeWidth; Foreground.SetAsSource (gr, r); - gr.Stroke (); - gr.Restore(); + + using (PathParser parser = new PathParser (path)) + parser.Draw (gr); + + gr.Restore (); } protected override int measureRawSize (LayoutingType lt) { if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0)) { - if (size != default(Size)) - contentSize = size; - else - { - using (Surface drawing = new ImageSurface(Format.A1, 1, 1)) - { - using (Context ctx = new Context(drawing)) - { - using (PathParser parser = new PathParser (path)) - parser.Draw (ctx); - Rectangle r = ctx.StrokeExtents(); - contentSize = new Size(r.Right, r.Bottom); - } - } - } + if (size != default (Size)) + contentSize = size; + else { + using (Context ctx = new Context (IFace.surf)) { + using (PathParser parser = new PathParser (path)) + parser.Draw (ctx, true); + Rectangle r = ctx.StrokeExtents (); + contentSize = new Size (r.Right, r.Bottom); + } + } } return lt == LayoutingType.Width ? - contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin; + contentSize.Width + 2 * Margin : contentSize.Height + 2 * Margin; } } } diff --git a/Directory.Build.props b/Directory.Build.props index 66bf8132..4ef561d4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,8 +7,8 @@ Jean-Philippe Bruyère 7.2 - 0.8.8 + 0.8.9 $(CrowVersion)-beta - true + true diff --git a/Samples/BasicTests/BasicTests.cs b/Samples/BasicTests/BasicTests.cs index 8d76b31e..90917302 100644 --- a/Samples/BasicTests/BasicTests.cs +++ b/Samples/BasicTests/BasicTests.cs @@ -32,8 +32,9 @@ namespace tests //testFiles = new string [] { @"Interfaces/Experimental/testDock.crow" }; //testFiles = new string [] { @"Interfaces/Divers/welcome.crow" }; //testFiles = new string [] { @"Interfaces/TemplatedGroup/3.crow" }; - //testFiles = new string [] { @"Interfaces/Divers/perfMeasures.crow" }; - testFiles = new string [] { @"Interfaces/Divers/colorPicker2.crow" }; + //testFiles = new string [] { @"Interfaces/Divers/testShape.crow" }; + testFiles = new string [] { @"Interfaces/TemplatedControl/testEnumSelector.crow" }; + //testFiles = new string [] { @"Interfaces/Divers/colorPicker2.crow" }; testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray (); @@ -126,6 +127,16 @@ namespace tests NotifyValueChanged ("IntValue", intValue); } } + VerticalAlignment currentVAlign; + public VerticalAlignment CurrentVAlign { + get => currentVAlign; + set { + if (currentVAlign == value) + return; + currentVAlign = value; + NotifyValueChanged ("CurrentVAlign", currentVAlign); + } + } void onSpinnerValueChange (object sender, ValueChangeEventArgs e) { if (e.MemberName != "Value") diff --git a/Samples/BasicTests/BasicTests.csproj b/Samples/BasicTests/BasicTests.csproj index 813b9b66..71a7a829 100644 --- a/Samples/BasicTests/BasicTests.csproj +++ b/Samples/BasicTests/BasicTests.csproj @@ -14,6 +14,9 @@ + + + data\%(RecursiveDir)%(Filename)%(Extension) @@ -29,5 +32,14 @@ ui.%(Filename)%(Extension) Templates\%(Filename)%(Extension) - + + + images.%(Filename)%(Extension) + Images\%(Filename)%(Extension) + + + Icons.%(Filename)%(Extension) + Icons\%(Filename)%(Extension) + + \ No newline at end of file diff --git a/Samples/ShowCase/main.cs b/Samples/ShowCase/main.cs index d780c511..ac103290 100644 --- a/Samples/ShowCase/main.cs +++ b/Samples/ShowCase/main.cs @@ -206,5 +206,11 @@ namespace tests } - + public static class Extensions + { + public static Fill GetIcon (this Alignment align) + { + return (Crow.Fill)Fill.Parse ("#images.valign.svg"); + } + } } \ No newline at end of file diff --git a/Samples/common/samples.style b/Samples/common/samples.style new file mode 100644 index 00000000..ff956325 --- /dev/null +++ b/Samples/common/samples.style @@ -0,0 +1,67 @@ +FpsLabel { + Width = "30"; + Font = "droid, 10"; + Margin = "0"; + TextAlignment = "Center"; +} +FpsDisp { + Font = "droid bold, 10"; + Width = "60"; + Margin = "0"; + CornerRadius = "3"; + TextAlignment = "Center"; + Background = "MediumSeaGreen"; +} +HStackMeasure { + Margin = "2"; + Width = "Fit"; + Height = "Fit"; + Background = "DimGrey"; +} +CheckBox2 { + Template= "Interfaces/CheckBox2.imlt"; + Background = "Jet"; + Checked="{Background=MediumSeaGreen}"; + Unchecked = "{Background=Jet}"; +} +CheckBox3 { + Template= "Interfaces/CheckBox2.imlt"; + Background = "Jet"; + Width = "Stretched"; + Height = "Fit"; + CornerRadius = "5"; + Checked="{Background=MediumSeaGreen}"; + Unchecked = "{Background=Jet}"; +} +labPerf { + Font = "droid, 8"; + Width = "50%"; +} +labPerfVal{ + Font = "droid, 8"; + Width = "50%"; +} +DbgLogViewer{ + Background = "Onyx"; + Font = "mono, 8"; + Foreground = "LightGrey"; + Focusable = "true"; +} +DockWindow{ + Background = "0.1,0.1,0.1,0.5"; +} + +valignStyle { + Template="#ui.enumSingleSVG.itmp"; + Checked="{Background=MediumSeaGreen}"; + Unchecked = "{Background=Black}"; + //Initialized="GetDrawModeIcon"; + //Initialized="{Background=Blue}"; +} +valignStyle2 { + Template="#ui.enumGetIcons.itmp"; + Checked="{Background=MediumSeaGreen}"; + Unchecked = "{Background=Black}"; + //Initialized="GetDrawModeIcon"; + //Initialized="{Background=Blue}"; +} \ No newline at end of file diff --git a/Samples/common/ui/Icons/Bottom.svg b/Samples/common/ui/Icons/Bottom.svg new file mode 100644 index 00000000..38e5fa62 --- /dev/null +++ b/Samples/common/ui/Icons/Bottom.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Samples/common/ui/Icons/Center.svg b/Samples/common/ui/Icons/Center.svg new file mode 100644 index 00000000..ac2efdb8 --- /dev/null +++ b/Samples/common/ui/Icons/Center.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Samples/common/ui/Icons/Top.svg b/Samples/common/ui/Icons/Top.svg new file mode 100644 index 00000000..01d11d52 --- /dev/null +++ b/Samples/common/ui/Icons/Top.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Samples/common/ui/Interfaces/Divers/0.crow b/Samples/common/ui/Interfaces/Divers/0.crow index 8850e26d..c98d6410 100644 --- a/Samples/common/ui/Interfaces/Divers/0.crow +++ b/Samples/common/ui/Interfaces/Divers/0.crow @@ -64,10 +64,10 @@ - - - - + + + + diff --git a/Samples/common/ui/Interfaces/Divers/testShape.crow b/Samples/common/ui/Interfaces/Divers/testShape.crow index 99b89b07..14af0f21 100644 --- a/Samples/common/ui/Interfaces/Divers/testShape.crow +++ b/Samples/common/ui/Interfaces/Divers/testShape.crow @@ -1,6 +1,5 @@  - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/Samples/common/ui/Interfaces/GraphicObject/5.crow b/Samples/common/ui/Interfaces/GraphicObject/5.crow index 0e0560fc..8fdf887d 100644 --- a/Samples/common/ui/Interfaces/GraphicObject/5.crow +++ b/Samples/common/ui/Interfaces/GraphicObject/5.crow @@ -1,5 +1,5 @@  - + diff --git a/Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow b/Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow new file mode 100644 index 00000000..303f5432 --- /dev/null +++ b/Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/common/ui/images/valign.svg b/Samples/common/ui/images/valign.svg new file mode 100644 index 00000000..b24cf26b --- /dev/null +++ b/Samples/common/ui/images/valign.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Samples/common/ui/templates/CheckBox2.imlt b/Samples/common/ui/templates/CheckBox2.imlt index c2bfe8da..048d495b 100644 --- a/Samples/common/ui/templates/CheckBox2.imlt +++ b/Samples/common/ui/templates/CheckBox2.imlt @@ -1,4 +1,4 @@ -