]> O.S.I.I.S - jp/crow.git/commitdiff
:book: tutorials and some small improvements (iml fragment loading helpers
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 4 Feb 2018 20:04:32 +0000 (21:04 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 4 Feb 2018 20:04:32 +0000 (21:04 +0100)
36 files changed:
Crow.csproj
Crow.sln
README.md
Templates/ColorPicker.template
Templates/Spinner.template
Tests/CrowWindow.cs
Tests/GraphicObjects/ColorCircleSelector.cs [new file with mode: 0644]
Tests/GraphicObjects/SimpleGauge.cs [new file with mode: 0644]
Tests/HelloCube.cs [deleted file]
Tests/Showcase.cs
Tests/Tests.csproj
Tests/Tutorials/T1_HelloWorld.cs [new file with mode: 0644]
Tests/Tutorials/T2_IML.cs [new file with mode: 0644]
Tests/Tutorials/T3_OpenGLCube.cs [new file with mode: 0644]
Tests/Tutorials/T4_Gauge.cs [new file with mode: 0644]
Tests/Tutorials/test.crow [new file with mode: 0755]
src/BmpPicture.cs
src/Fill/Fill.cs
src/Gradient.cs
src/GraphicObjects/Border.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/HueSelector.cs
src/GraphicObjects/NumericControl.cs
src/GraphicObjects/SaturationValueSelector.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TestCairoPatch.cs [new file with mode: 0644]
src/GraphicObjects/Trend.cs
src/Instantiator.cs
src/Interface.cs
src/Mono.Cairo/Context.cs
src/Mono.Cairo/Rectangle.cs
src/Mono.Cairo/Surface.cs
src/SolidColor.cs
src/SvgPicture.cs
src/rsvg/Handle.cs

index 3a8228ef97dcff3fdd8f70c296a121b7c0058d36..b58634dbbc1c16354befaf1d9ed81e4cd86e3305 100644 (file)
@@ -15,7 +15,6 @@
     <WarningLevel>4</WarningLevel>
     <NoWin32Manifest>False</NoWin32Manifest>
     <SignAssembly>true</SignAssembly>
-    <DelaySign>False</DelaySign>
     <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <Description>C# Rapid Open Widget</Description>
index 83e55eb5e132a7321a844503c009150f823d580e..21c870816006e28f83fbd0b78053f75b4172d199 100644 (file)
--- a/Crow.sln
+++ b/Crow.sln
@@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow", "Crow.csproj", "{C29
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{74289092-9F70-4941-AFCB-DFD7BE2140B6}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow.Test", "Crow.Test\Crow.Test.csproj", "{42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -19,34 +21,45 @@ Global
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Any CPU.Build.0 = Release|Any CPU
+               {42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(MonoDevelopProperties) = preSolution
                Policies = $0
                $0.StandardHeader = $1
                $1.Text = @\n${FileName}\n \nAuthor:\n      ${AuthorName} <${AuthorEmail}>\n\nCopyright (c) 2013-2017 Jean-Philippe Bruyère\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.
-               $1.IncludeInNewFiles = True
                $0.DotNetNamingPolicy = $2
-               $2.DirectoryNamespaceAssociation = None
-               $2.ResourceNamePolicy = FileFormatDefault
                $0.TextStylePolicy = $3
-               $3.FileWidth = 120
-               $3.TabsToSpaces = False
                $3.EolMarker = Unix
-               $3.inheritsSet = VisualStudio
-               $3.inheritsScope = text/plain
                $3.scope = text/x-csharp
                $0.CSharpFormattingPolicy = $4
                $4.AfterDelegateDeclarationParameterComma = True
-               $4.inheritsSet = Mono
-               $4.inheritsScope = text/x-csharp
                $4.scope = text/x-csharp
+               $4.IndentSwitchSection = False
+               $4.NewLinesForBracesInProperties = False
+               $4.NewLinesForBracesInAccessors = False
+               $4.NewLinesForBracesInAnonymousMethods = False
+               $4.NewLinesForBracesInControlBlocks = False
+               $4.NewLinesForBracesInAnonymousTypes = False
+               $4.NewLinesForBracesInObjectCollectionArrayInitializers = False
+               $4.NewLinesForBracesInLambdaExpressionBody = False
+               $4.NewLineForElse = False
+               $4.NewLineForCatch = False
+               $4.NewLineForFinally = False
+               $4.NewLineForMembersInObjectInit = False
+               $4.NewLineForMembersInAnonymousTypes = False
+               $4.NewLineForClausesInQuery = False
+               $4.SpacingAfterMethodDeclarationName = True
+               $4.SpaceAfterMethodCallName = True
+               $4.SpaceBeforeOpenSquareBracket = True
                $0.VersionControlPolicy = $5
                $5.CommitMessageStyle = $6
                $6.Indent = @\t
                $6.FileSeparator = ", "
                $6.LastFilePostfix = "@:\n  "
                $6.Wrap = False
-               $5.inheritsSet = Mono
                description = @C.R.O.W. c# Rapid Open Widgets\n\nCrow is a pure c# widget toolkit with XML definition of interface, bindings, styling...\n
                version = 0.5
        EndGlobalSection
index 8d0bc2afe57b8facd28173fa60afb08b6de9e1b6..17ecb240dd253604e10903d3b6201e63bbe37d0e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ Please report bugs and issues on [GitHub](https://github.com/jpbruyere/Crow/issu
 ## Getting Start
 
 ### Requirements
-- [mono > 4.5](http://www.mono-project.com/download/)
+- [mono > 5.0](http://www.mono-project.com/download/)
 - [Cairo Graphic Library](https://cairographics.org/) >= 1.10 
 - [rsvg library](https://developer.gnome.org/rsvg/) for svg rendering
 - [nuget](https://www.nuget.org/).
index 81bb0bd185be440da07ed8f0eeeed21260aa40a3..d6bda34644262b225228ed85e9c44e7c97df2416 100755 (executable)
@@ -8,38 +8,36 @@
                                        Width="128" Height="128"/>
                                <HueSelector Hue="{²./H}" Focusable="true" Name="hueSelector" Margin="0" Width="128" Height="20"/>
                        </VerticalStack>
-                       <VerticalStack Margin="2" Spacing="0">
-                               <HorizontalStack Height="Fit" Width="Stretched" Spacing="2">
-                                       <GraphicObject Width="34" Height="21" Background="{./SelectedColor}"/>
-                                       <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./HexColor}" />
-                               </HorizontalStack>
+                       <VerticalStack Margin="5" Spacing="0">
+                               <GraphicObject Width="34" Height="21" Background="{./SelectedColor}"/>
+                               <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./HexColor}" />                              
                                <HorizontalStack Height="Fit">
-                                       <Label Text="Red:" Width="40"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./R}" Width="60"  />
+                                       <Label Text="R" Width="Fit"/>
+                                       <Spinner Style="ColorSpinner" Value="{²./R}" Width="40"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
-                                       <Label Text="Green:" Width="40"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./G}" Width="60"  />
+                                       <Label Text="G" Width="Fit"/>
+                                       <Spinner Style="ColorSpinner" Value="{²./G}" Width="40"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
-                                       <Label Text="Blue:" Width="40"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./B}" Width="60"  />
+                                       <Label Text="B" Width="Fit"/>
+                                       <Spinner Style="ColorSpinner" Value="{²./B}" Width="40"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
-                                       <Label Text="Alpha:" Width="40"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./A}" Width="60"  />
+                                       <Label Text="A" Width="Fit"/>
+                                       <Spinner Style="ColorSpinner" Value="{²./A}" Width="40"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
-                                       <Label Text="Hue:" Width="40"/>
-                                       <Spinner Style="HSVSpinner" Value="{²./H}" Width="60"  />
+                                       <Label Text="H" Width="Fit"/>
+                                       <Spinner Style="HSVSpinner" Value="{²./H}" Width="40"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
-                                       <Label Text="Sat:" Width="40"/>
-                                       <Spinner Style="HSVSpinner" Value="{²./S}" Width="60"  />
+                                       <Label Text="S" Width="Fit"/>
+                                       <Spinner Style="HSVSpinner" Value="{²./S}" Width="40"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
-                                       <Label Text="Val:" Width="40"/>
-                                       <Spinner Style="HSVSpinner" Value="{²./V}" Width="60"  />
+                                       <Label Text="V" Width="Fit"/>
+                                       <Spinner Style="HSVSpinner" Value="{²./V}" Width="40"  />
                                </HorizontalStack>
                        </VerticalStack>
                </HorizontalStack>
index 5d1dd69381443d9f6bd98f86c973dc90d304c3b8..4d3569bf0b0ce80e975493b3f294ff239d092932 100755 (executable)
@@ -2,8 +2,8 @@
 <HorizontalStack MinimumSize="40,10" Name="hstack" Margin="0" Spacing="0">
        <Border BorderWidth="1" Width="80%"  Background="White" 
                Foreground="{./Foreground}" Margin="0">
-               <Label Foreground="{./Foreground}" Font="{./Font}" Width="Stretched"
-                       Text="{./Value}" TextAlignment="Right" Margin="0"/>
+               <TextBox Foreground="{./Foreground}" Font="{./Font}" Width="Stretched"
+                       Text="{²./Value}" TextAlignment="Right" Margin="0"/>
        </Border>
        <VerticalStack MinimumSize="8,10" Width="20%" Height="Stretched" Spacing="0" Margin="0" Background="Red">
                <Button MouseRepeat="true" Width="Stretched" Height="50%" Margin="0" MouseClick="./onUp"
index 9ef774832daf7268cc2b0be7eff955a4aadfd905..d4447a1fa9943a46cab820be819023f1a5e584a0 100644 (file)
@@ -211,12 +211,35 @@ namespace Crow
                public void DeleteWidget (GraphicObject g, int interfaceIdx = 0){
                        ifaceControl [interfaceIdx].CrowInterface.DeleteWidget (g);
                }
-               public GraphicObject Load (string path, int interfaceIdx = 0){
+               /// <summary>
+               /// check if a default interface exists, create one if not
+               /// </summary>
+               void checkDefaultIFace (){
                        if (ifaceControl.Count == 0)//create default orthogonal interface
                                addInterfaceControler (new InterfaceControler (
-                                                       new Rectangle (0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height)));
+                                       new Rectangle (0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height)));                        
+               }
+               /// <summary>
+               /// Load the content of the IML file pointed by path and add it to the current interface
+               /// graphic tree.
+               /// </summary>
+               /// <param name="path">the path of the IML file to load</param>
+               /// <param name="interfaceIdx">interface index to bind to, a default one is created if none exists</param>
+               public GraphicObject Load (string path, int interfaceIdx = 0){
+                       checkDefaultIFace();
                        return ifaceControl [interfaceIdx].CrowInterface.LoadInterface (path);
                }
+               /// <summary>
+               /// Load the content of the IML string passed as first argument and add it to the current interface
+               /// graphic tree.
+               /// </summary>
+               /// <param name="path">a valid IML string</param>
+               /// <param name="interfaceIdx">interface index to bind to, a default one is created if none exists</param>
+               public void LoadIMLFragment (string imlFragment, int interfaceIdx = 0){
+                       checkDefaultIFace();
+                       ifaceControl [interfaceIdx].CrowInterface.LoadIMLFragment (imlFragment);
+               }
+
                public GraphicObject FindByName (string nameToFind){
                        for (int i = 0; i < ifaceControl.Count; i++) {
                                GraphicObject tmp = ifaceControl [i].CrowInterface.FindByName (nameToFind);
diff --git a/Tests/GraphicObjects/ColorCircleSelector.cs b/Tests/GraphicObjects/ColorCircleSelector.cs
new file mode 100644 (file)
index 0000000..7ab9a9b
--- /dev/null
@@ -0,0 +1,149 @@
+//
+// TestCairoPatch.cs
+//
+// Author:
+//       jp <>
+//
+// 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 Cairo;
+using Crow;
+
+namespace Test
+{
+       public class ColorCircleSelector : GraphicObject
+       {
+               void computeControlPoints (
+                       double xc, double yc,
+                       double x1, double y1,
+                       out double x2, out double y2,
+                       out double x3, out double y3,
+                       double x4, double y4){
+                       double ax = x1 - xc;
+                       double ay = y1 - yc;
+                       double bx = x4 - xc;
+                       double byy = y4 - yc;
+                       double q1 = ax * ax + ay * ay;
+                       double q2 = q1 + ax * bx + ay * byy;
+                       double k2 = 4.0/3.0 * (Math.Sqrt(2.0 * q1 * q2) - q2) / (ax * byy - ay * bx);
+
+
+                       x2 = xc + ax - k2 * ay;
+                       y2 = yc + ay + k2 * ax;
+                       x3 = xc + bx + k2 * byy;
+                       y3 = yc + byy - k2 * bx;
+               }
+               protected override void onDraw (Context gr)
+               {
+                       base.onDraw (gr);
+
+                       double radius = 100;
+
+                       double pi3 = Math.PI / 3.0;
+
+                       MeshPattern mp = new MeshPattern ();
+
+                       double x1 = radius,y1 = 0,
+                       x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0,
+                       xc = radius,yc = radius;
+
+                       double dx = Math.Sin (pi3) * radius;
+                       double dy = Math.Cos (pi3) * radius;
+
+                       mp.BeginPatch ();
+                       mp.MoveTo (xc, yc);
+                       mp.LineTo (x1, y1);
+                       x4 = xc + dx;
+                       y4 = yc - dy;
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (0, 1, 1, 1);
+                       mp.SetCornerColorRGB (1, 1, 0, 0);
+                       mp.SetCornerColorRGB (2, 1, 1, 0);
+
+                       x1 = x4;
+                       y1 = y4;
+                       y4 = yc + dy;
+
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (3, 0, 1, 0);
+                       mp.EndPatch ();
+
+                       x1 = x4;
+                       y1 = y4;
+                       x4 = xc;
+                       y4 = yc * 2.0;
+
+                       mp.BeginPatch ();
+                       mp.MoveTo (xc, yc);
+                       mp.LineTo (x1, y1);
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (0, 1, 1, 1);
+                       mp.SetCornerColorRGB (1, 0, 1, 0);
+                       mp.SetCornerColorRGB (2, 0, 1, 1);
+
+                       x1 = x4;
+                       y1 = y4;
+                       x4 = xc-dx;
+                       y4 = yc+dy;
+
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (3, 0, 0, 1);
+                       mp.EndPatch ();
+
+                       x1 = x4;
+                       y1 = y4;
+                       y4 = yc - dy;
+
+                       mp.BeginPatch ();
+                       mp.MoveTo (xc, yc);
+                       mp.LineTo (x1, y1);
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (0, 1, 1, 1);
+                       mp.SetCornerColorRGB (1, 0, 0, 1);
+                       mp.SetCornerColorRGB (2, 1, 0, 1);
+
+                       x1 = x4;
+                       y1 = y4;
+                       x4 = radius;
+                       y4 = 0;
+
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (3, 1, 0, 0);
+                       mp.EndPatch ();
+
+                       gr.SetSource (mp);
+                       gr.Paint ();
+               }
+       }
+}
+
diff --git a/Tests/GraphicObjects/SimpleGauge.cs b/Tests/GraphicObjects/SimpleGauge.cs
new file mode 100644 (file)
index 0000000..ce92abe
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// SimpleGauge.cs
+//
+// Author:
+//       jp <>
+//
+// 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 Crow;
+using System.ComponentModel;
+using Cairo;
+
+namespace Tutorials
+{
+       public class SimpleGauge : GraphicObject
+       {               
+               public SimpleGauge () : base() {}
+               public SimpleGauge (Interface iface): base (iface){}
+
+               int level;
+
+               [DefaultValue(0)]
+               public int Level
+               {
+                       get { return level; }
+                       set {
+                               if (level == value)
+                                       return;
+                               level = value;
+                               NotifyValueChanged ("Level", level);
+                       }
+               }
+
+               protected override void onDraw (Context gr)
+               {
+                       base.onDraw (gr);
+
+                       Rectangle r = ClientRectangle;
+                       int height = r.Height / 100 * level;
+                       r.Y += r.Height - height;
+                       r.Height = height;
+                       Foreground.SetAsSource (gr);
+                       gr.Rectangle (r);
+                       gr.Fill ();
+               }
+       }
+}
+
diff --git a/Tests/HelloCube.cs b/Tests/HelloCube.cs
deleted file mode 100644 (file)
index c616acb..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-//
-// HelloCube.cs
-//
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// 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 OpenTK;
-using OpenTK.Graphics.OpenGL;
-using Crow;
-
-namespace Tests
-{
-       class HelloCube : CrowWindow
-       {
-               [STAThread]
-               static void Main ()
-               {
-                       HelloCube win = new HelloCube ();
-                       win.Run (30);
-               }
-
-               public HelloCube ()
-                       : base(800, 600,"Crow Test with OpenTK")
-               {
-               }
-
-               vaoMesh cube;
-               Texture texture;
-               Matrix4 projection, modelview;
-
-               void initGL(){
-                       GL.Enable (EnableCap.CullFace);
-                       GL.Enable (EnableCap.Blend);
-                       GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
-
-                       cube = vaoMesh.CreateCube ();
-                       texture = new Texture ("image/textest.png");
-
-                       projection =
-                               Matrix4.CreatePerspectiveFieldOfView (
-                                       MathHelper.PiOver4,
-                                       ClientRectangle.Width / (float)ClientRectangle.Height, 1.0f, 10.0f);
-                       modelview = Matrix4.LookAt(new Vector3(5,5,5), Vector3.Zero, Vector3.UnitZ);
-               }
-
-               protected override void OnLoad (EventArgs e)
-               {
-                       base.OnLoad (e);
-
-                       AddWidget(
-                               new Window (this.CurrentInterface)
-                               {
-                                       Caption = "Hello World"
-                               }
-                       );
-                       initGL ();
-               }
-               public override void OnRender (FrameEventArgs e)
-               {                       
-                       base.OnRender (e);
-
-                       shader.SetMVP(modelview * projection);
-
-                       GL.BindTexture (TextureTarget.Texture2D, texture);
-                       cube.Render (BeginMode.Triangles);
-                       GL.BindTexture (TextureTarget.Texture2D, 0);
-               }
-       }
-}
\ No newline at end of file
index 95df6a2723f105dd9145ac904c583585f11409eb..59629dac1a06c9be587183d380afe176ee89b1a0 100644 (file)
@@ -33,6 +33,7 @@ using System.Collections.Generic;
 using System.Reflection;
 using System.Linq;
 using System.Text;
+using Crow.IML;
 
 namespace Tests
 {
index 2994acbad3b35d0ff4b350dab68ea4bf003c1dc7..f1ee0708f32f4148dbe8fcfc2c2aacf6e1cc88a5 100644 (file)
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
     <DefineConstants>DEBUG;TRACE;MEASURE_TIME</DefineConstants>
-    <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
-    <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>none</DebugType>
     <Optimize>true</Optimize>
     <WarningLevel>0</WarningLevel>
     <ConsolePause>false</ConsolePause>
-    <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
-    <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
+    <StartAction>Program</StartAction>
+    <StartProgram>%24{TargetName}</StartProgram>
+    <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
+    <StartAction>Program</StartAction>
+    <StartProgram>%24{TargetName}</StartProgram>
+    <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
+    <ConsolePause>false</ConsolePause>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Compile Include="OpenGL\vaoMesh.cs" />
     <Compile Include="OpenGL\Texture.cs" />
     <Compile Include="HelloWorld.cs" />
-    <Compile Include="HelloCube.cs" />
     <Compile Include="CrowWindow.cs" />
     <Compile Include="Hello3D.cs" />
     <Compile Include="OpenGL\Extensions.cs" />
     <Compile Include="InterfaceControler.cs" />
     <Compile Include="Showcase.cs" />
+    <Compile Include="GraphicObjects\ColorCircleSelector.cs" />
+    <Compile Include="GraphicObjects\SimpleGauge.cs" />
+    <Compile Include="Tutorials\T1_HelloWorld.cs" />
+    <Compile Include="Tutorials\T3_OpenGLCube.cs" />
+    <Compile Include="Tutorials\T4_Gauge.cs" />
+    <Compile Include="Tutorials\T2_IML.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="image\u.svg">
     <Folder Include="Interfaces\TemplatedControl\" />
     <Folder Include="Interfaces\TemplatedContainer\" />
     <Folder Include="Interfaces\TemplatedGroup\" />
+    <Folder Include="GraphicObjects\" />
+    <Folder Include="Tutorials\" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="image\tetra.png">
     <EmbeddedResource Include="Interfaces\CheckBox2.imlt" />
     <EmbeddedResource Include="Interfaces\perfMsr.crow" />
     <EmbeddedResource Include="ui\showcase.crow" />
+    <EmbeddedResource Include="Tutorials\test.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Crow.csproj">
diff --git a/Tests/Tutorials/T1_HelloWorld.cs b/Tests/Tutorials/T1_HelloWorld.cs
new file mode 100644 (file)
index 0000000..539085d
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// HelloWorld.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// 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 Crow;
+
+namespace Tutorials
+{
+       class T1_HelloWorld : CrowWindow
+       {
+               public T1_HelloWorld ()
+                       : base(800, 600,"Hello World")
+               {
+               }
+
+               protected override void OnLoad (EventArgs e)
+               {
+                       base.OnLoad (e);
+                       AddWidget (new Label (CurrentInterface) { Text = "Hello World" });
+               }
+
+               [STAThread]
+               static void Main ()
+               {
+                       T1_HelloWorld win = new T1_HelloWorld ();
+                       win.Run (30);
+               }
+       }
+}
\ No newline at end of file
diff --git a/Tests/Tutorials/T2_IML.cs b/Tests/Tutorials/T2_IML.cs
new file mode 100644 (file)
index 0000000..57eea83
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// HelloWorld.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// 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 Crow;
+
+namespace Tutorials
+{
+       class T2_IML : CrowWindow
+       {
+               public T2_IML ()
+                       : base(800, 600,"First app with OpenTK")
+               {
+               }
+
+               protected override void OnLoad (EventArgs e)
+               {
+                       base.OnLoad (e);
+                       Load ("#Tests.Tutorials.test.crow");
+               }
+
+               [STAThread]
+               static void Main ()
+               {
+                       T2_IML win = new T2_IML ();
+                       win.Run (30);
+               }
+       }
+}
\ No newline at end of file
diff --git a/Tests/Tutorials/T3_OpenGLCube.cs b/Tests/Tutorials/T3_OpenGLCube.cs
new file mode 100644 (file)
index 0000000..c920c62
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// HelloCube.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// 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 OpenTK;
+using OpenTK.Graphics.OpenGL;
+using Crow;
+
+namespace Tutorials
+{
+       class T3_OpenGLCube : CrowWindow
+       {
+               [STAThread]
+               static void Main ()
+               {
+                       T3_OpenGLCube win = new T3_OpenGLCube ();
+                       win.Run (30);
+               }
+
+               public T3_OpenGLCube ()
+                       : base(800, 600,"Crow Test with OpenTK")
+               {
+               }
+
+               vaoMesh cube;
+               Texture texture;
+               Matrix4 projection, modelview;
+
+               protected override void OnLoad (EventArgs e)
+               {
+                       base.OnLoad (e);
+
+                       GL.Enable (EnableCap.CullFace);
+                       GL.Enable (EnableCap.Blend);
+                       GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
+
+                       cube = vaoMesh.CreateCube ();
+                       texture = new Texture ("image/textest.png");
+
+                       projection =
+                               Matrix4.CreatePerspectiveFieldOfView (
+                                       MathHelper.PiOver4,
+                                       ClientRectangle.Width / (float)ClientRectangle.Height, 1.0f, 10.0f);
+                       modelview = Matrix4.LookAt(new Vector3(5,5,5), Vector3.Zero, Vector3.UnitZ);
+
+                       AddWidget(
+                               new Window (this.CurrentInterface)
+                               {
+                                       Caption = "Hello World"
+                               }
+                       );
+               }
+               public override void OnRender (FrameEventArgs e)
+               {                       
+                       base.OnRender (e);
+
+                       shader.SetMVP(modelview * projection);
+
+                       GL.BindTexture (TextureTarget.Texture2D, texture);
+                       cube.Render (BeginMode.Triangles);
+                       GL.BindTexture (TextureTarget.Texture2D, 0);
+               }
+       }
+}
\ No newline at end of file
diff --git a/Tests/Tutorials/T4_Gauge.cs b/Tests/Tutorials/T4_Gauge.cs
new file mode 100644 (file)
index 0000000..2b9ec57
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// HelloWorld.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// 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 Crow;
+
+namespace Tutorials
+{
+       class T4_Gauge : CrowWindow
+       {
+               public T4_Gauge ()
+                       : base(800, 600,"Simple Gauge Tutorial")
+               {
+               }
+
+               protected override void OnLoad (EventArgs e)
+               {
+                       base.OnLoad (e);
+                       AddWidget (new SimpleGauge (CurrentInterface) {
+                               Level = 40,
+                               Width = 30, Height = "50%",
+                               Foreground = Color.UnitedNationsBlue, Background = Color.Jet
+                       });
+               }
+
+               [STAThread]
+               static void Main ()
+               {
+                       T4_Gauge win = new T4_Gauge ();
+                       win.Run (30);
+               }
+       }
+}
\ No newline at end of file
diff --git a/Tests/Tutorials/test.crow b/Tests/Tutorials/test.crow
new file mode 100755 (executable)
index 0000000..a1299e7
--- /dev/null
@@ -0,0 +1,3 @@
+<Window Height="400" Width="50%" Caption="My first Window">
+       <Label Text="Hello World"/>
+</Window>
\ No newline at end of file
index 79302354cf90ca59cd7297081e3b762cc9636c8b..b827161514f4ee9b877f31a8d7ab8f2eac568a98 100644 (file)
@@ -114,7 +114,7 @@ namespace Crow
                        }
 
                        using (ImageSurface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
-                               using (Cairo.Context gr = new Context (tmp)) {
+                               using (Context gr = new Context (tmp)) {
                                        gr.Translate (bounds.Left, bounds.Top);
                                        gr.Scale (widthRatio, heightRatio);
                                        gr.Translate ((bounds.Width/widthRatio - Dimensions.Width)/2, (bounds.Height/heightRatio - Dimensions.Height)/2);
@@ -137,7 +137,7 @@ namespace Crow
                /// <param name="gr">drawing Backend context</param>
                /// <param name="rect">bounds of the target surface to paint</param>
                /// <param name="subPart">used for svg only</param>
-               public override void Paint (Cairo.Context gr, Rectangle rect, string subPart = "")
+               public override void Paint (Context gr, Rectangle rect, string subPart = "")
                {
                        float widthRatio = 1f;
                        float heightRatio = 1f;
index d0a14f602e064b5be4c512b621ed5534a0f87546..d98e47cfe4a0a00e2065d1c133ebf1ba5c1f11b8 100644 (file)
@@ -26,6 +26,7 @@
 
 using System;
 using System.Collections.Generic;
+using Cairo;
 
 namespace Crow
 {
@@ -38,8 +39,8 @@ namespace Crow
                /// set content of fill as source for drawing operations on the backend context
                /// </summary>
                /// <param name="ctx">backend context</param>
-               /// <param name="bounds">drawing operation bounding box</param>
-               public abstract void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle));
+               /// <param name="bounds">paint operation bounding box, unused for SolidColor</param>
+               public abstract void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle));
                public static object Parse (string s){
                        if (string.IsNullOrEmpty (s))
                                return null;
index 56873889aad136e544c096299bcffb13570a574f..0806e885b8aab9f24395cca6dbce0cffa709e7a3 100644 (file)
@@ -26,6 +26,7 @@
 
 using System;
 using System.Collections.Generic;
+using Cairo;
 
 namespace Crow
 {
@@ -78,7 +79,7 @@ namespace Crow
 
                #region implemented abstract members of Fill
 
-               public override void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle))
+               public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle))
                {
                        Cairo.Gradient grad = null;
                        switch (GradientType) {
index a7c039c3001080cfd347c1c7895cd7cc4dd69676..569315cc0bee394fda2293dfdad5aa5b43ac3f6f 100644 (file)
@@ -28,6 +28,7 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
+using Cairo;
 
 namespace Crow
 {
@@ -126,7 +127,7 @@ namespace Crow
                        int tmp = base.measureRawSize (lt);
                        return tmp < 0 ? tmp : tmp + 2 * BorderWidth;
                }
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        drawborder2 (gr);
 
@@ -141,7 +142,7 @@ namespace Crow
                                child.Paint (ref gr);
                        gr.Restore ();
                }
-               void drawborder2(Cairo.Context gr){
+               void drawborder2(Context gr){
                        Rectangle rBack = new Rectangle (Slot.Size);
 
                        //rBack.Inflate (-Margin);
@@ -228,7 +229,7 @@ namespace Crow
                                }
                        }
                }
-               void drawborder1(Cairo.Context gr){
+               void drawborder1(Context gr){
                        Rectangle rBack = new Rectangle (Slot.Size);
 
                        //rBack.Inflate (-Margin);
index 2523810ef23c81ba99dc2bc61e00e69fb7c6c11c..b7ca11f61a44c93983cb637b586ebadd17bacab3 100644 (file)
@@ -38,7 +38,7 @@ using Crow.IML;
 namespace Crow
 {
        /// <summary>
-       /// This is the base class for all the graphic trees elements
+       /// The base class for all the graphic tree elements.
        /// </summary>
        public class GraphicObject : ILayoutable, IValueChange, IDisposable
        {
@@ -1375,7 +1375,7 @@ namespace Crow
 
                #region Rendering
                /// <summary> This is the common overridable drawing routine to create new widget </summary>
-               protected virtual void onDraw(Cairo.Context gr)
+               protected virtual void onDraw(Context gr)
                {
                        #if DEBUG_UPDATE
                        Debug.WriteLine (string.Format("OnDraw -> {0}", this.ToString ()));
@@ -1400,13 +1400,13 @@ namespace Crow
                        if (bmp != null)
                                bmp.Dispose ();
                        bmp = new ImageSurface (Format.Argb32, Slot.Width, Slot.Height);
-                       using (Cairo.Context gr = new Cairo.Context (bmp)) {
+                       using (Context gr = new Context (bmp)) {
                                gr.Antialias = Interface.Antialias;
                                onDraw (gr);
                        }
                        bmp.Flush ();
                }
-               protected virtual void UpdateCache(Cairo.Context ctx){
+               protected virtual void UpdateCache(Context ctx){
                        #if DEBUG_UPDATE
                        Debug.WriteLine (string.Format("UpdateCache -> {0}", this.ToString ()));
                        #endif
@@ -1425,7 +1425,7 @@ namespace Crow
                }
                /// <summary> Chained painting routine on the parent context of the actual cached version
                /// of the widget </summary>
-               public virtual void Paint (ref Cairo.Context ctx)
+               public virtual void Paint (ref Context ctx)
                {
                        #if DEBUG_UPDATE
                        Debug.WriteLine (string.Format("Paint -> {0}", this.ToString ()));
@@ -1461,7 +1461,7 @@ namespace Crow
                                LastPaintedSlot = Slot;
                        }
                }
-               void paintDisabled(Cairo.Context gr, Rectangle rb){
+               void paintDisabled(Context gr, Rectangle rb){
                        gr.Operator = Operator.Xor;
                        gr.SetSourceRGBA (0.6, 0.6, 0.6, 0.3);
                        gr.Rectangle (rb);
index a94053fdb2140075b1783a36a470952087d0e02f..08c84deb22f5c5bb3709e6c74b6c13759fb49140 100644 (file)
@@ -67,11 +67,13 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        base.onDraw (gr);
 
                        Rectangle r = ClientRectangle;
+                       r.Height -= 4;
+                       r.Y += 2;
 
                        Gradient.Type gt = Gradient.Type.Horizontal;
                        if (Orientation == Orientation.Vertical)
@@ -111,9 +113,9 @@ namespace Crow
                                r.Y = mousePos.Y - 2;
                        }
 
-                       CairoHelpers.CairoRectangle (ctx, r, 2);
+                       CairoHelpers.CairoRectangle (ctx, r, 1);
                        ctx.SetSourceColor (Color.White);
-                       ctx.LineWidth = 2.0;
+                       ctx.LineWidth = 1.0;
                        ctx.Stroke();
                        ctx.Restore ();
                }
index d8fdead40251d04043ddf3e941fb8592fb513e72..21cb19616b607a1cfb8fb361a25c8b68ad8d7d13 100644 (file)
@@ -113,7 +113,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               [XmlAttributeAttribute][DefaultValue(0.0)]
+               [DefaultValue(0.0)]
                public double Value
                {
                        get { return _actualValue; }
index 8d72668508d49eea472253da1c902dec0d4b2c69..b0bf270e8746447e293588330a12d053cb42d95e 100644 (file)
@@ -65,7 +65,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        base.onDraw (gr);
 
index 2fdc3802bb0a0b4144d626b8db7c39ba79351dee..9dfff864745fa277707913891432e21b562ad4c1 100644 (file)
@@ -28,6 +28,7 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
+using Cairo;
 
 namespace Crow
 {
@@ -105,7 +106,7 @@ namespace Crow
                                NotifyValueChanged ("IsSelected", isSelected);
                        }
                }
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        gr.Save ();
 
index 01ba22c23f333882a710534c6f0be73436564ca4..6e236c8d71c730155a9f68c171d5b0d667fa1d25 100644 (file)
@@ -34,6 +34,7 @@ using System.Linq;
 using System.Collections.Generic;
 using System.Text;
 using System.Reflection;
+using Cairo;
 
 namespace Crow
 {
@@ -105,7 +106,7 @@ namespace Crow
                ///this allow applying root background to random template's component
                /// </summary>
                /// <param name="gr">Backend context</param>
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        gr.Save ();
 
diff --git a/src/GraphicObjects/TestCairoPatch.cs b/src/GraphicObjects/TestCairoPatch.cs
new file mode 100644 (file)
index 0000000..f155d3c
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// TestCairoPatch.cs
+//
+// Author:
+//       jp <>
+//
+// 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 Cairo;
+
+namespace Crow
+{
+       public class TestCairoPatch : GraphicObject
+       {
+               void computeControlPoints (
+                       double xc, double yc,
+                       double x1, double y1,
+                       out double x2, out double y2,
+                       out double x3, out double y3,
+                       double x4, double y4){
+                       double ax = x1 - xc;
+                       double ay = y1 - yc;
+                       double bx = x4 - xc;
+                       double byy = y4 - yc;
+                       double q1 = ax * ax + ay * ay;
+                       double q2 = q1 + ax * bx + ay * byy;
+                       double k2 = 4.0/3.0 * (Math.Sqrt(2.0 * q1 * q2) - q2) / (ax * byy - ay * bx);
+
+
+                       x2 = xc + ax - k2 * ay;
+                       y2 = yc + ay + k2 * ax;
+                       x3 = xc + bx + k2 * byy;
+                       y3 = yc + byy - k2 * bx;
+               }
+               protected override void onDraw (Context gr)
+               {
+                       base.onDraw (gr);
+
+                       double radius = 100;
+
+                       double pi3 = Math.PI / 3.0;
+
+                       MeshPattern mp = new MeshPattern ();
+
+                       double x1 = radius,y1 = 0,
+                       x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0,
+                       xc = radius,yc = radius;
+
+                       double dx = Math.Sin (pi3) * radius;
+                       double dy = Math.Cos (pi3) * radius;
+
+                       mp.BeginPatch ();
+                       mp.MoveTo (xc, yc);
+                       mp.LineTo (x1, y1);
+                       x4 = xc + dx;
+                       y4 = yc - dy;
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (0, 1, 1, 1);
+                       mp.SetCornerColorRGB (1, 1, 0, 0);
+                       mp.SetCornerColorRGB (2, 1, 1, 0);
+
+                       x1 = x4;
+                       y1 = y4;
+                       y4 = yc + dy;
+
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (3, 0, 1, 0);
+                       mp.EndPatch ();
+
+                       x1 = x4;
+                       y1 = y4;
+                       x4 = xc;
+                       y4 = yc * 2.0;
+
+                       mp.BeginPatch ();
+                       mp.MoveTo (xc, yc);
+                       mp.LineTo (x1, y1);
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (0, 1, 1, 1);
+                       mp.SetCornerColorRGB (1, 0, 1, 0);
+                       mp.SetCornerColorRGB (2, 0, 1, 1);
+
+                       x1 = x4;
+                       y1 = y4;
+                       x4 = xc-dx;
+                       y4 = yc+dy;
+
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (3, 0, 0, 1);
+                       mp.EndPatch ();
+
+                       x1 = x4;
+                       y1 = y4;
+                       y4 = yc - dy;
+
+                       mp.BeginPatch ();
+                       mp.MoveTo (xc, yc);
+                       mp.LineTo (x1, y1);
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (0, 1, 1, 1);
+                       mp.SetCornerColorRGB (1, 0, 0, 1);
+                       mp.SetCornerColorRGB (2, 1, 0, 1);
+
+                       x1 = x4;
+                       y1 = y4;
+                       x4 = radius;
+                       y4 = 0;
+
+                       computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4);
+                       mp.CurveTo (x2, y2, x3, y3, x4, y4);
+
+                       mp.SetCornerColorRGB (3, 1, 0, 0);
+                       mp.EndPatch ();
+
+                       gr.SetSource (mp);
+                       gr.Paint ();
+               }
+       }
+}
+
index 50a1e56f6556dc6df8c6ba46f79b5eba7603f192..055c870dcd2154bf443dc7d928b434fdb1aee28a 100644 (file)
@@ -28,6 +28,7 @@ using System;
 using System.Collections.Generic;
 using System.Xml.Serialization;
 using System.ComponentModel;
+using Cairo;
 
 namespace Crow
 {
@@ -139,7 +140,7 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        base.onDraw (gr);
 
index a1012e2b339b7d75a6d715c5836184c67f85502e..902092e2228efd045c56961e22c7a44f3e0d21b7 100644 (file)
@@ -36,7 +36,7 @@ using System.Collections.Generic;
 using System.Linq;
 using Crow.IML;
 
-namespace Crow
+namespace Crow.IML
 {
        public delegate object InstanciatorInvoker(Interface iface);
 
@@ -123,7 +123,15 @@ namespace Crow
                public GraphicObject CreateInstance(Interface iface){
                        return loader (iface) as GraphicObject;
                }
-
+               /// <summary>
+               /// Creates a new instance of T compiled in the instantiator
+               /// and bind it the an interface
+               /// </summary>
+               /// <returns>The new T instance</returns>
+               /// <param name="iface">The interface to bind to</param>
+               public T CreateInstance<T>(Interface iface){
+                       return (T)loader (iface);
+               }
                List<DynamicMethod> dsValueChangedDynMeths = new List<DynamicMethod>();
                List<Delegate> cachedDelegates = new List<Delegate>();
                /// <summary>
index 15c6de35493585934aadc20a8bdb236ace6c9dd0..32b9549efc3ede87235e234576a981c02bc91b2f 100644 (file)
@@ -35,6 +35,7 @@ using System.Xml;
 using System.Xml.Serialization;
 using Cairo;
 using System.Globalization;
+using Crow.IML;
 
 namespace Crow
 {
@@ -212,6 +213,8 @@ namespace Crow
                }
                /// <summary> Search for .style resources in assembly </summary>
                static void loadStylingFromAssembly (Assembly assembly) {
+                       if (assembly == null)
+                               return;
                        foreach (string s in assembly
                                .GetManifestResourceNames ()
                                .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) {
@@ -221,9 +224,9 @@ namespace Crow
                }
                static void loadCursors(){
                        //Load cursors
-                       XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0];
-                       XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0];
-                       XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0];
+                       XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[3];
+                       XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[3];
+                       XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[3];
                        XCursor.NE = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0];
                        XCursor.SW = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0];
                        XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0];
@@ -258,6 +261,8 @@ namespace Crow
                        }
                }
                static void searchTemplatesIn(Assembly assembly){
+                       if (assembly == null)
+                               return;
                        foreach (string resId in assembly
                                .GetManifestResourceNames ()
                                .Where (r => r.EndsWith (".template", StringComparison.OrdinalIgnoreCase))) {
@@ -295,7 +300,18 @@ namespace Crow
                        }
                        return stream;
                }
-
+               /// <summary>
+               /// Add the content of the IML fragment to the graphic tree of this interface
+               /// </summary>
+               /// <returns>return the new instance for convenience, may be ignored</returns>
+               /// <param name="imlFragment">a valid IML string</param>
+               public GraphicObject LoadIMLFragment (string imlFragment) {
+                       lock (UpdateMutex) {
+                               GraphicObject tmp = Instantiator.CreateFromImlFragment (imlFragment).CreateInstance(this);
+                               AddWidget (tmp);
+                               return tmp;
+                       }
+               }
                /// <summary>Create an instance of a GraphicObject and add it to the GraphicTree
                /// of this Interface</summary>
                public GraphicObject LoadInterface (string path)
@@ -303,7 +319,6 @@ namespace Crow
                        lock (UpdateMutex) {
                                GraphicObject tmp = Load (path);
                                AddWidget (tmp);
-
                                return tmp;
                        }
                }
index 3b731a98093bcc935d2d4e2c0a41b5805cba4d79..264774dd49922bdbe6684e837521407ec7601d51 100644 (file)
@@ -450,7 +450,7 @@ namespace Cairo {
                        NativeMethods.cairo_arc_negative (handle, xc, yc, radius, angle1, angle2);
                }
 
-               public void Rectangle (Rectangle rectangle)
+               public void Rectangle (Crow.Rectangle rectangle)
                {
                        Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                }
@@ -518,11 +518,11 @@ namespace Cairo {
                        NativeMethods.cairo_stroke_preserve (handle);
                }
 
-               public Rectangle StrokeExtents ()
+               public Crow.Rectangle StrokeExtents ()
                {
                        double x1, y1, x2, y2;
                        NativeMethods.cairo_stroke_extents (handle, out x1, out y1, out x2, out y2);
-                       return new Rectangle (x1, y1, x2 - x1, y2 - y1);
+                       return new Crow.Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1));
                }
 
                public void Fill ()
@@ -530,11 +530,11 @@ namespace Cairo {
                        NativeMethods.cairo_fill (handle);
                }
 
-               public Rectangle FillExtents ()
+               public Crow.Rectangle FillExtents ()
                {
                        double x1, y1, x2, y2;
                        NativeMethods.cairo_fill_extents (handle, out x1, out y1, out x2, out y2);
-                       return new Rectangle (x1, y1, x2 - x1, y2 - y1);
+                       return new Crow.Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1));
                }
 
                public void FillPreserve ()
index 233a1bacf4d3891ff01776e5ea4f4efa64797d90..6766aa450c5e480a3a5034df0b4035017e924c00 100644 (file)
@@ -30,70 +30,70 @@ using System;
 
 namespace Cairo
 {
-       public struct Rectangle
-       {
-               double x;
-               double y;
-               double width;
-               double height;
-               
-               public Rectangle (double x, double y, double width, double height)
-               {
-                       this.x = x;
-                       this.y = y;
-                       this.width = width;
-                       this.height = height;
-               }
-               
-               public Rectangle (Point point, double width, double height)
-               {
-                       x = point.X;
-                       y = point.Y;
-                       this.width = width;
-                       this.height = height;
-               }
-               
-               public double X {
-                       get { return x; }
-               }
-               
-               public double Y {
-                       get { return y; }
-               }
-               
-               public double Width {
-                       get { return width; }
-               }
-               
-               public double Height {
-                       get { return height; }
-               }
-               
-               public override bool Equals (object obj)
-               {
-                       if (obj is Rectangle)
-                               return this == (Rectangle)obj;
-                       return false;
-               }
-               
-               public override int GetHashCode ()
-               {
-                       return (int) (x + y + width + height);
-               }
-
-               public override string ToString ()
-               {
-                       return String.Format ("x:{0} y:{1} w:{2} h:{3}", x, y, width, height);
-               }
-               
-               public static bool operator == (Rectangle rectangle, Rectangle other)
-               {
-                       return rectangle.X == other.X && rectangle.Y == other.Y && rectangle.Width == other.Width && rectangle.Height == other.Height;
-               }
-               
-               public static bool operator != (Rectangle rectangle, Rectangle other)
-               {
-                       return !(rectangle == other);
-               }
-       }
+//     public struct Rectangle
+//     {
+//             double x;
+//             double y;
+//             double width;
+//             double height;
+//             
+//             public Rectangle (double x, double y, double width, double height)
+//             {
+//                     this.x = x;
+//                     this.y = y;
+//                     this.width = width;
+//                     this.height = height;
+//             }
+//             
+//             public Rectangle (Point point, double width, double height)
+//             {
+//                     x = point.X;
+//                     y = point.Y;
+//                     this.width = width;
+//                     this.height = height;
+//             }
+//             
+//             public double X {
+//                     get { return x; }
+//             }
+//             
+//             public double Y {
+//                     get { return y; }
+//             }
+//             
+//             public double Width {
+//                     get { return width; }
+//             }
+//             
+//             public double Height {
+//                     get { return height; }
+//             }
+//             
+//             public override bool Equals (object obj)
+//             {
+//                     if (obj is Rectangle)
+//                             return this == (Rectangle)obj;
+//                     return false;
+//             }
+//             
+//             public override int GetHashCode ()
+//             {
+//                     return (int) (x + y + width + height);
+//             }
+//
+//             public override string ToString ()
+//             {
+//                     return String.Format ("x:{0} y:{1} w:{2} h:{3}", x, y, width, height);
+//             }
+//             
+//             public static bool operator == (Rectangle rectangle, Rectangle other)
+//             {
+//                     return rectangle.X == other.X && rectangle.Y == other.Y && rectangle.Width == other.Width && rectangle.Height == other.Height;
+//             }
+//             
+//             public static bool operator != (Rectangle rectangle, Rectangle other)
+//             {
+//                     return !(rectangle == other);
+//             }
+//     }
 }
index d38b75556e5eb93b1f384103f7025beeefe66443..6a55496a516e155cdccd2e34bcce5e984e026649 100644 (file)
@@ -169,9 +169,9 @@ namespace Cairo {
                        NativeMethods.cairo_surface_mark_dirty (Handle);
                }
 
-               public void MarkDirty (Rectangle rectangle)
+               public void MarkDirty (Crow.Rectangle rectangle)
                {
-                       NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);
+                       NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                }
 
                public IntPtr Handle {
index a8574b35f3fb94a62aa813864ae47be197ec95aa..d6423d318ad8259bd60a026f6dbc03abd66409bc 100644 (file)
@@ -31,6 +31,7 @@ using System.Text;
 using System.Xml.Serialization;
 using System.Reflection;
 using System.Diagnostics;
+using Cairo;
 
 
 
@@ -48,7 +49,7 @@ namespace Crow
 
                #region implemented abstract members of Fill
 
-               public override void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle))
+               public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle))
                {
                        ctx.SetSourceRGBA (color.R, color.G, color.B, color.A);
                }
