aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-23 02:23:24 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-23 02:23:24 +0100
commitd396c47e492aa7badcfefba41c36c516558fb1ec (patch)
treeb8a6b6f68313aa9ac9bf7bb10c1004df7489e633
parentdbb9034d864fc42f92a66b08a0734edc3dc73e8c (diff)
save commit, Drawing2D shared lib
-rw-r--r--Backends/CairoBackend/CairoBackend.csproj15
-rw-r--r--Backends/CairoBackend/src/Cairo.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs)0
-rw-r--r--Backends/CairoBackend/src/CairoDebug.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/CairoDebug.cs)0
-rw-r--r--Backends/CairoBackend/src/Content.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Content.cs)1
-rw-r--r--Backends/CairoBackend/src/Context.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Context.cs)17
-rw-r--r--Backends/CairoBackend/src/DRMDevice.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/DRMDevice.cs)0
-rw-r--r--Backends/CairoBackend/src/DRMSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/DRMSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/Device.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Device.cs)0
-rw-r--r--Backends/CairoBackend/src/DirectFBSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/DirectFBSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/Distance.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Distance.cs)0
-rw-r--r--Backends/CairoBackend/src/EGLDevice.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/EGLDevice.cs)0
-rw-r--r--Backends/CairoBackend/src/Extend.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Extend.cs)0
-rw-r--r--Backends/CairoBackend/src/FillRule.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/FillRule.cs)0
-rw-r--r--Backends/CairoBackend/src/Filter.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Filter.cs)0
-rw-r--r--Backends/CairoBackend/src/FontExtents.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/FontExtents.cs)14
-rw-r--r--Backends/CairoBackend/src/FontFace.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/FontFace.cs)0
-rw-r--r--Backends/CairoBackend/src/FontOptions.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/FontOptions.cs)0
-rw-r--r--Backends/CairoBackend/src/FontSlant.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/FontSlant.cs)0
-rw-r--r--Backends/CairoBackend/src/FontType.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/FontType.cs)0
-rw-r--r--Backends/CairoBackend/src/FontWeight.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/FontWeight.cs)0
-rw-r--r--Backends/CairoBackend/src/GLSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/GLXDevice.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/GLXDevice.cs)0
-rw-r--r--Backends/CairoBackend/src/GlitzSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/GlitzSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/Glyph.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Glyph.cs)0
-rw-r--r--Backends/CairoBackend/src/Gradient.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Gradient.cs)0
-rw-r--r--Backends/CairoBackend/src/HintMetrics.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/HintMetrics.cs)0
-rw-r--r--Backends/CairoBackend/src/HintStyle.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/HintStyle.cs)0
-rw-r--r--Backends/CairoBackend/src/ImageSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/LineCap.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/LineCap.cs)0
-rw-r--r--Backends/CairoBackend/src/LineJoin.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/LineJoin.cs)0
-rw-r--r--Backends/CairoBackend/src/LinearGradient.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/LinearGradient.cs)1
-rw-r--r--Backends/CairoBackend/src/Matrix.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs)0
-rw-r--r--Backends/CairoBackend/src/MeshPattern.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/MeshPattern.cs)1
-rw-r--r--Backends/CairoBackend/src/NativeMethods-internal.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/NativeMethods-internal.cs)0
-rw-r--r--Backends/CairoBackend/src/NativeMethods.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs)17
-rw-r--r--Backends/CairoBackend/src/PSSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/PSSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/Path.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Path.cs)0
-rw-r--r--Backends/CairoBackend/src/Pattern.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Pattern.cs)0
-rw-r--r--Backends/CairoBackend/src/PatternType.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/PatternType.cs)0
-rw-r--r--Backends/CairoBackend/src/PdfSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/PdfSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/RadialGradient.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/RadialGradient.cs)0
-rw-r--r--Backends/CairoBackend/src/Region.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Region.cs)25
-rw-r--r--Backends/CairoBackend/src/ScaledFont.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/ScaledFont.cs)0
-rw-r--r--Backends/CairoBackend/src/SolidPattern.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/SolidPattern.cs)0
-rw-r--r--Backends/CairoBackend/src/Status.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Status.cs)0
-rw-r--r--Backends/CairoBackend/src/SubpixelOrder.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/SubpixelOrder.cs)0
-rw-r--r--Backends/CairoBackend/src/Surface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Surface.cs)5
-rw-r--r--Backends/CairoBackend/src/SurfacePattern.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/SurfacePattern.cs)0
-rw-r--r--Backends/CairoBackend/src/SurfaceType.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/SurfaceType.cs)0
-rw-r--r--Backends/CairoBackend/src/SvgSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/SvgSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/SvgVersion.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/SvgVersion.cs)0
-rw-r--r--Backends/CairoBackend/src/TextExtents.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/TextExtents.cs)0
-rw-r--r--Backends/CairoBackend/src/WGLDevice.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/WGLDevice.cs)0
-rw-r--r--Backends/CairoBackend/src/Win32Surface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/Win32Surface.cs)0
-rw-r--r--Backends/CairoBackend/src/XcbSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/XcbSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/XlibSurface.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/XlibSurface.cs)0
-rw-r--r--Backends/CairoBackend/src/rsvg/SvgHandle.cs (renamed from Crow/src/GraphicBackends/Mono.Cairo/rsvg/SvgHandle.cs)1
-rw-r--r--Backends/VkvgBackend/VkvgBackend.csproj15
-rw-r--r--Backends/VkvgBackend/src/Context.cs (renamed from Crow/src/GraphicBackends/vkvg/Context.cs)14
-rw-r--r--Backends/VkvgBackend/src/Device.cs (renamed from Crow/src/GraphicBackends/vkvg/Device.cs)0
-rw-r--r--Backends/VkvgBackend/src/Gradient.cs (renamed from Crow/src/GraphicBackends/vkvg/Gradient.cs)0
-rw-r--r--Backends/VkvgBackend/src/Matrix.cs (renamed from Crow/src/GraphicBackends/vkvg/Matrix.cs)0
-rw-r--r--Backends/VkvgBackend/src/NativeMethods.cs (renamed from Crow/src/GraphicBackends/vkvg/NativeMethods.cs)0
-rw-r--r--Backends/VkvgBackend/src/Pattern.cs (renamed from Crow/src/GraphicBackends/vkvg/Pattern.cs)0
-rw-r--r--Backends/VkvgBackend/src/Surface.cs (renamed from Crow/src/GraphicBackends/vkvg/Surface.cs)0
-rw-r--r--Backends/VkvgBackend/src/SvgHandle.cs (renamed from Crow/src/GraphicBackends/vkvg/SvgHandle.cs)0
-rw-r--r--Backends/VkvgBackend/src/TextRun.cs (renamed from Crow/src/GraphicBackends/vkvg/TextRun.cs)0
-rw-r--r--Backends/VkvgBackend/src/VulkanContext.cs (renamed from Crow/src/GraphicBackends/vkvg/VulkanContext.cs)12
-rw-r--r--Backends/VkvgBackend/src/tmp/FontOptions.cs (renamed from Crow/src/GraphicBackends/vkvg/tmp/FontOptions.cs)0
-rw-r--r--Backends/VkvgBackend/src/tmp/Region.cs (renamed from Crow/src/GraphicBackends/vkvg/tmp/Region.cs)6
-rw-r--r--Crow.sln15
-rw-r--r--Crow/Crow.csproj13
-rw-r--r--Crow/src/2d/RectangleD.cs166
-rw-r--r--Crow/src/Cairo/CairoHelpers.cs18
-rw-r--r--Crow/src/DebugUtils/DbgEvent.cs1
-rw-r--r--Crow/src/DebugUtils/DbgLayoutEvent.cs6
-rw-r--r--Crow/src/DebugUtils/DbgWidgetEvent.cs4
-rw-r--r--Crow/src/ExtensionsMethods.cs12
-rw-r--r--Crow/src/Fill/BmpPicture.cs27
-rw-r--r--Crow/src/Fill/Fill.cs9
-rw-r--r--Crow/src/Fill/Gradient.cs7
-rw-r--r--Crow/src/Fill/Picture.cs15
-rw-r--r--Crow/src/Fill/SolidColor.cs7
-rw-r--r--Crow/src/Fill/SvgPicture.cs11
-rw-r--r--Crow/src/Font.cs12
-rw-r--r--Crow/src/GraphicBackends/Mono.Cairo/Antialias.cs43
-rw-r--r--Crow/src/GraphicBackends/Mono.Cairo/Format.cs48
-rw-r--r--Crow/src/GraphicBackends/Mono.Cairo/Operator.cs62
-rw-r--r--Crow/src/GraphicBackends/vkvg/Enums.cs143
-rw-r--r--Crow/src/GraphicBackends/vkvg/TextExtents.cs72
-rw-r--r--Crow/src/Input/MouseEventArgs.cs3
-rw-r--r--Crow/src/Interface.cs27
-rw-r--r--Crow/src/Text/IEditableTextWidget.cs7
-rw-r--r--Crow/src/Widgets/Border.cs11
-rw-r--r--Crow/src/Widgets/CircleMeter.cs13
-rw-r--r--Crow/src/Widgets/ColorSelector.cs3
-rw-r--r--Crow/src/Widgets/ColorSlider.cs7
-rw-r--r--Crow/src/Widgets/ComboBox.cs3
-rw-r--r--Crow/src/Widgets/DockStack.cs3
-rw-r--r--Crow/src/Widgets/DockWindow.cs7
-rw-r--r--Crow/src/Widgets/Gauge.cs7
-rw-r--r--Crow/src/Widgets/GroupBase.cs8
-rw-r--r--Crow/src/Widgets/HueSelector.cs7
-rw-r--r--Crow/src/Widgets/ILayoutable.cs3
-rw-r--r--Crow/src/Widgets/Image.cs4
-rw-r--r--Crow/src/Widgets/Label.cs55
-rw-r--r--Crow/src/Widgets/MenuItem.cs3
-rw-r--r--Crow/src/Widgets/Popper.cs3
-rw-r--r--Crow/src/Widgets/PrivateContainer.cs12
-rw-r--r--Crow/src/Widgets/SaturationValueSelector.cs11
-rw-r--r--Crow/src/Widgets/ScrollBar.cs1
-rw-r--r--Crow/src/Widgets/Scroller.cs7
-rw-r--r--Crow/src/Widgets/ScrollingStack.cs8
-rw-r--r--Crow/src/Widgets/Shape.cs15
-rw-r--r--Crow/src/Widgets/Slider.cs3
-rw-r--r--Crow/src/Widgets/Splitter.cs25
-rw-r--r--Crow/src/Widgets/Table.cs7
-rw-r--r--Crow/src/Widgets/TableRow copy.cs83
-rw-r--r--Crow/src/Widgets/TemplatedControl.cs4
-rw-r--r--Crow/src/Widgets/TemplatedGroup.cs3
-rw-r--r--Crow/src/Widgets/TextBox.cs10
-rw-r--r--Crow/src/Widgets/Widget.cs20
-rw-r--r--Crow/src/Widgets/Window.cs3
-rw-r--r--Directory.Build.props4
-rw-r--r--Drawing2D/Drawing2D.csproj35
-rw-r--r--Drawing2D/src/Colors.cs (renamed from Crow/src/Colors.cs)3
-rw-r--r--Drawing2D/src/Device.cs18
-rw-r--r--Drawing2D/src/Enums.cs149
-rw-r--r--Drawing2D/src/FontExtents.cs (renamed from Crow/src/GraphicBackends/vkvg/FontExtents.cs)56
-rw-r--r--Drawing2D/src/IContext.cs93
-rw-r--r--Drawing2D/src/Matrix.cs21
-rw-r--r--Drawing2D/src/Pattern.cs13
-rw-r--r--Drawing2D/src/Point.cs (renamed from Crow/src/2d/Point.cs)9
-rw-r--r--Drawing2D/src/PointD.cs (renamed from Crow/src/2d/PointD.cs)34
-rw-r--r--Drawing2D/src/Rectangle.cs (renamed from Crow/src/2d/Rectangle.cs)55
-rw-r--r--Drawing2D/src/RectangleD.cs156
-rw-r--r--Drawing2D/src/Size.cs (renamed from Crow/src/2d/Size.cs)9
-rw-r--r--Drawing2D/src/SizeD.cs (renamed from Crow/src/2d/SizeD.cs)32
-rw-r--r--Drawing2D/src/Surface.cs23
-rw-r--r--Drawing2D/src/TextExtents.cs60
-rw-r--r--Samples/ShowCase/ShowCase.cs6
-rw-r--r--Samples/common/src/Editor.cs6
-rw-r--r--Samples/common/src/SampleBase.cs4
-rw-r--r--Samples/common/src/TestWidget.cs4
144 files changed, 1049 insertions, 962 deletions
diff --git a/Backends/CairoBackend/CairoBackend.csproj b/Backends/CairoBackend/CairoBackend.csproj
new file mode 100644
index 00000000..f4fe4d57
--- /dev/null
+++ b/Backends/CairoBackend/CairoBackend.csproj
@@ -0,0 +1,15 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp3.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Compile Include="src\**\*.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\..\Drawing2D\Drawing2D.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs b/Backends/CairoBackend/src/Cairo.cs
index 309c7f4a..309c7f4a 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs
+++ b/Backends/CairoBackend/src/Cairo.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/CairoDebug.cs b/Backends/CairoBackend/src/CairoDebug.cs
index 890793da..890793da 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/CairoDebug.cs
+++ b/Backends/CairoBackend/src/CairoDebug.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Content.cs b/Backends/CairoBackend/src/Content.cs
index 13927c1d..a908a0d8 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Content.cs
+++ b/Backends/CairoBackend/src/Content.cs
@@ -33,7 +33,6 @@ using System;
namespace Crow.Drawing
{
//[Flags]
-
public enum Content
{
Color = 0x1000,
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Context.cs b/Backends/CairoBackend/src/Context.cs
index f8c1c0e7..5b92166c 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Context.cs
+++ b/Backends/CairoBackend/src/Context.cs
@@ -37,6 +37,7 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
+using Drawing2D;
namespace Crow.Drawing {
@@ -443,11 +444,11 @@ namespace Crow.Drawing {
NativeMethods.cairo_arc_negative (handle, center.X, center.Y, radius, angle1, angle2);
}
- public void Rectangle (Crow.Rectangle rectangle)
+ public void Rectangle (Rectangle rectangle)
{
Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
}
- public void Rectangle (Crow.RectangleD rectangle)
+ public void Rectangle (RectangleD rectangle)
{
Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
}
@@ -515,11 +516,11 @@ namespace Crow.Drawing {
NativeMethods.cairo_stroke_preserve (handle);
}
- public Crow.Rectangle StrokeExtents ()
+ public Rectangle StrokeExtents ()
{
double x1, y1, x2, y2;
NativeMethods.cairo_stroke_extents (handle, out x1, out y1, out x2, out y2);
- return new Crow.Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1));
+ return new Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1));
}
public void Fill ()
@@ -527,11 +528,11 @@ namespace Crow.Drawing {
NativeMethods.cairo_fill (handle);
}
- public Crow.Rectangle FillExtents ()
+ public Rectangle FillExtents ()
{
double x1, y1, x2, y2;
NativeMethods.cairo_fill_extents (handle, out x1, out y1, out x2, out y2);
- return new Crow.Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1));
+ return new Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1));
}
public void FillPreserve ()
@@ -875,7 +876,7 @@ namespace Crow.Drawing {
public void ShowText (ReadOnlySpan<char> s, int tabSize) {
int size = s.Length * 4 + 1;
Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
- int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes, tabSize);
+ int encodedBytes = Text.Encoding.ToUtf8 (s, bytes, tabSize);
bytes[encodedBytes] = 0;
ShowText (bytes.Slice (0, encodedBytes + 1));
}
@@ -886,7 +887,7 @@ namespace Crow.Drawing {
public void TextExtents (ReadOnlySpan<char> s, int tabSize, out TextExtents extents) {
int size = s.Length * 4 + 1;
Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
- int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes, tabSize);
+ int encodedBytes = Text.Encoding.ToUtf8 (s, bytes, tabSize);
bytes[encodedBytes] = 0;
TextExtents (bytes.Slice (0, encodedBytes + 1), out extents);
}
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/DRMDevice.cs b/Backends/CairoBackend/src/DRMDevice.cs
index c08ad030..c08ad030 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/DRMDevice.cs
+++ b/Backends/CairoBackend/src/DRMDevice.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/DRMSurface.cs b/Backends/CairoBackend/src/DRMSurface.cs
index b1fcfb76..b1fcfb76 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/DRMSurface.cs
+++ b/Backends/CairoBackend/src/DRMSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Device.cs b/Backends/CairoBackend/src/Device.cs
index 426d4ca2..426d4ca2 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Device.cs
+++ b/Backends/CairoBackend/src/Device.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/DirectFBSurface.cs b/Backends/CairoBackend/src/DirectFBSurface.cs
index 4f52ec72..4f52ec72 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/DirectFBSurface.cs
+++ b/Backends/CairoBackend/src/DirectFBSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Distance.cs b/Backends/CairoBackend/src/Distance.cs
index eaa7d5a3..eaa7d5a3 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Distance.cs
+++ b/Backends/CairoBackend/src/Distance.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/EGLDevice.cs b/Backends/CairoBackend/src/EGLDevice.cs
index 93150884..93150884 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/EGLDevice.cs
+++ b/Backends/CairoBackend/src/EGLDevice.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Extend.cs b/Backends/CairoBackend/src/Extend.cs
index 01a7969d..01a7969d 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Extend.cs
+++ b/Backends/CairoBackend/src/Extend.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/FillRule.cs b/Backends/CairoBackend/src/FillRule.cs
index 314a7830..314a7830 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/FillRule.cs
+++ b/Backends/CairoBackend/src/FillRule.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Filter.cs b/Backends/CairoBackend/src/Filter.cs
index 5b521048..5b521048 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Filter.cs
+++ b/Backends/CairoBackend/src/Filter.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/FontExtents.cs b/Backends/CairoBackend/src/FontExtents.cs
index 99a26d2c..73164b29 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/FontExtents.cs
+++ b/Backends/CairoBackend/src/FontExtents.cs
@@ -18,10 +18,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
@@ -44,27 +44,27 @@ namespace Crow.Drawing
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; }
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/FontFace.cs b/Backends/CairoBackend/src/FontFace.cs
index e4fd1a6e..e4fd1a6e 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/FontFace.cs
+++ b/Backends/CairoBackend/src/FontFace.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/FontOptions.cs b/Backends/CairoBackend/src/FontOptions.cs
index 977b6993..977b6993 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/FontOptions.cs
+++ b/Backends/CairoBackend/src/FontOptions.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/FontSlant.cs b/Backends/CairoBackend/src/FontSlant.cs
index 4ce74a24..4ce74a24 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/FontSlant.cs
+++ b/Backends/CairoBackend/src/FontSlant.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/FontType.cs b/Backends/CairoBackend/src/FontType.cs
index 80d672c4..80d672c4 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/FontType.cs
+++ b/Backends/CairoBackend/src/FontType.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/FontWeight.cs b/Backends/CairoBackend/src/FontWeight.cs
index 51c0e8d2..51c0e8d2 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/FontWeight.cs
+++ b/Backends/CairoBackend/src/FontWeight.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs b/Backends/CairoBackend/src/GLSurface.cs
index 45112024..45112024 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs
+++ b/Backends/CairoBackend/src/GLSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/GLXDevice.cs b/Backends/CairoBackend/src/GLXDevice.cs
index 086cf1f4..086cf1f4 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/GLXDevice.cs
+++ b/Backends/CairoBackend/src/GLXDevice.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/GlitzSurface.cs b/Backends/CairoBackend/src/GlitzSurface.cs
index fc12c673..fc12c673 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/GlitzSurface.cs
+++ b/Backends/CairoBackend/src/GlitzSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Glyph.cs b/Backends/CairoBackend/src/Glyph.cs
index c015e6de..c015e6de 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Glyph.cs
+++ b/Backends/CairoBackend/src/Glyph.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Gradient.cs b/Backends/CairoBackend/src/Gradient.cs
index c9b8116c..c9b8116c 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Gradient.cs
+++ b/Backends/CairoBackend/src/Gradient.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/HintMetrics.cs b/Backends/CairoBackend/src/HintMetrics.cs
index fbb78ad6..fbb78ad6 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/HintMetrics.cs
+++ b/Backends/CairoBackend/src/HintMetrics.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/HintStyle.cs b/Backends/CairoBackend/src/HintStyle.cs
index 713dafae..713dafae 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/HintStyle.cs
+++ b/Backends/CairoBackend/src/HintStyle.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs b/Backends/CairoBackend/src/ImageSurface.cs
index 28330105..28330105 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs
+++ b/Backends/CairoBackend/src/ImageSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/LineCap.cs b/Backends/CairoBackend/src/LineCap.cs
index b9fcb220..b9fcb220 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/LineCap.cs
+++ b/Backends/CairoBackend/src/LineCap.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/LineJoin.cs b/Backends/CairoBackend/src/LineJoin.cs
index 2ec44b69..2ec44b69 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/LineJoin.cs
+++ b/Backends/CairoBackend/src/LineJoin.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/LinearGradient.cs b/Backends/CairoBackend/src/LinearGradient.cs
index 69d9a939..3b98be03 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/LinearGradient.cs
+++ b/Backends/CairoBackend/src/LinearGradient.cs
@@ -28,6 +28,7 @@
//
using System;
+using Drawing2D;
namespace Crow.Drawing {
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs b/Backends/CairoBackend/src/Matrix.cs
index 0224fd5f..0224fd5f 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs
+++ b/Backends/CairoBackend/src/Matrix.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/MeshPattern.cs b/Backends/CairoBackend/src/MeshPattern.cs
index 99cd72c1..aef35481 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/MeshPattern.cs
+++ b/Backends/CairoBackend/src/MeshPattern.cs
@@ -28,6 +28,7 @@
//
using System;
+using Drawing2D;
namespace Crow.Drawing {
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods-internal.cs b/Backends/CairoBackend/src/NativeMethods-internal.cs
index 6e6d507c..6e6d507c 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods-internal.cs
+++ b/Backends/CairoBackend/src/NativeMethods-internal.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs b/Backends/CairoBackend/src/NativeMethods.cs
index f547661e..48ee42f7 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs
+++ b/Backends/CairoBackend/src/NativeMethods.cs
@@ -33,6 +33,7 @@
using System;
using System.Runtime.InteropServices;
+using Drawing2D;
namespace Crow.Drawing
{
@@ -548,7 +549,7 @@ namespace Crow.Drawing
internal static extern bool cairo_region_contains_point (IntPtr region, int x, int y);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern RegionOverlap cairo_region_contains_rectangle (IntPtr region, ref Crow.Rectangle rectangle);
+ internal static extern RegionOverlap cairo_region_contains_rectangle (IntPtr region, ref Rectangle rectangle);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern IntPtr cairo_region_copy (IntPtr original);
@@ -557,7 +558,7 @@ namespace Crow.Drawing
internal static extern IntPtr cairo_region_create ();
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_region_create_rectangle (ref Crow.Rectangle rect);
+ internal static extern IntPtr cairo_region_create_rectangle (ref Rectangle rect);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern IntPtr cairo_region_create_rectangles (IntPtr rects, int count);
@@ -569,16 +570,16 @@ namespace Crow.Drawing
internal static extern bool cairo_region_equal (IntPtr a, IntPtr b);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_region_get_extents (IntPtr region, out Crow.Rectangle extents);
+ internal static extern void cairo_region_get_extents (IntPtr region, out Rectangle extents);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_region_get_rectangle (IntPtr region, int nth, out Crow.Rectangle rectangle);
+ internal static extern void cairo_region_get_rectangle (IntPtr region, int nth, out Rectangle rectangle);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern Status cairo_region_intersect (IntPtr dst, IntPtr other);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_intersect_rectangle (IntPtr dst, ref Crow.Rectangle rectangle);
+ internal static extern Status cairo_region_intersect_rectangle (IntPtr dst, ref Rectangle rectangle);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern bool cairo_region_is_empty (IntPtr region);
@@ -596,7 +597,7 @@ namespace Crow.Drawing
internal static extern Status cairo_region_subtract (IntPtr dst, IntPtr other);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_subtract_rectangle (IntPtr dst, ref Crow.Rectangle rectangle);
+ internal static extern Status cairo_region_subtract_rectangle (IntPtr dst, ref Rectangle rectangle);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern void cairo_region_translate (IntPtr region, int dx, int dy);
@@ -605,13 +606,13 @@ namespace Crow.Drawing
internal static extern Status cairo_region_union (IntPtr dst, IntPtr other);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_union_rectangle (IntPtr dst, ref Crow.Rectangle rectangle);
+ internal static extern Status cairo_region_union_rectangle (IntPtr dst, ref Rectangle rectangle);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern Status cairo_region_xor (IntPtr dst, IntPtr other);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_xor_rectangle (IntPtr dst, ref Crow.Rectangle rectangle);
+ internal static extern Status cairo_region_xor_rectangle (IntPtr dst, ref Rectangle rectangle);
#endregion
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/PSSurface.cs b/Backends/CairoBackend/src/PSSurface.cs
index ca3c1d7d..ca3c1d7d 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/PSSurface.cs
+++ b/Backends/CairoBackend/src/PSSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Path.cs b/Backends/CairoBackend/src/Path.cs
index 9d5e9456..9d5e9456 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Path.cs
+++ b/Backends/CairoBackend/src/Path.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Pattern.cs b/Backends/CairoBackend/src/Pattern.cs
index 1180e632..1180e632 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Pattern.cs
+++ b/Backends/CairoBackend/src/Pattern.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/PatternType.cs b/Backends/CairoBackend/src/PatternType.cs
index 008d8e55..008d8e55 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/PatternType.cs
+++ b/Backends/CairoBackend/src/PatternType.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/PdfSurface.cs b/Backends/CairoBackend/src/PdfSurface.cs
index 16287b76..16287b76 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/PdfSurface.cs
+++ b/Backends/CairoBackend/src/PdfSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/RadialGradient.cs b/Backends/CairoBackend/src/RadialGradient.cs
index e76f7df1..e76f7df1 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/RadialGradient.cs
+++ b/Backends/CairoBackend/src/RadialGradient.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Region.cs b/Backends/CairoBackend/src/Region.cs
index 9cac680b..f4fa7572 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Region.cs
+++ b/Backends/CairoBackend/src/Region.cs
@@ -22,6 +22,7 @@
using System;
using System.Runtime.InteropServices;
+using Drawing2D;
namespace Crow.Drawing
{
@@ -61,7 +62,7 @@ namespace Crow.Drawing
{
}
- public Region (Crow.Rectangle rect)
+ public Region (Rectangle rect)
{
handle = NativeMethods.cairo_region_create_rectangle (ref rect);
}
@@ -115,9 +116,9 @@ namespace Crow.Drawing
get { return NativeMethods.cairo_region_status (Handle); }
}
- public Crow.Rectangle Extents {
+ public Rectangle Extents {
get {
- Crow.Rectangle result;
+ Rectangle result;
NativeMethods.cairo_region_get_extents (Handle, out result);
return result;
}
@@ -127,9 +128,9 @@ namespace Crow.Drawing
get { return NativeMethods.cairo_region_num_rectangles (Handle); }
}
- public Crow.Rectangle GetRectangle (int nth)
+ public Rectangle GetRectangle (int nth)
{
- Crow.Rectangle val;
+ Rectangle val;
NativeMethods.cairo_region_get_rectangle (Handle, nth, out val);
return val;
}
@@ -138,7 +139,7 @@ namespace Crow.Drawing
get { return NativeMethods.cairo_region_is_empty (Handle); }
}
- public RegionOverlap Contains (Crow.Rectangle rectangle)
+ public RegionOverlap Contains (Rectangle rectangle)
{
return NativeMethods.cairo_region_contains_rectangle (Handle, ref rectangle);
}
@@ -158,7 +159,7 @@ namespace Crow.Drawing
return NativeMethods.cairo_region_subtract (Handle, other.Handle);
}
- public Status SubtractRectangle (Crow.Rectangle rectangle)
+ public Status SubtractRectangle (Rectangle rectangle)
{
return NativeMethods.cairo_region_subtract_rectangle (Handle, ref rectangle);
}
@@ -168,7 +169,7 @@ namespace Crow.Drawing
return NativeMethods.cairo_region_intersect (Handle, other.Handle);
}
- public Status IntersectRectangle (Crow.Rectangle rectangle)
+ public Status IntersectRectangle (Rectangle rectangle)
{
return NativeMethods.cairo_region_intersect_rectangle (Handle, ref rectangle);
}
@@ -178,7 +179,7 @@ namespace Crow.Drawing
return NativeMethods.cairo_region_union (Handle, other.Handle);
}
- public Status UnionRectangle (Crow.Rectangle rectangle)
+ public Status UnionRectangle (Rectangle rectangle)
{
return NativeMethods.cairo_region_union_rectangle (Handle, ref rectangle);
}
@@ -188,7 +189,7 @@ namespace Crow.Drawing
return NativeMethods.cairo_region_xor (Handle, other.Handle);
}
- public Status XorRectangle (Crow.Rectangle rectangle)
+ public Status XorRectangle (Rectangle rectangle)
{
return NativeMethods.cairo_region_xor_rectangle (Handle, ref rectangle);
}
@@ -196,8 +197,8 @@ namespace Crow.Drawing
if (IsEmpty)
return;
NativeMethods.cairo_region_destroy (Handle);
- handle = NativeMethods.cairo_region_create ();
+ handle = NativeMethods.cairo_region_create ();
}
- public bool OverlapOut (Crow.Rectangle rectangle) => Contains (rectangle) == RegionOverlap.Out;
+ public bool OverlapOut (Rectangle rectangle) => Contains (rectangle) == RegionOverlap.Out;
}
}
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/ScaledFont.cs b/Backends/CairoBackend/src/ScaledFont.cs
index 1d70646d..1d70646d 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/ScaledFont.cs
+++ b/Backends/CairoBackend/src/ScaledFont.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/SolidPattern.cs b/Backends/CairoBackend/src/SolidPattern.cs
index 5c5da80b..5c5da80b 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/SolidPattern.cs
+++ b/Backends/CairoBackend/src/SolidPattern.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Status.cs b/Backends/CairoBackend/src/Status.cs
index 9a0b8eed..9a0b8eed 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Status.cs
+++ b/Backends/CairoBackend/src/Status.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/SubpixelOrder.cs b/Backends/CairoBackend/src/SubpixelOrder.cs
index a67776df..a67776df 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/SubpixelOrder.cs
+++ b/Backends/CairoBackend/src/SubpixelOrder.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs b/Backends/CairoBackend/src/Surface.cs
index 10967a93..92256fad 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs
+++ b/Backends/CairoBackend/src/Surface.cs
@@ -35,6 +35,7 @@
using System;
using System.Collections;
+using Drawing2D;
namespace Crow.Drawing {
@@ -143,7 +144,7 @@ namespace Crow.Drawing {
NativeMethods.cairo_surface_destroy (handle);
handle = IntPtr.Zero;
}
- public virtual void SetSize (int width, int height) {
+ public virtual void SetSize (int width, int height) {
}
public Status Finish ()
@@ -162,7 +163,7 @@ namespace Crow.Drawing {
NativeMethods.cairo_surface_mark_dirty (Handle);
}
- public void MarkDirty (Crow.Rectangle rectangle)
+ public void MarkDirty (Rectangle rectangle)
{
NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
}
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/SurfacePattern.cs b/Backends/CairoBackend/src/SurfacePattern.cs
index 6c4539c8..6c4539c8 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/SurfacePattern.cs
+++ b/Backends/CairoBackend/src/SurfacePattern.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/SurfaceType.cs b/Backends/CairoBackend/src/SurfaceType.cs
index 5333e536..5333e536 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/SurfaceType.cs
+++ b/Backends/CairoBackend/src/SurfaceType.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/SvgSurface.cs b/Backends/CairoBackend/src/SvgSurface.cs
index 4e22148d..4e22148d 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/SvgSurface.cs
+++ b/Backends/CairoBackend/src/SvgSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/SvgVersion.cs b/Backends/CairoBackend/src/SvgVersion.cs
index 85bc6caf..85bc6caf 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/SvgVersion.cs
+++ b/Backends/CairoBackend/src/SvgVersion.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/TextExtents.cs b/Backends/CairoBackend/src/TextExtents.cs
index 4dd606fd..4dd606fd 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/TextExtents.cs
+++ b/Backends/CairoBackend/src/TextExtents.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/WGLDevice.cs b/Backends/CairoBackend/src/WGLDevice.cs
index fda7d93f..fda7d93f 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/WGLDevice.cs
+++ b/Backends/CairoBackend/src/WGLDevice.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Win32Surface.cs b/Backends/CairoBackend/src/Win32Surface.cs
index 53b79e92..53b79e92 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Win32Surface.cs
+++ b/Backends/CairoBackend/src/Win32Surface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/XcbSurface.cs b/Backends/CairoBackend/src/XcbSurface.cs
index 72c4dbe8..72c4dbe8 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/XcbSurface.cs
+++ b/Backends/CairoBackend/src/XcbSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/XlibSurface.cs b/Backends/CairoBackend/src/XlibSurface.cs
index fbe9e01f..fbe9e01f 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/XlibSurface.cs
+++ b/Backends/CairoBackend/src/XlibSurface.cs
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/rsvg/SvgHandle.cs b/Backends/CairoBackend/src/rsvg/SvgHandle.cs
index 1477b14f..fc2d8a2b 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/rsvg/SvgHandle.cs
+++ b/Backends/CairoBackend/src/rsvg/SvgHandle.cs
@@ -1,6 +1,7 @@
//Copyright GPL2
using System;
using System.Runtime.InteropServices;
+using Drawing2D;
namespace Crow.Drawing {
diff --git a/Backends/VkvgBackend/VkvgBackend.csproj b/Backends/VkvgBackend/VkvgBackend.csproj
new file mode 100644
index 00000000..f4fe4d57
--- /dev/null
+++ b/Backends/VkvgBackend/VkvgBackend.csproj
@@ -0,0 +1,15 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp3.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Compile Include="src\**\*.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\..\Drawing2D\Drawing2D.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/Crow/src/GraphicBackends/vkvg/Context.cs b/Backends/VkvgBackend/src/Context.cs
index d8f45611..11f63de3 100644
--- a/Crow/src/GraphicBackends/vkvg/Context.cs
+++ b/Backends/VkvgBackend/src/Context.cs
@@ -79,16 +79,20 @@ namespace Crow.Drawing
get;
}
public TextExtents TextExtents (ReadOnlySpan<char> s, int tabSize = 4) {
- TextExtents (s, tabSize, out TextExtents extents);
+ TextExtents (s, tabSize, out TextExtents extents);
return extents;
}
public void TextExtents (ReadOnlySpan<char> s, int tabSize, out TextExtents extents) {
+ if (s.Length == 0) {
+ extents = default;
+ return;
+ }
int size = s.Length * 4 + 1;
Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes, tabSize);
bytes[encodedBytes] = 0;
TextExtents (bytes.Slice (0, encodedBytes + 1), out extents);
- }
+ }
public void TextExtents (Span<byte> bytes, out TextExtents extents) {
NativeMethods.vkvg_text_extents (handle, ref bytes.GetPinnableReference (), out extents);
}
@@ -158,7 +162,7 @@ namespace Crow.Drawing
public void ArcNegative (PointD center, double radius, double angle1, double angle2)
{
NativeMethods.vkvg_arc_negative (handle, (float)center.X, (float)center.Y, (float)radius, (float)angle1, (float)angle2);
- }
+ }
public void ArcNegative(float xc, float yc, float radius, float a1, float a2)
{
NativeMethods.vkvg_arc_negative(handle, xc, yc, radius, a1, a2);
@@ -365,13 +369,13 @@ namespace Crow.Drawing
NativeMethods.vkvg_set_dash(handle, value, (uint)value.Length, 0);
}
}
-
+
public void PushGroup () {
}
public void PopGroupToSource () {
-
+
}
#region IDisposable implementation
diff --git a/Crow/src/GraphicBackends/vkvg/Device.cs b/Backends/VkvgBackend/src/Device.cs
index 6ff0230c..6ff0230c 100644
--- a/Crow/src/GraphicBackends/vkvg/Device.cs
+++ b/Backends/VkvgBackend/src/Device.cs
diff --git a/Crow/src/GraphicBackends/vkvg/Gradient.cs b/Backends/VkvgBackend/src/Gradient.cs
index 9f6bed2d..9f6bed2d 100644
--- a/Crow/src/GraphicBackends/vkvg/Gradient.cs
+++ b/Backends/VkvgBackend/src/Gradient.cs
diff --git a/Crow/src/GraphicBackends/vkvg/Matrix.cs b/Backends/VkvgBackend/src/Matrix.cs
index 2dc541ed..2dc541ed 100644
--- a/Crow/src/GraphicBackends/vkvg/Matrix.cs
+++ b/Backends/VkvgBackend/src/Matrix.cs
diff --git a/Crow/src/GraphicBackends/vkvg/NativeMethods.cs b/Backends/VkvgBackend/src/NativeMethods.cs
index d96eab8f..d96eab8f 100644
--- a/Crow/src/GraphicBackends/vkvg/NativeMethods.cs
+++ b/Backends/VkvgBackend/src/NativeMethods.cs
diff --git a/Crow/src/GraphicBackends/vkvg/Pattern.cs b/Backends/VkvgBackend/src/Pattern.cs
index b25e26b2..b25e26b2 100644
--- a/Crow/src/GraphicBackends/vkvg/Pattern.cs
+++ b/Backends/VkvgBackend/src/Pattern.cs
diff --git a/Crow/src/GraphicBackends/vkvg/Surface.cs b/Backends/VkvgBackend/src/Surface.cs
index dba19ca4..dba19ca4 100644
--- a/Crow/src/GraphicBackends/vkvg/Surface.cs
+++ b/Backends/VkvgBackend/src/Surface.cs
diff --git a/Crow/src/GraphicBackends/vkvg/SvgHandle.cs b/Backends/VkvgBackend/src/SvgHandle.cs
index d923d89f..d923d89f 100644
--- a/Crow/src/GraphicBackends/vkvg/SvgHandle.cs
+++ b/Backends/VkvgBackend/src/SvgHandle.cs
diff --git a/Crow/src/GraphicBackends/vkvg/TextRun.cs b/Backends/VkvgBackend/src/TextRun.cs
index f4553692..f4553692 100644
--- a/Crow/src/GraphicBackends/vkvg/TextRun.cs
+++ b/Backends/VkvgBackend/src/TextRun.cs
diff --git a/Crow/src/GraphicBackends/vkvg/VulkanContext.cs b/Backends/VkvgBackend/src/VulkanContext.cs
index 801458a2..610faa71 100644
--- a/Crow/src/GraphicBackends/vkvg/VulkanContext.cs
+++ b/Backends/VkvgBackend/src/VulkanContext.cs
@@ -21,9 +21,9 @@ namespace Crow.Drawing {
public uint width { get; protected set; }
public uint height { get; protected set; }
- protected Instance instance;
+ protected Instance instance;
protected PhysicalDevice phy;
- protected vke.Device dev;
+ protected vke.Device dev;
protected Queue graphicQueue;//for vkvg, we must have at least a graphic queue
public Crow.Drawing.Device VkvgDevice { get; protected set; }
@@ -31,7 +31,7 @@ namespace Crow.Drawing {
public VulkanContextBase (Interface iface) {
this.iface = iface;
- }
+ }
protected void createVkvgDevice () => VkvgDevice =
@@ -204,11 +204,11 @@ namespace Crow.Drawing {
}
internal vke.Image blitSource;
-
+
void buildBlitCommand (Crow.Drawing.Surface surf) {
//Console.WriteLine ($"build blit w:{width} h:{height}");
cmdPool.Reset();
-
+
blitSource = new vke.Image (dev, new VkImage((ulong)surf.VkImage.ToInt64()), Vulkan.VkFormat.B8g8r8a8Unorm,
Vulkan.VkImageUsageFlags.TransferSrc | Vulkan.VkImageUsageFlags.TransferDst | Vulkan.VkImageUsageFlags.ColorAttachment,
width, height);
@@ -217,7 +217,7 @@ namespace Crow.Drawing {
vke.Image blitDest = swapChain.images[i];
vke.PrimaryCommandBuffer cmd = cmds[i];
cmd.Start();
-
+
blitDest.SetLayout (cmd, VkImageAspectFlags.Color,
VkImageLayout.Undefined, VkImageLayout.TransferDstOptimal,
VkPipelineStageFlags.BottomOfPipe, VkPipelineStageFlags.Transfer);
diff --git a/Crow/src/GraphicBackends/vkvg/tmp/FontOptions.cs b/Backends/VkvgBackend/src/tmp/FontOptions.cs
index 1d9764fb..1d9764fb 100644
--- a/Crow/src/GraphicBackends/vkvg/tmp/FontOptions.cs
+++ b/Backends/VkvgBackend/src/tmp/FontOptions.cs
diff --git a/Crow/src/GraphicBackends/vkvg/tmp/Region.cs b/Backends/VkvgBackend/src/tmp/Region.cs
index 83dc7f2b..1821ae2b 100644
--- a/Crow/src/GraphicBackends/vkvg/tmp/Region.cs
+++ b/Backends/VkvgBackend/src/tmp/Region.cs
@@ -4,14 +4,14 @@
using System.Collections.Generic;
using System;
-using Crow.Drawing;
+
namespace Crow {
public enum RegionOverlap {
In,
Out,
Part,
- }
+ }
public class Region : IDisposable
{
public List<Rectangle> list = new List<Rectangle>();
@@ -127,7 +127,7 @@ namespace Crow {
public void Dispose()
{
-
+
}
}
}
diff --git a/Crow.sln b/Crow.sln
index cdd60dd3..e9e8fd86 100644
--- a/Crow.sln
+++ b/Crow.sln
@@ -21,6 +21,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShowCase", "Samples\ShowCas
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfTests", "Samples\PerfTests\PerfTests.csproj", "{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Drawing2D", "Drawing2D\Drawing2D.csproj", "{B9E665AC-92A5-4F53-A021-7B27A8014BC3}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Backends", "Backends", "{451F5727-2A2E-4361-A41B-089429ADE8F9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CairoBackend", "Backends\CairoBackend\CairoBackend.csproj", "{E06441A9-0CFD-45BB-9478-99D28CEB327F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +45,14 @@ Global
{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B9E665AC-92A5-4F53-A021-7B27A8014BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B9E665AC-92A5-4F53-A021-7B27A8014BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B9E665AC-92A5-4F53-A021-7B27A8014BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B9E665AC-92A5-4F53-A021-7B27A8014BC3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E06441A9-0CFD-45BB-9478-99D28CEB327F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E06441A9-0CFD-45BB-9478-99D28CEB327F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E06441A9-0CFD-45BB-9478-99D28CEB327F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E06441A9-0CFD-45BB-9478-99D28CEB327F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -47,6 +61,7 @@ Global
{F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6}
{56329D48-D382-4850-93DE-59C453894E8A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6}
{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6}
+ {E06441A9-0CFD-45BB-9478-99D28CEB327F} = {451F5727-2A2E-4361-A41B-089429ADE8F9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {00D4E149-7131-49F4-BAAD-559AA961A78E}
diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj
index 2771f658..5a7fdc4e 100644
--- a/Crow/Crow.csproj
+++ b/Crow/Crow.csproj
@@ -51,13 +51,13 @@
<PackageReference Include="StbImageSharp" Version="2.22.4" />
</ItemGroup>
- <PropertyGroup Condition=" '$(CrowDebugLogEnabled)' == 'true'" >
+ <PropertyGroup Condition=" '$(CrowDebugLogEnabled)' == 'true'">
<DefineConstants>$(DefineConstants);DEBUG_LOG</DefineConstants>
</PropertyGroup>
- <PropertyGroup Condition=" '$(CrowDebugStatsEnabled)' == 'true'" >
+ <PropertyGroup Condition=" '$(CrowDebugStatsEnabled)' == 'true'">
<DefineConstants>$(DefineConstants);DEBUG_STATS</DefineConstants>
</PropertyGroup>
- <PropertyGroup Condition=" '$(CrowDesignModeEnabled)' == 'true'" >
+ <PropertyGroup Condition=" '$(CrowDesignModeEnabled)' == 'true'">
<DefineConstants>$(DefineConstants);DESIGN_MODE</DefineConstants>
</PropertyGroup>
<!--<ItemGroup>
@@ -74,8 +74,7 @@
</ItemGroup>
<ItemGroup Condition=" '$(CrowVkvgBackend)' != 'true'">
- <Compile Include="src\GraphicBackends\Mono.Cairo\**\*.*"
- Exclude="src\GraphicBackends\Mono.Cairo\NativeMethods-internal.cs" />
+ <Compile Include="src\GraphicBackends\Mono.Cairo\**\*.*" Exclude="src\GraphicBackends\Mono.Cairo\NativeMethods-internal.cs" />
</ItemGroup>
<ItemGroup>
@@ -92,4 +91,8 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Remove="src\Widgets\ColorPicker2.cs" />
</ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Drawing2D\Drawing2D.csproj" />
+ </ItemGroup>
</Project>
diff --git a/Crow/src/2d/RectangleD.cs b/Crow/src/2d/RectangleD.cs
deleted file mode 100644
index 817b3adc..00000000
--- a/Crow/src/2d/RectangleD.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
-//
-// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-using System;
-using System.Runtime.InteropServices;
-
-namespace Crow {
- [StructLayout(LayoutKind.Sequential)]
- public struct RectangleD
- {
- public static readonly RectangleD Zero = new RectangleD (0, 0, 0, 0);
-
- public double X, Y, Width, Height;
-
- #region ctor
- public RectangleD(PointD p, Size s): this (p.X, p.Y, s.Width, s.Height) { }
- public RectangleD(SizeD s) : this (0, 0, s.Width, s.Height) { }
- public RectangleD(double x, double y, double width, double height) {
- X = x;
- Y = y;
- Width = width;
- Height = height;
- }
- #endregion
-
- #region PROPERTIES
- [XmlIgnore]public double Left{
- get => X;
- set { X = value; }
- }
- [XmlIgnore]public double Top{
- get => Y;
- set { Y = value; }
- }
- [XmlIgnore] public double Right => X + Width;
- [XmlIgnore]public double Bottom => Y + Height;
- [XmlIgnore]public SizeD Size{
- get => new SizeD (Width, Height);
- set {
- Width = value.Width;
- Height = value.Height;
- }
- }
- [XmlIgnore]public PointD Position{
- get => new PointD (X, Y);
- set {
- X = value.X;
- Y = value.Y;
- }
- }
- [XmlIgnore]public PointD TopLeft{
- get => new PointD (X, Y);
- set {
- X = value.X;
- Y = value.Y;
- }
- }
- [XmlIgnore] public PointD TopRight => new PointD (Right, Y);
- [XmlIgnore] public PointD BottomLeft => new PointD (X, Bottom);
- [XmlIgnore] public PointD BottomRight => new PointD (Right, Bottom);
- [XmlIgnore] public PointD Center => new PointD (Left + Width / 2, Top + Height / 2);
- [XmlIgnore] public PointD CenterD => new PointD (Left + Width / 2.0, Top + Height / 2.0);
-
- #endregion
-
- #region FUNCTIONS
- public void Inflate(double xDelta, double yDelta)
- {
- this.X -= xDelta;
- this.Width += 2 * xDelta;
- this.Y -= yDelta;
- this.Height += 2 * yDelta;
- }
- public void Inflate(double delta)
- {
- Inflate (delta, delta);
- }
- public RectangleD Inflated (double delta) => Inflated (delta, delta);
- public RectangleD Inflated (double deltaX, double deltaY) {
- RectangleD r = this;
- r.Inflate (deltaX, deltaY);
- return r;
- }
- public bool ContainsOrIsEqual (PointD p) => (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height);
- public bool ContainsOrIsEqual (RectangleD r) => r.TopLeft >= this.TopLeft && r.BottomRight <= this.BottomRight;
- public bool Intersect(RectangleD r)
- {
- double maxLeft = Math.Max(this.Left, r.Left);
- double minRight = Math.Min(this.Right, r.Right);
- double maxTop = Math.Max(this.Top, r.Top);
- double minBottom = Math.Min(this.Bottom, r.Bottom);
-
- return (maxLeft < minRight) && (maxTop < minBottom);
- }
- public RectangleD Intersection(RectangleD r)
- {
- RectangleD result = new RectangleD();
-
- if (r.Left >= Left)
- result.Left = r.Left;
- else
- result.TopLeft = TopLeft;
-
- if (r.Right >= Right)
- result.Width = Right - result.Left;
- else
- result.Width = r.Right - result.Left;
-
- if (r.Top >= Top)
- result.Top = r.Top;
- else
- result.Top = Top;
-
- if (r.Bottom >= Bottom)
- result.Height = Bottom - result.Top;
- else
- result.Height = r.Bottom - result.Top;
-
- return result;
- }
- #endregion
-
- #region operators
- public static RectangleD operator +(RectangleD r1, RectangleD r2)
- {
- double x = Math.Min(r1.X, r2.X);
- double y = Math.Min(r1.Y, r2.Y);
- double x2 = Math.Max(r1.Right, r2.Right);
- double y2 = Math.Max(r1.Bottom, r2.Bottom);
- return new RectangleD(x, y, x2 - x, y2 - y);
- }
- public static RectangleD operator + (RectangleD r, PointD p) => new RectangleD (r.X + p.X, r.Y + p.Y, r.Width, r.Height);
- public static RectangleD operator - (RectangleD r, PointD p) => new RectangleD (r.X - p.X, r.Y - p.Y, r.Width, r.Height);
- public static bool operator == (RectangleD r1, RectangleD r2) => r1.TopLeft == r2.TopLeft && r1.Size == r2.Size;
- public static bool operator != (RectangleD r1, RectangleD r2) => !(r1.TopLeft == r2.TopLeft && r1.Size == r2.Size);
-
- public static implicit operator RectangleD(Rectangle r) => new RectangleD(r.X,r.Y,r.Width,r.Height);
- #endregion
-
- public override string ToString () => $"{X},{Y},{Width},{Height}";
- public static RectangleD Parse(string s)
- {
- string[] d = s.Split(new char[] { ',' });
- return new RectangleD(
- double.Parse(d[0]),
- double.Parse(d[1]),
- double.Parse(d[2]),
- double.Parse(d[3]));
- }
- public override int GetHashCode ()
- {
- unchecked // Overflow is fine, just wrap
- {
- int hash = 17;
- // Suitable nullity checks etc, of course :)
- hash = hash * 23 + X.GetHashCode();
- hash = hash * 23 + Y.GetHashCode();
- hash = hash * 23 + Width.GetHashCode();
- hash = hash * 23 + Height.GetHashCode();
- return hash;
- }
- }
- public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (RectangleD)) ?
- false : this == (RectangleD)obj;
- }
-}
diff --git a/Crow/src/Cairo/CairoHelpers.cs b/Crow/src/Cairo/CairoHelpers.cs
index ea9a94ba..200ced48 100644
--- a/Crow/src/Cairo/CairoHelpers.cs
+++ b/Crow/src/Cairo/CairoHelpers.cs
@@ -1,14 +1,14 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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 Crow.Drawing;
+using Drawing2D;
namespace Crow
{
public static class CairoHelpers
- {
+ {
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
{
if (val.CompareTo(min) < 0) return min;
@@ -33,18 +33,18 @@ namespace Crow
return arr[minp];
}
- public static void CairoRectangle(Context gr, RectangleD r, double radius, double stroke = 0.0)
+ public static void CairoRectangle(IContext gr, RectangleD r, double radius, double stroke = 0.0)
{
if (radius > 0)
DrawRoundedRectangle (gr, r, radius, stroke);
else
gr.Rectangle (r, stroke);
}
- public static void CairoCircle(Context gr, RectangleD r)
+ public static void CairoCircle(IContext gr, RectangleD r)
{
gr.Arc(r.X + r.Width/2.0, r.Y + r.Height/2.0, Math.Min(r.Width,r.Height)/2.0, 0, 2.0*Math.PI);
}
- public static void DrawRoundedRectangle(Context gr, RectangleD r, double radius, double stroke = 0.0)
+ public static void DrawRoundedRectangle(IContext gr, RectangleD r, double radius, double stroke = 0.0)
{
if (stroke>0.0) {
gr.LineWidth = stroke;
@@ -54,7 +54,7 @@ namespace Crow
}else
DrawRoundedRectangle(gr, r.X, r.Y, r.Width, r.Height, radius);
}
- public static void DrawRoundedRectangle(Context gr, double x, double y, double width, double height, double radius)
+ public static void DrawRoundedRectangle(IContext gr, double x, double y, double width, double height, double radius)
{
//gr.Save();
@@ -72,7 +72,7 @@ namespace Crow
gr.ClosePath();
//gr.Restore();
}
- public static void StrokeRaisedRectangle(Context gr, Rectangle r, double width = 1)
+ public static void StrokeRaisedRectangle(IContext gr, Rectangle r, double width = 1)
{
//gr.Save();
r.Inflate((int)-width / 2, (int)-width / 2);
@@ -91,7 +91,7 @@ namespace Crow
//gr.Restore();
}
- public static void StrokeLoweredRectangle(Context gr, Rectangle r, double width = 1)
+ public static void StrokeLoweredRectangle(IContext gr, Rectangle r, double width = 1)
{
//gr.Save();
r.Inflate((int)-width / 2, (int)-width / 2);
diff --git a/Crow/src/DebugUtils/DbgEvent.cs b/Crow/src/DebugUtils/DbgEvent.cs
index e3144d90..791dc544 100644
--- a/Crow/src/DebugUtils/DbgEvent.cs
+++ b/Crow/src/DebugUtils/DbgEvent.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
+using Drawing2D;
namespace Crow.DebugLogger
{
diff --git a/Crow/src/DebugUtils/DbgLayoutEvent.cs b/Crow/src/DebugUtils/DbgLayoutEvent.cs
index 750ac31a..18d4a270 100644
--- a/Crow/src/DebugUtils/DbgLayoutEvent.cs
+++ b/Crow/src/DebugUtils/DbgLayoutEvent.cs
@@ -1,10 +1,8 @@
// Copyright (c) 2013-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.Collections.Generic;
-using System.Threading;
+using Drawing2D;
namespace Crow.DebugLogger
{
public class DbgLayoutEvent : DbgWidgetEvent
@@ -49,6 +47,6 @@ namespace Crow.DebugLogger
return Colors.Orange;
}
}
- }
+ }
}
} \ No newline at end of file
diff --git a/Crow/src/DebugUtils/DbgWidgetEvent.cs b/Crow/src/DebugUtils/DbgWidgetEvent.cs
index cf61a79b..6f3f1dff 100644
--- a/Crow/src/DebugUtils/DbgWidgetEvent.cs
+++ b/Crow/src/DebugUtils/DbgWidgetEvent.cs
@@ -1,9 +1,7 @@
// Copyright (c) 2013-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.Collections.Generic;
-using System.Threading;
+using Drawing2D;
namespace Crow.DebugLogger
{
diff --git a/Crow/src/ExtensionsMethods.cs b/Crow/src/ExtensionsMethods.cs
index 5bd9382e..41c31a64 100644
--- a/Crow/src/ExtensionsMethods.cs
+++ b/Crow/src/ExtensionsMethods.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -9,7 +9,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using Crow.Drawing;
+using Drawing2D;
namespace Crow
{
@@ -17,7 +17,7 @@ namespace Crow
{
#region Cairo extensions
- public static void Rectangle(this Context ctx, Rectangle r, double stroke = 0.0)
+ public static void Rectangle(this IContext ctx, Rectangle r, double stroke = 0.0)
{
if (stroke > 0.0) {
ctx.LineWidth = stroke;
@@ -51,7 +51,7 @@ namespace Crow
public static PointD Multiply(this PointD p1, double v){
return new PointD(p1.X * v, p1.Y * v);
}
- public static void DrawCote(this Context ctx, PointD p1, PointD p2,
+ public static void DrawCote(this IContext ctx, PointD p1, PointD p2,
double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0)
{
PointD vDir = p2.Substract(p1);
@@ -88,7 +88,7 @@ namespace Crow
ctx.LineWidth = stroke;
ctx.Stroke ();
}
- public static void DrawCoteInverse(this Context ctx, PointD p1, PointD p2,
+ public static void DrawCoteInverse(this IContext ctx, PointD p1, PointD p2,
double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0)
{
PointD vDir = p2.Substract(p1);
@@ -120,7 +120,7 @@ namespace Crow
ctx.LineWidth = stroke;
ctx.Stroke ();
}
- public static void DrawCoteFixed(this Context ctx, PointD p1, PointD p2,
+ public static void DrawCoteFixed(this IContext ctx, PointD p1, PointD p2,
double stroke = 1.0, double coteWidth = 3.0)
{
PointD vDir = p2.Substract(p1);
diff --git a/Crow/src/Fill/BmpPicture.cs b/Crow/src/Fill/BmpPicture.cs
index 6bf9add5..faefd4ed 100644
--- a/Crow/src/Fill/BmpPicture.cs
+++ b/Crow/src/Fill/BmpPicture.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -6,7 +6,8 @@ using System;
using System.IO;
using System.Runtime.InteropServices;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -103,12 +104,12 @@ namespace Crow
image = new byte[bitmapSize];
System.Runtime.InteropServices.Marshal.Copy (data.Scan0, image, 0, bitmapSize);
- bitmap.UnlockBits (data);
+ bitmap.UnlockBits (data);
}*/
#region implemented abstract members of Fill
public override bool IsLoaded => image != null;
- public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle))
+ public override void SetAsSource (Interface iFace, IContext ctx, Rectangle bounds = default(Rectangle))
{
if (image == null)
load (iFace);
@@ -133,14 +134,14 @@ namespace Crow
#else
using (Surface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
#endif
- using (Context gr = new Context (tmp)) {
+ using (IContext 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);
#if VKVG
- using (Surface imgSurf = new Surface (iFace.vkvgDevice, image, Dimensions.Width, Dimensions.Height))
+ 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))
+ using (Surface imgSurf = new ImageSurface (image, Format.Argb32, Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width))
#endif
{
gr.SetSource (imgSurf, 0,0);
@@ -148,7 +149,7 @@ namespace Crow
}
}
ctx.SetSource (tmp);
- }
+ }
}
#endregion
@@ -159,7 +160,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 (Interface iFace, Context gr, Rectangle rect, string subPart = "")
+ public override void Paint (Interface iFace, IContext gr, Rectangle rect, string subPart = "")
{
if (image == null)
load (iFace);
@@ -188,11 +189,11 @@ namespace Crow
gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2);
#if VKVG
- using (Surface imgSurf = new Surface (iFace.vkvgDevice, image, Dimensions.Width, Dimensions.Height))
+ 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 (Surface imgSurf = new ImageSurface (image, Format.Argb32, Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width))
+#endif
+ {
gr.SetSource (imgSurf, 0,0);
gr.Paint ();
}
diff --git a/Crow/src/Fill/Fill.cs b/Crow/src/Fill/Fill.cs
index 2faeca80..338e40c6 100644
--- a/Crow/src/Fill/Fill.cs
+++ b/Crow/src/Fill/Fill.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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 Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -17,13 +18,13 @@ namespace Crow
/// </summary>
/// <param name="ctx">backend context</param>
/// <param name="bounds">paint operation bounding box, unused for SolidColor</param>
- public abstract void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle));
+ public abstract void SetAsSource (Interface iFace, IContext ctx, Rectangle bounds = default(Rectangle));
public static Fill Parse (string s){
ReadOnlySpan<char> tmp = s.AsSpan ();
if (tmp.Length == 0)
return null;
if (tmp.Length > 8 && tmp.Slice (1, 8).SequenceEqual ("gradient"))
- return (Fill)Gradient.Parse (s);
+ return (Fill)Gradient.Parse (s);
if (tmp.EndsWith (".svg", StringComparison.OrdinalIgnoreCase) ||
tmp.EndsWith (".png", StringComparison.OrdinalIgnoreCase) ||
tmp.EndsWith (".jpg", StringComparison.OrdinalIgnoreCase) ||
diff --git a/Crow/src/Fill/Gradient.cs b/Crow/src/Fill/Gradient.cs
index 2d344c73..ba461518 100644
--- a/Crow/src/Fill/Gradient.cs
+++ b/Crow/src/Fill/Gradient.cs
@@ -1,11 +1,12 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.Collections.Generic;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -58,7 +59,7 @@ namespace Crow
#region implemented abstract members of Fill
- public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle))
+ public override void SetAsSource (Interface iFace, IContext ctx, Rectangle bounds = default(Rectangle))
{
Crow.Drawing.Gradient grad = null;
switch (GradientType) {
diff --git a/Crow/src/Fill/Picture.cs b/Crow/src/Fill/Picture.cs
index b915f6d4..b5655c1a 100644
--- a/Crow/src/Fill/Picture.cs
+++ b/Crow/src/Fill/Picture.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -6,7 +6,8 @@ using System;
using System.IO;
using System.Collections.Generic;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -24,7 +25,7 @@ namespace Crow
}
/// <summary>
/// virtual class for loading and drawing picture in the interface
- ///
+ ///
/// Every loaded resources are stored in a dictonary with their path as key and shared
/// among interface elements
/// </summary>
@@ -72,7 +73,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 abstract void Paint(Interface iFace, Context ctx, Rectangle rect, string subPart = "");
+ public abstract void Paint(Interface iFace, IContext ctx, Rectangle rect, string subPart = "");
public abstract bool IsLoaded { get; }
public abstract void load (Interface iface);
#region Operators
@@ -84,12 +85,12 @@ namespace Crow
{
if (string.IsNullOrEmpty (path))
return null;
-
+
Picture _pic = null;
- if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
+ if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
_pic = new SvgPicture (path);
- else
+ else
_pic = new BmpPicture (path);
return _pic;
diff --git a/Crow/src/Fill/SolidColor.cs b/Crow/src/Fill/SolidColor.cs
index 6977a8bc..199c4788 100644
--- a/Crow/src/Fill/SolidColor.cs
+++ b/Crow/src/Fill/SolidColor.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -10,7 +10,8 @@ using System.Xml.Serialization;
using System.Reflection;
using System.Diagnostics;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -25,7 +26,7 @@ namespace Crow
#endregion
#region implemented abstract members of Fill
- public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default)
+ public override void SetAsSource (Interface iFace, IContext ctx, Rectangle bounds = default)
{
ctx.SetSource (color.R / 255.0, color.G / 255.0, color.B / 255.0, color.A / 255.0);
}
diff --git a/Crow/src/Fill/SvgPicture.cs b/Crow/src/Fill/SvgPicture.cs
index 80d380ed..0bd85f75 100644
--- a/Crow/src/Fill/SvgPicture.cs
+++ b/Crow/src/Fill/SvgPicture.cs
@@ -1,11 +1,12 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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 Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -67,7 +68,7 @@ namespace Crow
#region implemented abstract members of Fill
public override bool IsLoaded => hSVG != null;
- public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle))
+ public override void SetAsSource (Interface iFace, IContext ctx, Rectangle bounds = default(Rectangle))
{
if (hSVG == null)
load (iFace);
@@ -92,7 +93,7 @@ namespace Crow
#else
using (Surface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
#endif
- using (Context gr = new Context (tmp)) {
+ using (IContext 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);
@@ -111,7 +112,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 this coma separated list of svg part identified with their svg 'id' attribute.</param>
- public override void Paint (Interface iFace, Context gr, Rectangle rect, string subPart = "")
+ public override void Paint (Interface iFace, IContext gr, Rectangle rect, string subPart = "")
{
if (hSVG == null)
load (iFace);
diff --git a/Crow/src/Font.cs b/Crow/src/Font.cs
index 0d6534ff..acfe9760 100644
--- a/Crow/src/Font.cs
+++ b/Crow/src/Font.cs
@@ -3,7 +3,7 @@
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
-using Crow.Drawing;
+
namespace Crow
{
@@ -40,7 +40,7 @@ namespace Crow
}
public FontSlant Slant {
- get{
+ get{
switch (Style) {
case FontStyle.Italic:
return FontSlant.Italic;
@@ -50,19 +50,19 @@ namespace Crow
}
}
public FontWeight Wheight {
- get{
+ get{
switch (Style) {
case FontStyle.Bold:
return FontWeight.Bold;
default:
return FontWeight.Normal;
- }
+ }
}
}
#region Operators
public static implicit operator string(Font c) => c.ToString();
-
+
public static implicit operator Font(string s) => (Font)Parse(s);
#endregion
@@ -90,7 +90,7 @@ namespace Crow
f.Style = EnumsNET.Enums.Parse<FontStyle> (tmp.Slice (ioc + 1).ToString (), true);
}
}
- return f;
+ return f;
}
}
}
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Antialias.cs b/Crow/src/GraphicBackends/Mono.Cairo/Antialias.cs
deleted file mode 100644
index fd98f604..00000000
--- a/Crow/src/GraphicBackends/Mono.Cairo/Antialias.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Mono.Cairo.Antialias.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 Antialias
- {
- Default,
- None,
- Grey,
- Subpixel,
- }
-}
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Format.cs b/Crow/src/GraphicBackends/Mono.Cairo/Format.cs
deleted file mode 100644
index 4078b168..00000000
--- a/Crow/src/GraphicBackends/Mono.Cairo/Format.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Mono.Cairo.Format.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 Format
- {
- Argb32 = 0,
- Rgb24 = 1,
- A8 = 2,
- A1 = 3,
- Rgb16565 = 4,
-
- //[Obsolete ("Use Argb32")]
- ARGB32 = Argb32,
- //[Obsolete ("Use Rgb24")]
- RGB24 = Rgb24,
- }
-}
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Operator.cs b/Crow/src/GraphicBackends/Mono.Cairo/Operator.cs
deleted file mode 100644
index 7de2d11e..00000000
--- a/Crow/src/GraphicBackends/Mono.Cairo/Operator.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// Mono.Cairo.Operator.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 Operator
- {
- Clear,
- Source,
- Over,
- In,
- Out,
- Atop,
-
- Dest,
- DestOver,
- DestIn,
- DestOut,
- DestAtop,
-
- Xor,
- Add,
- Saturate,
- Multiply,
- Screen,
- Overlay,
- Darken,
- Lighten,
-
- }
-}
diff --git a/Crow/src/GraphicBackends/vkvg/Enums.cs b/Crow/src/GraphicBackends/vkvg/Enums.cs
deleted file mode 100644
index c76a4c3b..00000000
--- a/Crow/src/GraphicBackends/vkvg/Enums.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright (c) 2018-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-
-using System;
-
-namespace Crow.Drawing
-{
- public enum Status
- {
- Success = 0,
- NoMemory,
- InvalidRestore,
- InvalidPopGroup,
- NoCurrentPoint,
- InvalidMatrix,
- InvalidStatus,
- NullPointer,
- InvalidString,
- InvalidPathData,
- ReadError,
- WriteError,
- SurfaceFinished,
- SurfaceTypeMismatch,
- PatternTypeMismatch,
- InvalidContent,
- InvalidFormat,
- InvalidVisual,
- FileNotFound,
- InvalidDash
- }
-
- public enum Direction
- {
- Horizontal = 0,
- Vertical = 1
- }
-
- public enum Format
- {
- ARGB32,
- RGB24,
- A8,
- A1
- }
-
- public enum Extend
- {
- None,
- Repeat,
- Reflect,
- Pad
- }
-
- public enum Filter
- {
- Fast,
- Good,
- Best,
- Nearest,
- Bilinear,
- Gaussian,
- }
-
- public enum PatternType
- {
- Solid,
- Surface,
- Linear,
- Radial,
- Mesh,
- RasterSource,
- }
-
- public enum Operator
- {
- Clear,
- Source,
- Over,
- In,
- Out,
- Atop,
-
- Dest,
- DestOver,
- DestIn,
- DestOut,
- DestAtop,
-
- Xor,
- Add,
- Saturate,
- }
-
- public enum FontSlant
- {
- Normal,
- Italic,
- Oblique
- }
- public enum FontWeight
- {
- Normal,
- Bold,
- }
-
- public enum SampleCount
- {
- Sample_1 = 0x00000001,
- Sample_2 = 0x00000002,
- Sample_4 = 0x00000004,
- Sample_8 = 0x00000008,
- Sample_16 = 0x00000010,
- Sample_32 = 0x00000020,
- Sample_64 = 0x00000040
- }
-
- public enum LineCap
- {
- Butt,
- Round,
- Square
- }
-
- public enum LineJoin
- {
- Miter,
- Round,
- Bevel
- }
- public enum FillRule
- {
- EvenOdd,
- NonZero,
- }
- public enum Antialias
- {
- Default,
- None,
- Grey,
- Subpixel,
- }
-} \ No newline at end of file
diff --git a/Crow/src/GraphicBackends/vkvg/TextExtents.cs b/Crow/src/GraphicBackends/vkvg/TextExtents.cs
deleted file mode 100644
index bd320e40..00000000
--- a/Crow/src/GraphicBackends/vkvg/TextExtents.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2018-2020 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.Runtime.InteropServices;
-
-namespace Crow.Drawing
-{
- [StructLayout (LayoutKind.Sequential)]
- public struct TextExtents
- {
- float xbearing;
- float ybearing;
- float width;
- float height;
- float xadvance;
- float yadvance;
-
- public float XBearing {
- get { return xbearing; }
- set { xbearing = value; }
- }
-
- public float YBearing {
- get { return ybearing; }
- set { ybearing = value; }
- }
-
- public float Width {
- get { return width; }
- set { width = value; }
- }
-
- public float Height {
- get { return height; }
- set { height = value; }
- }
-
- public float XAdvance {
- get { return xadvance; }
- set { xadvance = value; }
- }
-
- public float 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/Crow/src/Input/MouseEventArgs.cs b/Crow/src/Input/MouseEventArgs.cs
index 9b242dd6..7fd025e3 100644
--- a/Crow/src/Input/MouseEventArgs.cs
+++ b/Crow/src/Input/MouseEventArgs.cs
@@ -1,9 +1,10 @@
// Copyright (c) 2006-2014 Stefanos Apostolopoulos <stapostol@gmail.com>
-// Copyright (c) 2014-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2014-2022 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 Glfw;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs
index d3dd99f4..4db0163f 100644
--- a/Crow/src/Interface.cs
+++ b/Crow/src/Interface.cs
@@ -15,10 +15,12 @@ using System.Runtime.InteropServices;
using System.Threading;
using Crow.IML;
-using Crow.Drawing;
+
using Glfw;
using Path = System.IO.Path;
+using Drawing2D;
+
namespace Crow
{
/// <summary>
@@ -179,14 +181,9 @@ namespace Crow
hWin = glfwWindowHandle;
PerformanceMeasure.InitMeasures ();
}
-#if VKVG
- /// <summary>
- /// constant boolean telling if crow assembly was built with `VKVG` support.
- /// </summary>
- public const bool HaveVkvgBackend = true;
-#else
- public const bool HaveVkvgBackend = false;
-#endif
+ IDevice dev;
+ public IDevice Device => dev;
+
/// <summary>
/// Create a standard Crow interface.
/// </summary>
@@ -323,7 +320,7 @@ namespace Crow
#if (VKVG)
vkCtx.CreateSurface (clientRectangle.Width, clientRectangle.Height, ref surf);
#else
- surf = new ImageSurface (Format.Argb32, r.Width, r.Height);
+ surf = new ImageSurface (Format.ARGB32, r.Width, r.Height);
#endif
}
public Surface CreateSurface (ref Rectangle r) {
@@ -1188,7 +1185,7 @@ namespace Crow
/// - Drawing
/// Result: the Interface bitmap is drawn in memory (byte[] bmp) and a dirtyRect and bitmap are available
/// </summary>
- public void Update(Context ctx = null){
+ public void Update(IContext ctx = null){
CrowThread[] tmpThreads;
lock (CrowThreads) {
@@ -1308,7 +1305,7 @@ namespace Crow
PerformanceMeasure.End (PerformanceMeasure.Kind.Clipping);
DbgLogger.EndEvent (DbgEvtType.ClippingRegistration, true);
}
- void clear(Context ctx) {
+ void clear(IContext ctx) {
for (int i = 0; i < clipping.NumRectangles; i++)
ctx.Rectangle (clipping.GetRectangle (i));
@@ -1345,7 +1342,7 @@ namespace Crow
/// <summary>Clipping Rectangles drive the drawing process. For compositing, each object under a clip rectangle should be
/// repainted. If it contains also clip rectangles, its cache will be update, or if not cached a full redraw will take place</summary>
- protected virtual void processDrawing(Context ctx){
+ protected virtual void processDrawing(IContext ctx){
DbgLogger.StartEvent (DbgEvtType.ProcessDrawing);
PerformanceMeasure.Begin (PerformanceMeasure.Kind.Drawing);
@@ -1429,7 +1426,7 @@ namespace Crow
RegisterClip (w.ScreenCoordinates (w.Slot));
}
[Conditional ("DEBUG_HIGHLIGHT_FOCUS")]
- void debugHighlightFocus (Context ctx) {
+ void debugHighlightFocus (IContext ctx) {
if (HoverWidget!= null) {
ctx.SetSource (Colors.Purple);
ctx.Rectangle (HoverWidget.ScreenCoordinates (HoverWidget.Slot), 1);
@@ -1456,7 +1453,7 @@ namespace Crow
internal Rectangle? textCursor = null;//last printed cursor, used to clear it.
public bool forceTextCursor = true;//when true, cursor is printed even if blinkingCursor.elapsed is not reached.
Stopwatch blinkingCursor = Stopwatch.StartNew ();
- void drawTextCursor (Context ctx) {
+ void drawTextCursor (IContext ctx) {
if (forceTextCursor) {
if (FocusedWidget is IEditableTextWidget lab) {
if (lab.DrawCursor (ctx, out Rectangle c)) {
diff --git a/Crow/src/Text/IEditableTextWidget.cs b/Crow/src/Text/IEditableTextWidget.cs
index d72f1de7..2dce5009 100644
--- a/Crow/src/Text/IEditableTextWidget.cs
+++ b/Crow/src/Text/IEditableTextWidget.cs
@@ -1,8 +1,9 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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 Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -20,6 +21,6 @@ namespace Crow
/// <param name="ctx">The master interface context on which to draw the cursor</param>
/// <param name="rect">Return a clipping rectangle containing the cursor position to be cleared when needed</param>
/// <returns>True if cursor were drawed, false otherwise</returns>
- bool DrawCursor (Context ctx, out Rectangle rect);
+ bool DrawCursor (IContext ctx, out Rectangle rect);
}
} \ No newline at end of file
diff --git a/Crow/src/Widgets/Border.cs b/Crow/src/Widgets/Border.cs
index 1957498f..95aa1a52 100644
--- a/Crow/src/Widgets/Border.cs
+++ b/Crow/src/Widgets/Border.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.ComponentModel;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -100,7 +101,7 @@ namespace Crow
int tmp = base.measureRawSize (lt);
return tmp < 0 ? tmp : tmp + 2 * BorderWidth;
}*/
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
drawborder2 (gr);
@@ -114,7 +115,7 @@ namespace Crow
//gr.Restore ();
}
- void drawborder2(Context gr){
+ void drawborder2(IContext gr){
Rectangle rBack = new Rectangle (Slot.Size);
//rBack.Inflate (-Margin);
@@ -201,7 +202,7 @@ namespace Crow
}
}
}
- void drawborder1(Context gr){
+ void drawborder1(IContext gr){
Rectangle rBack = new Rectangle (Slot.Size);
//rBack.Inflate (-Margin);
diff --git a/Crow/src/Widgets/CircleMeter.cs b/Crow/src/Widgets/CircleMeter.cs
index e076ca66..56550f57 100644
--- a/Crow/src/Widgets/CircleMeter.cs
+++ b/Crow/src/Widgets/CircleMeter.cs
@@ -1,10 +1,11 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.ComponentModel;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow {
public class CircleMeter : Gauge {
@@ -14,7 +15,7 @@ namespace Crow {
#endregion
double startAngle, endAngle;
- int lineWidth, backgroundLineWidth;
+ int lineWidth, backgroundLineWidth;
/// <summary>
/// Starting andle in degree corresponding to the minimum value
/// </summary>
@@ -60,7 +61,7 @@ namespace Crow {
}
/// <summary>
/// Line width used to draw the background arc from start to end angle
- /// </summary>
+ /// </summary>
[DefaultValue (10)]
public int BackgroundLineWidth {
get => backgroundLineWidth;
@@ -73,7 +74,7 @@ namespace Crow {
}
}
const double rad = Math.PI * 2.0 / 360.0;
- protected override void onDraw (Context gr) {
+ protected override void onDraw (IContext gr) {
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
/*Rectangle r = new Rectangle (Slot.Size);
@@ -112,7 +113,7 @@ namespace Crow {
gr.Arc (r.CenterD, radius, sArad, sArad + valAngle);
else
gr.ArcNegative (r.CenterD, radius, sArad, sArad + valAngle);
- gr.Stroke ();
+ gr.Stroke ();
/*} else {
double valAngle = (sArad - sErad) * valRatio;
}*/
diff --git a/Crow/src/Widgets/ColorSelector.cs b/Crow/src/Widgets/ColorSelector.cs
index aa6a1aa9..89f44204 100644
--- a/Crow/src/Widgets/ColorSelector.cs
+++ b/Crow/src/Widgets/ColorSelector.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using Glfw;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/ColorSlider.cs b/Crow/src/Widgets/ColorSlider.cs
index 04182918..605212da 100644
--- a/Crow/src/Widgets/ColorSlider.cs
+++ b/Crow/src/Widgets/ColorSlider.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -6,7 +6,8 @@ using System;
using System.ComponentModel;
using Glfw;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -136,7 +137,7 @@ namespace Crow
base.onMouseDown (sender, e);
}
- protected override void onDraw (Context gr) {
+ protected override void onDraw (IContext gr) {
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
base.onDraw (gr);
diff --git a/Crow/src/Widgets/ComboBox.cs b/Crow/src/Widgets/ComboBox.cs
index 22103ac3..71a2b2fc 100644
--- a/Crow/src/Widgets/ComboBox.cs
+++ b/Crow/src/Widgets/ComboBox.cs
@@ -1,6 +1,7 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/DockStack.cs b/Crow/src/Widgets/DockStack.cs
index d75df567..6d1a835d 100644
--- a/Crow/src/Widgets/DockStack.cs
+++ b/Crow/src/Widgets/DockStack.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.Text;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/DockWindow.cs b/Crow/src/Widgets/DockWindow.cs
index 51e89885..d0b57191 100644
--- a/Crow/src/Widgets/DockWindow.cs
+++ b/Crow/src/Widgets/DockWindow.cs
@@ -1,10 +1,11 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.Xml.Serialization;
-using Crow.Drawing;
+
+using Drawing2D;
using Glfw;
@@ -200,7 +201,7 @@ namespace Crow
break;
}
Surface dragImg = IFace.CreateSurface (r.Width, r.Height);
- using (Context gr = new Context(dragImg)) {
+ using (IContext gr = new Context(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/Gauge.cs b/Crow/src/Widgets/Gauge.cs
index b0e34ca6..8cab26c1 100644
--- a/Crow/src/Widgets/Gauge.cs
+++ b/Crow/src/Widgets/Gauge.cs
@@ -1,11 +1,12 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.ComponentModel;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow {
public class Gauge : Widget
@@ -93,7 +94,7 @@ namespace Crow {
}
#endregion
- protected override void onDraw (Context gr) {
+ protected override void onDraw (IContext gr) {
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
base.onDraw (gr);
diff --git a/Crow/src/Widgets/GroupBase.cs b/Crow/src/Widgets/GroupBase.cs
index bed807e0..1de8787f 100644
--- a/Crow/src/Widgets/GroupBase.cs
+++ b/Crow/src/Widgets/GroupBase.cs
@@ -9,7 +9,7 @@ using System.ComponentModel;
using System.Threading;
using static Crow.Logger;
-using Crow.Drawing;
+
namespace Crow
{
@@ -220,7 +220,7 @@ namespace Crow
}
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
@@ -247,11 +247,11 @@ namespace Crow
DbgLogger.EndEvent (DbgEvtType.GODraw);
}
- protected override void UpdateCache (Context ctx)
+ protected override void UpdateCache (IContext ctx)
{
DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
if (!Clipping.IsEmpty) {
- using (Context gr = new Context (bmp)) {
+ using (IContext gr = new Context (bmp)) {
for (int i = 0; i < Clipping.NumRectangles; i++)
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
diff --git a/Crow/src/Widgets/HueSelector.cs b/Crow/src/Widgets/HueSelector.cs
index c4d3172a..4b46ed54 100644
--- a/Crow/src/Widgets/HueSelector.cs
+++ b/Crow/src/Widgets/HueSelector.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -6,7 +6,8 @@ using System;
using System.Xml.Serialization;
using System.ComponentModel;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -48,7 +49,7 @@ namespace Crow
RegisterForRedraw ();
}
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
base.onDraw (gr);
diff --git a/Crow/src/Widgets/ILayoutable.cs b/Crow/src/Widgets/ILayoutable.cs
index 18cd2ccf..6007f023 100644
--- a/Crow/src/Widgets/ILayoutable.cs
+++ b/Crow/src/Widgets/ILayoutable.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.Collections.Generic;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/Image.cs b/Crow/src/Widgets/Image.cs
index eb6ee0d0..7bcc1d32 100644
--- a/Crow/src/Widgets/Image.cs
+++ b/Crow/src/Widgets/Image.cs
@@ -8,7 +8,7 @@ using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
-using Crow.Drawing;
+
namespace Crow
{
@@ -171,7 +171,7 @@ namespace Crow
else
return _pic.Dimensions.Height + 2 * Margin;
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
base.onDraw (gr);
diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs
index 15a38357..e012f352 100644
--- a/Crow/src/Widgets/Label.cs
+++ b/Crow/src/Widgets/Label.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -7,8 +7,9 @@ using System.Linq;
using System.ComponentModel;
using Glfw;
-using Crow.Drawing;
+
using Crow.Text;
+using Drawing2D;
namespace Crow
{
@@ -363,7 +364,7 @@ namespace Crow
}
}
- protected virtual void measureTextBounds (Context gr) {
+ protected virtual void measureTextBounds (IContext gr) {
fe = gr.FontExtents;
te = new TextExtents ();
@@ -386,7 +387,7 @@ namespace Crow
cachedTextSize.Width = lines[longestLine].LengthInPixel;
textMeasureIsUpToDate = true;
}
- protected virtual void drawContent (Context gr) {
+ protected virtual void drawContent (IContext gr) {
Rectangle cb = ClientRectangle;
fe = gr.FontExtents;
double lineHeight = fe.Ascent + fe.Descent;
@@ -513,7 +514,7 @@ 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 (Context gr = new Context (IFace.surf)) {
+ using (IContext gr = new Context (IFace.surf)) {
setFontForContext (gr);
updateLocation (gr, ClientRectangle.Width, ref hoverLoc);
}
@@ -526,7 +527,7 @@ namespace Crow
return null;
return cursor;
}
- public virtual bool DrawCursor (Context ctx, out Rectangle rect) {
+ public virtual bool DrawCursor (IContext ctx, out Rectangle rect) {
if (CurrentLoc == null) {
rect = default;
return false;
@@ -563,7 +564,7 @@ namespace Crow
return true;
}
- protected void updateLocation (Context gr, int clientWidth, ref CharLocation? location) {
+ protected void updateLocation (IContext gr, int clientWidth, ref CharLocation? location) {
if (location == null)
return;
CharLocation loc = location.Value;
@@ -647,7 +648,7 @@ namespace Crow
getLines ();
if (!textMeasureIsUpToDate) {
- using (Context gr = new Context (IFace.surf)) {
+ using (IContext gr = new Context (IFace.surf)) {
setFontForContext (gr);
measureTextBounds (gr);
}
@@ -656,32 +657,34 @@ namespace Crow
return Margin * 2 + (lt == LayoutingType.Height ? cachedTextSize.Height : cachedTextSize.Width);
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
DbgLogger.StartEvent(DbgEvtType.GODraw, this);
+ try {
+ base.onDraw (gr);
- base.onDraw (gr);
-
- setFontForContext (gr);
+ setFontForContext (gr);
- if (!textMeasureIsUpToDate) {
- lock (linesMutex)
- measureTextBounds (gr);
- }
+ if (!textMeasureIsUpToDate) {
+ lock (linesMutex)
+ measureTextBounds (gr);
+ }
- if (ClipToClientRect) {
- gr.Save ();
- CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
- gr.Clip ();
- }
+ if (ClipToClientRect) {
+ gr.Save ();
+ CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+ gr.Clip ();
+ }
- lock (linesMutex)
- drawContent (gr);
+ lock (linesMutex)
+ drawContent (gr);
- if (ClipToClientRect)
- gr.Restore ();
+ if (ClipToClientRect)
+ gr.Restore ();
- DbgLogger.EndEvent (DbgEvtType.GODraw);
+ } finally {
+ DbgLogger.EndEvent (DbgEvtType.GODraw);
+ }
}
#endregion
diff --git a/Crow/src/Widgets/MenuItem.cs b/Crow/src/Widgets/MenuItem.cs
index 4fc6d86a..d4da43c6 100644
--- a/Crow/src/Widgets/MenuItem.cs
+++ b/Crow/src/Widgets/MenuItem.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.ComponentModel;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/Popper.cs b/Crow/src/Widgets/Popper.cs
index e8ba3fe9..99ddcb32 100644
--- a/Crow/src/Widgets/Popper.cs
+++ b/Crow/src/Widgets/Popper.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.ComponentModel;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/PrivateContainer.cs b/Crow/src/Widgets/PrivateContainer.cs
index d0bd9859..498ba80b 100644
--- a/Crow/src/Widgets/PrivateContainer.cs
+++ b/Crow/src/Widgets/PrivateContainer.cs
@@ -1,9 +1,11 @@
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
-using Crow.Drawing;
+
+using Drawing2D;
+
using static Crow.Logger;
namespace Crow
{
@@ -183,7 +185,7 @@ namespace Crow
RegisterForLayouting (LayoutingType.Height);
}
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
@@ -207,13 +209,13 @@ namespace Crow
DbgLogger.EndEvent (DbgEvtType.GODraw);
}
- protected override void UpdateCache (Context ctx)
+ protected override void UpdateCache (IContext ctx)
{
DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
Rectangle rb = Slot + Parent.ClientRectangle.Position;
if (!Clipping.IsEmpty) {
- using (Context gr = new Context (bmp)) {
+ using (IContext gr = new Context (bmp)) {
for (int i = 0; i < Clipping.NumRectangles; i++)
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
diff --git a/Crow/src/Widgets/SaturationValueSelector.cs b/Crow/src/Widgets/SaturationValueSelector.cs
index 6fc23522..7f0af78a 100644
--- a/Crow/src/Widgets/SaturationValueSelector.cs
+++ b/Crow/src/Widgets/SaturationValueSelector.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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 Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -16,7 +17,7 @@ namespace Crow
#endregion
double v, s;
-
+
public virtual double V {
get { return v; }
set {
@@ -29,7 +30,7 @@ namespace Crow
RegisterForRedraw ();
}
}
-
+
public virtual double S {
get { return s; }
set {
@@ -42,7 +43,7 @@ namespace Crow
RegisterForRedraw ();
}
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
base.onDraw (gr);
diff --git a/Crow/src/Widgets/ScrollBar.cs b/Crow/src/Widgets/ScrollBar.cs
index ebec12f1..efbf3fb1 100644
--- a/Crow/src/Widgets/ScrollBar.cs
+++ b/Crow/src/Widgets/ScrollBar.cs
@@ -3,6 +3,7 @@
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.ComponentModel;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/Scroller.cs b/Crow/src/Widgets/Scroller.cs
index 8eb9aaf3..db563cb0 100644
--- a/Crow/src/Widgets/Scroller.cs
+++ b/Crow/src/Widgets/Scroller.cs
@@ -1,11 +1,12 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.ComponentModel;
-using Crow.Drawing;
+
using Glfw;
+using Drawing2D;
namespace Crow
{
@@ -189,7 +190,7 @@ namespace Crow
return;
updateMaxScroll(layoutType);
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
Rectangle rBack = new Rectangle (Slot.Size);
diff --git a/Crow/src/Widgets/ScrollingStack.cs b/Crow/src/Widgets/ScrollingStack.cs
index 07f968a0..de9c0005 100644
--- a/Crow/src/Widgets/ScrollingStack.cs
+++ b/Crow/src/Widgets/ScrollingStack.cs
@@ -4,7 +4,7 @@
using System;
using System.ComponentModel;
-using Crow.Drawing;
+
namespace Crow {
public class ScrollingStack : GenericStack {
@@ -101,7 +101,7 @@ namespace Crow {
NotifyValueChanged ("ChildRatio", Math.Min (1.0, (double)Children.Count / visibleItems));
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
@@ -132,11 +132,11 @@ namespace Crow {
DbgLogger.EndEvent (DbgEvtType.GODraw);
}
- protected override void UpdateCache (Context ctx)
+ protected override void UpdateCache (IContext ctx)
{
DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
if (!Clipping.IsEmpty) {
- using (Context gr = new Context (bmp)) {
+ using (IContext gr = new Context (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 a70a3a9e..c6cca0d6 100644
--- a/Crow/src/Widgets/Shape.cs
+++ b/Crow/src/Widgets/Shape.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -6,7 +6,8 @@ using System;
using System.ComponentModel;
using System.IO;
using System.Text;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -39,7 +40,7 @@ namespace Crow
char[] buffer = new char[20];
double readDouble ()
{
- int length = 0;
+ int length = 0;
while (Peek () >= 0) {
buffer[length] = (char)Read ();
@@ -54,7 +55,7 @@ namespace Crow
}
return double.Parse (buffer.AsSpan(0, length));
}
- public void Draw (Context gr, bool measure = false)
+ public void Draw (IContext gr, bool measure = false)
{
char c;
@@ -178,7 +179,7 @@ namespace Crow
}
}
/// <summary>
- /// View box
+ /// View box
/// </summary>
[DefaultValue ("32,32")]
public Size Size {
@@ -194,7 +195,7 @@ namespace Crow
}
}
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
base.onDraw (gr);
@@ -243,7 +244,7 @@ namespace Crow
if (size != default (Size))
contentSize = size;
else {
- using (Context ctx = new Context (IFace.surf)) {
+ using (IContext ctx = new Context (IFace.surf)) {
using (PathParser parser = new PathParser (path))
parser.Draw (ctx, true);
Rectangle r = ctx.StrokeExtents ();
diff --git a/Crow/src/Widgets/Slider.cs b/Crow/src/Widgets/Slider.cs
index 8d6615a7..dbd7e58d 100644
--- a/Crow/src/Widgets/Slider.cs
+++ b/Crow/src/Widgets/Slider.cs
@@ -1,10 +1,11 @@
-// Copyright (c) 2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2020-2022 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.ComponentModel;
+using Drawing2D;
namespace Crow
{
diff --git a/Crow/src/Widgets/Splitter.cs b/Crow/src/Widgets/Splitter.cs
index d1f2d97d..e48f184b 100644
--- a/Crow/src/Widgets/Splitter.cs
+++ b/Crow/src/Widgets/Splitter.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 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.ComponentModel;
+using Drawing2D;
namespace Crow
{
@@ -37,11 +38,11 @@ namespace Crow
public override ILayoutable Parent {
get => base.Parent;
set {
- if (value != null) {
+ if (value != null) {
GenericStack gs = value as GenericStack;
if (gs == null)
throw new Exception ("Splitter may only be child of stack");
-
+
}
base.Parent = value;
}
@@ -54,9 +55,9 @@ namespace Crow
else
IFace.MouseCursor = MouseCursor.sb_v_double_arrow;
}
-
+
public override void onMouseMove (object sender, MouseMoveEventArgs e)
- {
+ {
GenericStack gs = Parent as GenericStack;
Rectangle gsRect = gs.ClientRectangle;
Point m = gs.ScreenPointToLocal (e.Position);
@@ -66,7 +67,7 @@ namespace Crow
lock (IFace.UpdateMutex) {
Widget w0 = gs.Children[ptrSplit - 1];
Widget w1 = gs.Children[ptrSplit + 1];
- if (gs.Orientation == Orientation.Horizontal) {
+ if (gs.Orientation == Orientation.Horizontal) {
int x = m.X - Slot.Width / 2 - gs.Spacing;
if (x > w0.Slot.Left + w0.MinimumSize.Width &&
@@ -76,14 +77,14 @@ namespace Crow
w0.Width = new Measure((int)Math.Round (100.0 * (x - w0.Slot.X) / (double)gsRect.Width), Unit.Percent);
else
w0.Width = x - w0.Slot.X;
- }
+ }
if (w1.Width != Measure.Stretched) {
x += Slot.Width + 2 * gs.Spacing;
if (w1.Width.IsRelativeToParent)
w1.Width = new Measure((int)Math.Round (100.0 * (w1.Slot.Right - x) / (double)gsRect.Width), Unit.Percent);
else
w1.Width = w1.Slot.Right - x;
- }
+ }
}
} else {
int y = m.Y - Slot.Height / 2 - gs.Spacing;
@@ -102,17 +103,17 @@ namespace Crow
w1.Height = new Measure((int)Math.Round (100.0 * (w1.Slot.Bottom - y) / (double)gsRect.Height), Unit.Percent);
else
w1.Height = w1.Slot.Bottom - y;
- }
+ }
}
}
}
e.Handled = true;
}
-
+
base.onMouseMove (sender, e);
}
-
+
public override bool UpdateLayout (LayoutingType layoutType)
{
GenericStack gs = Parent as GenericStack;
@@ -128,7 +129,7 @@ namespace Crow
Height = Measure.Stretched;
}
return base.UpdateLayout (layoutType);
- }
+ }
#endregion
}
}
diff --git a/Crow/src/Widgets/Table.cs b/Crow/src/Widgets/Table.cs
index 834a5820..86338573 100644
--- a/Crow/src/Widgets/Table.cs
+++ b/Crow/src/Widgets/Table.cs
@@ -1,10 +1,11 @@
-// Copyright (c) 2019-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2019-2022 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.ComponentModel;
using System.Linq;
-using Crow.Drawing;
+
+using Drawing2D;
namespace Crow
{
@@ -337,7 +338,7 @@ namespace Crow
}
- protected override void onDraw (Context gr) {
+ protected override void onDraw (IContext gr) {
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
base.onDraw (gr);
diff --git a/Crow/src/Widgets/TableRow copy.cs b/Crow/src/Widgets/TableRow copy.cs
index 1579af7a..cb9ebb04 100644
--- a/Crow/src/Widgets/TableRow copy.cs
+++ b/Crow/src/Widgets/TableRow copy.cs
@@ -1,9 +1,10 @@
-// Copyright (c) 2019-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2019-2022 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.ComponentModel;
using System.Linq;
+using Drawing2D;
using Glfw;
@@ -32,7 +33,7 @@ namespace Crow
}
#endregion
- public Table Table => Parent as Table;
+ public Table Table => Parent as Table;
public override void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType)
{
@@ -42,9 +43,9 @@ namespace Crow
return;
}
if (this == Table.Children[0])
- layoutType &= (~LayoutingType.X);
+ layoutType &= (~LayoutingType.X);
else
- layoutType &= (~(LayoutingType.X|LayoutingType.Width));
+ layoutType &= (~(LayoutingType.X|LayoutingType.Width));
}
@@ -57,7 +58,7 @@ namespace Crow
case LayoutingType.Height:
childrenRWLock.EnterReadLock ();
foreach (Widget c in Children.Where (cc => cc.Height.IsRelativeToParent))
- c.RegisterForLayouting (LayoutingType.Height);
+ c.RegisterForLayouting (LayoutingType.Height);
childrenRWLock.ExitReadLock ();
break;
}
@@ -75,23 +76,23 @@ namespace Crow
return;
int spacing = Table.Spacing;
ObservableList<Column> cols = Table.Columns;
-
+
Widget first = Children[0];
TableRow firstRow = Table.Children[0] as TableRow;
if (firstRow == this) {
base.ComputeChildrenPositions();
return;
- }
- childrenRWLock.EnterReadLock();
-
+ }
+ childrenRWLock.EnterReadLock();
+
for (int i = 0; i < Children.Count && i < firstRow.Children.Count; i++)
{
Widget w = Children[i];
w.Slot.X = firstRow.Children[i].Slot.X;
- setChildWidth (w, firstRow.Children[i].Slot.Width);
-
+ setChildWidth (w, firstRow.Children[i].Slot.Width);
+
}
childrenRWLock.ExitReadLock();
@@ -107,23 +108,23 @@ namespace Crow
return;
int spacing = Table.Spacing;
ObservableList<Column> cols = Table.Columns;
-
+
Widget first = Children[0];
TableRow firstRow = Table.Children[0] as TableRow;
if (firstRow == this) {
base.ComputeChildrenPositions();
return;
- }
- childrenRWLock.EnterReadLock();
-
+ }
+ childrenRWLock.EnterReadLock();
+
for (int i = 0; i < Children.Count && i < firstRow.Children.Count; i++)
{
Widget w = Children[i];
w.Slot.X = firstRow.Children[i].Slot.X;
- setChildWidth (w, firstRow.Children[i].Slot.Width);
-
+ setChildWidth (w, firstRow.Children[i].Slot.Width);
+
}
childrenRWLock.ExitReadLock();
@@ -139,23 +140,23 @@ namespace Crow
return;
int spacing = Table.Spacing;
ObservableList<Column> cols = Table.Columns;
-
+
Widget first = Children[0];
TableRow firstRow = Table.Children[0] as TableRow;
if (firstRow == this) {
base.ComputeChildrenPositions();
return;
- }
- childrenRWLock.EnterReadLock();
-
+ }
+ childrenRWLock.EnterReadLock();
+
for (int i = 0; i < Children.Count && i < firstRow.Children.Count; i++)
{
Widget w = Children[i];
w.Slot.X = firstRow.Children[i].Slot.X;
- setChildWidth (w, firstRow.Children[i].Slot.Width);
-
+ setChildWidth (w, firstRow.Children[i].Slot.Width);
+
}
childrenRWLock.ExitReadLock();
@@ -171,29 +172,29 @@ namespace Crow
return;
int spacing = Table.Spacing;
ObservableList<Column> cols = Table.Columns;
-
+
Widget first = Children[0];
TableRow firstRow = Table.Children[0] as TableRow;
if (firstRow == this) {
base.ComputeChildrenPositions();
return;
- }
- childrenRWLock.EnterReadLock();
-
+ }
+ childrenRWLock.EnterReadLock();
+
for (int i = 0; i < Children.Count && i < firstRow.Children.Count; i++)
{
Widget w = Children[i];
w.Slot.X = firstRow.Children[i].Slot.X;
- setChildWidth (w, firstRow.Children[i].Slot.Width);
-
+ setChildWidth (w, firstRow.Children[i].Slot.Width);
+
}
childrenRWLock.ExitReadLock();
IsDirty = true;
}*/
-
+
/*public override bool UpdateLayout(LayoutingType layoutType)
{
RegisteredLayoutings &= (~layoutType);
@@ -204,7 +205,7 @@ namespace Crow
if (layoutType == LayoutingType.Width) {
if (firstRow.RegisteredLayoutings.HasFlag (LayoutingType.Width))
return false;
- if (this != firstRow) {
+ if (this != firstRow) {
Slot.Width = firstRow.Slot.Width;
if (Slot.Width != LastSlots.Width) {
IsDirty = true;
@@ -217,14 +218,14 @@ namespace Crow
return true;
}
}
-
+
return base.UpdateLayout(layoutType);
}*/
/*public override int measureRawSize (LayoutingType lt) {
if (lt == LayoutingType.Width) {
if (Table == null)
return -1;
- TableRow firstRow = Table.Children[0] as TableRow;
+ TableRow firstRow = Table.Children[0] as TableRow;
if (this != firstRow) {
if (firstRow.RegisteredLayoutings.HasFlag (LayoutingType.Width))
return -1;
@@ -239,7 +240,7 @@ namespace Crow
if (arg.LayoutType == LayoutingType.Width) {
Widget w = sender as Widget;
TableRow firstRow = Table.Children[0] as TableRow;
- int c = Children.IndexOf(w);
+ int c = Children.IndexOf(w);
if (c < Table.Columns.Count) {
Column col = Table.Columns[c];
if (col.Width.IsFit) {
@@ -264,12 +265,12 @@ namespace Crow
if (arg.LayoutType == LayoutingType.Width) {
if (row == firstRow) {
base.OnChildLayoutChanges (sender, arg);
- int idx = Children.IndexOf (go);
+ int idx = Children.IndexOf (go);
foreach (TableRow r in Table.Children.Skip(1)) {
if (idx < r.Children.Count)
r.setChildWidth (r.Children[idx], go.Slot.Width);
r.contentSize = firstRow.contentSize;
- }
+ }
} //else
this.RegisterForLayouting (LayoutingType.ArrangeChildren);
return;
@@ -277,17 +278,17 @@ namespace Crow
base.OnChildLayoutChanges (sender, arg);
}*/
- int splitIndex = -1;
+ int splitIndex = -1;
const int minColumnSize = 10;
int Spacing => Table.Spacing;
public override void onMouseMove(object sender, MouseMoveEventArgs e)
- {
+ {
if (Spacing > 0 && Table != null && Table.Children.Count > 0) {
Point m = ScreenPointToLocal (e.Position);
if (IFace.IsDown (Glfw.MouseButton.Left) && splitIndex >= 0) {
TableRow firstRow = Table.Children[0] as TableRow;
Rectangle cb = ClientRectangle;
- int splitPos = (int)(0.5 * Spacing + m.X);
+ int splitPos = (int)(0.5 * Spacing + m.X);
if (splitPos > firstRow.Children[splitIndex].Slot.Left + minColumnSize && splitPos < firstRow.Children[splitIndex+1].Slot.Right - minColumnSize) {
Table.Columns[splitIndex+1].Width = firstRow.Children[splitIndex+1].Slot.Right - splitPos;
splitPos -= Spacing;
@@ -295,9 +296,9 @@ namespace Crow
Table.RegisterForLayouting (LayoutingType.Width);
e.Handled = true;
}
- //Console.WriteLine ($"left:{firstRow.Children[splitIndex].Slot.Left} right:{firstRow.Children[splitIndex+1].Slot.Right} cb.X:{cb.X} splitPos:{splitPos} m:{m}");
+ //Console.WriteLine ($"left:{firstRow.Children[splitIndex].Slot.Left} right:{firstRow.Children[splitIndex+1].Slot.Right} cb.X:{cb.X} splitPos:{splitPos} m:{m}");
} else {
- splitIndex = -1;
+ splitIndex = -1;
for (int i = 0; i < Children.Count - 1; i++)
{
Rectangle r = Children[i].Slot;
diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs
index 99ff7d23..a59576d3 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 Crow.Drawing;
+
namespace Crow
{
@@ -92,7 +92,7 @@ namespace Crow
///this allow applying root background to random template's component
/// </summary>
/// <param name="gr">Backend context</param>
- protected override void onDraw (Context gr)
+ protected override void onDraw (IContext gr)
{
DbgLogger.StartEvent (DbgEvtType.GODraw, this);
diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs
index ed955d72..d9706969 100644
--- a/Crow/src/Widgets/TemplatedGroup.cs
+++ b/Crow/src/Widgets/TemplatedGroup.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -9,6 +9,7 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading;
+using Drawing2D;
using Crow.IML;
diff --git a/Crow/src/Widgets/TextBox.cs b/Crow/src/Widgets/TextBox.cs
index e3fac1b4..ff9bec25 100644
--- a/Crow/src/Widgets/TextBox.cs
+++ b/Crow/src/Widgets/TextBox.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -6,7 +6,9 @@ using System;
using System.ComponentModel;
using Crow.Text;
-using Crow.Drawing;
+
+using Drawing2D;
+
using Glfw;
namespace Crow
@@ -175,7 +177,7 @@ namespace Crow
base.OnLayoutChanges (layoutType);
updateMaxScrolls (layoutType);
}
- protected override void drawContent (Context gr) {
+ protected override void drawContent (IContext gr) {
gr.Translate (-scrollX, -scrollY);
base.drawContent (gr);
gr.Translate (scrollX, scrollY);
@@ -185,7 +187,7 @@ namespace Crow
protected override void updateHoverLocation (Point mouseLocalPos) {
base.updateHoverLocation (mouseLocalPos + new Point (ScrollX, ScrollY));
}
- protected override void measureTextBounds (Context gr) {
+ protected override void measureTextBounds (IContext gr) {
base.measureTextBounds (gr);
updateMaxScrolls (LayoutingType.Height);
updateMaxScrolls (LayoutingType.Width);
diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs
index 30c8b9d8..45c62efa 100644
--- a/Crow/src/Widgets/Widget.cs
+++ b/Crow/src/Widgets/Widget.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -11,11 +11,11 @@ using System.Runtime.CompilerServices;
using System.Diagnostics;
using Crow.IML;
-using Crow.Drawing;
+
using System.Threading;
using Glfw;
using System.Linq;
-
+using Drawing2D;
#if DESIGN_MODE
using System.Xml;
@@ -1927,7 +1927,7 @@ namespace Crow
}
#endregion
- protected void setFontForContext (Context gr) {
+ protected void setFontForContext (IContext gr) {
#if VKVG
gr.FontFace = Font.Name;
gr.FontSize = (uint)Font.Size;
@@ -1942,7 +1942,7 @@ namespace Crow
#region Rendering
/// <summary> This is the common overridable drawing routine to create new widget </summary>
- protected virtual void onDraw(Context gr)
+ protected virtual void onDraw(IContext gr)
{
DbgLogger.StartEvent(DbgEvtType.GODraw, this);
@@ -1978,7 +1978,7 @@ namespace Crow
//bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
DbgLogger.StartEvent (DbgEvtType.GOCreateContext, this);
- using (Context gr = new Context (bmp)) {
+ using (IContext gr = new Context (bmp)) {
DbgLogger.EndEvent (DbgEvtType.GOCreateContext);
gr.Antialias = Interface.Antialias;
onDraw (gr);
@@ -1988,7 +1988,7 @@ namespace Crow
DbgLogger.EndEvent (DbgEvtType.GORecreateCache);
}
- protected void paintCache(Context ctx, Rectangle rb) {
+ protected void paintCache(IContext ctx, Rectangle rb) {
DbgLogger.StartEvent(DbgEvtType.GOPaintCache, this);
if (clearBackground) {
ctx.Operator = Operator.Clear;
@@ -2003,7 +2003,7 @@ namespace Crow
#endif
DbgLogger.EndEvent(DbgEvtType.GOPaintCache);
}
- protected virtual void UpdateCache(Context ctx){
+ protected virtual void UpdateCache(IContext ctx){
DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
paintCache (ctx, Slot + Parent.ClientRectangle.Position);
DbgLogger.AddEvent (DbgEvtType.GOResetClip, this);
@@ -2012,7 +2012,7 @@ namespace Crow
}
/// <summary> Chained painting routine on the parent context of the actual cached version
/// of the widget </summary>
- public virtual void Paint (Context ctx)
+ public virtual void Paint (IContext ctx)
{
if (!IsVisible)
return;
@@ -2071,7 +2071,7 @@ namespace Crow
DbgLogger.EndEvent (DbgEvtType.GOPaint);
}
- void paintDisabled(Context gr, Rectangle rb){
+ void paintDisabled(IContext gr, Rectangle rb){
//gr.Operator = Operator.Xor;
gr.SetSource (0.2, 0.2, 0.2, 0.8);
gr.Rectangle (rb);
diff --git a/Crow/src/Widgets/Window.cs b/Crow/src/Widgets/Window.cs
index 73d89f1d..168fb101 100644
--- a/Crow/src/Widgets/Window.cs
+++ b/Crow/src/Widgets/Window.cs
@@ -1,10 +1,11 @@
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.ComponentModel;
using Glfw;
+using Drawing2D;
namespace Crow
{
diff --git a/Directory.Build.props b/Directory.Build.props
index 2da796a8..76dad08e 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,8 +6,8 @@
<Authors>Jean-Philippe Bruyère</Authors>
<LangVersion>7.3</LangVersion>
- <CrowVersion>0.9.8</CrowVersion>
- <CrowPackageVersion>$(CrowVersion)</CrowPackageVersion>
+ <CrowVersion>0.9.9</CrowVersion>
+ <CrowPackageVersion>$(CrowVersion)-beta</CrowPackageVersion>
<!-- If you dont have a native libstb on your system, enable the managed version of stb here
TODO: this could be detected on startup or install automatically-->
diff --git a/Drawing2D/Drawing2D.csproj b/Drawing2D/Drawing2D.csproj
new file mode 100644
index 00000000..0bb94879
--- /dev/null
+++ b/Drawing2D/Drawing2D.csproj
@@ -0,0 +1,35 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp3.0</TargetFramework>
+ <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
+
+ <AssemblyVersion>1.0.0</AssemblyVersion>
+ <PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
+
+ <Title>Drawing 2D Library</Title>
+ <Description>
+ 2d shapes and drawing interfaces used in C.R.O.W and Vke.net.
+ </Description>
+ <License>MIT</License>
+ <Authors>Jean-Philippe Bruyère</Authors>
+ <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
+ <PackageTags>Crow 2D GUI Widget Interface C# Net</PackageTags>
+ <PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
+
+ <PackageProjectUrl>https://github.com/jpbruyere/Crow/wiki</PackageProjectUrl>
+ <PackageCopyright>Copyright 2022</PackageCopyright>
+ <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Compile Include="src\**\*.cs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Enums.NET" Version="4.0.0" />
+ </ItemGroup>
+
+
+</Project>
diff --git a/Crow/src/Colors.cs b/Drawing2D/src/Colors.cs
index d24f5e94..2bd58ada 100644
--- a/Crow/src/Colors.cs
+++ b/Drawing2D/src/Colors.cs
@@ -5,9 +5,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
-//using FastEnumUtility;
-namespace Crow
+namespace Drawing2D
{
public enum Colors : UInt32
{
diff --git a/Drawing2D/src/Device.cs b/Drawing2D/src/Device.cs
new file mode 100644
index 00000000..8beb1b79
--- /dev/null
+++ b/Drawing2D/src/Device.cs
@@ -0,0 +1,18 @@
+// Copyright (c) 2018-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Drawing2D
+{
+ public interface IDevice: IDisposable
+ {
+ //IntPtr Handle => handle;
+
+ void GetDpy (out int hdpy, out int vdpy);
+ void SetDpy (int hdpy, int vdpy);
+ ISurface CreateSurface (int width, int height);
+ }
+}
+
diff --git a/Drawing2D/src/Enums.cs b/Drawing2D/src/Enums.cs
new file mode 100644
index 00000000..b13f29af
--- /dev/null
+++ b/Drawing2D/src/Enums.cs
@@ -0,0 +1,149 @@
+// Copyright (c) 2018-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Drawing2D
+{
+ public enum Status
+ {
+ Success = 0,
+ NoMemory,
+ InvalidRestore,
+ InvalidPopGroup,
+ NoCurrentPoint,
+ InvalidMatrix,
+ InvalidStatus,
+ NullPointer,
+ InvalidString,
+ InvalidPathData,
+ ReadError,
+ WriteError,
+ SurfaceFinished,
+ SurfaceTypeMismatch,
+ PatternTypeMismatch,
+ InvalidContent,
+ InvalidFormat,
+ InvalidVisual,
+ FileNotFound,
+ InvalidDash
+ }
+
+ public enum Direction
+ {
+ Horizontal = 0,
+ Vertical = 1
+ }
+
+ public enum Format
+ {
+ ARGB32,
+ RGB24,
+ A8,
+ A1,
+ Rgb16565 = 4
+ }
+
+ public enum Extend
+ {
+ None,
+ Repeat,
+ Reflect,
+ Pad
+ }
+
+ public enum Filter
+ {
+ Fast,
+ Good,
+ Best,
+ Nearest,
+ Bilinear,
+ Gaussian,
+ }
+
+ public enum PatternType
+ {
+ Solid,
+ Surface,
+ Linear,
+ Radial,
+ Mesh,
+ RasterSource,
+ }
+
+ public enum Operator
+ {
+ Clear,
+ Source,
+ Over,
+ In,
+ Out,
+ Atop,
+
+ Dest,
+ DestOver,
+ DestIn,
+ DestOut,
+ DestAtop,
+
+ Xor,
+ Add,
+ Saturate,
+ Multiply,
+ Screen,
+ Overlay,
+ Darken,
+ Lighten,
+ }
+
+ public enum FontSlant
+ {
+ Normal,
+ Italic,
+ Oblique
+ }
+ public enum FontWeight
+ {
+ Normal,
+ Bold,
+ }
+
+ public enum SampleCount
+ {
+ Sample_1 = 0x00000001,
+ Sample_2 = 0x00000002,
+ Sample_4 = 0x00000004,
+ Sample_8 = 0x00000008,
+ Sample_16 = 0x00000010,
+ Sample_32 = 0x00000020,
+ Sample_64 = 0x00000040
+ }
+
+ public enum LineCap
+ {
+ Butt,
+ Round,
+ Square
+ }
+
+ public enum LineJoin
+ {
+ Miter,
+ Round,
+ Bevel
+ }
+ public enum FillRule
+ {
+ EvenOdd,
+ NonZero,
+ }
+ public enum Antialias
+ {
+ Default,
+ None,
+ Grey,
+ Subpixel,
+ }
+} \ No newline at end of file
diff --git a/Crow/src/GraphicBackends/vkvg/FontExtents.cs b/Drawing2D/src/FontExtents.cs
index 769b9a69..19532880 100644
--- a/Crow/src/GraphicBackends/vkvg/FontExtents.cs
+++ b/Drawing2D/src/FontExtents.cs
@@ -18,10 +18,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
@@ -30,45 +30,45 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2018-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2018-2022 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.Runtime.InteropServices;
-namespace Crow.Drawing
+namespace Drawing2D
{
[StructLayout (LayoutKind.Sequential)]
- public struct FontExtents
+ public struct FontExtents : IEquatable<FontExtents>
{
float ascent;
float descent;
float height;
float maxXAdvance;
float maxYAdvance;
-
+
public float Ascent {
- get { return ascent; }
+ get => ascent;
set { ascent = value; }
}
-
+
public float Descent {
- get { return descent; }
+ get => descent;
set { descent = value; }
}
-
+
public float Height {
- get { return height; }
+ get => height;
set { height = value; }
}
-
+
public float MaxXAdvance {
- get { return maxXAdvance; }
+ get => maxXAdvance;
set { maxXAdvance = value; }
}
-
+
public float MaxYAdvance {
- get { return maxYAdvance; }
+ get => maxYAdvance;
set { maxYAdvance = value; }
}
@@ -81,26 +81,14 @@ namespace Crow.Drawing
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 override int GetHashCode () => HashCode.Combine (ascent, descent, height, maxXAdvance, maxYAdvance);
+ public override bool Equals (object obj) => obj is FontExtents fe ? Equals (fe) : false;
- 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 bool Equals(FontExtents other) =>
+ ascent == other.ascent && descent == other.descent && height == other.height &&
+ maxXAdvance == other.maxXAdvance && maxYAdvance == other.maxYAdvance;
- public static bool operator != (FontExtents extents, FontExtents other)
- {
- return !(extents == other);
- }
+ public static bool operator == (FontExtents extents, FontExtents other) => extents.Equals (other);
+ public static bool operator != (FontExtents extents, FontExtents other) => !extents.Equals (other);
}
}
diff --git a/Drawing2D/src/IContext.cs b/Drawing2D/src/IContext.cs
new file mode 100644
index 00000000..d393289b
--- /dev/null
+++ b/Drawing2D/src/IContext.cs
@@ -0,0 +1,93 @@
+// Copyright (c) 2018-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Drawing2D
+{
+ public interface IContext : IDisposable
+ {
+
+ IntPtr Handle { get; }
+
+ double LineWidth { get; set; }
+ LineJoin LineJoin { get; set; }
+ LineCap LineCap { get; set; }
+ uint FontSize { get; set; }
+ string FontFace { get; set; }
+ Operator Operator { get; set; }
+ FillRule FillRule { get; set; }
+ FontExtents FontExtents { get; set; }
+ Antialias Antialias { get; set; }
+ TextExtents TextExtents (ReadOnlySpan<char> s, int tabSize = 4);
+ void TextExtents (ReadOnlySpan<char> s, int tabSize, out TextExtents extents);
+ void TextExtents (Span<byte> bytes, out TextExtents extents);
+ Matrix Matrix { get; set; }
+ void ShowText (string text);
+ void ShowText (ReadOnlySpan<char> s, int tabSize = 4);
+ void ShowText (Span<byte> bytes);
+ void Save();
+ void Restore();
+ void Flush();
+ void Clear();
+ void Paint();
+ void PaintWithAlpha (double alpha);
+
+ void Arc(float xc, float yc, float radius, float a1, float a2);
+ void Arc(double xc, double yc, double radius, double a1, double a2);
+ void Arc (PointD center, double radius, double angle1, double angle2);
+ void ArcNegative (PointD center, double radius, double angle1, double angle2);
+ void ArcNegative(float xc, float yc, float radius, float a1, float a2);
+ void Rectangle(float x, float y, float width, float height);
+ void Scale(float sx, float sy);
+ void Translate(float dx, float dy);
+ void Rotate(float alpha);
+ void ArcNegative(double xc, double yc, double radius, double a1, double a2);
+ void Rectangle(double x, double y, double width, double height);
+ void Scale(double sx, double sy);
+ void Translate(double dx, double dy);
+ void Translate(PointD p);
+ void Rotate(double alpha);
+ void Fill();
+ void FillPreserve();
+ void Stroke();
+ void StrokePreserve();
+ void Clip();
+ void ClipPreserve();
+ void ResetClip();
+ void NewPath();
+ void NewSubPath();
+ void ClosePath();
+ void MoveTo(PointD p);
+ void MoveTo(Point p);
+ void MoveTo(float x, float y);
+ void RelMoveTo(float x, float y);
+ void LineTo(float x, float y);
+ void LineTo(Point p);
+ void LineTo(PointD p);
+ void RelLineTo(float x, float y);
+ void CurveTo(float x1, float y1, float x2, float y2, float x3, float y3);
+ void RelCurveTo(float x1, float y1, float x2, float y2, float x3, float y3);
+ void MoveTo(double x, double y);
+ void RelMoveTo(double x, double y);
+ void LineTo(double x, double y);
+ void RelLineTo(double x, double y);
+ void CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
+ void RelCurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
+ void SetSource(IPattern pat);
+ void SetSource (Color color);
+ void SetSource(float r, float g, float b, float a = 1f);
+ void SetSource(double r, double g, double b, double a = 1.0);
+ void SetSource(ISurface surf, float x = 0f, float y = 0f);
+ void SetSourceSurface(ISurface surf, float x = 0f, float y = 0f);
+ void RenderSvg(IntPtr svgNativeHandle, string subId = null);
+ Rectangle StrokeExtents ();
+ void SetDash (double [] dashes, double offset = 0);
+ float[] Dashes { set; }
+
+ //void PushGroup ();
+ //void PopGroupToSource ();
+ }
+}
+
diff --git a/Drawing2D/src/Matrix.cs b/Drawing2D/src/Matrix.cs
new file mode 100644
index 00000000..4e6918ba
--- /dev/null
+++ b/Drawing2D/src/Matrix.cs
@@ -0,0 +1,21 @@
+// Copyright (c) 2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Drawing2D {
+ public struct Matrix {
+ float xx; float yx;
+ float xy; float yy;
+ float x0; float y0;
+
+ public float XX, YX;
+ public float XY, YY;
+ public float X0, Y0;
+
+ public override string ToString () {
+ return string.Format ($"({xx};{yx};{xy};{yy};{x0};{y0})");
+ }
+ }
+}
diff --git a/Drawing2D/src/Pattern.cs b/Drawing2D/src/Pattern.cs
new file mode 100644
index 00000000..f8c31438
--- /dev/null
+++ b/Drawing2D/src/Pattern.cs
@@ -0,0 +1,13 @@
+// Copyright (c) 2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+namespace Drawing2D
+{
+ public interface IPattern : IDisposable
+ {
+ Extend Extend { get; set; }
+ Filter Filter { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Crow/src/2d/Point.cs b/Drawing2D/src/Point.cs
index c2f982bd..72bb2232 100644
--- a/Crow/src/2d/Point.cs
+++ b/Drawing2D/src/Point.cs
@@ -1,15 +1,12 @@
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-namespace Crow
+namespace Drawing2D
{
- public struct Point : IEquatable<Point>, IEquatable<int>
+ public struct Point : IEquatable<Point>, IEquatable<int>
{
public int X, Y;
diff --git a/Crow/src/2d/PointD.cs b/Drawing2D/src/PointD.cs
index d70e5b82..e873c72f 100644
--- a/Crow/src/2d/PointD.cs
+++ b/Drawing2D/src/PointD.cs
@@ -1,11 +1,11 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
-namespace Crow {
- public struct PointD {
+namespace Drawing2D {
+ public struct PointD : IEquatable<PointD>, IEquatable<double> {
public double X;
public double Y;
public PointD (double x, double y)
@@ -33,10 +33,10 @@ namespace Crow {
public static PointD operator / (PointD p1, PointD p2) => new PointD (p1.X / p2.X, p1.Y / p2.Y);
public static PointD operator / (PointD p, double d) => new PointD (p.X / d, p.Y / d);
- public static bool operator == (PointD s1, PointD s2) => s1.X == s2.X && s1.Y == s2.Y;
- public static bool operator == (PointD s, double i) => s.X == i && s.Y == i;
- public static bool operator != (PointD s1, PointD s2) => !(s1.X == s2.X && s1.Y == s2.Y);
- public static bool operator != (PointD s, double i) => !(s.X == i && s.Y == i);
+ public static bool operator == (PointD s1, PointD s2) => s1.Equals (s2);
+ public static bool operator == (PointD s, double i) => s.Equals (i);
+ public static bool operator != (PointD s1, PointD s2) => !s1.Equals (s2);
+ public static bool operator != (PointD s, double i) => !s.Equals (i);
public static bool operator > (PointD p1, PointD p2) => p1.X > p2.X && p1.Y > p2.Y;
public static bool operator > (PointD s, double i) => s.X > i && s.Y > i;
public static bool operator < (PointD p1, PointD p2) => p1.X < p2.X && p1.Y < p2.Y;
@@ -46,9 +46,13 @@ namespace Crow {
public static bool operator <= (PointD p1, PointD p2) => p1.X <= p2.X && p1.Y <= p2.Y;
public static bool operator <= (PointD s, double i) => s.X <= i && s.Y <= i;
+ public override int GetHashCode () => HashCode.Combine (X, Y);
+ public override bool Equals (object obj) =>
+ obj is PointD p ? Equals (p) : obj is double d ? Equals (d) : false;
+ public bool Equals(PointD other) => X == other.X && Y == other.Y;
+ public bool Equals(double i) => X == i && Y == i;
+
public override string ToString () => string.Format ("{0},{1}", X, Y);
- public override bool Equals (object obj) => obj is PointD ? this == (PointD)obj :
- obj is Point && (Point)this == (Point)obj;
public static PointD Parse (string s)
{
if (string.IsNullOrEmpty (s))
@@ -63,17 +67,5 @@ namespace Crow {
throw new Exception ("Crow.PointD Parsing Error: " + s);
}
- public override int GetHashCode ()
- {
-#pragma warning disable RECS0025 // Champ autre qu’en lecture seule référencé dans « GetHashCode() »
- unchecked {
- var hashCode = 1861411795;
- hashCode = hashCode * -1521134295 + X.GetHashCode ();
-
- hashCode = hashCode * -1521134295 + Y.GetHashCode ();
- return hashCode;
- }
-#pragma warning restore RECS0025 // Champ autre qu’en lecture seule référencé dans « GetHashCode() » }
- }
}
} \ No newline at end of file
diff --git a/Crow/src/2d/Rectangle.cs b/Drawing2D/src/Rectangle.cs
index 278decb5..ac0d83c7 100644
--- a/Crow/src/2d/Rectangle.cs
+++ b/Drawing2D/src/Rectangle.cs
@@ -1,12 +1,12 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.Runtime.InteropServices;
-namespace Crow {
+namespace Drawing2D {
[StructLayout(LayoutKind.Sequential)]
- public struct Rectangle
+ public struct Rectangle : IEquatable<Rectangle>
{
public static readonly Rectangle Zero = new Rectangle (0, 0, 0, 0);
@@ -24,44 +24,43 @@ namespace Crow {
#endregion
#region PROPERTIES
- [XmlIgnore]public int Left{
+ public int Left{
get => X;
set { X = value; }
}
- [XmlIgnore]public int Top{
+ public int Top{
get => Y;
set { Y = value; }
}
- [XmlIgnore] public int Right => X + Width;
- [XmlIgnore]public int Bottom => Y + Height;
- [XmlIgnore]public Size Size{
+ public int Right => X + Width;
+ public int Bottom => Y + Height;
+ public Size Size{
get => new Size (Width, Height);
set {
Width = value.Width;
Height = value.Height;
}
}
- [XmlIgnore]
public SizeD SizeD => new SizeD (Width, Height);
- [XmlIgnore]public Point Position{
+ public Point Position{
get => new Point (X, Y);
set {
X = value.X;
Y = value.Y;
}
}
- [XmlIgnore]public Point TopLeft{
+ public Point TopLeft{
get => new Point (X, Y);
set {
X = value.X;
Y = value.Y;
}
}
- [XmlIgnore] public Point TopRight => new Point (Right, Y);
- [XmlIgnore] public Point BottomLeft => new Point (X, Bottom);
- [XmlIgnore] public Point BottomRight => new Point (Right, Bottom);
- [XmlIgnore] public Point Center => new Point (Left + Width / 2, Top + Height / 2);
- [XmlIgnore] public Point CenterD => new PointD (Left + Width / 2.0, Top + Height / 2.0);
+ public Point TopRight => new Point (Right, Y);
+ public Point BottomLeft => new Point (X, Bottom);
+ public Point BottomRight => new Point (Right, Bottom);
+ public Point Center => new Point (Left + Width / 2, Top + Height / 2);
+ public Point CenterD => new PointD (Left + Width / 2.0, Top + Height / 2.0);
#endregion
@@ -153,13 +152,18 @@ namespace Crow {
}
public static Rectangle operator + (Rectangle r, Point p) => new Rectangle (r.X + p.X, r.Y + p.Y, r.Width, r.Height);
public static Rectangle operator - (Rectangle r, Point p) => new Rectangle (r.X - p.X, r.Y - p.Y, r.Width, r.Height);
- public static bool operator == (Rectangle r1, Rectangle r2) => r1.TopLeft == r2.TopLeft && r1.Size == r2.Size;
- public static bool operator != (Rectangle r1, Rectangle r2) => !(r1.TopLeft == r2.TopLeft && r1.Size == r2.Size);
+ public static bool operator == (Rectangle r1, Rectangle r2) => r1.Equals (r2);
+ public static bool operator != (Rectangle r1, Rectangle r2) => !r1.Equals (r2);
public static implicit operator Rectangle (RectangleD r) => new Rectangle ((int)Math.Round(r.X), (int)Math.Round (r.Y),
(int)Math.Round (r.Width), (int)Math.Round (r.Height));
#endregion
+ public override int GetHashCode () => HashCode.Combine (X, Y, Width, Height);
+ public override bool Equals (object obj) => obj is Rectangle r ? Equals (r) : false;
+ public bool Equals(Rectangle other) =>
+ X == other.X && Y == other.Y && Width == other.Width && Height == other.Height;
+
public override string ToString () => $"{X},{Y},{Width},{Height}";
public static Rectangle Parse(string s)
{
@@ -170,20 +174,5 @@ namespace Crow {
int.Parse(d[2]),
int.Parse(d[3]));
}
- public override int GetHashCode ()
- {
- unchecked // Overflow is fine, just wrap
- {
- int hash = 17;
- // Suitable nullity checks etc, of course :)
- hash = hash * 23 + X.GetHashCode();
- hash = hash * 23 + Y.GetHashCode();
- hash = hash * 23 + Width.GetHashCode();
- hash = hash * 23 + Height.GetHashCode();
- return hash;
- }
- }
- public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (Rectangle)) ?
- false : this == (Rectangle)obj;
}
}
diff --git a/Drawing2D/src/RectangleD.cs b/Drawing2D/src/RectangleD.cs
new file mode 100644
index 00000000..2d3f3931
--- /dev/null
+++ b/Drawing2D/src/RectangleD.cs
@@ -0,0 +1,156 @@
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+using System.Runtime.InteropServices;
+
+namespace Drawing2D {
+ [StructLayout(LayoutKind.Sequential)]
+ public struct RectangleD
+ {
+ public static readonly RectangleD Zero = new RectangleD (0, 0, 0, 0);
+
+ public double X, Y, Width, Height;
+
+ #region ctor
+ public RectangleD(PointD p, Size s): this (p.X, p.Y, s.Width, s.Height) { }
+ public RectangleD(SizeD s) : this (0, 0, s.Width, s.Height) { }
+ public RectangleD(double x, double y, double width, double height) {
+ X = x;
+ Y = y;
+ Width = width;
+ Height = height;
+ }
+ #endregion
+
+ #region PROPERTIES
+ public double Left{
+ get => X;
+ set { X = value; }
+ }
+ public double Top{
+ get => Y;
+ set { Y = value; }
+ }
+ public double Right => X + Width;
+ public double Bottom => Y + Height;
+ public SizeD Size{
+ get => new SizeD (Width, Height);
+ set {
+ Width = value.Width;
+ Height = value.Height;
+ }
+ }
+ public PointD Position{
+ get => new PointD (X, Y);
+ set {
+ X = value.X;
+ Y = value.Y;
+ }
+ }
+ public PointD TopLeft{
+ get => new PointD (X, Y);
+ set {
+ X = value.X;
+ Y = value.Y;
+ }
+ }
+ public PointD TopRight => new PointD (Right, Y);
+ public PointD BottomLeft => new PointD (X, Bottom);
+ public PointD BottomRight => new PointD (Right, Bottom);
+ public PointD Center => new PointD (Left + Width / 2, Top + Height / 2);
+ public PointD CenterD => new PointD (Left + Width / 2.0, Top + Height / 2.0);
+
+ #endregion
+
+ #region FUNCTIONS
+ public void Inflate(double xDelta, double yDelta)
+ {
+ this.X -= xDelta;
+ this.Width += 2 * xDelta;
+ this.Y -= yDelta;
+ this.Height += 2 * yDelta;
+ }
+ public void Inflate(double delta)
+ {
+ Inflate (delta, delta);
+ }
+ public RectangleD Inflated (double delta) => Inflated (delta, delta);
+ public RectangleD Inflated (double deltaX, double deltaY) {
+ RectangleD r = this;
+ r.Inflate (deltaX, deltaY);
+ return r;
+ }
+ public bool ContainsOrIsEqual (PointD p) => (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height);
+ public bool ContainsOrIsEqual (RectangleD r) => r.TopLeft >= this.TopLeft && r.BottomRight <= this.BottomRight;
+ public bool Intersect(RectangleD r)
+ {
+ double maxLeft = Math.Max(this.Left, r.Left);
+ double minRight = Math.Min(this.Right, r.Right);
+ double maxTop = Math.Max(this.Top, r.Top);
+ double minBottom = Math.Min(this.Bottom, r.Bottom);
+
+ return (maxLeft < minRight) && (maxTop < minBottom);
+ }
+ public RectangleD Intersection(RectangleD r)
+ {
+ RectangleD result = new RectangleD();
+
+ if (r.Left >= Left)
+ result.Left = r.Left;
+ else
+ result.TopLeft = TopLeft;
+
+ if (r.Right >= Right)
+ result.Width = Right - result.Left;
+ else
+ result.Width = r.Right - result.Left;
+
+ if (r.Top >= Top)
+ result.Top = r.Top;
+ else
+ result.Top = Top;
+
+ if (r.Bottom >= Bottom)
+ result.Height = Bottom - result.Top;
+ else
+ result.Height = r.Bottom - result.Top;
+
+ return result;
+ }
+ #endregion
+
+ #region operators
+ public static RectangleD operator +(RectangleD r1, RectangleD r2)
+ {
+ double x = Math.Min(r1.X, r2.X);
+ double y = Math.Min(r1.Y, r2.Y);
+ double x2 = Math.Max(r1.Right, r2.Right);
+ double y2 = Math.Max(r1.Bottom, r2.Bottom);
+ return new RectangleD(x, y, x2 - x, y2 - y);
+ }
+ public static RectangleD operator + (RectangleD r, PointD p) => new RectangleD (r.X + p.X, r.Y + p.Y, r.Width, r.Height);
+ public static RectangleD operator - (RectangleD r, PointD p) => new RectangleD (r.X - p.X, r.Y - p.Y, r.Width, r.Height);
+ public static bool operator == (RectangleD r1, RectangleD r2) => r1.Equals (r2);
+ public static bool operator != (RectangleD r1, RectangleD r2) => !r1.Equals (r2);
+
+ public static implicit operator RectangleD(Rectangle r) => new RectangleD(r.X,r.Y,r.Width,r.Height);
+ #endregion
+
+ public override int GetHashCode () => HashCode.Combine (X, Y, Width, Height);
+ public override bool Equals (object obj) => obj is RectangleD r ? Equals (r) : false;
+ public bool Equals (RectangleD other) =>
+ X == other.X && Y == other.Y && Width == other.Width && Height == other.Height;
+
+ public override string ToString () => $"{X},{Y},{Width},{Height}";
+ public static RectangleD Parse(string s)
+ {
+ string[] d = s.Split(new char[] { ',' });
+ return new RectangleD(
+ double.Parse(d[0]),
+ double.Parse(d[1]),
+ double.Parse(d[2]),
+ double.Parse(d[3]));
+ }
+ }
+}
diff --git a/Crow/src/2d/Size.cs b/Drawing2D/src/Size.cs
index ee023285..acd5c06c 100644
--- a/Crow/src/2d/Size.cs
+++ b/Drawing2D/src/Size.cs
@@ -1,13 +1,13 @@
-// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
-namespace Crow
+namespace Drawing2D
{
public struct Size : IEquatable<Size>, IEquatable<int>
- {
+ {
public int Width, Height;
#region CTOR
@@ -56,9 +56,10 @@ namespace Crow
public override int GetHashCode () => HashCode.Combine (Width, Height);
public override bool Equals (object obj) => obj is Size s ? Equals(s) : false;
+
public override string ToString () => $"{Width},{Height}";
public static Size Parse(string s)
- {
+ {
ReadOnlySpan<char> tmp = s.AsSpan ();
if (tmp.Length == 0)
return default (Size);
diff --git a/Crow/src/2d/SizeD.cs b/Drawing2D/src/SizeD.cs
index 2dbdb02b..dd466491 100644
--- a/Crow/src/2d/SizeD.cs
+++ b/Drawing2D/src/SizeD.cs
@@ -1,10 +1,11 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+// Copyright (c) 2013-2022 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
-namespace Crow
+namespace Drawing2D
{
- public struct SizeD {
+ public struct SizeD : IEquatable<SizeD>, IEquatable<double> {
public static SizeD Zero => new SizeD (0, 0);
public double Width, Height;
@@ -28,8 +29,8 @@ namespace Crow
public static implicit operator string (SizeD s) => s.ToString ();
public static implicit operator SizeD (string s) => string.IsNullOrEmpty (s) ? Zero : Parse (s);
- public static bool operator == (SizeD s1, SizeD s2) => (s1.Width == s2.Width && s1.Height == s2.Height);
- public static bool operator != (SizeD s1, SizeD s2) => (s1.Width == s2.Width && s1.Height == s2.Height);
+ public static bool operator == (SizeD s1, SizeD s2) => s1.Equals (s2);
+ public static bool operator != (SizeD s1, SizeD s2) => !s1.Equals (s2);
public static bool operator > (SizeD s1, SizeD s2) => (s1.Width > s2.Width && s1.Height > s2.Height);
public static bool operator >= (SizeD s1, SizeD s2) => (s1.Width >= s2.Width && s1.Height >= s2.Height);
public static bool operator < (SizeD s1, SizeD s2) => (s1.Width < s2.Width) ? s1.Height <= s2.Height :
@@ -39,26 +40,19 @@ namespace Crow
public static bool operator > (SizeD s, double i) => s.Width > i && s.Height > i;
public static bool operator >= (SizeD s, double i) => s.Width >= i && s.Height >= i;
public static bool operator <= (SizeD s1, SizeD s2) => (s1.Width <= s2.Width && s1.Height <= s2.Height);
- public static bool operator == (SizeD s, double i) => (s.Width == i && s.Height == i);
- public static bool operator != (SizeD s, double i) => (s.Width == i && s.Height == i);
+ public static bool operator == (SizeD s, double i) => s.Equals (i);
+ public static bool operator != (SizeD s, double i) => !s.Equals (i);
public static SizeD operator + (SizeD s1, SizeD s2) => new SizeD (s1.Width + s2.Width, s1.Height + s2.Height);
public static SizeD operator + (SizeD s, double i) => new SizeD (s.Width + i, s.Height + i);
public static SizeD operator * (SizeD s, double i) => new SizeD (s.Width * i, s.Height * i);
public static SizeD operator / (SizeD s, double i) => new SizeD (s.Width / i, s.Height / i);
#endregion
- public override int GetHashCode ()
- {
- unchecked // Overflow is fine, just wrap
- {
- int hash = 17;
- // Suitable nullity checks etc, of course :)
- hash = hash * 23 + Width.GetHashCode ();
- hash = hash * 23 + Height.GetHashCode ();
- return hash;
- }
- }
- public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (SizeD)) ? false : this == (SizeD)obj;
+ public override int GetHashCode () => HashCode.Combine (Width, Height);
+ public override bool Equals (object obj) => obj is SizeD s ? Equals (s) : false;
+ public bool Equals(SizeD other) => Width == other.Width && Height == other.Height;
+ public bool Equals(double other) => Width == other && Height == other;
+
public override string ToString () => $"{Width},{Height}";
public static SizeD Parse (string s)
{
diff --git a/Drawing2D/src/Surface.cs b/Drawing2D/src/Surface.cs
new file mode 100644
index 00000000..696f1ae2
--- /dev/null
+++ b/Drawing2D/src/Surface.cs
@@ -0,0 +1,23 @@
+// Copyright (c) 2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Drawing2D
+{
+ public interface ISurface: IDisposable
+ {
+ //IntPtr Handle { get; }
+ int Width { get; }
+ int Height { get; }
+
+ void Flush ();
+
+ void WriteToPng (string path);
+ void WriteTo (IntPtr bitmap);
+ void Clear ();
+ ISurface CreateSimilar (int width, int height);
+ }
+}
+
diff --git a/Drawing2D/src/TextExtents.cs b/Drawing2D/src/TextExtents.cs
new file mode 100644
index 00000000..7d1939b7
--- /dev/null
+++ b/Drawing2D/src/TextExtents.cs
@@ -0,0 +1,60 @@
+// Copyright (c) 2018-2022 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.Runtime.InteropServices;
+
+namespace Drawing2D
+{
+ [StructLayout (LayoutKind.Sequential)]
+ public struct TextExtents : IEquatable<TextExtents>
+ {
+ float xBearing;
+ float yBearing;
+ float width;
+ float height;
+ float xAdvance;
+ float yAdvance;
+
+ public float XBearing {
+ get => xBearing;
+ set { xBearing = value; }
+ }
+
+ public float YBearing {
+ get => yBearing;
+ set { yBearing = value; }
+ }
+
+ public float Width {
+ get => width;
+ set { width = value; }
+ }
+
+ public float Height {
+ get => height;
+ set { height = value; }
+ }
+
+ public float XAdvance {
+ get => xAdvance;
+ set { xAdvance = value; }
+ }
+
+ public float YAdvance {
+ get => yAdvance;
+ set { yAdvance = value; }
+ }
+
+ public override int GetHashCode () =>
+ HashCode.Combine (xBearing, yBearing, width, height, xAdvance, yAdvance);
+ public override bool Equals (object obj) => obj is TextExtents te ? Equals (te) : false;
+
+ public bool Equals(TextExtents other) =>
+ xBearing == other.xBearing && yBearing == other.yBearing && width == other.width && height == other.height &&
+ xAdvance == other.xAdvance && yAdvance == other.yAdvance;
+ public static bool operator == (TextExtents extents, TextExtents other) => extents.Equals (other);
+ public static bool operator != (TextExtents extents, TextExtents other )=> !extents.Equals (other);
+ }
+}
diff --git a/Samples/ShowCase/ShowCase.cs b/Samples/ShowCase/ShowCase.cs
index 49663438..4f3d79f8 100644
--- a/Samples/ShowCase/ShowCase.cs
+++ b/Samples/ShowCase/ShowCase.cs
@@ -20,11 +20,13 @@ namespace ShowCase
class Showcase : SampleBaseForEditor
{
DbgEvtType[] logEvts = {
- DbgEvtType.MouseEnter,
+ DbgEvtType.IFace,
+ DbgEvtType.Widget
+ /*DbgEvtType.MouseEnter,
DbgEvtType.MouseLeave,
DbgEvtType.WidgetMouseDown,
DbgEvtType.WidgetMouseUp,
- DbgEvtType.WidgetMouseClick,
+ DbgEvtType.WidgetMouseClick,*/
};
static void Main ()
{
diff --git a/Samples/common/src/Editor.cs b/Samples/common/src/Editor.cs
index 90335d83..0de7af55 100644
--- a/Samples/common/src/Editor.cs
+++ b/Samples/common/src/Editor.cs
@@ -6,13 +6,15 @@ using System;
using Glfw;
using Crow.Text;
using System.Collections.Generic;
-using Crow.Drawing;
+
using System.Threading.Tasks;
using System.Linq;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Collections;
+using Drawing2D;
+
namespace Crow
{
public class Editor : TextBox {
@@ -293,7 +295,7 @@ namespace Crow
base.onKeyDown(sender, e);
}
- protected override void drawContent (Context gr) {
+ protected override void drawContent (IContext gr) {
try {
lock(TokenMutex) {
if (source == null || source.Tokens.Length == 0) {
diff --git a/Samples/common/src/SampleBase.cs b/Samples/common/src/SampleBase.cs
index 91b787fb..6d06dba4 100644
--- a/Samples/common/src/SampleBase.cs
+++ b/Samples/common/src/SampleBase.cs
@@ -10,7 +10,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
-using Crow.Drawing;
+
using System.Diagnostics;
namespace Samples
@@ -390,7 +390,7 @@ namespace Samples
initCommands();
base.OnInitialized();
}
- protected override void processDrawing(Context ctx)
+ protected override void processDrawing(IContext ctx)
{
base.processDrawing(ctx);
}
diff --git a/Samples/common/src/TestWidget.cs b/Samples/common/src/TestWidget.cs
index bf2f6bd0..40970d80 100644
--- a/Samples/common/src/TestWidget.cs
+++ b/Samples/common/src/TestWidget.cs
@@ -1,11 +1,11 @@
//Tutorial
using Crow;
-using Crow.Drawing;
+
using Glfw;
namespace TestWidget {
public class TestWidget : Widget {
- protected override void onDraw (Context gr) {
+ protected override void onDraw (IContext gr) {
base.onDraw (gr);
gr.SetSource (myColor);
gr.Rectangle (ClientRectangle);