From 2b974cc30f568a82bb0b1da9c82339ab943ac841 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sat, 4 Dec 2021 20:27:22 +0100 Subject: [PATCH] wip --- Backends/CairoBackend/CairoBackend.csproj | 18 +++++++++++++++ Backends/CairoBackend/src/CairoBackendBase.cs | 2 +- Backends/CairoBackend/src/DefaultBackend.cs | 2 +- Backends/CairoBackend/src/ImageBackend.cs | 4 ++++ Crow/src/Interface.cs | 23 +++++++++---------- Directory.Build.props | 3 --- Drawing2D/Drawing2D.csproj | 2 +- Drawing2D/src/Point.cs | 3 +++ Drawing2D/src/PointD.cs | 2 ++ Samples/HelloWorld/main.cs | 9 ++++++-- Samples/PerfTests/Program.cs | 2 +- Samples/ShowCase/ShowCase.cs | 3 ++- Samples/common/src/SampleBase.cs | 2 +- 13 files changed, 52 insertions(+), 23 deletions(-) diff --git a/Backends/CairoBackend/CairoBackend.csproj b/Backends/CairoBackend/CairoBackend.csproj index 986ad859..8e724258 100644 --- a/Backends/CairoBackend/CairoBackend.csproj +++ b/Backends/CairoBackend/CairoBackend.csproj @@ -2,11 +2,29 @@ netcoreapp3.0 + + 0.0.1 + $(AssemblyVersion)-beta + + C.R.O.W Cairo Backend + C.R.O.W. is a widget toolkit and rendering engine developed in C# with templates, styles, compositing, and bindings. + https://github.com/jpbruyere/Crow + Crow GUI Backend cairo + False + https://github.com/jpbruyere/Crow/wiki + MIT + crow.png + Copyright 2021 + + + True + true false + diff --git a/Backends/CairoBackend/src/CairoBackendBase.cs b/Backends/CairoBackend/src/CairoBackendBase.cs index 1e1b2e82..db6895c2 100644 --- a/Backends/CairoBackend/src/CairoBackendBase.cs +++ b/Backends/CairoBackend/src/CairoBackendBase.cs @@ -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); } diff --git a/Backends/CairoBackend/src/DefaultBackend.cs b/Backends/CairoBackend/src/DefaultBackend.cs index 7f805063..24d719da 100644 --- a/Backends/CairoBackend/src/DefaultBackend.cs +++ b/Backends/CairoBackend/src/DefaultBackend.cs @@ -3,7 +3,7 @@ using Crow.CairoBackend; namespace Crow.Backends { - public class DefaultBackend : EglBackend { + public class DefaultBackend : ImageBackend { /// /// Create a new generic backend bound to the application surface /// diff --git a/Backends/CairoBackend/src/ImageBackend.cs b/Backends/CairoBackend/src/ImageBackend.cs index 0181451a..d8518f31 100644 --- a/Backends/CairoBackend/src/ImageBackend.cs +++ b/Backends/CairoBackend/src/ImageBackend.cs @@ -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) diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 9a1ab102..74d0ed94 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -217,7 +217,7 @@ namespace Crow /// the height of the window /// A valid GLFW window handle /// - 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 /// the height of the native window /// If 'false' start the ui update (InterfaceThread method) in a dedicated thread /// If 'yes', create the main rendering surface on the native window - 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. /// public virtual void Run () { + initBackend (); + + if (!SingleThreaded) { + Thread t = new Thread (InterfaceThread) { + IsBackground = true + }; + t.Start (); + } + Init (); if (SingleThreaded) { diff --git a/Directory.Build.props b/Directory.Build.props index 76dad08e..15fef0b4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,9 +23,6 @@ false - - false - 0.2.14 diff --git a/Drawing2D/Drawing2D.csproj b/Drawing2D/Drawing2D.csproj index 33b36ca2..bd40f7a5 100644 --- a/Drawing2D/Drawing2D.csproj +++ b/Drawing2D/Drawing2D.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netstandard2.1 false 1.0.0 diff --git a/Drawing2D/src/Point.cs b/Drawing2D/src/Point.cs index 72bb2232..8f4066a5 100644 --- a/Drawing2D/src/Point.cs +++ b/Drawing2D/src/Point.cs @@ -8,6 +8,9 @@ namespace Drawing2D { public struct Point : IEquatable, IEquatable { + public static readonly Point UnitX = new Point (1,0); + public static readonly Point UnitY = new Point (0,1); + public int X, Y; #region CTOR diff --git a/Drawing2D/src/PointD.cs b/Drawing2D/src/PointD.cs index e873c72f..7737cbfc 100644 --- a/Drawing2D/src/PointD.cs +++ b/Drawing2D/src/PointD.cs @@ -6,6 +6,8 @@ using System; namespace Drawing2D { public struct PointD : IEquatable, IEquatable { + 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) diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs index 20fa9a27..fd70a2b9 100644 --- a/Samples/HelloWorld/main.cs +++ b/Samples/HelloWorld/main.cs @@ -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 (@"