aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
-rw-r--r--Crow/Default.style11
-rw-r--r--Crow/src/Cairo/CairoHelpers.cs12
-rw-r--r--Crow/src/DebugUtils/DbgEvtType.cs2
-rw-r--r--Crow/src/DebugUtils/DebugLogger.cs2
-rw-r--r--Crow/src/DebugUtils/PerformanceMeasure.cs2
-rw-r--r--Crow/src/Fill/BmpPicture.cs28
-rw-r--r--Crow/src/Fill/Picture.cs5
-rw-r--r--Crow/src/Fill/SvgPicture.cs61
-rw-r--r--Crow/src/GraphicBackends/Mono.Cairo/Region.cs2
-rw-r--r--Crow/src/GraphicBackends/Mono.Cairo/rsvg/DimensionData.cs (renamed from Crow/src/rsvg/DimensionData.cs)0
-rw-r--r--Crow/src/GraphicBackends/Mono.Cairo/rsvg/SvgHandle.cs (renamed from Crow/src/rsvg/Handle.cs)37
-rw-r--r--Crow/src/GraphicBackends/vkvg/Context.cs1
-rw-r--r--Crow/src/GraphicBackends/vkvg/NativeMethods.cs4
-rw-r--r--Crow/src/GraphicBackends/vkvg/Surface.cs11
-rw-r--r--Crow/src/GraphicBackends/vkvg/SvgHandle.cs44
-rw-r--r--Crow/src/GraphicBackends/vkvg/VulkanContext.cs24
-rw-r--r--Crow/src/GraphicBackends/vkvg/tmp/Region.cs98
-rw-r--r--Crow/src/Interface.cs75
-rw-r--r--Crow/src/Widgets/Border.cs10
-rw-r--r--Crow/src/Widgets/Expandable.cs2
-rw-r--r--Crow/src/Widgets/GroupBase.cs4
-rw-r--r--Crow/src/Widgets/Image.cs2
-rw-r--r--Crow/src/Widgets/Label.cs4
-rw-r--r--Crow/src/Widgets/PrivateContainer.cs2
-rw-r--r--Crow/src/Widgets/Scroller.cs7
-rw-r--r--Crow/src/Widgets/Shape.cs6
-rw-r--r--Crow/src/Widgets/TemplatedControl.cs10
-rw-r--r--Crow/src/Widgets/Widget.cs14
-rw-r--r--Samples/BasicTests/BasicTests.cs8
-rw-r--r--Samples/HelloWorld/main.cs20
-rw-r--r--Samples/common/samples.style6
-rw-r--r--Samples/common/ui/Interfaces/Divers/welcome.crow48
-rw-r--r--Samples/common/ui/Interfaces/Stack/StretchedInFit4.crow8
-rw-r--r--Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow2
34 files changed, 366 insertions, 206 deletions
diff --git a/Crow/Default.style b/Crow/Default.style
index 46de42c9..428939a0 100644
--- a/Crow/Default.style
+++ b/Crow/Default.style
@@ -319,7 +319,7 @@ TableHeaderLabel {
}
Button, CheckBox, RadioButton, ComboBox, Expandable,
-MessageBox, Popper, Slider, Spinner, TextBox, NumericControl {
+MessageBox, Popper, Slider, Spinner, TextBox, NumericControl, EnumSelector {
//Focusable = "true";
Foreground="${ControlForeground}";
Height = "Fit";
@@ -328,6 +328,9 @@ MessageBox, Popper, Slider, Spinner, TextBox, NumericControl {
Margin="0";
BubbleMouseEvent="MouseWheel|Keyboard";
}
-//TemplatedControl, GenericStack {
-// CacheEnabled="true";
-//} \ No newline at end of file
+TemplatedGroup {
+ UseLoadingThread = "false";
+}
+TemplatedControl, GenericStack {
+ CacheEnabled="true";
+} \ No newline at end of file
diff --git a/Crow/src/Cairo/CairoHelpers.cs b/Crow/src/Cairo/CairoHelpers.cs
index 129879a1..2903b73c 100644
--- a/Crow/src/Cairo/CairoHelpers.cs
+++ b/Crow/src/Cairo/CairoHelpers.cs
@@ -64,7 +64,7 @@ namespace Crow
}
public static void DrawRoundedRectangle(Context gr, double x, double y, double width, double height, double radius)
{
- gr.Save();
+ //gr.Save();
if ((radius > height / 2) || (radius > width / 2))
radius = min(height / 2, width / 2);
@@ -78,11 +78,11 @@ namespace Crow
gr.LineTo(x + radius, y + height);
gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
gr.ClosePath();
- gr.Restore();
+ //gr.Restore();
}
public static void StrokeRaisedRectangle(Context gr, Rectangle r, double width = 1)
{
- gr.Save();
+ //gr.Save();
r.Inflate((int)-width / 2, (int)-width / 2);
gr.LineWidth = width;
gr.SetSource(Colors.White);
@@ -97,11 +97,11 @@ namespace Crow
gr.LineTo(r.BottomLeft);
gr.Stroke();
- gr.Restore();
+ //gr.Restore();
}
public static void StrokeLoweredRectangle(Context gr, Rectangle r, double width = 1)
{
- gr.Save();
+ //gr.Save();
r.Inflate((int)-width / 2, (int)-width / 2);
gr.LineWidth = width;
gr.SetSource(Colors.DarkGrey);
@@ -115,7 +115,7 @@ namespace Crow
gr.LineTo(r.BottomLeft);
gr.Stroke();
- gr.Restore();
+ //gr.Restore();
}
}
}
diff --git a/Crow/src/DebugUtils/DbgEvtType.cs b/Crow/src/DebugUtils/DbgEvtType.cs
index be7f66dd..1b56d77a 100644
--- a/Crow/src/DebugUtils/DbgEvtType.cs
+++ b/Crow/src/DebugUtils/DbgEvtType.cs
@@ -75,6 +75,8 @@ namespace Crow
GOUpdateCache = Widget | Drawing | 0x03,
GOPaintCache = Widget | Drawing | 0x04,
GOPaint = Widget | Drawing | 0x05,
+ GOCreateSurface = Widget | Drawing | 0x06,
+ GOCreateContext = Widget | Drawing | 0x07,
GOLockUpdate = Widget | Lock | 0x01,
GOLockClipping = Widget | Lock | 0x02,
diff --git a/Crow/src/DebugUtils/DebugLogger.cs b/Crow/src/DebugUtils/DebugLogger.cs
index b773b990..07313382 100644
--- a/Crow/src/DebugUtils/DebugLogger.cs
+++ b/Crow/src/DebugUtils/DebugLogger.cs
@@ -265,7 +265,7 @@ lock (logMutex) {
public static void Save(Interface iface, string dbgLogFilePath = "debug.log") {
#if DEBUG_LOG
using (Stream stream = new FileStream (dbgLogFilePath, FileMode.Create, FileAccess.Write))
- Save (iface, stream);
+ Save (iface, stream, 0);
Console.WriteLine ($"Crow Debug Log saved to: {System.IO.Path.GetFullPath(dbgLogFilePath)}");
#endif
}
diff --git a/Crow/src/DebugUtils/PerformanceMeasure.cs b/Crow/src/DebugUtils/PerformanceMeasure.cs
index f4cf76a8..8cd72d97 100644
--- a/Crow/src/DebugUtils/PerformanceMeasure.cs
+++ b/Crow/src/DebugUtils/PerformanceMeasure.cs
@@ -29,7 +29,7 @@ namespace Crow
public static void InitMeasures () {
Measures = new PerformanceMeasure[4];
Measures[(int)Kind.Update] = new PerformanceMeasure (Kind.Update, 1);
- Measures[(int)Kind.Clipping] = new PerformanceMeasure (Kind.Clipping, 1);
+ Measures[(int)Kind.Clipping] = new PerformanceMeasure (Kind.Clipping, 0);
Measures[(int)Kind.Layouting] = new PerformanceMeasure (Kind.Layouting, 1);
Measures[(int)Kind.Drawing] = new PerformanceMeasure (Kind.Drawing, 1);
}
diff --git a/Crow/src/Fill/BmpPicture.cs b/Crow/src/Fill/BmpPicture.cs
index 8284e3a1..4a629105 100644
--- a/Crow/src/Fill/BmpPicture.cs
+++ b/Crow/src/Fill/BmpPicture.cs
@@ -34,7 +34,7 @@ namespace Crow
/// <summary>
/// load the image for rendering from the path given as argument
/// </summary>
- void load (Interface iFace) {
+ public override void load (Interface iFace) {
if (iFace.sharedPictures.ContainsKey (Path)) {
sharedPicture sp = iFace.sharedPictures[Path];
image = (byte[])sp.Data;
@@ -51,6 +51,9 @@ namespace Crow
#if STB_SHARP
StbImageSharp.ImageResult stbi = StbImageSharp.ImageResult.FromStream (stream, StbImageSharp.ColorComponents.RedGreenBlueAlpha);
image = new byte[stbi.Data.Length];
+ #if VKVG
+ Array.Copy (stbi.Data, image, stbi.Data.Length);
+ #else
//rgba to argb for cairo.
for (int i = 0; i < stbi.Data.Length; i += 4) {
image[i] = stbi.Data[i + 2];
@@ -58,17 +61,22 @@ namespace Crow
image[i + 2] = stbi.Data[i];
image[i + 3] = stbi.Data[i + 3];
}
+ #endif
Dimensions = new Size (stbi.Width, stbi.Height);
#else
using (StbImage stbi = new StbImage (stream)) {
image = new byte [stbi.Size];
- //rgba to argb for cairo.
+ #if VKVG
+ Marshal.Copy (stbi.Handle, image, 0, stbi.Size);
+ #else
for (int i = 0; i < stbi.Size; i+=4) {
+ //rgba to argb for cairo. ???? looks like bgra to me.
image [i] = Marshal.ReadByte (stbi.Handle, i + 2);
image [i + 1] = Marshal.ReadByte (stbi.Handle, i + 1);
image [i + 2] = Marshal.ReadByte (stbi.Handle, i);
image [i + 3] = Marshal.ReadByte (stbi.Handle, i + 3);
}
+ #endif
Dimensions = new Size (stbi.Width, stbi.Height);
}
#endif
@@ -102,7 +110,7 @@ namespace Crow
}*/
#region implemented abstract members of Fill
-
+ public override bool IsLoaded => image != null;
public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle))
{
if (image == null)
@@ -133,7 +141,7 @@ namespace Crow
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, ref 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
@@ -174,22 +182,26 @@ namespace Crow
widthRatio = heightRatio;
}
- gr.Save ();
+ //gr.Save ();
+
+ Matrix m = gr.Matrix;
gr.Translate (rect.Left,rect.Top);
gr.Scale (widthRatio, heightRatio);
gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2);
#if VKVG
- using (Surface imgSurf = new Surface (iFace.vkvgDevice, ref 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
- {
+ {
gr.SetSource (imgSurf, 0,0);
gr.Paint ();
}
- gr.Restore ();
+
+ gr.Matrix = m;
+ //gr.Restore ();
}
}
}
diff --git a/Crow/src/Fill/Picture.cs b/Crow/src/Fill/Picture.cs
index 8c885bc8..07da3fb4 100644
--- a/Crow/src/Fill/Picture.cs
+++ b/Crow/src/Fill/Picture.cs
@@ -62,7 +62,7 @@ namespace Crow
/// <summary>
/// unscaled dimensions fetched on loading
/// </summary>
- public Size Dimensions;
+ public Size Dimensions { get; protected set; }
/// <summary>
/// if true and image has to be scalled, it will be scaled in both direction
/// equaly
@@ -98,7 +98,8 @@ namespace Crow
/// <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 bool IsLoaded { get; }
+ public abstract void load (Interface iface);
#region Operators
public static implicit operator Picture(string path) => Parse (path) as Picture;
public static implicit operator string(Picture _pic) => _pic == null ? null : _pic.Path;
diff --git a/Crow/src/Fill/SvgPicture.cs b/Crow/src/Fill/SvgPicture.cs
index 1f1bb12e..0c7e8d62 100644
--- a/Crow/src/Fill/SvgPicture.cs
+++ b/Crow/src/Fill/SvgPicture.cs
@@ -17,7 +17,7 @@ namespace Crow
/// </summary>
public class SvgPicture : Picture
{
- Rsvg.Handle hSVG;
+ SvgHandle hSVG;
#region CTOR
/// <summary>
@@ -31,45 +31,49 @@ namespace Crow
public SvgPicture (string path) : base(path) {}
#endregion
- bool load (Interface iFace)
+ public override void load (Interface iFace)
{
- if (string.IsNullOrEmpty(Path))
- return false;
if (iFace.sharedPictures.ContainsKey (Path)) {
sharedPicture sp = iFace.sharedPictures [Path];
- hSVG = (Rsvg.Handle)sp.Data;
+ hSVG = (SvgHandle)sp.Data;
Dimensions = sp.Dims;
- return true;
+ return;
}
using (Stream stream = iFace.GetStreamFromPath (Path))
- load (stream);
+ load (iFace, stream);
iFace.sharedPictures [Path] = new sharedPicture (hSVG, Dimensions);
- return true;
}
- void load (Stream stream) {
+ void load (Interface iface, Stream stream) {
using (BinaryReader sr = new BinaryReader (stream)) {
- hSVG = new Rsvg.Handle (sr.ReadBytes ((int)stream.Length));
- Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+#if VKVG
+ hSVG = new SvgHandle (iface.vkvgDevice, sr.ReadBytes ((int)stream.Length));
+#else
+ hSVG = new SvgHandle (sr.ReadBytes ((int)stream.Length));
+#endif
+ Dimensions = hSVG.Dimensions;
}
}
- internal static sharedPicture CreateSharedPicture (Stream stream) {
+ internal static sharedPicture CreateSharedPicture (Interface iface, Stream stream) {
SvgPicture pic = new SvgPicture ();
- pic.load (stream);
+ pic.load (iface, stream);
return new sharedPicture (pic.hSVG, pic.Dimensions);
}
- public void LoadSvgFragment (string fragment) {
- hSVG = new Rsvg.Handle (System.Text.Encoding.Unicode.GetBytes(fragment));
+ public void LoadSvgFragment (Interface iface, string fragment) {
+#if VKVG
+ hSVG = new SvgHandle (iface.vkvgDevice, System.Text.Encoding.Unicode.GetBytes(fragment));
+#else
+ hSVG = new SvgHandle (System.Text.Encoding.Unicode.GetBytes(fragment));
+#endif
Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
}
#region implemented abstract members of Fill
-
+ public override bool IsLoaded => hSVG != null;
public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle))
{
if (hSVG == null)
- if (!load (iFace))
- return;
+ load (iFace);
float widthRatio = 1f;
float heightRatio = 1f;
@@ -86,16 +90,20 @@ namespace Crow
widthRatio = heightRatio;
}
- /*using (Surface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
+#if VKVG
+ using (Surface tmp = new Surface (iFace.vkvgDevice, bounds.Width, bounds.Height)) {
+#else
+ using (Surface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
+#endif
using (Context gr = new Context (tmp)) {
gr.Translate (bounds.Left, bounds.Top);
gr.Scale (widthRatio, heightRatio);
gr.Translate ((bounds.Width/widthRatio - Dimensions.Width)/2, (bounds.Height/heightRatio - Dimensions.Height)/2);
- hSVG.RenderCairo (gr);
+ hSVG.Render (gr);
}
ctx.SetSource (tmp);
- }*/
+ }
}
#endregion
@@ -109,8 +117,7 @@ namespace Crow
public override void Paint (Interface iFace, Context gr, Rectangle rect, string subPart = "")
{
if (hSVG == null)
- if (!load (iFace))
- return;
+ load (iFace);
float widthRatio = 1f;
float heightRatio = 1f;
@@ -126,21 +133,21 @@ namespace Crow
widthRatio = heightRatio;
}
- /*gr.Save ();
+ gr.Save ();
gr.Translate (rect.Left,rect.Top);
gr.Scale (widthRatio, heightRatio);
gr.Translate (((float)rect.Width/widthRatio - Dimensions.Width)/2f, ((float)rect.Height/heightRatio - Dimensions.Height)/2f);
if (string.IsNullOrEmpty (subPart))
- hSVG.RenderCairo (gr);
+ hSVG.Render (gr);
else {
string[] parts = subPart.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string p in parts)
- hSVG.RenderCairoSub (gr, "#" + subPart);
+ hSVG.Render (gr, "#" + subPart);
}
- gr.Restore (); */
+ gr.Restore ();
}
}
}
diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Region.cs b/Crow/src/GraphicBackends/Mono.Cairo/Region.cs
index e1540089..3488c528 100644
--- a/Crow/src/GraphicBackends/Mono.Cairo/Region.cs
+++ b/Crow/src/GraphicBackends/Mono.Cairo/Region.cs
@@ -198,6 +198,6 @@ namespace Crow.Cairo
NativeMethods.cairo_region_destroy (Handle);
handle = NativeMethods.cairo_region_create ();
}
- public bool DoesNotContains (Crow.Rectangle rectangle) => Contains (p.Slot) == RegionOverlap.Out;
+ public bool OverlapOut (Crow.Rectangle rectangle) => Contains (p.Slot) == RegionOverlap.Out;
}
}
diff --git a/Crow/src/rsvg/DimensionData.cs b/Crow/src/GraphicBackends/Mono.Cairo/rsvg/DimensionData.cs
index 66aab91c..66aab91c 100644
--- a/Crow/src/rsvg/DimensionData.cs
+++ b/Crow/src/GraphicBackends/Mono.Cairo/rsvg/DimensionData.cs
diff --git a/Crow/src/rsvg/Handle.cs b/Crow/src/GraphicBackends/Mono.Cairo/rsvg/SvgHandle.cs
index bd0e725e..a5c8a8f5 100644
--- a/Crow/src/rsvg/Handle.cs
+++ b/Crow/src/GraphicBackends/Mono.Cairo/rsvg/SvgHandle.cs
@@ -1,18 +1,11 @@
//Copyright GPL2
-#if VKVG
-using vkvg;
-#else
-using Crow.Cairo;
-#endif
+using System;
+using System.Runtime.InteropServices;
+namespace Crow.Cairo {
-namespace Rsvg {
- using System;
- using System.Collections;
- using System.Runtime.InteropServices;
-
- public sealed class Handle {
+ public sealed class SvgHandle : IDisposable {
const string lib = "rsvg-2.40";
public IntPtr Raw;
@@ -44,16 +37,16 @@ namespace Rsvg {
[DllImport (lib)]
static extern IntPtr rsvg_handle_get_metadata (IntPtr raw);
- public Handle ()
+ public SvgHandle ()
{
Raw = rsvg_handle_new();
}
- public Handle (byte[] data)
+ public SvgHandle (byte[] data)
{
Raw = rsvg_handle_new_from_data(data, new UIntPtr ((ulong) (data == null ? 0 : data.Length)), out IntPtr error);
if (error != IntPtr.Zero) throw new Exception (error.ToString());
}
- public Handle (string file_name)
+ public SvgHandle (string file_name)
{
Raw = rsvg_handle_new_from_file(file_name, out IntPtr error);
if (error != IntPtr.Zero) throw new Exception (error.ToString());
@@ -64,30 +57,26 @@ namespace Rsvg {
public void SetDpiXY (double dpi_x, double dpi_y) => rsvg_handle_set_dpi_x_y (Raw, dpi_x, dpi_y);
- public void RenderCairo(Context cr) =>
+ public void Render(Context cr) =>
rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle);
- public void RenderCairoSub (Context cr, string id) =>
+ public void Render (Context cr, string id) =>
rsvg_handle_render_cairo_sub (Raw, cr == null ? IntPtr.Zero : cr.Handle, id);
- public DimensionData Dimensions {
+ public Size Dimensions {
get {
DimensionData dimension_data;
IntPtr native_dimension_data = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (DimensionData)));
rsvg_handle_get_dimensions(Raw, native_dimension_data);
dimension_data = DimensionData.New (native_dimension_data);
Marshal.FreeHGlobal (native_dimension_data);
- return dimension_data;
+ return new Size (dimension_data.Width, dimension_data.Height);
}
}
- public bool Close() {
+ public void Dispose() {
bool raw_ret = rsvg_handle_close(Raw, out IntPtr error);
- if (error != IntPtr.Zero) throw new Exception (error.ToString());
- return raw_ret;
+ if (error != IntPtr.Zero) throw new Exception (error.ToString());
}
-
- public string Title => throw new NotSupportedException ();
- public string Metadata => throw new NotSupportedException ();
}
}
diff --git a/Crow/src/GraphicBackends/vkvg/Context.cs b/Crow/src/GraphicBackends/vkvg/Context.cs
index 870573ba..27db38b4 100644
--- a/Crow/src/GraphicBackends/vkvg/Context.cs
+++ b/Crow/src/GraphicBackends/vkvg/Context.cs
@@ -16,6 +16,7 @@ namespace vkvg
public Context(Surface surf)
{
handle = NativeMethods.vkvg_create(surf.Handle);
+ this.FillRule = FillRule.NonZero;
}
~Context()
{
diff --git a/Crow/src/GraphicBackends/vkvg/NativeMethods.cs b/Crow/src/GraphicBackends/vkvg/NativeMethods.cs
index 1a633521..2e345643 100644
--- a/Crow/src/GraphicBackends/vkvg/NativeMethods.cs
+++ b/Crow/src/GraphicBackends/vkvg/NativeMethods.cs
@@ -239,7 +239,7 @@ namespace vkvg
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr vkvg_surface_create_from_svg_fragment(IntPtr dev, byte[] filePath);
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
- internal static extern IntPtr vkvg_surface_create_from_bitmap(IntPtr dev, ref byte[] data, uint width, uint height);
+ internal static extern IntPtr vkvg_surface_create_from_bitmap(IntPtr dev, ref byte data, uint width, uint height);
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
internal static extern void vkvg_surface_destroy(IntPtr surf);
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
@@ -262,7 +262,7 @@ namespace vkvg
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr nsvg_load_file(IntPtr dev, string filePath);
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
- internal static extern IntPtr nsvg_load(IntPtr dev, byte[] fragment);
+ internal static extern IntPtr nsvg_load(IntPtr dev, ref byte fragment);
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
internal static extern void nsvg_destroy(IntPtr nsvgImage);
[DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)]
diff --git a/Crow/src/GraphicBackends/vkvg/Surface.cs b/Crow/src/GraphicBackends/vkvg/Surface.cs
index de7682cf..d942b5c5 100644
--- a/Crow/src/GraphicBackends/vkvg/Surface.cs
+++ b/Crow/src/GraphicBackends/vkvg/Surface.cs
@@ -11,15 +11,18 @@ namespace vkvg
IntPtr handle = IntPtr.Zero;
Device vkvgDev;
- public Surface (Device device, int width, int heigth)
+ public Surface (Device device, int width, int height)
{
vkvgDev = device;
- handle = NativeMethods.vkvg_surface_create (device.Handle, (uint)width, (uint)heigth);
+ if (width <= 0 || height <= 0)
+ handle = NativeMethods.vkvg_surface_create (device.Handle, 1, 1);
+ else
+ handle = NativeMethods.vkvg_surface_create (device.Handle, (uint)width, (uint)height);
}
- public Surface (Device device, ref byte[] data, int width, int heigth)
+ public Surface (Device device, Span<byte> data, int width, int heigth)
{
vkvgDev = device;
- handle = NativeMethods.vkvg_surface_create (device.Handle, (uint)width, (uint)heigth);
+ handle = NativeMethods.vkvg_surface_create_from_bitmap (device.Handle, ref data.GetPinnableReference(), (uint)width, (uint)heigth);
}
public Surface (Device device, string imgPath) {
vkvgDev = device;
diff --git a/Crow/src/GraphicBackends/vkvg/SvgHandle.cs b/Crow/src/GraphicBackends/vkvg/SvgHandle.cs
new file mode 100644
index 00000000..fb55f74e
--- /dev/null
+++ b/Crow/src/GraphicBackends/vkvg/SvgHandle.cs
@@ -0,0 +1,44 @@
+//Copyright GPL2
+using System;
+using System.Runtime.InteropServices;
+using Crow;
+
+namespace vkvg {
+
+
+ public sealed class SvgHandle : IDisposable {
+
+ public IntPtr Raw;
+
+ public SvgHandle (vkvg.Device dev, Span<byte> bytes)
+ {
+ /*int size = svgFragment.Length * 4 + 1;
+ Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
+ int encodedBytes = Crow.Text.Encoding.ToUtf8 (svgFragment, bytes);
+ bytes[encodedBytes] = 0;*/
+ Raw = NativeMethods.nsvg_load (dev.Handle, ref bytes.GetPinnableReference());
+ }
+ public SvgHandle (vkvg.Device dev, string file_name)
+ {
+ Raw = NativeMethods.nsvg_load_file (dev.Handle, file_name);
+ }
+
+ public void Render(Context cr) =>
+ cr.RenderSvg (Raw);
+
+ public void Render (Context cr, string id) =>
+ cr.RenderSvg (Raw, id);
+
+ public Size Dimensions {
+ get {
+ NativeMethods.nsvg_get_size (Raw, out int w, out int h);
+ return new Size (w, h);
+ }
+ }
+
+ public void Dispose() {
+ NativeMethods.nsvg_destroy (Raw);
+ }
+
+ }
+}
diff --git a/Crow/src/GraphicBackends/vkvg/VulkanContext.cs b/Crow/src/GraphicBackends/vkvg/VulkanContext.cs
index 8ca1eb6d..4488fb8f 100644
--- a/Crow/src/GraphicBackends/vkvg/VulkanContext.cs
+++ b/Crow/src/GraphicBackends/vkvg/VulkanContext.cs
@@ -45,7 +45,7 @@ namespace vkvg {
uint frameCount;
Stopwatch frameChrono;
- string[] EnabledInstanceExtensions => null;
+ string[] EnabledInstanceExtensions => new string[] { Ext.I.VK_EXT_debug_utils };
string[] EnabledDeviceExtensions => new string[] { Ext.D.VK_KHR_swapchain };
@@ -53,10 +53,11 @@ namespace vkvg {
public void WaitIdle() => dev.WaitIdle ();
public VulkanContext (IntPtr hWin, uint _width, uint _height, bool vsync = false) {
this.hWin = hWin;
- Instance.VALIDATION = true;
- /*Instance.RENDER_DOC_CAPTURE = true;*/
+ //Instance.VALIDATION = true;
+ //Instance.RENDER_DOC_CAPTURE = true;
SwapChain.IMAGES_USAGE = VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransferDst;
+ SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Unorm;
List<string> instExts = new List<string> (Glfw3.GetRequiredInstanceExtensions ());
if (EnabledInstanceExtensions != null)
@@ -99,11 +100,12 @@ namespace vkvg {
}
public vkvg.Device CreateVkvgDevice () =>
- new vkvg.Device (instance.Handle, phy.Handle, dev.VkDev.Handle, presentQueue.qFamIndex);
+ new vkvg.Device (instance.Handle, phy.Handle, dev.VkDev.Handle, presentQueue.qFamIndex, SampleCount.Sample_8);
internal vke.Image blitSource;
public void BuildBlitCommand (vkvg.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,
@@ -144,20 +146,26 @@ namespace vkvg {
/// Main render method called each frame. get next swapchain image, process resize if needed, submit and present to the presentQueue.
/// Wait QueueIdle after presenting.
/// </summary>
- public void render () {
+ public bool render () {
+ WaitIdle();
+
int idx = swapChain.GetNextImage ();
if (idx < 0) {
width = swapChain.Width;
height = swapChain.Height;
- return;
+ //Console.WriteLine ($"get next image failed w:{width} h:{height}");
+ return false;
}
if (cmds[idx] == null)
- return;
+ return false;
WaitAndResetDrawFence();
presentQueue.Submit (cmds[idx], swapChain.presentComplete, drawComplete[idx], drawFence);
- presentQueue.Present (swapChain, drawComplete[idx]);
+ presentQueue.Present (swapChain, drawComplete[idx]);
+
+ WaitIdle();
+ return true;
}
#region IDisposable Support
diff --git a/Crow/src/GraphicBackends/vkvg/tmp/Region.cs b/Crow/src/GraphicBackends/vkvg/tmp/Region.cs
index 2d061e64..c07aa065 100644
--- a/Crow/src/GraphicBackends/vkvg/tmp/Region.cs
+++ b/Crow/src/GraphicBackends/vkvg/tmp/Region.cs
@@ -13,41 +13,49 @@ namespace Crow {
Part,
}
public class Region : IDisposable
- {
- public List<Rectangle> list = new List<Rectangle>();
- public int count => list.Count;
+ {
+ public List<Rectangle> list = new List<Rectangle>();
+ public int count => list.Count;
public int NumRectangles => list.Count;
public bool IsEmpty => list.Count == 0;
public Rectangle GetRectangle(int i) => list[i];
- public void AddRectangle(Rectangle r)
- {
+ public void AddRectangle(Rectangle r)
+ {
+ if (r == default)
+ return;
if (DoesNotContains (r)) {
list.Add (r);
boundsUpToDate = false;
}
- }
- public void Reset()
- {
- list = new List<Rectangle>();
+ }
+ public void Reset()
+ {
+ list = new List<Rectangle>();
_bounds = default;
boundsUpToDate = true;
- }
- public bool DoesNotContains(Rectangle r)
- {
- foreach (Rectangle rInList in list)
- if (rInList.ContainsOrIsEqual(r))
- return false;
- return true;
- }
+ }
+ public bool DoesNotContains(Rectangle r)
+ {
+ foreach (Rectangle rInList in list)
+ if (rInList.ContainsOrIsEqual(r))
+ return false;
+ return true;
+ }
+ public bool OverlapOut (Rectangle r) {
+ foreach (Rectangle rInList in list)
+ if (rInList.Intersect(r))
+ return false;
+ return true;
+ }
- public bool intersect(Rectangle r)
- {
- foreach (Rectangle rInList in list)
- if (rInList.Intersect(r))
- return true;
- return false;
- }
+ public bool intersect(Rectangle r)
+ {
+ foreach (Rectangle rInList in list)
+ if (rInList.Intersect(r))
+ return true;
+ return false;
+ }
public void stroke(Context ctx, Color c)
{
foreach (Rectangle r in list)
@@ -58,27 +66,29 @@ namespace Crow {
ctx.LineWidth = 2;
ctx.Stroke ();
}
- public void clearAndClip(Context ctx)
- {
+ public void clearAndClip(Context ctx)
+ {
if (list.Count == 0)
return;
- foreach (Rectangle r in list)
- ctx.Rectangle(r);
+ foreach (Rectangle r in list)
+ ctx.Rectangle(r);
ctx.ClipPreserve();
ctx.Operator = Operator.Clear;
- ctx.Fill();
- ctx.Operator = Operator.Over;
- }
+ ctx.Fill();
+ ctx.Operator = Operator.Over;
+ }
- public void clip(Context ctx)
- {
- foreach (Rectangle r in list)
- ctx.Rectangle(r);
+ public void clip(Context ctx)
+ {
+ foreach (Rectangle r in list)
+ ctx.Rectangle(r);
- ctx.Clip();
- }
+ ctx.Clip();
+ }
public void UnionRectangle (Rectangle r) {
+ /*if (r == default)
+ System.Diagnostics.Debugger.Break ();*/
AddRectangle (r);
}
Rectangle _bounds;
@@ -99,13 +109,13 @@ namespace Crow {
}
}
public void clear(Context ctx)
- {
- foreach (Rectangle r in list)
- ctx.Rectangle(r);
- ctx.Operator = Operator.Clear;
- ctx.Fill();
- ctx.Operator = Operator.Over;
- }
+ {
+ foreach (Rectangle r in list)
+ ctx.Rectangle(r);
+ ctx.Operator = Operator.Clear;
+ ctx.Fill();
+ ctx.Operator = Operator.Over;
+ }
public override string ToString ()
{
string tmp = "";
diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs
index 5825661a..367ed25e 100644
--- a/Crow/src/Interface.cs
+++ b/Crow/src/Interface.cs
@@ -150,12 +150,12 @@ namespace Crow
PerformanceMeasure.InitMeasures ();
- if (startUIThread) {
+ /*if (startUIThread) {
Thread t = new Thread (InterfaceThread) {
IsBackground = true
};
t.Start ();
- }
+ }*/
}
#endregion
@@ -206,7 +206,7 @@ namespace Crow
#if VKVG
vkCtx = new VulkanContext (hWin, (uint)clientRectangle.Width, (uint)clientRectangle.Height);
vkvgDevice = vkCtx.CreateVkvgDevice ();
- surf = new Surface (vkvgDevice, clientRectangle.Width, clientRectangle.Height);
+ surf = new Surface (vkvgDevice, clientRectangle.Width, clientRectangle.Height);
vkCtx.BuildBlitCommand (surf);
#else
switch (Environment.OSVersion.Platform) {
@@ -259,8 +259,8 @@ namespace Crow
image [i + 2] = Marshal.ReadByte (stbi.Handle, i);
image [i + 3] = Marshal.ReadByte (stbi.Handle, i + 3);
}
- Glfw.Image icon = new Glfw.Image (stbi.Width, stbi.Height, image);
- Glfw3.setWindowIcon (hWin, 1, ref icon);
+ Glfw.Image icon = new Glfw.Image ((uint)stbi.Width, (uint)stbi.Height, image);
+ Glfw3.SetWindowIcon (hWin, 1, ref icon);
icon.Dispose();
}
#endif
@@ -382,7 +382,10 @@ namespace Crow
Terminate ();
}
public virtual void Terminate () {}
- public virtual void UpdateFrame () { Thread.Sleep (1); }
+ public virtual void UpdateFrame () {
+ Update ();
+ Thread.Sleep (UPDATE_INTERVAL);
+ }
public virtual void Quit () => Glfw3.SetWindowShouldClose (hWin, 1);
@@ -707,7 +710,7 @@ namespace Crow
string resId = $"#{pic.Substring (path.Length + 1).Replace (Path.DirectorySeparatorChar, '.')}";
using (Stream s = new FileStream (pic, FileMode.Open, FileAccess.Read)) {
if (resId.EndsWith (".svg", StringComparison.OrdinalIgnoreCase))
- sharedPictures[resId] = SvgPicture.CreateSharedPicture (s);
+ sharedPictures[resId] = SvgPicture.CreateSharedPicture (this, s);
else
sharedPictures[resId] = BmpPicture.CreateSharedPicture (s);
}
@@ -1039,18 +1042,24 @@ namespace Crow
clippingRegistration ();
- if (ctx == null) {
- using (ctx = new Context (surf))
+
+ if (!clipping.IsEmpty) {
+ if (ctx == null) {
+ using (ctx = new Context (surf))
+ processDrawing (ctx);
+ }else
processDrawing (ctx);
- }else
- processDrawing (ctx);
+ }
#if VKVG
if (IsDirty) {
- IsDirty = false;
- vkCtx.render ();
+ if (vkCtx.render ())
+ IsDirty = false;
+ else {
+ resizeVulkanContext();
+ }
}
-#endif
+#endif
} finally {
@@ -1062,6 +1071,19 @@ namespace Crow
PerformanceMeasure.Notify ();
}
+ void resizeVulkanContext () {
+ vkCtx.WaitIdle();
+ vkCtx.blitSource?.Dispose ();
+ surf?.Dispose ();
+ surf = new Surface (vkvgDevice, clientRectangle.Width, clientRectangle.Height);
+ vkCtx.BuildBlitCommand (surf);
+ vkCtx.WaitIdle();
+ foreach (Widget g in GraphicTree)
+ g.RegisterForLayouting (LayoutingType.All);
+
+ registerRefreshClientRectangle ();
+
+ }
/// <summary>Layouting loop, this is the first step of the udpate and process registered
/// Layouting queue items. Failing LQI's are requeued in this cycle until MaxTry is reached which
/// trigger an enqueue for the next Update Cycle</summary>
@@ -1118,7 +1140,7 @@ namespace Crow
ctx.ClipPreserve ();
ctx.Operator = Operator.Clear;
- ctx.Fill ();
+ ctx.Fill ();
ctx.Operator = Operator.Over;
}
bool solidBackground = false;
@@ -1148,7 +1170,7 @@ namespace Crow
if (DragImage != null)
clipping.UnionRectangle(DragImageBounds);
- if (!clipping.IsEmpty) {
+
PerformanceMeasure.Begin (PerformanceMeasure.Kind.Drawing);
#if VKVG
@@ -1158,13 +1180,14 @@ namespace Crow
if (SolidBackground)
clear (ctx);
+ ctx.Flush();
#endif
for (int i = GraphicTree.Count -1; i >= 0 ; i--){
Widget p = GraphicTree[i];
if (!p.IsVisible)
continue;
- if (clipping.DoesNotContains (p.Slot))
+ if (clipping.OverlapOut (p.Slot))
continue;
//ctx.Save ();
@@ -1191,15 +1214,17 @@ namespace Crow
#if DEBUG_CLIP_RECTANGLE
ctx.LineWidth = 1;
- ctx.SetSource(1,0,0,0.5);
+ ctx.SetSource(1,1,0,0.5);
for (int i = 0; i < clipping.NumRectangles; i++)
ctx.Rectangle(clipping.GetRectangle(i));
ctx.Stroke ();
+
#endif
#if VKVG
+ ctx.Flush();
//vkCtx.render ();
- vkCtx.WaitIdle();
+ //vkCtx.WaitIdle();
#else
ctx.PopGroupToSource ();
@@ -1215,9 +1240,9 @@ namespace Crow
PerformanceMeasure.End (PerformanceMeasure.Kind.Drawing);
IsDirty = true;
- }
+
- drawTextCursor (ctx);
+ //drawTextCursor (ctx);
debugHighlightFocus (ctx);
@@ -1398,11 +1423,7 @@ namespace Crow
clientRectangle = bounds;
#if VKVG
- vkCtx.WaitIdle();
- vkCtx.blitSource?.Dispose ();
- surf?.Dispose ();
- surf = new Surface (vkvgDevice, clientRectangle.Width, clientRectangle.Height);
- vkCtx.BuildBlitCommand (surf);
+
#else
switch (Environment.OSVersion.Platform) {
case PlatformID.MacOSX:
@@ -1425,11 +1446,11 @@ namespace Crow
case PlatformID.WinCE:
throw new PlatformNotSupportedException ("Unable to create cairo surface.");
}
-#endif
foreach (Widget g in GraphicTree)
g.RegisterForLayouting (LayoutingType.All);
registerRefreshClientRectangle ();
+#endif
}
}
diff --git a/Crow/src/Widgets/Border.cs b/Crow/src/Widgets/Border.cs
index 0dc156f2..8fe98003 100644
--- a/Crow/src/Widgets/Border.cs
+++ b/Crow/src/Widgets/Border.cs
@@ -108,15 +108,15 @@ namespace Crow
{
drawborder2 (gr);
- gr.Save ();
+ /*gr.Save ();
if (ClipToClientRect) {
CairoHelpers.CairoRectangle (gr, ClientRectangle, Math.Max (0.0, CornerRadius - Margin));
gr.Clip ();
- }
+ }*/
+
+ child?.Paint (gr);
- if (child != null)
- child.Paint (gr);
- gr.Restore ();
+ //gr.Restore ();
}
void drawborder2(Context gr){
Rectangle rBack = new Rectangle (Slot.Size);
diff --git a/Crow/src/Widgets/Expandable.cs b/Crow/src/Widgets/Expandable.cs
index d63249bb..1e334c2e 100644
--- a/Crow/src/Widgets/Expandable.cs
+++ b/Crow/src/Widgets/Expandable.cs
@@ -49,7 +49,7 @@ namespace Crow
public override void OnDataSourceChanged(object sender, DataSourceChangeEventArgs e)
{
base.OnDataSourceChanged(sender, e);
- NotifyValueChanged ("IsExpandable", IsExpandable);
+ //NotifyValueChanged ("IsExpandable", IsExpandable);
}
/// <summary>
diff --git a/Crow/src/Widgets/GroupBase.cs b/Crow/src/Widgets/GroupBase.cs
index 6387048f..7a30f34e 100644
--- a/Crow/src/Widgets/GroupBase.cs
+++ b/Crow/src/Widgets/GroupBase.cs
@@ -259,7 +259,7 @@ namespace Crow
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
gr.Operator = Operator.Clear;
- gr.Fill();
+ gr.Fill();
gr.Operator = Operator.Over;
base.onDraw (gr);
@@ -274,7 +274,7 @@ namespace Crow
foreach (Widget c in Children) {
if (!c.IsVisible)
continue;
- if (Clipping.DoesNotContains (c.Slot + ClientRectangle.Position))
+ if (Clipping.OverlapOut (c.Slot + ClientRectangle.Position))
continue;
c.Paint (gr);
}
diff --git a/Crow/src/Widgets/Image.cs b/Crow/src/Widgets/Image.cs
index 001931b3..c460c598 100644
--- a/Crow/src/Widgets/Image.cs
+++ b/Crow/src/Widgets/Image.cs
@@ -165,6 +165,8 @@ namespace Crow
{
if (_pic == null)
return 2 * Margin;
+ if (!_pic.IsLoaded)
+ _pic.load (IFace);
//_pic = "#Crow.Images.Icons.IconAlerte.svg";
//TODO:take scalling in account
if (lt == LayoutingType.Width)
diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs
index f11066e2..de485184 100644
--- a/Crow/src/Widgets/Label.cs
+++ b/Crow/src/Widgets/Label.cs
@@ -641,6 +641,8 @@ namespace Crow
protected override void onDraw (Context gr)
{
+ DbgLogger.StartEvent(DbgEvtType.GODraw, this);
+
base.onDraw (gr);
setFontForContext (gr);
@@ -661,6 +663,8 @@ namespace Crow
if (ClipToClientRect)
gr.Restore ();
+
+ DbgLogger.EndEvent (DbgEvtType.GODraw);
}
#endregion
diff --git a/Crow/src/Widgets/PrivateContainer.cs b/Crow/src/Widgets/PrivateContainer.cs
index 65a93357..af7367e4 100644
--- a/Crow/src/Widgets/PrivateContainer.cs
+++ b/Crow/src/Widgets/PrivateContainer.cs
@@ -224,7 +224,7 @@ namespace Crow
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
gr.Operator = Operator.Clear;
- gr.Fill();
+ gr.Fill();
gr.Operator = Operator.Over;
onDraw (gr);
diff --git a/Crow/src/Widgets/Scroller.cs b/Crow/src/Widgets/Scroller.cs
index 8a8f640d..1d56b56b 100644
--- a/Crow/src/Widgets/Scroller.cs
+++ b/Crow/src/Widgets/Scroller.cs
@@ -191,8 +191,9 @@ namespace Crow
Background.SetAsSource (IFace, gr, rBack);
CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
gr.Fill ();
-
+
gr.Save ();
+
if (ClipToClientRect) {
//clip to scrolled client zone
CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
@@ -200,8 +201,12 @@ namespace Crow
}
gr.Translate (-ScrollX, -ScrollY);
+
if (child != null)
child.Paint (gr);
+
+ //gr.Translate (ScrollX, ScrollY);
+
gr.Restore ();
}
diff --git a/Crow/src/Widgets/Shape.cs b/Crow/src/Widgets/Shape.cs
index da00ae37..20cbeb6c 100644
--- a/Crow/src/Widgets/Shape.cs
+++ b/Crow/src/Widgets/Shape.cs
@@ -223,7 +223,8 @@ namespace Crow
widthRatio = heightRatio;
}
- gr.Save ();
+ Matrix m = gr.Matrix;
+ //gr.Save ();
gr.Translate (cr.Left, cr.Top);
gr.Scale (widthRatio, heightRatio);
@@ -235,7 +236,8 @@ namespace Crow
using (PathParser parser = new PathParser (path))
parser.Draw (gr);
- gr.Restore ();
+ //gr.Restore ();
+ gr.Matrix = m;
}
diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs
index aaf5a962..0ee818bb 100644
--- a/Crow/src/Widgets/TemplatedControl.cs
+++ b/Crow/src/Widgets/TemplatedControl.cs
@@ -86,26 +86,26 @@ namespace Crow
//public override T FindByType<T> () => this is TemplatedControl tg ? tg : default (T);
public Widget FindByNameInTemplate (string nameToFind) => child?.FindByName (nameToFind);
/// <summary>
- ///onDraw is overrided to prevent default drawing of background, template top container
+ ///onDraw is overriden to prevent default drawing of background, template top container
///may have a binding to root background or a fixed one.
///this allow applying root background to random template's component
/// </summary>
/// <param name="gr">Backend context</param>
protected override void onDraw (Context gr)
{
- DbgLogger.StartEvent (DbgEvtType.GODraw, this);
-
- gr.Save ();
+ DbgLogger.StartEvent (DbgEvtType.GODraw, this);
if (ClipToClientRect) {
//clip to client zone
+ gr.Save ();
CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
gr.Clip ();
}
child?.Paint (gr);
- gr.Restore ();
+ if (ClipToClientRect)
+ gr.Restore ();
DbgLogger.EndEvent (DbgEvtType.GODraw);
}
diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs
index 8c3b82a2..601c6033 100644
--- a/Crow/src/Widgets/Widget.cs
+++ b/Crow/src/Widgets/Widget.cs
@@ -1934,13 +1934,18 @@ namespace Crow
bmp.SetSize (Slot.Width, Slot.Height);*/
bmp?.Dispose ();
#if (VKVG)
+ DbgLogger.StartEvent (DbgEvtType.GOCreateSurface, this);
bmp = new Surface (IFace.vkvgDevice, Slot.Width, Slot.Height);
+ DbgLogger.EndEvent (DbgEvtType.GOCreateSurface);
+ //bmp.Clear();
#else
bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height);
#endif
//bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
+ DbgLogger.StartEvent (DbgEvtType.GOCreateContext, this);
using (Context gr = new Context (bmp)) {
+ DbgLogger.EndEvent (DbgEvtType.GOCreateContext);
gr.Antialias = Interface.Antialias;
onDraw (gr);
}
@@ -1958,8 +1963,9 @@ namespace Crow
ctx.Operator = Operator.Over;
}
- ctx.SetSource (bmp, rb.X, rb.Y);
+ ctx.SetSource (bmp, rb.X, rb.Y);
ctx.Paint ();
+ ctx.Flush ();
DbgLogger.EndEvent(DbgEvtType.GOPaintCache);
}
protected virtual void UpdateCache(Context ctx){
@@ -2009,13 +2015,15 @@ namespace Crow
paintDisabled (ctx, Slot + Parent.ClientRectangle.Position);
} else {
Rectangle rb = Slot + Parent.ClientRectangle.Position;
- ctx.Save ();
+ //ctx.Save ();
ctx.Translate (rb.X, rb.Y);
onDraw (ctx);
- ctx.Restore ();
+ ctx.Translate (-rb.X, -rb.Y);
+
+ //ctx.Restore ();
if (!IsEnabled)
paintDisabled (ctx, rb);
diff --git a/Samples/BasicTests/BasicTests.cs b/Samples/BasicTests/BasicTests.cs
index 11eed07e..9de4e4c1 100644
--- a/Samples/BasicTests/BasicTests.cs
+++ b/Samples/BasicTests/BasicTests.cs
@@ -11,6 +11,10 @@ namespace Samples
{
static void Main ()
{
+ DbgLogger.IncludeEvents = DbgEvtType.Widget;
+ DbgLogger.DiscardEvents = DbgEvtType.None;
+ Crow.DbgLogger.ConsoleOutput = false;
+
using (BasicTests app = new BasicTests ()) {
app.SolidBackground = false;
app.Run ();
@@ -42,12 +46,12 @@ namespace Samples
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray ();
- /*testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedControl", "*.crow")).ToArray ();
+ testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedControl", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedContainer", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedGroup", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Wrapper", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray ();
- testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/DragAndDrop", "*.crow")).ToArray ();*/
+ testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/DragAndDrop", "*.crow")).ToArray ();
//testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Experimental", "*.crow")).ToArray ();
Load (testFiles [idx]).DataSource = this;
diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs
index e2be248e..cb5b413b 100644
--- a/Samples/HelloWorld/main.cs
+++ b/Samples/HelloWorld/main.cs
@@ -7,7 +7,25 @@ namespace HelloWorld
class Program : SampleBase {
static void Main (string[] args) {
using (Interface app = new Program ()) {
- app.Initialized += (sender, e) => (sender as Interface).Load ("#HelloWorld.helloworld.crow").DataSource = sender;
+ //app.Initialized += (sender, e) => (sender as Interface).Load ("#HelloWorld.helloworld.crow").DataSource = sender;
+ /*app.Initialized += (sender, e) => (sender as Interface).LoadIMLFragment (@"
+<Border Background='Red' Margin='100' Fit='true' BorderWidth='10'>
+<Image Path='/mnt/devel/CrowIDE/Crow/Images/screenshot3.png' Width='100' Height='100' />
+</Border>
+").DataSource = sender;*/
+app.Initialized += (sender, e) => (sender as Interface).LoadIMLFragment (@"
+<Container Background='Jet' Margin='10' CacheEnabled='false'>
+ <CheckBox Background='Blue' CacheEnabled='false'>
+ <Template>
+ <Border Background='{./Background}' Margin='5' CacheEnabled='false'>
+ <HorizontalStack Margin='30' CacheEnabled='true'>
+ <Label Background='Pink' Fit='true' CacheEnabled='false'/>
+ </HorizontalStack>
+ </Border>
+ </Template>
+ </CheckBox>
+</Container>
+").DataSource = sender;
app.Run ();
}
}
diff --git a/Samples/common/samples.style b/Samples/common/samples.style
index 6f78b149..ee5a541a 100644
--- a/Samples/common/samples.style
+++ b/Samples/common/samples.style
@@ -4,14 +4,14 @@ FpsLabel {
Width = "30";
Font = "droid, 10";
Margin = "0";
- TextAlignment = "Center";
+ //TextAlignment = "Center";
}
FpsDisp {
Font = "droid bold, 10";
Width = "60";
Margin = "0";
- CornerRadius = "3";
- TextAlignment = "Center";
+ //CornerRadius = "3";
+ //TextAlignment = "Center";
Background = "MediumSeaGreen";
}
HStackMeasure {
diff --git a/Samples/common/ui/Interfaces/Divers/welcome.crow b/Samples/common/ui/Interfaces/Divers/welcome.crow
index 9c7e942c..cddf8bff 100644
--- a/Samples/common/ui/Interfaces/Divers/welcome.crow
+++ b/Samples/common/ui/Interfaces/Divers/welcome.crow
@@ -1,19 +1,33 @@
<?xml version="1.0"?>
-<Border BorderStyle="Sunken" Fit="true" Background="0.8,0.8,0.9,0.5" CornerRadius="30">
- <VerticalStack Margin="20" Spacing="10">
- <Image Path="#Crow.Icons.crow.svg" Width="64" Height="64" Background="WhiteSmoke" CornerRadius="5" Margin="5"/>
-<!-- <Label Font="Times bold, 60" Text="C.R.O.W"/>-->
- <HorizontalStack Fit="true" DataSource="{CrowVersion}" Spacing="0" Background="Grey" Margin="10" CornerRadius="15">
- <Label Foreground="Jet" Font="mono, 12" Text="version: "/>
- <Label Foreground="Black" Font="mono, 16" Text="{Major}"/>
- <Label Foreground="Black" Font="mono, 12" Text="."/>
- <Label Foreground="Black" Font="mono, 16" Text="{Minor}"/>
- <Label Foreground="Black" Font="mono, 12" Text="."/>
- <Label Foreground="DarkBlue" Font="mono, 14" Text="{Build}" VerticalAlignment="Bottom"/>
+<VerticalStack>
+<ListBox Data="{PerfMeasures}" Height="Fit">
+ <Template>
+ <VerticalStack Name="ItemsContainer" Width="90%" Spacing="2"/>
+ </Template>
+ <ItemTemplate>
+ <HorizontalStack Style="HStackMeasure" Width="Stretched">
+ <Label Text="{Name}" Style="FpsLabel" Width="Stretched"/>
+ <Label Text="{current}" Style="FpsDisp" Width="25%" TextAlignment="Right" Margin="2"/>
+ <Label Text="{minimum}" Style="FpsDisp" Width="25%" TextAlignment="Right" Margin="2"/>
+ <Label Text="{maximum}" Style="FpsDisp" Width="25%" TextAlignment="Right" Margin="2"/>
+ <Button Width="Fit" Caption="reset" MouseClick="onResetClick"/>
</HorizontalStack>
- <Label Font="20" Text="Press &lt;F2&gt; and &lt;F3&gt; to cycle into the examples"/>
- <Label Font="20" Text="Those are basic tests used to validate changes,"/>
- <Label Foreground="Onyx" Font="20" Text="&lt;F5&gt; => File dialog example"/>
- <Label Foreground="Onyx" Font="20" Text="&lt;F6&gt; => Window example"/>
- </VerticalStack>
-</Border> \ No newline at end of file
+ </ItemTemplate>
+</ListBox>
+<ListBox Data="{PerfMeasures}" Height="Fit">
+ <Template>
+
+ <VerticalStack Name="ItemsContainer" Width="90%" Spacing="2"/>
+
+ </Template>
+ <ItemTemplate>
+ <HorizontalStack Style="HStackMeasure" Width="Stretched">
+ <Label Text="{Name}" Style="FpsLabel" Width="Stretched"/>
+ <Label Text="{current}" Style="FpsDisp" Width="25%" TextAlignment="Right" Margin="2"/>
+ <Label Text="{minimum}" Style="FpsDisp" Width="25%" TextAlignment="Right" Margin="2"/>
+ <Label Text="{maximum}" Style="FpsDisp" Width="25%" TextAlignment="Right" Margin="2"/>
+ <Button Width="Fit" Caption="reset" MouseClick="onResetClick"/>
+ </HorizontalStack>
+ </ItemTemplate>
+</ListBox>
+</VerticalStack>
diff --git a/Samples/common/ui/Interfaces/Stack/StretchedInFit4.crow b/Samples/common/ui/Interfaces/Stack/StretchedInFit4.crow
index 2c0b7721..7dc7be90 100644
--- a/Samples/common/ui/Interfaces/Stack/StretchedInFit4.crow
+++ b/Samples/common/ui/Interfaces/Stack/StretchedInFit4.crow
@@ -1,10 +1,12 @@
<?xml version="1.0"?>
<Container Background="DimGrey" Margin="10" Width="Fit" Height="Fit" >
- <Popper Width="Stretched" Margin="10" Background="RoyalBlue">
- <Container Width="Fit" Height="Fit" Margin="10" Background="Blue">
+ <Popper Width="Stretched" Margin="0" Background="Red"
+ MouseEnter="{Background=Yellow}"
+ MouseLeave="{Background=Red}">
+ <Container Width="Fit" Height="Fit" Margin="10" Background="{./Background}">
<Container Margin="10" Background="Yellow">
<Container Margin="10" Background="FireBrick">
- <CheckBox/>
+
</Container>
</Container>
</Container>
diff --git a/Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow b/Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow
index 63590efd..1e6e03fa 100644
--- a/Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow
+++ b/Samples/common/ui/Interfaces/TemplatedControl/testEnumSelector.crow
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<VerticalStack Spacing="5" Margin="5">
- <EnumSelector Caption="Vertical Alignemnt" EnumValue="{²CurrentVAlign}" Width="200">
+ <EnumSelector Caption="Vertical Alignemnt" EnumValue="{²CurrentVAlign}" Width="200" Background="Onyx">
<Template>
<Popper Caption="{./Caption}" CornerRadius="{./CornerRadius}" Foreground="{./Foreground}" Background="{./Background}">
<Template>