index b402685249ee8b3941f7becd03536d3de5d9f85e..01aaeb5fa75ca4aa94682a28af43664d0426f222 100644 (file)
@@ -91,7 +91,7 @@ namespace Crow
                        }
 
                        using (ImageSurface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
-                               using (Cairo.Context gr = new Context (tmp)) {
+                               using (Context gr = new Context (tmp)) {
                                        gr.Translate (bounds.Left, bounds.Top);
                                        gr.Scale (widthRatio, heightRatio);
                                        gr.Translate ((bounds.Width/widthRatio - Dimensions.Width)/2, (bounds.Height/heightRatio - Dimensions.Height)/2);
@@ -110,7 +110,7 @@ namespace Crow
                /// <param name="gr">drawing Backend context</param>
                /// <param name="rect">bounds of the target surface to paint</param>
                /// <param name="subPart">limit rendering to svg part named 'subPart'</param>
-               public override void Paint (Cairo.Context gr, Rectangle rect, string subPart = "")
+               public override void Paint (Context gr, Rectangle rect, string subPart = "")
                {
                        float widthRatio = 1f;
                        float heightRatio = 1f;
index 039d3b6e7dddf6e2d4f3c9c57c8654d0a10e946d..e13f79ad57f4ae65d5625272f93326b171e97d54 100644 (file)
@@ -1,4 +1,7 @@
 //Copyright GPL2
+using Cairo;
+
+
 namespace Rsvg {
 
        using System;
@@ -55,7 +58,7 @@ namespace Rsvg {
                [DllImport("rsvg-2")]
                static extern void rsvg_handle_render_cairo(IntPtr raw, IntPtr cr);
 
-               public void RenderCairo(Cairo.Context cr) {
+               public void RenderCairo(Context cr) {
                        unsafe{
                                rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle);
                        }