From: jpbruyere Date: Wed, 7 Jun 2017 21:36:29 +0000 (+0200) Subject: workinprogress X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=60ab9840d644f806cb010f9e4f385107a6f51ebf;p=jp%2Fcrow.git workinprogress --- diff --git a/.gitignore b/.gitignore index 6e57eec4..0ac65dfd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ Crow.userprefs Debug packages *.o +*.so *.nupkg /GOLib.suo /tmp @@ -23,3 +24,5 @@ Tests/Tests.userprefs src/GraphicObjects/Panel.cs src/GraphicObjects/VerticalWrappingWidget.cs src/GraphicObjects/HorizontalWrappingWidget.cs +MDEmbedTest/mdembed +*.exe diff --git a/MDEmbedTest/libcrow.so b/MDEmbedTest/libcrow.so index ff874cc4..e151c8a1 100755 Binary files a/MDEmbedTest/libcrow.so and b/MDEmbedTest/libcrow.so differ diff --git a/MDEmbedTest/main.c b/MDEmbedTest/main.c index a6f06783..d9bd129a 100644 --- a/MDEmbedTest/main.c +++ b/MDEmbedTest/main.c @@ -73,6 +73,7 @@ main(int argc, char* argv[]) { mono_add_internal_call ("Crow.Native.LibCrow::crow_context_process_clipping", crow_context_process_clipping); mono_add_internal_call ("Crow.Native.LibCrow::crow_context_process_layouting", crow_context_process_layouting); mono_add_internal_call ("Crow.Native.LibCrow::crow_context_process_drawing", crow_context_process_drawing); + mono_add_internal_call ("Crow.Native.LibCrow::crow_context_resize", crow_context_resize); mono_add_internal_call ("Crow.Native.LibCrow::crow_object_create", crow_object_create); mono_add_internal_call ("Crow.Native.LibCrow::crow_object_destroy", crow_object_destroy); diff --git a/MDEmbedTest/test.cs b/MDEmbedTest/test.cs index 6a24f927..75d60444 100644 --- a/MDEmbedTest/test.cs +++ b/MDEmbedTest/test.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.CompilerServices; +using System.ComponentModel; class MonoEmbed { [MethodImplAttribute(MethodImplOptions.InternalCall)] diff --git a/src/Crow.Native/LibCrow.cs b/src/Crow.Native/LibCrow.cs index bd0a1473..28994f02 100644 --- a/src/Crow.Native/LibCrow.cs +++ b/src/Crow.Native/LibCrow.cs @@ -47,6 +47,8 @@ namespace Crow.Native internal static extern void crow_context_process_clipping (IntPtr ctx); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void crow_context_process_drawing (IntPtr ctx, IntPtr cairoCtx); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + internal static extern void crow_context_resize (IntPtr ctx, int width, int height); [MethodImplAttribute(MethodImplOptions.InternalCall)] unsafe internal static extern crow_object_t* crow_object_create(); diff --git a/src/Crow.Native/crow_object_t.cs b/src/Crow.Native/crow_object_t.cs index e6f5b492..b131795e 100644 --- a/src/Crow.Native/crow_object_t.cs +++ b/src/Crow.Native/crow_object_t.cs @@ -37,6 +37,7 @@ namespace Crow.Native { [StructLayout(LayoutKind.Sequential)] unsafe public struct crow_object_t { public CrowType TypeObj; + internal int managedIdx;//private managed ptr to allow libcrow to call instance methods public IntPtr Context; public int ChildrenCount; public crow_object_t* Parent; diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 5486030e..4b81ed28 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -74,6 +74,9 @@ namespace Crow nativeHnd = LibCrow.crow_object_create (); LibCrow.crow_object_set_type (nativeHnd, CrowType.Simple); nativeHnd->Context = Interface.CurrentInterface.layoutingCtx; + nativeHnd->managedIdx = Interface.CurrentInterface.GraphiTreePointer; + Interface.CurrentInterface.GraphicTree [Interface.CurrentInterface.GraphiTreePointer] = this; + Interface.CurrentInterface.GraphiTreePointer++; nativeHnd->IsDirty = 1; //nativeHnd->OnLayoutChanged = Marshal.GetFunctionPointerForDelegate((LayoutChangedCallBack)OnLayoutChanges); } diff --git a/src/Interface.cs b/src/Interface.cs index 77f822f0..7d5eed13 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -136,7 +136,9 @@ namespace Crow #region Public Fields /// Graphic Tree of this interface - public List GraphicTree = new List(); + public GraphicObject[] GraphicTree = new GraphicObject[1024]; + public int GraphiTreePointer = 0; + /// Interface's resulting bitmap public byte[] bmp; /// resulting bitmap limited to last redrawn part @@ -501,21 +503,14 @@ namespace Crow #endregion public void ProcessResize(Rectangle bounds){ - lock (UpdateMutex) { - unsafe { - nativeHnd->Slot.Width = bounds.Width; - nativeHnd->Slot.Height = bounds.Height; - } + lock (UpdateMutex) { clientRectangle = bounds; int stride = 4 * ClientRectangle.Width; int bmpSize = Math.Abs (stride) * ClientRectangle.Height; bmp = new byte[bmpSize]; dirtyBmp = new byte[bmpSize]; - foreach (GraphicObject g in GraphicTree) - g.RegisterForLayouting (LayoutingType.All); - - RegisterClip (clientRectangle); + LibCrow.crow_context_resize (layoutingCtx, bounds.Width, bounds.Height); } } @@ -551,62 +546,62 @@ namespace Crow return true; } - if (HoverWidget != null) { - //check topmost graphicobject first - GraphicObject tmp = HoverWidget; - GraphicObject topc = null; - while (!(tmp is Interface)) { - topc = tmp; - tmp = tmp.LogicalParent; - } - int idxhw = GraphicTree.IndexOf (topc); - if (idxhw != 0) { - int i = 0; - while (i < idxhw) { - if (GraphicTree [i].localLogicalParentIsNull) { - if (GraphicTree [i].MouseIsIn (e.Position)) { - while (HoverWidget != null) { - HoverWidget.onMouseLeave (HoverWidget, e); - HoverWidget = HoverWidget.LogicalParent; - } - - GraphicTree [i].checkHoverWidget (e); - return true; - } - } - i++; - } - } - - if (HoverWidget.MouseIsIn (e.Position)) { - HoverWidget.checkHoverWidget (e); - return true; - } else { - HoverWidget.onMouseLeave (HoverWidget, e); - //seek upward from last focused graph obj's - while (!(HoverWidget.LogicalParent is Interface)) { - HoverWidget = HoverWidget.LogicalParent; - if (HoverWidget.MouseIsIn (e.Position)) { - HoverWidget.checkHoverWidget (e); - return true; - } else - HoverWidget.onMouseLeave (HoverWidget, e); - } - } - } - - //top level graphic obj's parsing - lock (GraphicTree) { - for (int i = 0; i < GraphicTree.Count; i++) { - GraphicObject g = GraphicTree [i]; - if (g.MouseIsIn (e.Position)) { - g.checkHoverWidget (e); -// if (g is Window) -// PutOnTop (g); - return true; - } - } - } +// if (HoverWidget != null) { +// //check topmost graphicobject first +// GraphicObject tmp = HoverWidget; +// GraphicObject topc = null; +// while (!(tmp is Interface)) { +// topc = tmp; +// tmp = tmp.LogicalParent; +// } +// int idxhw = GraphicTree.IndexOf (topc); +// if (idxhw != 0) { +// int i = 0; +// while (i < idxhw) { +// if (GraphicTree [i].localLogicalParentIsNull) { +// if (GraphicTree [i].MouseIsIn (e.Position)) { +// while (HoverWidget != null) { +// HoverWidget.onMouseLeave (HoverWidget, e); +// HoverWidget = HoverWidget.LogicalParent; +// } +// +// GraphicTree [i].checkHoverWidget (e); +// return true; +// } +// } +// i++; +// } +// } +// +// if (HoverWidget.MouseIsIn (e.Position)) { +// HoverWidget.checkHoverWidget (e); +// return true; +// } else { +// HoverWidget.onMouseLeave (HoverWidget, e); +// //seek upward from last focused graph obj's +// while (!(HoverWidget.LogicalParent is Interface)) { +// HoverWidget = HoverWidget.LogicalParent; +// if (HoverWidget.MouseIsIn (e.Position)) { +// HoverWidget.checkHoverWidget (e); +// return true; +// } else +// HoverWidget.onMouseLeave (HoverWidget, e); +// } +// } +// } +// +// //top level graphic obj's parsing +// lock (GraphicTree) { +// for (int i = 0; i < GraphicTree.Count; i++) { +// GraphicObject g = GraphicTree [i]; +// if (g.MouseIsIn (e.Position)) { +// g.checkHoverWidget (e); +//// if (g is Window) +//// PutOnTop (g); +// return true; +// } +// } +// } HoverWidget = null; return false; }