]> O.S.I.I.S - jp/crow.git/commitdiff
workinprogress
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 7 Jun 2017 21:36:29 +0000 (23:36 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 7 Jun 2017 21:36:29 +0000 (23:36 +0200)
.gitignore
MDEmbedTest/libcrow.so
MDEmbedTest/main.c
MDEmbedTest/test.cs
src/Crow.Native/LibCrow.cs
src/Crow.Native/crow_object_t.cs
src/GraphicObjects/GraphicObject.cs
src/Interface.cs

index 6e57eec4327a775ac2e22fc4cce1f02af508ad9c..0ac65dfdc3ebb151ab1612ff0dd586348b73d751 100644 (file)
@@ -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
index ff874cc49d17c457a6a6ec1da5712cdbab1c7e39..e151c8a1a8b397921b52d30868b4d4be4e301f49 100755 (executable)
Binary files a/MDEmbedTest/libcrow.so and b/MDEmbedTest/libcrow.so differ
index a6f06783ea04511203b234b42fc3d5c7a09d72f0..d9bd129ae46ff8f6c713f7f28cefd49ca4a9461b 100644 (file)
@@ -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);
index 6a24f9275ec4e74531a13ba04677d569f209b5e0..75d60444ef01c2c2cc2be289053b76423ad1101a 100644 (file)
@@ -1,5 +1,6 @@
 using System;
 using System.Runtime.CompilerServices;
+using System.ComponentModel;
 
 class MonoEmbed {
        [MethodImplAttribute(MethodImplOptions.InternalCall)]
index bd0a147327cb5f1e44aeb3e2225e0107670fecb4..28994f02ce04c4d951a5bfeb8b180e973791af29 100644 (file)
@@ -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();
index e6f5b49295228a022413c3984c5acbef92142c2c..b131795e546b03b179faff1c0881c0ca9d1293b8 100644 (file)
@@ -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;
index 5486030e0639aa2f5d6d220671548513afe0705c..4b81ed28828551b9db402beb2f4acbe33120bd70 100644 (file)
@@ -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);
                        }
index 77f822f06271ba7b2e17598717208afcc772b5c0..7d5eed1345c6b063a0998369f0304a81eab723aa 100644 (file)
@@ -136,7 +136,9 @@ namespace Crow
 
                #region Public Fields
                /// <summary>Graphic Tree of this interface</summary>
-               public List<GraphicObject> GraphicTree = new List<GraphicObject>();
+               public GraphicObject[] GraphicTree = new GraphicObject[1024];
+               public int GraphiTreePointer = 0;
+
                /// <summary>Interface's resulting bitmap</summary>
                public byte[] bmp;
                /// <summary>resulting bitmap limited to last redrawn part</summary>
@@ -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;
                }