]> O.S.I.I.S - jp/crow.git/commitdiff
wip Backends 57/head
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 4 Dec 2021 19:27:22 +0000 (20:27 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 4 Dec 2021 19:27:22 +0000 (20:27 +0100)
13 files changed:
Backends/CairoBackend/CairoBackend.csproj
Backends/CairoBackend/src/CairoBackendBase.cs
Backends/CairoBackend/src/DefaultBackend.cs
Backends/CairoBackend/src/ImageBackend.cs
Crow/src/Interface.cs
Directory.Build.props
Drawing2D/Drawing2D.csproj
Drawing2D/src/Point.cs
Drawing2D/src/PointD.cs
Samples/HelloWorld/main.cs
Samples/PerfTests/Program.cs
Samples/ShowCase/ShowCase.cs
Samples/common/src/SampleBase.cs

index 986ad8592515ef23ca9e19a3c7fffc54b1f8f537..8e724258ef4ef994a94ca2556fade81efc276faa 100644 (file)
@@ -2,11 +2,29 @@
 
   <PropertyGroup>
          <TargetFramework>netcoreapp3.0</TargetFramework>
+
+               <AssemblyVersion>0.0.1</AssemblyVersion>
+               <PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
+
+               <Title>C.R.O.W Cairo Backend</Title>
+               <Description>C.R.O.W. is a widget toolkit and rendering engine developed in C# with templates, styles, compositing, and bindings.</Description>
+               <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
+               <PackageTags>Crow GUI Backend cairo</PackageTags>
+               <PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
+               <PackageProjectUrl>https://github.com/jpbruyere/Crow/wiki</PackageProjectUrl>
+               <PackageLicenseExpression>MIT</PackageLicenseExpression>
+               <PackageIcon>crow.png</PackageIcon>
+               <PackageCopyright>Copyright 2021</PackageCopyright>
+               <PackageReleaseNotes>
+               </PackageReleaseNotes>
+               <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
+               <GenerateDocumentationFile>true</GenerateDocumentationFile>
          <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
   </PropertyGroup>
 
   <ItemGroup>
          <Compile Include="src\**\*.cs" Exclude="src\NativeMethods-internal.cs" />
+    <Content Include="..\..\Images\crow.png" Pack="true" PackagePath="" />
   </ItemGroup>
 
   <ItemGroup>
index 1e1b2e821734112c97f1d78f25ec1a101cc0b6eb..db6895c2f0d42fe5b048eb2597c9c66e608f5aee 100644 (file)
@@ -114,7 +114,7 @@ namespace Crow.CairoBackend
                                ctx.Dispose ();
                        clipping = null;
                }
-               public void ResizeMainSurface (int width, int height)
+               public virtual void ResizeMainSurface (int width, int height)
                {
                        surf.Resize (width, height);
                }
