aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-23 04:19:32 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-23 04:19:32 +0100
commit362d83b9556355b1d3dfb6cb892896ed33371521 (patch)
treee3417a29d953ae79be4be119a4209be7f1101aab
parentd396c47e492aa7badcfefba41c36c516558fb1ec (diff)
wip, save commit
-rw-r--r--Backends/CairoBackend/CairoBackend.csproj17
-rw-r--r--Backends/CairoBackend/src/Cairo.cs2
-rw-r--r--Backends/CairoBackend/src/CairoDebug.cs4
-rw-r--r--Backends/CairoBackend/src/Content.cs2
-rw-r--r--Backends/CairoBackend/src/Context.cs31
-rw-r--r--Backends/CairoBackend/src/DRMDevice.cs2
-rw-r--r--Backends/CairoBackend/src/DRMSurface.cs9
-rw-r--r--Backends/CairoBackend/src/Device.cs57
-rw-r--r--Backends/CairoBackend/src/DirectFBSurface.cs2
-rw-r--r--Backends/CairoBackend/src/Distance.cs2
-rw-r--r--Backends/CairoBackend/src/EGLDevice.cs2
-rw-r--r--Backends/CairoBackend/src/Extend.cs45
-rw-r--r--Backends/CairoBackend/src/FillRule.cs41
-rw-r--r--Backends/CairoBackend/src/Filter.cs45
-rw-r--r--Backends/CairoBackend/src/FontExtents.cs104
-rw-r--r--Backends/CairoBackend/src/FontFace.cs2
-rw-r--r--Backends/CairoBackend/src/FontOptions.cs9
-rw-r--r--Backends/CairoBackend/src/FontSlant.cs42
-rw-r--r--Backends/CairoBackend/src/FontType.cs3
-rw-r--r--Backends/CairoBackend/src/FontWeight.cs41
-rw-r--r--Backends/CairoBackend/src/GLSurface.cs2
-rw-r--r--Backends/CairoBackend/src/GLXDevice.cs2
-rw-r--r--Backends/CairoBackend/src/GlitzSurface.cs2
-rw-r--r--Backends/CairoBackend/src/Glyph.cs2
-rw-r--r--Backends/CairoBackend/src/Gradient.cs5
-rw-r--r--Backends/CairoBackend/src/HintMetrics.cs2
-rw-r--r--Backends/CairoBackend/src/HintStyle.cs2
-rw-r--r--Backends/CairoBackend/src/ImageSurface.cs5
-rw-r--r--Backends/CairoBackend/src/LineCap.cs41
-rw-r--r--Backends/CairoBackend/src/LineJoin.cs42
-rw-r--r--Backends/CairoBackend/src/LinearGradient.cs2
-rw-r--r--Backends/CairoBackend/src/Matrix.cs2
-rw-r--r--Backends/CairoBackend/src/MeshPattern.cs2
-rw-r--r--Backends/CairoBackend/src/NativeMethods-internal.cs3
-rw-r--r--Backends/CairoBackend/src/NativeMethods.cs2
-rw-r--r--Backends/CairoBackend/src/PSSurface.cs2
-rw-r--r--Backends/CairoBackend/src/Path.cs2
-rw-r--r--Backends/CairoBackend/src/Pattern.cs3
-rw-r--r--Backends/CairoBackend/src/PatternType.cs44
-rw-r--r--Backends/CairoBackend/src/PdfSurface.cs2
-rw-r--r--Backends/CairoBackend/src/RadialGradient.cs2
-rw-r--r--Backends/CairoBackend/src/Region.cs2
-rw-r--r--Backends/CairoBackend/src/ScaledFont.cs4
-rw-r--r--Backends/CairoBackend/src/SolidPattern.cs4
-rw-r--r--Backends/CairoBackend/src/Status.cs2
-rw-r--r--Backends/CairoBackend/src/SubpixelOrder.cs3
-rw-r--r--Backends/CairoBackend/src/Surface.cs19
-rw-r--r--Backends/CairoBackend/src/SurfacePattern.cs3
-rw-r--r--Backends/CairoBackend/src/SurfaceType.cs4
-rw-r--r--Backends/CairoBackend/src/SvgSurface.cs2
-rw-r--r--Backends/CairoBackend/src/SvgVersion.cs4
-rw-r--r--Backends/CairoBackend/src/TextExtents.cs98
-rw-r--r--Backends/CairoBackend/src/WGLDevice.cs2
-rw-r--r--Backends/CairoBackend/src/Win32Surface.cs10
-rw-r--r--Backends/CairoBackend/src/XcbSurface.cs8
-rw-r--r--Backends/CairoBackend/src/XlibSurface.cs10
-rw-r--r--Backends/CairoBackend/src/rsvg/SvgHandle.cs16
-rw-r--r--Backends/VkvgBackend/VkvgBackend.csproj1
-rw-r--r--Crow/Crow.csproj7
-rw-r--r--Crow/src/Fill/BmpPicture.cs42
-rw-r--r--Crow/src/Interface.cs71
-rw-r--r--Crow/src/Widgets/ColorPicker.cs1
-rw-r--r--Crow/src/Widgets/DockWindow.cs4
-rw-r--r--Crow/src/Widgets/GroupBase.cs4
-rw-r--r--Crow/src/Widgets/Label.cs16
-rw-r--r--Crow/src/Widgets/PrivateContainer.cs2
-rw-r--r--Crow/src/Widgets/ScrollingStack.cs4
-rw-r--r--Crow/src/Widgets/Shape.cs2
-rw-r--r--Crow/src/Widgets/TemplatedControl.cs2
-rw-r--r--Crow/src/Widgets/Widget.cs16
-rw-r--r--Drawing2D/Drawing2D.csproj8
-rw-r--r--Drawing2D/src/IContext.cs6
-rw-r--r--Drawing2D/src/IDevice.cs (renamed from Drawing2D/src/Device.cs)2
-rw-r--r--Drawing2D/src/ISurface.cs (renamed from Drawing2D/src/Surface.cs)2
-rw-r--r--Drawing2D/src/StbImage.cs (renamed from Crow/src/StbImage.cs)4
75 files changed, 227 insertions, 791 deletions
diff --git a/Backends/CairoBackend/CairoBackend.csproj b/Backends/CairoBackend/CairoBackend.csproj
index f4fe4d57..dc9cb60a 100644
--- a/Backends/CairoBackend/CairoBackend.csproj
+++ b/Backends/CairoBackend/CairoBackend.csproj
@@ -1,15 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netcoreapp3.0</TargetFramework>
+ <TargetFramework>netcoreapp3.0</TargetFramework>
+ <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
- <ItemGroup>
- <Compile Include="src\**\*.cs" />
- </ItemGroup>
+ <ItemGroup>
+ <Compile Include="src\**\*.cs" Exclude="src\NativeMethods-internal.cs"/>
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="glfw-sharp" Version="$(GlfwSharpVersion)" />
+ <ProjectReference Include="..\..\Drawing2D\Drawing2D.csproj" />
+ </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\Drawing2D\Drawing2D.csproj" />
- </ItemGroup>
</Project>
diff --git a/Backends/CairoBackend/src/Cairo.cs b/Backends/CairoBackend/src/Cairo.cs
index 309c7f4a..55f1335c 100644
--- a/Backends/CairoBackend/src/Cairo.cs
+++ b/Backends/CairoBackend/src/Cairo.cs
@@ -34,7 +34,7 @@
using System;
using System.Runtime.InteropServices;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public static class CairoAPI {
static public int Version {
diff --git a/Backends/CairoBackend/src/CairoDebug.cs b/Backends/CairoBackend/src/CairoDebug.cs
index 890793da..c3e92beb 100644
--- a/Backends/CairoBackend/src/CairoDebug.cs
+++ b/Backends/CairoBackend/src/CairoDebug.cs
@@ -28,8 +28,8 @@
using System;
-namespace Crow.Drawing {
-
+namespace Crow.CairoBackend
+{
static class CairoDebug
{
static System.Collections.Generic.Dictionary<IntPtr,string> traces;
diff --git a/Backends/CairoBackend/src/Content.cs b/Backends/CairoBackend/src/Content.cs
index a908a0d8..9096bf07 100644
--- a/Backends/CairoBackend/src/Content.cs
+++ b/Backends/CairoBackend/src/Content.cs
@@ -30,7 +30,7 @@
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
//[Flags]
public enum Content
diff --git a/Backends/CairoBackend/src/Context.cs b/Backends/CairoBackend/src/Context.cs
index 5b92166c..965297be 100644
--- a/Backends/CairoBackend/src/Context.cs
+++ b/Backends/CairoBackend/src/Context.cs
@@ -39,15 +39,9 @@ using System.Runtime.InteropServices;
using System.Text;
using Drawing2D;
-namespace Crow.Drawing {
-
- [Obsolete ("Renamed Cairo.Context per suggestion from cairo binding guidelines.")]
- public class Graphics : Context {
- public Graphics (IntPtr state) : base (state) {}
- public Graphics (Surface surface) : base (surface) {}
- }
-
- public class Context : IDisposable
+namespace Crow.CairoBackend
+{
+ public class Context : IContext
{
IntPtr handle = IntPtr.Zero;
@@ -81,7 +75,7 @@ namespace Crow.Drawing {
}
}
- public Context (Surface surface) : this (NativeMethods.cairo_create (surface.Handle), true)
+ public Context (ISurface surface) : this (NativeMethods.cairo_create (surface.Handle), true)
{
}
@@ -698,17 +692,6 @@ namespace Crow.Drawing {
NativeMethods.cairo_identity_matrix (handle);
}
- [Obsolete ("Use SetFontSize() instead.")]
- public void FontSetSize (double scale)
- {
- SetFontSize (scale);
- }
-
- [Obsolete ("Use SetFontSize() instead.")]
- public double FontSize {
- set { SetFontSize (value); }
- }
-
public Matrix FontMatrix {
get {
Matrix m;
@@ -811,12 +794,6 @@ namespace Crow.Drawing {
NativeMethods.cairo_copy_page (handle);
}
- [Obsolete ("Use SelectFontFace() instead.")]
- public void FontFace (string family, FontSlant slant, FontWeight weight)
- {
- SelectFontFace (family, slant, weight);
- }
-
public void SetContextFontFace (FontFace value)
{
NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle);
diff --git a/Backends/CairoBackend/src/DRMDevice.cs b/Backends/CairoBackend/src/DRMDevice.cs
index c08ad030..7bca9e6a 100644
--- a/Backends/CairoBackend/src/DRMDevice.cs
+++ b/Backends/CairoBackend/src/DRMDevice.cs
@@ -29,7 +29,7 @@
//
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public class DRMDevice : Device
{
diff --git a/Backends/CairoBackend/src/DRMSurface.cs b/Backends/CairoBackend/src/DRMSurface.cs
index b1fcfb76..cf57d176 100644
--- a/Backends/CairoBackend/src/DRMSurface.cs
+++ b/Backends/CairoBackend/src/DRMSurface.cs
@@ -15,10 +15,10 @@
// 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
@@ -29,12 +29,13 @@
//
using System;
+using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class DRMSurface : Surface
{
-
+
public DRMSurface (IntPtr ptr, bool own) : base (ptr, own)
{}
diff --git a/Backends/CairoBackend/src/Device.cs b/Backends/CairoBackend/src/Device.cs
index 426d4ca2..5191a23d 100644
--- a/Backends/CairoBackend/src/Device.cs
+++ b/Backends/CairoBackend/src/Device.cs
@@ -28,15 +28,26 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
+using Drawing2D;
+using Glfw;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
- public class Device : IDisposable
+ public class Device : IDevice
{
IntPtr handle = IntPtr.Zero;
+ /// <summary> Global font rendering settings for Cairo </summary>
+ FontOptions FontRenderingOptions;
+ /// <summary> Global font rendering settings for Cairo </summary>
+ Antialias Antialias = Antialias.Subpixel;
protected Device()
{
+ FontRenderingOptions = new FontOptions ();
+ FontRenderingOptions.Antialias = Antialias.Subpixel;
+ FontRenderingOptions.HintMetrics = HintMetrics.On;
+ FontRenderingOptions.HintStyle = HintStyle.Full;
+ FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
}
protected Device (IntPtr ptr) : this (ptr, true)
@@ -94,8 +105,50 @@ namespace Crow.Drawing
return;
NativeMethods.cairo_device_destroy (handle);
+
+ FontRenderingOptions.Dispose ();
handle = IntPtr.Zero;
}
+
+ public void GetDpy(out int hdpy, out int vdpy)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetDpy(int hdpy, int vdpy)
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual ISurface CreateSurface(int width, int height)
+ {
+ throw new NotImplementedException();
+ }
+ public ISurface CreateSurface (IntPtr nativeWindoPointer, int width, int height) {
+ switch (Environment.OSVersion.Platform) {
+ case PlatformID.Unix:
+ IntPtr disp = Glfw3.GetX11Display ();
+ IntPtr nativeWin = Glfw3.GetX11Window (nativeWindoPointer);
+ Int32 scr = Glfw3.GetX11DefaultScreen (disp);
+ IntPtr visual = Glfw3.GetX11DefaultVisual (disp, scr);
+ return new XlibSurface (disp, nativeWin, visual, width, height);
+ case PlatformID.Win32NT:
+ case PlatformID.Win32S:
+ case PlatformID.Win32Windows:
+ IntPtr hWin32 = Glfw3.GetWin32Window (nativeWindoPointer);
+ IntPtr hdc = Glfw3.GetWin32DC (hWin32);
+ return new Win32Surface (hdc);
+ }
+ throw new PlatformNotSupportedException ("Unable to create cairo surface.");
+ }
+
+ public virtual IContext CreateContext(ISurface surf)
+ {
+ Context gr = new Context (surf);
+ gr.FontOptions = FontRenderingOptions;
+ gr.Antialias = Antialias;
+ throw new NotImplementedException();
+ }
}
}
diff --git a/Backends/CairoBackend/src/DirectFBSurface.cs b/Backends/CairoBackend/src/DirectFBSurface.cs
index 4f52ec72..ca7cd718 100644
--- a/Backends/CairoBackend/src/DirectFBSurface.cs
+++ b/Backends/CairoBackend/src/DirectFBSurface.cs
@@ -28,7 +28,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class DirectFBSurface : Surface
{
internal DirectFBSurface (IntPtr handle, bool owns) : base (handle, owns)
diff --git a/Backends/CairoBackend/src/Distance.cs b/Backends/CairoBackend/src/Distance.cs
index eaa7d5a3..160fa1e7 100644
--- a/Backends/CairoBackend/src/Distance.cs
+++ b/Backends/CairoBackend/src/Distance.cs
@@ -34,7 +34,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public struct Distance
{
diff --git a/Backends/CairoBackend/src/EGLDevice.cs b/Backends/CairoBackend/src/EGLDevice.cs
index 93150884..1f73ef4f 100644
--- a/Backends/CairoBackend/src/EGLDevice.cs
+++ b/Backends/CairoBackend/src/EGLDevice.cs
@@ -29,7 +29,7 @@
//
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public class EGLDevice : Device
{
diff --git a/Backends/CairoBackend/src/Extend.cs b/Backends/CairoBackend/src/Extend.cs
deleted file mode 100644
index 01a7969d..00000000
--- a/Backends/CairoBackend/src/Extend.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Mono.Cairo.Extend.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// John Luke (john.luke@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2005 John Luke
-//
-// 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;
-
-namespace Crow.Drawing
-{
-
- public enum Extend
- {
- None,
- Repeat,
- Reflect,
- Pad,
- }
-}
diff --git a/Backends/CairoBackend/src/FillRule.cs b/Backends/CairoBackend/src/FillRule.cs
deleted file mode 100644
index 314a7830..00000000
--- a/Backends/CairoBackend/src/FillRule.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Mono.Cairo.FillRule.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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;
-
-namespace Crow.Drawing
-{
-
- public enum FillRule
- {
- Winding,
- EvenOdd
- }
-}
diff --git a/Backends/CairoBackend/src/Filter.cs b/Backends/CairoBackend/src/Filter.cs
deleted file mode 100644
index 5b521048..00000000
--- a/Backends/CairoBackend/src/Filter.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Mono.Cairo.Filter.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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;
-
-namespace Crow.Drawing
-{
-
- public enum Filter
- {
- Fast,
- Good,
- Best,
- Nearest,
- Bilinear,
- Gaussian,
- }
-}
diff --git a/Backends/CairoBackend/src/FontExtents.cs b/Backends/CairoBackend/src/FontExtents.cs
deleted file mode 100644
index 73164b29..00000000
--- a/Backends/CairoBackend/src/FontExtents.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// Mono.Cairo.FontExtents.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-//
-// This is a simplistic binding of the Cairo API to C#. All functions
-// in cairo.h are transcribed into their C# equivelants
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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.Runtime.InteropServices;
-
-namespace Crow.Drawing
-{
- [StructLayout (LayoutKind.Sequential)]
- public struct FontExtents
- {
- double ascent;
- double descent;
- double height;
- double maxXAdvance;
- double maxYAdvance;
-
- public double Ascent {
- get { return ascent; }
- set { ascent = value; }
- }
-
- public double Descent {
- get { return descent; }
- set { descent = value; }
- }
-
- public double Height {
- get { return height; }
- set { height = value; }
- }
-
- public double MaxXAdvance {
- get { return maxXAdvance; }
- set { maxXAdvance = value; }
- }
-
- public double MaxYAdvance {
- get { return maxYAdvance; }
- set { maxYAdvance = value; }
- }
-
- public FontExtents (double ascent, double descent, double height, double maxXAdvance, double maxYAdvance)
- {
- this.ascent = ascent;
- this.descent = descent;
- this.height = height;
- this.maxXAdvance = maxXAdvance;
- this.maxYAdvance = maxYAdvance;
- }
-
- public override bool Equals (object obj)
- {
- if (obj is FontExtents)
- return this == (FontExtents) obj;
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (int) Ascent ^ (int) Descent ^ (int) Height ^ (int) MaxXAdvance ^ (int) MaxYAdvance;
- }
-
- public static bool operator == (FontExtents extents, FontExtents other)
- {
- return extents.Ascent == other.Ascent && extents.Descent == other.Descent && extents.Height == other.Height && extents.MaxXAdvance == other.MaxXAdvance && extents.MaxYAdvance == other.MaxYAdvance;
- }
-
- public static bool operator != (FontExtents extents, FontExtents other)
- {
- return !(extents == other);
- }
- }
-}
diff --git a/Backends/CairoBackend/src/FontFace.cs b/Backends/CairoBackend/src/FontFace.cs
index e4fd1a6e..5b97dc25 100644
--- a/Backends/CairoBackend/src/FontFace.cs
+++ b/Backends/CairoBackend/src/FontFace.cs
@@ -32,7 +32,7 @@
//
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public class FontFace : IDisposable
{
diff --git a/Backends/CairoBackend/src/FontOptions.cs b/Backends/CairoBackend/src/FontOptions.cs
index 977b6993..ee952bb3 100644
--- a/Backends/CairoBackend/src/FontOptions.cs
+++ b/Backends/CairoBackend/src/FontOptions.cs
@@ -13,10 +13,10 @@
// 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
@@ -27,8 +27,9 @@
//
using System;
+using Drawing2D;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public class FontOptions : IDisposable
{
@@ -107,7 +108,7 @@ namespace Crow.Drawing
{
return (int) NativeMethods.cairo_font_options_hash (handle);
}
-
+
public void Merge (FontOptions other)
{
if (other == null)
diff --git a/Backends/CairoBackend/src/FontSlant.cs b/Backends/CairoBackend/src/FontSlant.cs
deleted file mode 100644
index 4ce74a24..00000000
--- a/Backends/CairoBackend/src/FontSlant.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Mono.Cairo.FontSlant.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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;
-
-namespace Crow.Drawing
-{
-
- public enum FontSlant
- {
- Normal,
- Italic,
- Oblique
- }
-}
diff --git a/Backends/CairoBackend/src/FontType.cs b/Backends/CairoBackend/src/FontType.cs
index 80d672c4..664c2f58 100644
--- a/Backends/CairoBackend/src/FontType.cs
+++ b/Backends/CairoBackend/src/FontType.cs
@@ -28,9 +28,8 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
-
public enum FontType
{
Toy,
diff --git a/Backends/CairoBackend/src/FontWeight.cs b/Backends/CairoBackend/src/FontWeight.cs
deleted file mode 100644
index 51c0e8d2..00000000
--- a/Backends/CairoBackend/src/FontWeight.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Mono.Cairo.FontWeight.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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;
-
-namespace Crow.Drawing
-{
-
- public enum FontWeight
- {
- Normal,
- Bold,
- }
-}
diff --git a/Backends/CairoBackend/src/GLSurface.cs b/Backends/CairoBackend/src/GLSurface.cs
index 45112024..117bd60f 100644
--- a/Backends/CairoBackend/src/GLSurface.cs
+++ b/Backends/CairoBackend/src/GLSurface.cs
@@ -30,7 +30,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class GLSurface : Surface
{
diff --git a/Backends/CairoBackend/src/GLXDevice.cs b/Backends/CairoBackend/src/GLXDevice.cs
index 086cf1f4..8c080df5 100644
--- a/Backends/CairoBackend/src/GLXDevice.cs
+++ b/Backends/CairoBackend/src/GLXDevice.cs
@@ -29,7 +29,7 @@
//
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public class GLXDevice : Device
{
diff --git a/Backends/CairoBackend/src/GlitzSurface.cs b/Backends/CairoBackend/src/GlitzSurface.cs
index fc12c673..4497877b 100644
--- a/Backends/CairoBackend/src/GlitzSurface.cs
+++ b/Backends/CairoBackend/src/GlitzSurface.cs
@@ -28,7 +28,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class GlitzSurface : Surface
{
internal GlitzSurface (IntPtr handle, bool owns) : base (handle, owns)
diff --git a/Backends/CairoBackend/src/Glyph.cs b/Backends/CairoBackend/src/Glyph.cs
index c015e6de..fdd8436b 100644
--- a/Backends/CairoBackend/src/Glyph.cs
+++ b/Backends/CairoBackend/src/Glyph.cs
@@ -30,7 +30,7 @@
using System;
using System.Runtime.InteropServices;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
[StructLayout(LayoutKind.Sequential)]
public struct Glyph
diff --git a/Backends/CairoBackend/src/Gradient.cs b/Backends/CairoBackend/src/Gradient.cs
index c9b8116c..3dd0d9d2 100644
--- a/Backends/CairoBackend/src/Gradient.cs
+++ b/Backends/CairoBackend/src/Gradient.cs
@@ -28,8 +28,9 @@
//
using System;
-using Color = Crow.Color;
-namespace Crow.Drawing {
+using Color = Drawing2D.Color;
+
+namespace Crow.CairoBackend {
public class Gradient : Pattern
{
diff --git a/Backends/CairoBackend/src/HintMetrics.cs b/Backends/CairoBackend/src/HintMetrics.cs
index fbb78ad6..8f4f95c1 100644
--- a/Backends/CairoBackend/src/HintMetrics.cs
+++ b/Backends/CairoBackend/src/HintMetrics.cs
@@ -29,7 +29,7 @@
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public enum HintMetrics
diff --git a/Backends/CairoBackend/src/HintStyle.cs b/Backends/CairoBackend/src/HintStyle.cs
index 713dafae..66161747 100644
--- a/Backends/CairoBackend/src/HintStyle.cs
+++ b/Backends/CairoBackend/src/HintStyle.cs
@@ -29,7 +29,7 @@
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public enum HintStyle
diff --git a/Backends/CairoBackend/src/ImageSurface.cs b/Backends/CairoBackend/src/ImageSurface.cs
index 28330105..c2e5dec9 100644
--- a/Backends/CairoBackend/src/ImageSurface.cs
+++ b/Backends/CairoBackend/src/ImageSurface.cs
@@ -34,8 +34,9 @@
using System;
using System.Runtime.InteropServices;
+using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class ImageSurface : Surface
{
@@ -70,7 +71,7 @@ namespace Crow.Drawing {
}
public override int Width => NativeMethods.cairo_image_surface_get_width (Handle);
- public override int Height => NativeMethods.cairo_image_surface_get_height (Handle);
+ public override int Height => NativeMethods.cairo_image_surface_get_height (Handle);
public byte[] Data {
get {
diff --git a/Backends/CairoBackend/src/LineCap.cs b/Backends/CairoBackend/src/LineCap.cs
deleted file mode 100644
index b9fcb220..00000000
--- a/Backends/CairoBackend/src/LineCap.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Mono.Cairo.LineCap.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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;
-
-namespace Crow.Drawing
-{
-
- public enum LineCap
- {
- Butt,
- Round,
- Square,
- }
-}
diff --git a/Backends/CairoBackend/src/LineJoin.cs b/Backends/CairoBackend/src/LineJoin.cs
deleted file mode 100644
index 2ec44b69..00000000
--- a/Backends/CairoBackend/src/LineJoin.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Mono.Cairo.LineJoin.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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;
-
-namespace Crow.Drawing
-{
-
- public enum LineJoin
- {
- Miter,
- Round,
- Bevel
- }
-}
-
diff --git a/Backends/CairoBackend/src/LinearGradient.cs b/Backends/CairoBackend/src/LinearGradient.cs
index 3b98be03..32b83db2 100644
--- a/Backends/CairoBackend/src/LinearGradient.cs
+++ b/Backends/CairoBackend/src/LinearGradient.cs
@@ -30,7 +30,7 @@
using System;
using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class LinearGradient : Gradient
{
diff --git a/Backends/CairoBackend/src/Matrix.cs b/Backends/CairoBackend/src/Matrix.cs
index 0224fd5f..b1925688 100644
--- a/Backends/CairoBackend/src/Matrix.cs
+++ b/Backends/CairoBackend/src/Matrix.cs
@@ -34,7 +34,7 @@
using System;
using System.Runtime.InteropServices;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
[StructLayout(LayoutKind.Sequential)]
public class Matrix //: ICloneable
diff --git a/Backends/CairoBackend/src/MeshPattern.cs b/Backends/CairoBackend/src/MeshPattern.cs
index aef35481..f2576705 100644
--- a/Backends/CairoBackend/src/MeshPattern.cs
+++ b/Backends/CairoBackend/src/MeshPattern.cs
@@ -30,7 +30,7 @@
using System;
using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class MeshPattern : Pattern
{
diff --git a/Backends/CairoBackend/src/NativeMethods-internal.cs b/Backends/CairoBackend/src/NativeMethods-internal.cs
index 6e6d507c..714ff63a 100644
--- a/Backends/CairoBackend/src/NativeMethods-internal.cs
+++ b/Backends/CairoBackend/src/NativeMethods-internal.cs
@@ -34,8 +34,9 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
+using Drawing2D;
-namespace Cairo
+namespace Crow.CairoBackend
{
// sort the functions like in the following page so it is easier to find what is missing
// http://cairographics.org/manual/index-all.html
diff --git a/Backends/CairoBackend/src/NativeMethods.cs b/Backends/CairoBackend/src/NativeMethods.cs
index 48ee42f7..27f61154 100644
--- a/Backends/CairoBackend/src/NativeMethods.cs
+++ b/Backends/CairoBackend/src/NativeMethods.cs
@@ -35,7 +35,7 @@ using System;
using System.Runtime.InteropServices;
using Drawing2D;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
// sort the functions like in the following page so it is easier to find what is missing
// http://cairographics.org/manual/index-all.html
diff --git a/Backends/CairoBackend/src/PSSurface.cs b/Backends/CairoBackend/src/PSSurface.cs
index ca3c1d7d..fadb1b2e 100644
--- a/Backends/CairoBackend/src/PSSurface.cs
+++ b/Backends/CairoBackend/src/PSSurface.cs
@@ -28,7 +28,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class PSSurface : Surface
{
diff --git a/Backends/CairoBackend/src/Path.cs b/Backends/CairoBackend/src/Path.cs
index 9d5e9456..54ae4300 100644
--- a/Backends/CairoBackend/src/Path.cs
+++ b/Backends/CairoBackend/src/Path.cs
@@ -32,7 +32,7 @@ using System;
using System.Runtime.InteropServices;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class Path : IDisposable
{
diff --git a/Backends/CairoBackend/src/Pattern.cs b/Backends/CairoBackend/src/Pattern.cs
index 1180e632..545dda36 100644
--- a/Backends/CairoBackend/src/Pattern.cs
+++ b/Backends/CairoBackend/src/Pattern.cs
@@ -29,8 +29,9 @@
using System;
using System.Collections;
+using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class Pattern : IDisposable
{
diff --git a/Backends/CairoBackend/src/PatternType.cs b/Backends/CairoBackend/src/PatternType.cs
deleted file mode 100644
index 008d8e55..00000000
--- a/Backends/CairoBackend/src/PatternType.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Mono.Cairo.PatternType.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// 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;
-
-namespace Crow.Drawing {
-
-
- public enum PatternType
- {
- Solid,
- Surface,
- Linear,
- Radial,
- Mesh,
- RasterSource
- }
-}
-
diff --git a/Backends/CairoBackend/src/PdfSurface.cs b/Backends/CairoBackend/src/PdfSurface.cs
index 16287b76..676b596b 100644
--- a/Backends/CairoBackend/src/PdfSurface.cs
+++ b/Backends/CairoBackend/src/PdfSurface.cs
@@ -28,7 +28,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class PdfSurface : Surface
{
diff --git a/Backends/CairoBackend/src/RadialGradient.cs b/Backends/CairoBackend/src/RadialGradient.cs
index e76f7df1..d27aa548 100644
--- a/Backends/CairoBackend/src/RadialGradient.cs
+++ b/Backends/CairoBackend/src/RadialGradient.cs
@@ -29,7 +29,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class RadialGradient : Gradient
{
diff --git a/Backends/CairoBackend/src/Region.cs b/Backends/CairoBackend/src/Region.cs
index f4fa7572..5466b121 100644
--- a/Backends/CairoBackend/src/Region.cs
+++ b/Backends/CairoBackend/src/Region.cs
@@ -24,7 +24,7 @@ using System;
using System.Runtime.InteropServices;
using Drawing2D;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
[StructLayout(LayoutKind.Sequential)]
public struct RectangleList {
diff --git a/Backends/CairoBackend/src/ScaledFont.cs b/Backends/CairoBackend/src/ScaledFont.cs
index 1d70646d..8fc245e2 100644
--- a/Backends/CairoBackend/src/ScaledFont.cs
+++ b/Backends/CairoBackend/src/ScaledFont.cs
@@ -25,9 +25,9 @@
using System;
using System.Runtime.InteropServices;
+using Drawing2D;
-namespace Crow.Drawing {
-
+namespace Crow.CairoBackend {
public class ScaledFont : IDisposable
{
protected IntPtr handle = IntPtr.Zero;
diff --git a/Backends/CairoBackend/src/SolidPattern.cs b/Backends/CairoBackend/src/SolidPattern.cs
index 5c5da80b..8d52fb01 100644
--- a/Backends/CairoBackend/src/SolidPattern.cs
+++ b/Backends/CairoBackend/src/SolidPattern.cs
@@ -28,8 +28,8 @@
//
using System;
-using Color = Crow.Color;
-namespace Crow.Drawing {
+using Color = Drawing2D.Color;
+namespace Crow.CairoBackend {
public class SolidPattern : Pattern
{
diff --git a/Backends/CairoBackend/src/Status.cs b/Backends/CairoBackend/src/Status.cs
index 9a0b8eed..79252f64 100644
--- a/Backends/CairoBackend/src/Status.cs
+++ b/Backends/CairoBackend/src/Status.cs
@@ -32,7 +32,7 @@
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public enum Status
diff --git a/Backends/CairoBackend/src/SubpixelOrder.cs b/Backends/CairoBackend/src/SubpixelOrder.cs
index a67776df..569225f5 100644
--- a/Backends/CairoBackend/src/SubpixelOrder.cs
+++ b/Backends/CairoBackend/src/SubpixelOrder.cs
@@ -28,9 +28,8 @@
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
-
public enum SubpixelOrder
{
Default,
diff --git a/Backends/CairoBackend/src/Surface.cs b/Backends/CairoBackend/src/Surface.cs
index 92256fad..b41af1a4 100644
--- a/Backends/CairoBackend/src/Surface.cs
+++ b/Backends/CairoBackend/src/Surface.cs
@@ -37,9 +37,9 @@ using System;
using System.Collections;
using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
- public class Surface : IDisposable
+ public class Surface : ISurface
{
IntPtr handle = IntPtr.Zero;
@@ -226,5 +226,20 @@ namespace Crow.Drawing {
public uint ReferenceCount {
get { return NativeMethods.cairo_surface_get_reference_count (handle); }
}
+
+ public void WriteTo(IntPtr bitmap)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Clear()
+ {
+ throw new NotImplementedException();
+ }
+
+ public ISurface CreateSimilar(int width, int height)
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/Backends/CairoBackend/src/SurfacePattern.cs b/Backends/CairoBackend/src/SurfacePattern.cs
index 6c4539c8..7b06265f 100644
--- a/Backends/CairoBackend/src/SurfacePattern.cs
+++ b/Backends/CairoBackend/src/SurfacePattern.cs
@@ -28,8 +28,9 @@
//
using System;
+using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class SurfacePattern : Pattern
{
diff --git a/Backends/CairoBackend/src/SurfaceType.cs b/Backends/CairoBackend/src/SurfaceType.cs
index 5333e536..816635c9 100644
--- a/Backends/CairoBackend/src/SurfaceType.cs
+++ b/Backends/CairoBackend/src/SurfaceType.cs
@@ -28,9 +28,7 @@
using System;
-namespace Crow.Drawing {
-
-
+namespace Crow.CairoBackend {
public enum SurfaceType
{
Image,
diff --git a/Backends/CairoBackend/src/SvgSurface.cs b/Backends/CairoBackend/src/SvgSurface.cs
index 4e22148d..3eca6682 100644
--- a/Backends/CairoBackend/src/SvgSurface.cs
+++ b/Backends/CairoBackend/src/SvgSurface.cs
@@ -28,7 +28,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class SvgSurface : Surface
{
diff --git a/Backends/CairoBackend/src/SvgVersion.cs b/Backends/CairoBackend/src/SvgVersion.cs
index 85bc6caf..f79cc677 100644
--- a/Backends/CairoBackend/src/SvgVersion.cs
+++ b/Backends/CairoBackend/src/SvgVersion.cs
@@ -28,9 +28,7 @@
using System;
-namespace Crow.Drawing {
-
-
+namespace Crow.CairoBackend {
public enum SvgVersion
{
// FIXME: yuck
diff --git a/Backends/CairoBackend/src/TextExtents.cs b/Backends/CairoBackend/src/TextExtents.cs
deleted file mode 100644
index 4dd606fd..00000000
--- a/Backends/CairoBackend/src/TextExtents.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-// Mono.Cairo.TextExtents.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// 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.Runtime.InteropServices;
-
-namespace Crow.Drawing
-{
- [StructLayout (LayoutKind.Sequential)]
- public struct TextExtents
- {
- double xbearing;
- double ybearing;
- double width;
- double height;
- double xadvance;
- double yadvance;
-
- public double XBearing {
- get { return xbearing; }
- set { xbearing = value; }
- }
-
- public double YBearing {
- get { return ybearing; }
- set { ybearing = value; }
- }
-
- public double Width {
- get { return width; }
- set { width = value; }
- }
-
- public double Height {
- get { return height; }
- set { height = value; }
- }
-
- public double XAdvance {
- get { return xadvance; }
- set { xadvance = value; }
- }
-
- public double YAdvance {
- get { return yadvance; }
- set { yadvance = value; }
- }
-
- public override bool Equals (object obj)
- {
- if (obj is TextExtents)
- return this == (TextExtents)obj;
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (int)XBearing ^ (int)YBearing ^ (int)Width ^ (int)Height ^ (int)XAdvance ^ (int)YAdvance;
- }
-
- public static bool operator == (TextExtents extents, TextExtents other)
- {
- return extents.XBearing == other.XBearing && extents.YBearing == other.YBearing && extents.Width == other.Width && extents.Height == other.Height && extents.XAdvance == other.XAdvance && extents.YAdvance == other.YAdvance;
- }
-
- public static bool operator != (TextExtents extents, TextExtents other)
- {
- return !(extents == other);
- }
- }
-}
diff --git a/Backends/CairoBackend/src/WGLDevice.cs b/Backends/CairoBackend/src/WGLDevice.cs
index fda7d93f..18179948 100644
--- a/Backends/CairoBackend/src/WGLDevice.cs
+++ b/Backends/CairoBackend/src/WGLDevice.cs
@@ -29,7 +29,7 @@
//
using System;
-namespace Crow.Drawing
+namespace Crow.CairoBackend
{
public class WGLDevice : Device
{
diff --git a/Backends/CairoBackend/src/Win32Surface.cs b/Backends/CairoBackend/src/Win32Surface.cs
index 53b79e92..f620673e 100644
--- a/Backends/CairoBackend/src/Win32Surface.cs
+++ b/Backends/CairoBackend/src/Win32Surface.cs
@@ -13,10 +13,10 @@
// 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
@@ -28,14 +28,14 @@
using System;
-namespace Crow.Drawing {
-
+namespace Crow.CairoBackend {
+
public class Win32Surface : Surface
{
internal Win32Surface (IntPtr handle, bool owns) : base (handle, owns)
{
}
-
+
public Win32Surface (IntPtr hdc)
: base (NativeMethods.cairo_win32_surface_create (hdc), true)
{
diff --git a/Backends/CairoBackend/src/XcbSurface.cs b/Backends/CairoBackend/src/XcbSurface.cs
index 72c4dbe8..affc46f8 100644
--- a/Backends/CairoBackend/src/XcbSurface.cs
+++ b/Backends/CairoBackend/src/XcbSurface.cs
@@ -13,10 +13,10 @@
// 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
@@ -28,7 +28,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class XcbSurface : Surface
{
internal XcbSurface (IntPtr handle, bool owns) : base (handle, owns)
@@ -46,7 +46,7 @@ namespace Crow.Drawing {
return new XcbSurface (ptr, true);
}
public override void SetSize (int width, int height)
- {
+ {
NativeMethods.cairo_xcb_surface_set_size (Handle, width, height);
}
}
diff --git a/Backends/CairoBackend/src/XlibSurface.cs b/Backends/CairoBackend/src/XlibSurface.cs
index fbe9e01f..602400e5 100644
--- a/Backends/CairoBackend/src/XlibSurface.cs
+++ b/Backends/CairoBackend/src/XlibSurface.cs
@@ -21,10 +21,10 @@
// 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
@@ -36,7 +36,7 @@
using System;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public class XlibSurface : Surface
{
@@ -68,8 +68,8 @@ namespace Crow.Drawing {
public int Depth => NativeMethods.cairo_xlib_surface_get_depth (Handle);
public IntPtr Display => NativeMethods.cairo_xlib_surface_get_display (Handle);
public IntPtr Drawable => NativeMethods.cairo_xlib_surface_get_drawable (Handle);
- public override int Width => NativeMethods.cairo_xlib_surface_get_width (Handle);
- public override int Height => NativeMethods.cairo_xlib_surface_get_height (Handle);
+ public override int Width => NativeMethods.cairo_xlib_surface_get_width (Handle);
+ public override int Height => NativeMethods.cairo_xlib_surface_get_height (Handle);
public IntPtr Screen => NativeMethods.cairo_xlib_surface_get_screen (Handle);
public IntPtr Visual=> NativeMethods.cairo_xlib_surface_get_visual (Handle);
diff --git a/Backends/CairoBackend/src/rsvg/SvgHandle.cs b/Backends/CairoBackend/src/rsvg/SvgHandle.cs
index fc2d8a2b..1622ecfa 100644
--- a/Backends/CairoBackend/src/rsvg/SvgHandle.cs
+++ b/Backends/CairoBackend/src/rsvg/SvgHandle.cs
@@ -3,7 +3,7 @@ using System;
using System.Runtime.InteropServices;
using Drawing2D;
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
public sealed class SvgHandle : IDisposable {
@@ -43,12 +43,12 @@ namespace Crow.Drawing {
Raw = rsvg_handle_new();
}
public SvgHandle (byte[] data)
- {
+ {
Raw = rsvg_handle_new_from_data(data, new UIntPtr ((ulong) (data == null ? 0 : data.Length)), out IntPtr error);
if (error != IntPtr.Zero) throw new Exception (error.ToString());
}
public SvgHandle (string file_name)
- {
+ {
Raw = rsvg_handle_new_from_file(file_name, out IntPtr error);
if (error != IntPtr.Zero) throw new Exception (error.ToString());
}
@@ -60,10 +60,10 @@ namespace Crow.Drawing {
public void Render(Context cr) =>
rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle);
-
+
public void Render (Context cr, string id) =>
rsvg_handle_render_cairo_sub (Raw, cr == null ? IntPtr.Zero : cr.Handle, id);
-
+
[StructLayout(LayoutKind.Sequential)]
struct DimensionData {
@@ -79,7 +79,7 @@ namespace Crow.Drawing {
return DimensionData.Zero;
return (DimensionData) Marshal.PtrToStructure (raw, typeof (DimensionData));
}
- }
+ }
public Size Dimensions {
get {
DimensionData dimension_data;
@@ -91,9 +91,9 @@ namespace Crow.Drawing {
}
}
- public void Dispose() {
+ public void Dispose() {
bool raw_ret = rsvg_handle_close(Raw, out IntPtr error);
- if (error != IntPtr.Zero) throw new Exception (error.ToString());
+ if (error != IntPtr.Zero) throw new Exception (error.ToString());
}
}
}
diff --git a/Backends/VkvgBackend/VkvgBackend.csproj b/Backends/VkvgBackend/VkvgBackend.csproj
index f4fe4d57..c14bad89 100644
--- a/Backends/VkvgBackend/VkvgBackend.csproj
+++ b/Backends/VkvgBackend/VkvgBackend.csproj
@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
+ <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj
index 5a7fdc4e..ea3b3a02 100644
--- a/Crow/Crow.csproj
+++ b/Crow/Crow.csproj
@@ -44,13 +44,6 @@
<PackageReference Include="glfw-sharp" Version="$(GlfwSharpVersion)" />
</ItemGroup>
- <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
- <DefineConstants>$(DefineConstants);STB_SHARP</DefineConstants>
- </PropertyGroup>
- <ItemGroup Condition=" '$(CrowStbSharp)' == 'true'">
- <PackageReference Include="StbImageSharp" Version="2.22.4" />
- </ItemGroup>
-
<PropertyGroup Condition=" '$(CrowDebugLogEnabled)' == 'true'">
<DefineConstants>$(DefineConstants);DEBUG_LOG</DefineConstants>
</PropertyGroup>
diff --git a/Crow/src/Fill/BmpPicture.cs b/Crow/src/Fill/BmpPicture.cs
index faefd4ed..3f59c3d6 100644
--- a/Crow/src/Fill/BmpPicture.cs
+++ b/Crow/src/Fill/BmpPicture.cs
@@ -62,21 +62,21 @@ namespace Crow
#endif
Dimensions = new Size (stbi.Width, stbi.Height);
#else
- using (StbImage stbi = new StbImage (stream)) {
- image = new byte [stbi.Size];
+ using (StbImage stbi = new StbImage (stream)) {
+ image = new byte [stbi.Size];
#if VKVG
- Marshal.Copy (stbi.Handle, image, 0, stbi.Size);
+ Marshal.Copy (stbi.Handle, image, 0, stbi.Size);
#else
- for (int i = 0; i < stbi.Size; i+=4) {
- //rgba to argb for cairo. ???? looks like bgra to me.
- image [i] = Marshal.ReadByte (stbi.Handle, i + 2);
- image [i + 1] = Marshal.ReadByte (stbi.Handle, i + 1);
- image [i + 2] = Marshal.ReadByte (stbi.Handle, i);
- image [i + 3] = Marshal.ReadByte (stbi.Handle, i + 3);
- }
- #endif
- Dimensions = new Size (stbi.Width, stbi.Height);
+ for (int i = 0; i < stbi.Size; i+=4) {
+ //rgba to argb for cairo. ???? looks like bgra to me.
+ image [i] = Marshal.ReadByte (stbi.Handle, i + 2);
+ image [i + 1] = Marshal.ReadByte (stbi.Handle, i + 1);
+ image [i + 2] = Marshal.ReadByte (stbi.Handle, i);
+ image [i + 3] = Marshal.ReadByte (stbi.Handle, i + 3);
}
+ #endif
+ Dimensions = new Size (stbi.Width, stbi.Height);
+ }
#endif
}
internal static sharedPicture CreateSharedPicture (Stream stream) {
@@ -129,21 +129,13 @@ namespace Crow
widthRatio = heightRatio;
}
-#if VKVG
- using (Surface tmp = new Surface (iFace.vkvgDevice, bounds.Width, bounds.Height)) {
-#else
- using (Surface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
-#endif
- using (IContext gr = new Context (tmp)) {
+ using (ISurface tmp = iFace.Device.CreateSurface (bounds.Width, bounds.Height)) {
+ using (IContext gr = iFace.Device.CreateContext (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);
-#if VKVG
- using (Surface imgSurf = new Surface (iFace.vkvgDevice, image, Dimensions.Width, Dimensions.Height))
-#else
- using (Surface imgSurf = new ImageSurface (image, Format.Argb32, Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width))
-#endif
- {
+
+ using (ISurface imgSurf = iFace.Device.CreateSurface (bounds.Width, bounds.Height)) {
gr.SetSource (imgSurf, 0,0);
gr.Paint ();
}
@@ -151,7 +143,7 @@ namespace Crow
ctx.SetSource (tmp);
}
}
-#endregion
+ #endregion
/// <summary>
/// paint the image in the rectangle given in arguments according
diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs
index 4db0163f..be1a203f 100644
--- a/Crow/src/Interface.cs
+++ b/Crow/src/Interface.cs
@@ -122,11 +122,6 @@ namespace Crow
if (!Directory.Exists (CROW_CONFIG_ROOT))
Directory.CreateDirectory (CROW_CONFIG_ROOT);
- FontRenderingOptions = new FontOptions ();
- FontRenderingOptions.Antialias = Antialias.Subpixel;
- FontRenderingOptions.HintMetrics = HintMetrics.On;
- FontRenderingOptions.HintStyle = HintStyle.Full;
- FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
}
/// <summary>
/// Each time this array is set, the resolved Assemblies will be
@@ -288,27 +283,7 @@ namespace Crow
initBackend ();
vkCtx.CreateSurface (clientRectangle.Width, clientRectangle.Height, ref surf);
#else
- switch (Environment.OSVersion.Platform) {
- case PlatformID.MacOSX:
- break;
- case PlatformID.Unix:
- IntPtr disp = Glfw3.GetX11Display ();
- IntPtr nativeWin = Glfw3.GetX11Window (hWin);
- Int32 scr = Glfw3.GetX11DefaultScreen (disp);
- IntPtr visual = Glfw3.GetX11DefaultVisual (disp, scr);
- surf = new XlibSurface (disp, nativeWin, visual, clientRectangle.Width, clientRectangle.Height);
- break;
- case PlatformID.Win32NT:
- case PlatformID.Win32S:
- case PlatformID.Win32Windows:
- IntPtr hWin32 = Glfw3.GetWin32Window (hWin);
- IntPtr hdc = Glfw3.GetWin32DC (hWin32);
- surf = new Win32Surface (hdc);
- break;
- case PlatformID.Xbox:
- case PlatformID.WinCE:
- throw new PlatformNotSupportedException ("Unable to create cairo surface.");
- }
+
#endif
}
/// <summary>
@@ -323,42 +298,10 @@ namespace Crow
surf = new ImageSurface (Format.ARGB32, r.Width, r.Height);
#endif
}
- public Surface CreateSurface (ref Rectangle r) {
-#if (VKVG)
- return new Surface (vkvgDevice, r.Width, r.Height);
-#else
- return surf.CreateSimilar (Content.ColorAlpha, r.Width, r.Height);
-#endif
- }
- public Surface CreateSurface (int width, int height) {
-#if (VKVG)
- return new Surface (vkvgDevice, width, height);
-#else
- return surf.CreateSimilar (Content.ColorAlpha, width, height);
-#endif
- }
- public Surface CreateSurface (IntPtr existingSurfaceHandle) {
-#if (VKVG)
- return new Surface (vkvgDevice, existingSurfaceHandle);
-#else
- return Surface.Lookup (existingSurfaceHandle, false);
-#endif
- }
- public Surface CreateSurfaceForData (IntPtr data, int width, int height) {
-#if (VKVG)
- throw new NotImplementedException ();
-#else
- return new ImageSurface (data, Format.Argb32, width, height, width * 4);
-#endif
- }
public IntPtr SurfacePointer {
get {
lock(UpdateMutex)
-#if (VKVG)
- return (vkCtx as OffscreenVulkanContext).bitmap;
-#else
return surf.Handle;
-#endif
}
}
/// <summary>
@@ -679,10 +622,6 @@ namespace Crow
/// <summary> Above this count, the layouting is discard for the widget and it
/// will not be rendered on screen </summary>
public static int MaxDiscardCount = 5;
- /// <summary> Global font rendering settings for Cairo </summary>
- public static FontOptions FontRenderingOptions;
- /// <summary> Global font rendering settings for Cairo </summary>
- public static Antialias Antialias = Antialias.Subpixel;
/// <summary>
/// Each control need a ref to the root interface containing it, if not set in Widget.currentInterface,
@@ -712,8 +651,8 @@ namespace Crow
public event EventHandler<KeyEventArgs> KeyboardKeyUp;*/
#endregion
- /// <summary>Main Cairo surface</summary>
- public Surface surf;
+ /// <summary>Main backend surface</summary>
+ public ISurface surf;
#region Public Fields
/// <summary>Graphic Tree of this interface</summary>
@@ -767,7 +706,7 @@ namespace Crow
public DragDropEventArgs DragAndDropOperation = null;
internal Widget dragndropHover;
- public Surface DragImage = null;
+ public ISurface DragImage = null;
public Rectangle DragImageBounds, lastDragImageBounds;
public bool DragImageFolowMouse;//prevent dragImg to be moved by mouse
public void ClearDragImage () {
@@ -780,7 +719,7 @@ namespace Crow
DragImageBounds = lastDragImageBounds = default;
}
}
- public void CreateDragImage (Surface img, Rectangle bounds, bool followMouse = true) {
+ public void CreateDragImage (ISurface img, Rectangle bounds, bool followMouse = true) {
lock (UpdateMutex) {
if (DragImage != null)
ClearDragImage ();
diff --git a/Crow/src/Widgets/ColorPicker.cs b/Crow/src/Widgets/ColorPicker.cs
index 58810666..3b31ea43 100644
--- a/Crow/src/Widgets/ColorPicker.cs
+++ b/Crow/src/Widgets/ColorPicker.cs
@@ -7,6 +7,7 @@ using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/DockWindow.cs b/Crow/src/Widgets/DockWindow.cs
index d0b57191..6c6c49f9 100644
--- a/Crow/src/Widgets/DockWindow.cs
+++ b/Crow/src/Widgets/DockWindow.cs
@@ -200,8 +200,8 @@ namespace Crow
r.Inflate (r.Width / -3, r.Height / -3);
break;
}
- Surface dragImg = IFace.CreateSurface (r.Width, r.Height);
- using (IContext gr = new Context(dragImg)) {
+ ISurface dragImg = IFace.Device.CreateSurface (r.Width, r.Height);
+ using (IContext gr = IFace.Device.CreateContext (dragImg)) {
gr.LineWidth = 1;
gr.Rectangle (0,0,r.Width,r.Height);
gr.SetSource (0.2,0.3,0.9,0.5);
diff --git a/Crow/src/Widgets/GroupBase.cs b/Crow/src/Widgets/GroupBase.cs
index 1de8787f..1f62eb90 100644
--- a/Crow/src/Widgets/GroupBase.cs
+++ b/Crow/src/Widgets/GroupBase.cs
@@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
-
+using Drawing2D;
using static Crow.Logger;
@@ -251,7 +251,7 @@ namespace Crow
{
DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
if (!Clipping.IsEmpty) {
- using (IContext gr = new Context (bmp)) {
+ using (IContext gr = IFace.Device.CreateContext (bmp)) {
for (int i = 0; i < Clipping.NumRectangles; i++)
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs
index e012f352..3c3795c4 100644
--- a/Crow/src/Widgets/Label.cs
+++ b/Crow/src/Widgets/Label.cs
@@ -514,8 +514,9 @@ namespace Crow
int hoverLine = _multiline ?
(int)Math.Min (Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent + fe.Descent))), lines.Count - 1) : 0;
hoverLoc = new CharLocation (hoverLine, -1, mouseLocalPos.X);
- using (IContext gr = new Context (IFace.surf)) {
- setFontForContext (gr);
+ using (IContext gr = IFace.Device.CreateContext (IFace.surf)) {
+ gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+ gr.SetFontSize (Font.Size);
updateLocation (gr, ClientRectangle.Width, ref hoverLoc);
}
}
@@ -533,7 +534,8 @@ namespace Crow
return false;
}
if (!CurrentLoc.Value.HasVisualX) {
- setFontForContext (ctx);
+ ctx.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+ ctx.SetFontSize (Font.Size);
lock (linesMutex) {
if (currentLoc?.Column < 0) {
updateLocation (ctx, ClientRectangle.Width, ref currentLoc);
@@ -648,8 +650,9 @@ namespace Crow
getLines ();
if (!textMeasureIsUpToDate) {
- using (IContext gr = new Context (IFace.surf)) {
- setFontForContext (gr);
+ using (IContext gr = IFace.Device.CreateContext (IFace.surf)) {
+ gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+ gr.SetFontSize (Font.Size);
measureTextBounds (gr);
}
}
@@ -663,7 +666,8 @@ namespace Crow
try {
base.onDraw (gr);
- setFontForContext (gr);
+ gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+ gr.SetFontSize (Font.Size);
if (!textMeasureIsUpToDate) {
lock (linesMutex)
diff --git a/Crow/src/Widgets/PrivateContainer.cs b/Crow/src/Widgets/PrivateContainer.cs
index 498ba80b..3b705ea5 100644
--- a/Crow/src/Widgets/PrivateContainer.cs
+++ b/Crow/src/Widgets/PrivateContainer.cs
@@ -215,7 +215,7 @@ namespace Crow
Rectangle rb = Slot + Parent.ClientRectangle.Position;
if (!Clipping.IsEmpty) {
- using (IContext gr = new Context (bmp)) {
+ using (IContext gr = IFace.Device.CreateContext (bmp)) {
for (int i = 0; i < Clipping.NumRectangles; i++)
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
diff --git a/Crow/src/Widgets/ScrollingStack.cs b/Crow/src/Widgets/ScrollingStack.cs
index de9c0005..c67bf7d1 100644
--- a/Crow/src/Widgets/ScrollingStack.cs
+++ b/Crow/src/Widgets/ScrollingStack.cs
@@ -4,7 +4,7 @@
using System;
using System.ComponentModel;
-
+using Drawing2D;
namespace Crow {
public class ScrollingStack : GenericStack {
@@ -136,7 +136,7 @@ namespace Crow {
{
DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
if (!Clipping.IsEmpty) {
- using (IContext gr = new Context (bmp)) {
+ using (IContext gr = IFace.Device.CreateContext (bmp)) {
for (int i = 0; i < Clipping.NumRectangles; i++)
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
diff --git a/Crow/src/Widgets/Shape.cs b/Crow/src/Widgets/Shape.cs
index c6cca0d6..fea5d1e3 100644
--- a/Crow/src/Widgets/Shape.cs
+++ b/Crow/src/Widgets/Shape.cs
@@ -244,7 +244,7 @@ namespace Crow
if (size != default (Size))
contentSize = size;
else {
- using (IContext ctx = new Context (IFace.surf)) {
+ using (IContext ctx = IFace.Device.CreateContext (IFace.surf)) {
using (PathParser parser = new PathParser (path))
parser.Draw (ctx, true);
Rectangle r = ctx.StrokeExtents ();
diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs
index a59576d3..09f4f5cf 100644
--- a/Crow/src/Widgets/TemplatedControl.cs
+++ b/Crow/src/Widgets/TemplatedControl.cs
@@ -6,7 +6,7 @@ using System;
using System.ComponentModel;
using System.IO;
using System.Xml;
-
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs
index 45c62efa..875fa1a7 100644
--- a/Crow/src/Widgets/Widget.cs
+++ b/Crow/src/Widgets/Widget.cs
@@ -189,7 +189,7 @@ namespace Crow
#endif
/// <summary>
- /// The interface this widget is bound to when instantiated,
+ /// The interface this widget is bound to when instantiated,
/// </summary>
public readonly Interface IFace = null;
@@ -330,7 +330,7 @@ namespace Crow
/// <summary>Prevent requeuing multiple times the same widget</summary>
public bool IsQueueForClipping = false;
/// <summary>drawing Cache, if null, a redraw is done on repaint, cached or not</summary>
- public Surface bmp;
+ public ISurface bmp;
/// <summary>
/// If the widget dirty state is set to true, a full redraw will be triggered on paint.
/// </summary>
@@ -1928,16 +1928,7 @@ namespace Crow
#endregion
protected void setFontForContext (IContext gr) {
-#if VKVG
- gr.FontFace = Font.Name;
- gr.FontSize = (uint)Font.Size;
-#else
- gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
- gr.SetFontSize (Font.Size);
- gr.FontOptions = Interface.FontRenderingOptions;
- gr.Antialias = Interface.Antialias;
-#endif
}
#region Rendering
@@ -1978,9 +1969,8 @@ namespace Crow
//bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
DbgLogger.StartEvent (DbgEvtType.GOCreateContext, this);
- using (IContext gr = new Context (bmp)) {
+ using (IContext gr = IFace.Device.CreateContext (bmp)) {
DbgLogger.EndEvent (DbgEvtType.GOCreateContext);
- gr.Antialias = Interface.Antialias;
onDraw (gr);
}
diff --git a/Drawing2D/Drawing2D.csproj b/Drawing2D/Drawing2D.csproj
index 0bb94879..33b36ca2 100644
--- a/Drawing2D/Drawing2D.csproj
+++ b/Drawing2D/Drawing2D.csproj
@@ -31,5 +31,13 @@
<PackageReference Include="Enums.NET" Version="4.0.0" />
</ItemGroup>
+ <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
+ <DefineConstants>$(DefineConstants);STB_SHARP</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup Condition=" '$(CrowStbSharp)' == 'true'">
+ <Compile Remove="src\StbImage.cs" />
+ <PackageReference Include="StbImageSharp" Version="2.22.4" />
+ </ItemGroup>
+
</Project>
diff --git a/Drawing2D/src/IContext.cs b/Drawing2D/src/IContext.cs
index d393289b..9e080613 100644
--- a/Drawing2D/src/IContext.cs
+++ b/Drawing2D/src/IContext.cs
@@ -14,11 +14,11 @@ namespace Drawing2D
double LineWidth { get; set; }
LineJoin LineJoin { get; set; }
LineCap LineCap { get; set; }
- uint FontSize { get; set; }
- string FontFace { get; set; }
+ void SetFontSize (double scale);
+ void SelectFontFace (string family, FontSlant slant, FontWeight weight);
Operator Operator { get; set; }
FillRule FillRule { get; set; }
- FontExtents FontExtents { get; set; }
+ FontExtents FontExtents { get; }
Antialias Antialias { get; set; }
TextExtents TextExtents (ReadOnlySpan<char> s, int tabSize = 4);
void TextExtents (ReadOnlySpan<char> s, int tabSize, out TextExtents extents);
diff --git a/Drawing2D/src/Device.cs b/Drawing2D/src/IDevice.cs
index 8beb1b79..02224894 100644
--- a/Drawing2D/src/Device.cs
+++ b/Drawing2D/src/IDevice.cs
@@ -13,6 +13,8 @@ namespace Drawing2D
void GetDpy (out int hdpy, out int vdpy);
void SetDpy (int hdpy, int vdpy);
ISurface CreateSurface (int width, int height);
+
+ IContext CreateContext (ISurface surf);
}
}
diff --git a/Drawing2D/src/Surface.cs b/Drawing2D/src/ISurface.cs
index 696f1ae2..37bb510c 100644
--- a/Drawing2D/src/Surface.cs
+++ b/Drawing2D/src/ISurface.cs
@@ -8,7 +8,7 @@ namespace Drawing2D
{
public interface ISurface: IDisposable
{
- //IntPtr Handle { get; }
+ IntPtr Handle { get; }
int Width { get; }
int Height { get; }
diff --git a/Crow/src/StbImage.cs b/Drawing2D/src/StbImage.cs
index 8cb4d753..a55f3772 100644
--- a/Crow/src/StbImage.cs
+++ b/Drawing2D/src/StbImage.cs
@@ -1,11 +1,11 @@
-// Copyright (c) 2019 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2019-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.IO;
using System.Runtime.InteropServices;
-namespace Crow {
+namespace Drawing2D {
public class StbImage : IDisposable {
const string stblib = "stb";