index 7f8050636ef677f3b853e89fe9a281a6db2cfb09..24d719da74d3794cb5584097f6485832e017b710 100644 (file)
@@ -3,7 +3,7 @@ using Crow.CairoBackend;
 
 namespace Crow.Backends
 {
-       public class DefaultBackend : EglBackend {
+       public class DefaultBackend : ImageBackend {
                /// <summary>
                /// Create a new generic backend bound to the application surface
                /// </summary>
index 0181451a47f842b771b71c7ec59154b656b7553b..d8518f316db71b87c389dfebbcf769b63a868eed 100644 (file)
@@ -56,6 +56,10 @@ namespace Crow.CairoBackend
                public ImageBackend (int width, int height) : base () {
                        surf = new ImageSurface (Format.ARGB32, width, height);
                }
+               public ImageBackend (IntPtr surfaceBitmapData, int width, int height, int stride) : base () {
+                       surf = new ImageSurface (surfaceBitmapData, Format.ARGB32, width, height, stride);
+               }
+
                public override ISurface CreateSurface(int width, int height)
                        => new ImageSurface (Format.ARGB32, width, height);
                public override ISurface CreateSurface(byte[] data, int width, int height)
index 9a1ab1025c9bf7973b5675a594bbb823885b8229..74d0ed943b418f56ffc8bd85a82ff395c58cb8dc 100644 (file)
@@ -217,7 +217,7 @@ namespace Crow
                /// <param name="height">the height of the window</param>
                /// <param name="glfwWindowHandle">A valid GLFW window handle</param>
                /// <returns></returns>
-               public Interface (int width, int height, IntPtr glfwWindowHandle) : this (width, height, true, false)
+               public Interface (int width, int height, IntPtr glfwWindowHandle) : this (width, height, true)
                {
                        hWin = glfwWindowHandle;
                        PerformanceMeasure.InitMeasures ();
@@ -229,23 +229,13 @@ namespace Crow
                /// <param name="height">the height of the native window</param>
                /// <param name="singleThreaded">If 'false' start the ui update (InterfaceThread method) in a dedicated thread</param>
                /// <param name="createSurface">If 'yes', create the main rendering surface on the native window</param>
-               public Interface (int width = 800, int height = 600, bool singleThreaded = false, bool createSurface = true)
+               public Interface (int width = 800, int height = 600, bool singleThreaded = false)
                {
                        CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
                        //CurrentInterface = this;
                        clientRectangle = new Rectangle (0, 0, width, height);
                        SingleThreaded = singleThreaded;
-
-                       initBackend ();
-
                        PerformanceMeasure.InitMeasures ();
-
-                       if (!SingleThreaded) {
-                               Thread t = new Thread (InterfaceThread) {
-                                       IsBackground = true
-                               };
-                               t.Start ();
-                       }
                }
                #endregion
 
@@ -606,6 +596,15 @@ namespace Crow
                /// call Init() then enter the running loop performing ProcessEvents until running==false.
                /// </summary>
                public virtual void Run () {
+                       initBackend ();
+
+                       if (!SingleThreaded) {
+                               Thread t = new Thread (InterfaceThread) {
+                                       IsBackground = true
+                               };
+                               t.Start ();
+                       }
+
                        Init ();
 
                        if (SingleThreaded) {
index 76dad08efb6acfb38af94a34d5f821cf5a24f5bb..15fef0b4aa3103c4d176e0b25d21f9aa60760df9 100644 (file)
@@ -23,9 +23,6 @@
                <!-- Used only by CrowIDE and CrowEdit-->
                <CrowDesignModeEnabled>false</CrowDesignModeEnabled>
 
-               <!-- Experimental vkvg backend, testing only-->
-               <CrowVkvgBackend>false</CrowVkvgBackend>
-
                <GlfwSharpVersion>0.2.14</GlfwSharpVersion>
        </PropertyGroup>
 </Project>
index 33b36ca2fad741f550e2ab9abd4fde4caf273f9c..bd40f7a54cea3674e3c1470a1f15cadca2cbf07d 100644 (file)
@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
        <PropertyGroup>
-               <TargetFramework>netcoreapp3.0</TargetFramework>
+               <TargetFramework>netstandard2.1</TargetFramework>
                <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
 
                <AssemblyVersion>1.0.0</AssemblyVersion>
index 72bb22326daeb5f023ddf854d3383daf35f0a996..8f4066a5a3c8e55d9c10f337c74626fbd20ec006 100644 (file)
@@ -8,6 +8,9 @@ namespace Drawing2D
 {
        public struct Point : IEquatable<Point>, IEquatable<int>
     {
+               public static readonly Point UnitX = new Point (1,0);
+               public static readonly Point UnitY = new Point (0,1);
+
                public int X, Y;
 
                #region CTOR
index e873c72f866e9ccdc3cbc96289e4f697f75810ac..7737cbfcd80526ed8833234d39431f2b4ffa5f41 100644 (file)
@@ -6,6 +6,8 @@ using System;
 
 namespace Drawing2D {
        public struct PointD : IEquatable<PointD>, IEquatable<double> {
+               public static readonly PointD UnitX = new PointD (1,0);
+               public static readonly PointD UnitY = new PointD (0,1);
                public double X;
                public double Y;
                public PointD (double x, double y)
index 20fa9a27fc7ed31584f52c14c57dab4b13234995..fd70a2b96e8db47cd7d449bfa3e315aa361cc24e 100644 (file)
@@ -6,12 +6,17 @@ using Samples;
 namespace HelloWorld
 {
        class Program : Interface {
-               Program() : base (800, 600, true, true) {}
+               Program() : base (800, 600, true) {}
                static void Main (string[] args) {
                        using (Program app = new Program ()) {
-                               app.Initialized += (sender, e) => app.LoadIMLFragment (@"<Label Text='Hello World'/>");
+                               //app.Initialized += (sender, e) => app.LoadIMLFragment (@"<Label Text='Hello World' Background='Red' Top='50' Margin='0'/>");
+                               //app.Initialized += (sender, e) => app.LoadIMLFragment (@"<Window Caption='hello world'/>");
                                app.Run ();
                        }
                }
+               protected override void OnInitialized()
+               {
+                       Load ("/mnt/devel/crow/Samples/HelloWorld/ui/helloworld.crow");
+               }
        }
 }
index b4ec4bb112f4622d06fd24d854aa55f4581d9429..b1c6d950a36c249a414aedad551c16028d6a85d1 100644 (file)
@@ -64,7 +64,7 @@ namespace PerfTests
                }
 
                public TestInterface (string[] args, int width = 800, int height = 600)
-                       : base (width, height, true, false)
+                       : base (width, height, true)
                {
                        string outDir = null;
 
index 9096ebe639223bc22576a580e46d2f54746e1bae..958a6b13d68f46b78e8f6aadf667aa67ddffa6c7 100644 (file)
@@ -35,7 +35,6 @@ namespace ShowCase
                        Environment.SetEnvironmentVariable ("FONTCONFIG_PATH", @"C:\Users\Jean-Philippe\source\vcpkg\installed\x64-windows\tools\fontconfig\fonts");
 
                        using (Showcase app = new Showcase ()) {
-                               app.WindowTitle = "C.R.O.W Showcase";
                                //app.SetWindowIcon ("#Crow.Icons.crow.png");
                                //app.Theme = @"C:\Users\Jean-Philippe\source\Crow\Themes\TestTheme";
                                CurrentProgramInstance = app;
@@ -127,6 +126,8 @@ namespace ShowCase
                protected override void OnInitialized () {
                        base.OnInitialized ();
 
+                       WindowTitle = "C.R.O.W Showcase";
+
                        Load ("#ShowCase.showcase.crow").DataSource = this;
                        crowContainer = FindByName ("CrowContainer") as Container;
                        editor = FindByName ("tb") as Editor;
index 2e7440a1ae7ebfcdc8ffa0472fa4b2c00eb4b417..e469016c24fb77559db30c9e4ed82b85cc20eb8d 100644 (file)
@@ -19,7 +19,7 @@ namespace Samples
        public class SampleBase : Interface
        {
                public SampleBase(IntPtr hWin) : base(800, 600, hWin) { }
-               public SampleBase() : base(800, 600, true, true) { }
+               public SampleBase() : base (800, 600, true) { }
 
                public Version CrowVersion => Assembly.GetAssembly(typeof(Widget)).GetName().Version;