]> O.S.I.I.S - jp/crow.git/commitdiff
threaded combo, Monodevelop addin improve
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 5 Oct 2015 10:08:56 +0000 (12:08 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 5 Oct 2015 10:08:57 +0000 (12:08 +0200)
19 files changed:
GOLib.csproj
MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml
MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
MonoDevelop.GOLib/src/DisplayBinding.cs
MonoDevelop.GOLib/src/GOLibGtkHost.cs
MonoDevelop.GOLib/src/GOLibNodeExtension.cs
MonoDevelop.GOLib/src/GOLibView.cs
Tests/GOLIBTest_4.cs
Tests/Interfaces/fps.goml
Tests/Interfaces/test4.goml
Tests/Tests.csproj
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/Combobox.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/ListBox.cs
src/Interface.cs
src/LayoutingQueueItem.cs
src/OpenTKGameWindow.cs

index 989740d6bb0162420d66e4e65afc0f258c57f6ed..2cd31f8915b488a68a6316c82a7d33189f371f73 100644 (file)
@@ -46,7 +46,7 @@
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
     <OutputPath>bin\Debug</OutputPath>\r
-    <DefineConstants>TRACE;DEBUG;__linux__;DEBUG_LOAD_TIME</DefineConstants>\r
+    <DefineConstants>TRACE;DEBUG;__linux__;DEBUG_LOAD_TIME=1</DefineConstants>\r
   </PropertyGroup>\r
   <!--  <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">\r
     <DefineConstants>__linux__</DefineConstants>\r
index 5dcac15335b383de5d406985b76d7c5e5bfde38a..fe15b3e9ee3e378b0f71b0382d314f8895130d0a 100644 (file)
@@ -13,4 +13,7 @@
                        <File pattern="*.goml" />
                </MimeType>
        </Extension>
+<!--   <Extension path = "/MonoDevelop/DesignerSupport/PropertyProviders" extension-nodes="Class">
+               <Class class = "MonoDevelop.GOLib.GOLibItemPropertyProvider"/>
+       </Extension>-->
 </ExtensionModel>
\ No newline at end of file
index 4dfac2d9233ca8185fe10ba9c5a79dfc8885ef72..b2099b5a651138fc36514b56f5b9737ab5e97280 100644 (file)
     <OutputPath>build</OutputPath>
     <CustomCommands>
       <CustomCommands>
-        <Command type="Execute" 
-               command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe --no-redirect" 
-               workingdir="/usr/local/lib/monodevelop/bin" 
-               >
+        <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe --no-redirect" workingdir="/usr/local/lib/monodevelop/bin">
           <EnvironmentVariables>
             <Variable name="MONODEVELOP_DEV_ADDINS" value="${TargetDir}" />
             <Variable name="MONODEVELOP_CONSOLE_LOG_LEVEL" value="UpToDebug" />
             <Variable name="MONODEVELOP_LOGGING_PAD_LEVEL" value="UpToDebug" />
-            <Variable name="MONODEVELOP_CONSOLE_LOG_USE_COLOUR" value="True"/>
+            <Variable name="MONODEVELOP_CONSOLE_LOG_USE_COLOUR" value="True" />
           </EnvironmentVariables>
         </Command>
       </CustomCommands>
       <HintPath>\usr\local\lib\monodevelop\bin\MonoDevelop.Ide.dll</HintPath>
       <Private>False</Private>
     </Reference>
+    <Reference Include="MonoDevelop.Core">
+      <HintPath>\usr\local\lib\monodevelop\bin\MonoDevelop.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="MonoDevelop.DesignerSupport">
+      <HintPath>\usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
     <Reference Include="Mono.Cairo" />
     <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
       <Package>gtk-sharp-2.0</Package>
     <Reference Include="System.Xml" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Drawing" />
-    <Reference Include="MonoDevelop.DesignerSupport">
-      <HintPath>\usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
-      <Private>False</Private>
-    </Reference>
     <Reference Include="OpenTK">
       <HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
     </Reference>
-    <Reference Include="MonoDevelop.Core">
-      <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\bin\MonoDevelop.Core.dll</HintPath>
+    <Reference Include="MonoDevelop.SourceEditor2">
+      <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor2.dll</HintPath>
+    </Reference>
+    <Reference Include="Mono.TextEditor">
+      <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\bin\Mono.TextEditor.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup>
index 55c6e78af046cc4aa606156895a4fb2b0325473b..1898f16b868be41e845fa80501be3aa157c58bac 100644 (file)
@@ -64,7 +64,7 @@ namespace MonoDevelop.GOLib
                        }
                }
                public bool CanUseAsDefault 
-               { get { return false; }}
+               { get { return true; }}
 
                public IViewContent CreateContent (FilePath fileName, string mimeType, Project ownerProject)
                {                       
index f2a0bfa915a38204002b8d115fb4c22372e3ec6a..d041bba766993d3892729043237182c8251b26a8 100644 (file)
@@ -9,20 +9,31 @@ using MonoDevelop.Projects;
 using System.Diagnostics;
 using OpenTK.Input;
 using MonoDevelop.DesignerSupport;
+using System.IO;
+using MonoDevelop.Components.Commands;
 
 namespace MonoDevelop.GOLib
 {
-       public class GOLibGtkHost : Gtk.DrawingArea, ILayoutable, IGOLibHost, IPropertyPadProvider
+       public class GOLibGtkHost : Gtk.DrawingArea, ILayoutable, IGOLibHost, IPropertyPadProvider,ICommandDelegator
        {
+               #region ICommandDelegator implementation
+
+               public object GetDelegatedCommandTarget ()
+               {
+                       return hoverWidget;
+               }
+
+               #endregion
+
                #region IPropertyPadProvider implementation
 
                public object GetActiveComponent ()
                {
-                       return hoverWidget;
+                       return activeWidget;
                }
                public object GetProvider ()
                {
-                       return hoverWidget;
+                       return activeWidget;
                }
                public void OnEndEditing (object obj)
                {
@@ -30,7 +41,8 @@ namespace MonoDevelop.GOLib
                }
                public void OnChanged (object obj)
                {
-
+                       (obj as GraphicObject).registerForGraphicUpdate ();
+                       QueueDraw ();
                }
                #endregion
        
@@ -64,7 +76,7 @@ namespace MonoDevelop.GOLib
                        Cairo.Context cr =  Gdk.CairoHelper.Create(area.GdkWindow);
                        _redrawClip.AddRectangle (this.ClientRectangle);
 
-                       LoggingService.LogInfo ("expose event");
+                       //LoggingService.LogInfo ("expose event");
 
                        update (cr);
 
@@ -85,7 +97,8 @@ namespace MonoDevelop.GOLib
                                ((int)args.Event.X, (int)args.Event.Y, 
                                        gtkButtonIdToOpenTkButton(args.Event.Button), true);
                        Mouse_ButtonDown (o, e);
-                       DesignerSupport.DesignerSupport.Service.SetPadContent (this);
+
+                       DesignerSupport.DesignerSupport.Service.SetPadContent (this, this);
                }
                void GOLibGtkHost_ButtonReleaseEvent (object o, Gtk.ButtonReleaseEventArgs args)
                {
@@ -129,11 +142,42 @@ namespace MonoDevelop.GOLib
 
                public void Load(string path)
                {
-                       goWidget = Interface.Load (path);
+                       load(Interface.Load (path));
+               }
+
+               public void Load(Stream stream)
+               {
+                       GraphicObject tmp = null;
+                       try {
+                               tmp = Interface.Load (stream, Interface.GetTopContainerOfGOMLStream (stream));
+                       } catch (Exception ex) {
+                               return; 
+                       } 
+                       load (tmp);
+                       QueueDraw ();
+               }
+
+               void load(GraphicObject go)
+               {
+                       if (goWidget != null)
+                               DeleteWidget (goWidget);
+                       goWidget = go;
                        this.AddWidget (goWidget);
                }
 
+               public void AddWidget(GraphicObject g)
+               {
+                       g.Parent = this;
+                       GraphicObjects.Insert (0, g);
 
+                       g.RegisterForLayouting ((int)LayoutingType.Sizing);
+               }
+               public void DeleteWidget(GraphicObject g)
+               {
+                       g.Visible = false;//trick to ensure clip is added to refresh zone
+                       g.ClearBinding();
+                       GraphicObjects.Remove (g);
+               }
 
                public List<GraphicObject> GraphicObjects = new List<GraphicObject>();
                public Color Background = Color.Transparent;
@@ -294,20 +338,6 @@ namespace MonoDevelop.GOLib
                #endregion
                                        
 
-               public void AddWidget(GraphicObject g)
-               {
-                       g.Parent = this;
-                       GraphicObjects.Insert (0, g);
-
-                       g.RegisterForLayouting ((int)LayoutingType.Sizing);
-               }
-               public void DeleteWidget(GraphicObject g)
-               {
-                       g.Visible = false;//trick to ensure clip is added to refresh zone
-                       g.ClearBinding();
-                       GraphicObjects.Remove (g);
-               }
-
 //             public void LoadInterface<T>(string path, out T result)
 //             {
 //                     GraphicObject.Load<T> (path, out result, this);
@@ -335,11 +365,11 @@ namespace MonoDevelop.GOLib
                #region Mouse Handling
                void Mouse_Move(object sender, MouseMoveEventArgs e)
                {
-                       if (_activeWidget != null) {
-                               //send move evt even if mouse move outside bounds
-                               _activeWidget.onMouseMove (_activeWidget, e);
-                               return;
-                       }
+//                     if (_activeWidget != null) {
+//                             //send move evt even if mouse move outside bounds
+//                             _activeWidget.onMouseMove (_activeWidget, e);
+//                             return;
+//                     }
 
                        if (_hoverWidget != null) {
                                //check topmost graphicobject first
@@ -394,11 +424,11 @@ namespace MonoDevelop.GOLib
                }
                void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
                {
-                       if (_activeWidget == null)
-                               return;
+//                     if (_activeWidget == null)
+//                             return;
 
-                       _activeWidget.onMouseButtonUp (this, e);
-                       _activeWidget = null;
+                       //_activeWidget.onMouseButtonUp (this, e);
+                       //_activeWidget = null;
                        MouseButtonUp.Raise (this, e);
                }
                void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
@@ -407,17 +437,9 @@ namespace MonoDevelop.GOLib
                                MouseButtonDown.Raise (this, e);
                                return;
                        }
-
-                       GraphicObject g = _hoverWidget;
-                       while (!g.Focusable) {                          
-                               g = g.Parent as GraphicObject;
-                               if (g == null) {                                        
-                                       return;
-                               }
-                       }
-
-                       _activeWidget = g;
-                       _activeWidget.onMouseButtonDown (this, e);
+                               
+                       _activeWidget = _hoverWidget;
+                       //_activeWidget.onMouseButtonDown (this, e);
                }
 
                void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
index 3388c5796f0012b44a68731d69cd0e5fea90dca9..8c68d4cf450fac1dbe22a0998b29665344638b76 100644 (file)
@@ -31,6 +31,7 @@ using MonoDevelop.Components;
 using MonoDevelop.Components.Commands;
 using MonoDevelop.Ide;
 using System.Linq;
+using MonoDevelop.DesignerSupport;
 
 namespace MonoDevelop.GOLib
 {
@@ -64,7 +65,7 @@ namespace MonoDevelop.GOLib
                } 
        }
        
-       class GOLibCommandHandler: NodeCommandHandler 
+       class GOLibCommandHandler: NodeCommandHandler //, IPropertyPadProvider
        {
                [CommandHandler (Commands.ShowGOLibViewer)]
                protected void OnShowGOLibViewer () 
@@ -80,19 +81,55 @@ namespace MonoDevelop.GOLib
                        
                        IdeApp.Workbench.OpenDocument (view, true);
                        //IdeApp.Workbench.Documents.Where (d => d.FileName == file.FilePath);
-
                }
-               public override void ActivateItem ()
-               {
+
+//             public override void ActivateItem ()
+//             {
 //                     ProjectFile o = this.CurrentNode.DataItem as ProjectFile;
+//
 //                     Ide.Gui.Document[] doc = IdeApp.Workbench.Documents.Where (d => d.FileName == o.FilePath).ToArray();
-//                     if (doc [0].ActiveView != null)
-//                             return;
-                               //doc [0].ActiveView.Select();
-                       OnShowGOLibViewer ();
-               }
+//                     var tmp = MonoDevelop.Ide.Gui.DisplayBindingService.GetFileViewers (o.FilePath, o.Project).ToList();
+//
+//                     OnShowGOLibViewer ();
+//             }
 
+//             #region IPropertyPadProvider implementation
+//             public object GetActiveComponent ()
+//             {
+//                     if (CurrentNodes.Length == 1)
+//                             return CurrentNode.DataItem;
+//                     else
+//                             return null;
+//             }
+//             public object GetProvider ()
+//             {
+//                     return null;
+//             }
+//             public void OnEndEditing (object obj)
+//             {
+//                     throw new NotImplementedException ();
+//             }
+//             public void OnChanged (object obj)
+//             {
+//                     
+//             }
+//             #endregion
        }
 
+//     class GOLibItemPropertyProvider : IPropertyProvider
+//     {
+//             #region IPropertyProvider implementation
+//             public object CreateProvider (object obj)
+//             {
+//                     var projectFile = obj as ProjectFile;
+//                     return projectFile;
+//             }
+//
+//             public bool SupportsObject (object obj)
+//             {
+//                     return obj is ProjectFile;
+//             }
+//             #endregion
+//     }
 }
 
index 650cfd0959a8e41893acd6cbc46b9438ddddcbf8..a7cc3713e8454b6b0950ac8634acd019c04b1124 100644 (file)
@@ -55,44 +55,107 @@ using MonoDevelop.Core;
 using MonoDevelop.Ide;
 using go;
 using MonoDevelop.DesignerSupport;
+using MonoDevelop.SourceEditor;
 
 namespace MonoDevelop.GOLib
 {
-       class GOLibView : AbstractViewContent
+       class CustomVPaned : Gtk.VPaned, IPropertyPadProvider
+       {
+               #region IPropertyPadProvider implementation
+               public object GetActiveComponent ()
+               {
+                       return this.Child1 == null ? this as object: (this.Child1 as GOLibGtkHost).activeWidget as object;
+               }
+               public object GetProvider ()
+               {
+                       return null;
+                       //throw new NotImplementedException ();
+               }
+               public void OnEndEditing (object obj)
+               {
+                       //throw new NotImplementedException ();
+               }
+               public void OnChanged (object obj)
+               {
+                       //throw new NotImplementedException ();
+               }
+               #endregion
+               
+       }
+       class GOLibView : SourceEditorView
        {
                GOLibGtkHost gtkGoWidgetHost;
+               CustomVPaned gtkGOMLWidget;
 
 
                double zoom = 1.0;
                
                public override Gtk.Widget Control {
                        get {
-                               return gtkGoWidgetHost;
+                               return gtkGOMLWidget;
                        }
                }
 
-               public GOLibView ()
+               public GOLibView () : base()
                {                       
                        gtkGoWidgetHost = new GOLibGtkHost ();
+                       gtkGOMLWidget = new CustomVPaned ();
+                       gtkGOMLWidget.CanFocus = true;
+                       gtkGOMLWidget.Name = "vpaned1";
+                       gtkGOMLWidget.Add (gtkGoWidgetHost);
+                       gtkGOMLWidget.Add (base.Control);
+                       gtkGOMLWidget.SizeAllocated += GtkGOMLWidget_SizeAllocated;
 
+                       this.Document.DocumentUpdated += Document_DocumentUpdated;
+                       //this.DirtyChanged += GOLibView_DirtyChanged;
                }
 
-               public override void Load (string fileName)
-               {                                                       
-                       gtkGoWidgetHost.Load (fileName);
-                       ContentName = fileName;
-                       this.IsDirty = false;
+               void Document_DocumentUpdated (object sender, EventArgs e)
+               {
+                       reloadGOML ();
+               }
+
+               void GOLibView_DirtyChanged (object sender, EventArgs e)
+               {
 
-                       gtkGoWidgetHost.Show ();
                }
-               public override bool CanReuseView (string fileName)
+
+               void reloadGOML()
                {
-                       return base.CanReuseView (fileName);
+                       using (MemoryStream stream = new MemoryStream ()) {
+                               using (StreamWriter writer = new StreamWriter (stream)) {
+                                       writer.Write (this.Document.Text);
+                                       writer.Flush ();
+
+                                       stream.Position = 0;
+                                       gtkGoWidgetHost.Load (stream);
+                               }
+                       }                       
                }
-               public override void RedrawContent ()
+                       
+               void GtkGOMLWidget_SizeAllocated (object o, Gtk.SizeAllocatedArgs args)
                {
-                       base.RedrawContent ();
+                       gtkGoWidgetHost.SetSizeRequest (-1, args.Allocation.Height / 2);
+               }
+
+               public override void Load (string fileName)
+               {                                                       
+                       gtkGoWidgetHost.Load (fileName);
+                       //ContentName = fileName;
+                       //this.IsDirty = false;
+                       gtkGOMLWidget.ShowAll ();
+                       gtkGOMLWidget.Show ();
+
+                       base.Load (fileName);
                }
+//             public override bool CanReuseView (string fileName)
+//             {
+//                     return base.CanReuseView (fileName);
+//             }
+//             public override void RedrawContent ()
+//             {
+//                     base.RedrawContent ();
+//             }
 
        }
 }
index a5cdbb4903ca813293cb1c01d3b2cd9a51d4a894..62b9d25748d77c0cf579f71a4cf8c7a6c6b04d04 100644 (file)
@@ -82,6 +82,11 @@ namespace test
                        new ClsItem("string 1"),\r
                        new ClsItem("string 2")\r
                        });\r
+               int i = 0;\r
+               Color[] colorsArray;\r
+               volatile List<GraphicObject> loadedCols = new List<GraphicObject>();\r
+               volatile bool allColsLoaded = false;\r
+               private static readonly object mutex = new object();\r
 \r
                protected override void OnLoad (EventArgs e)\r
                {\r
@@ -114,9 +119,18 @@ namespace test
 //                     };\r
 \r
 \r
-                       int i = 0;\r
-                       foreach (Color col in Color.ColorDic) {\r
-                               HorizontalStack s = colors.addChild (new HorizontalStack () { Fit = true});\r
+                       colorsArray = Color.ColorDic.ToArray ();\r
+\r
+                       Thread t = new Thread (loadingThread);\r
+                       t.Start ();\r
+\r
+//                     ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));\r
+               }\r
+\r
+               void loadingThread()\r
+               {                       \r
+                       foreach (Color col in colorsArray) {\r
+                               HorizontalStack s = new HorizontalStack () { Fit = true};\r
                                s.HorizontalAlignment = HorizontalAlignment.Left;\r
                                Border b = new Border () {\r
                                        Bounds = new Size (32, 20),\r
@@ -140,10 +154,18 @@ namespace test
                                        }\r
                                );\r
                                i++;\r
-                               if (i > 150)\r
-                                       break;\r
-                       }\r
-//                     ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));\r
+\r
+                               while(true){\r
+                                       lock (mutex) {\r
+                                               loadedCols.Add (s);\r
+                                               break;\r
+                                       }\r
+                               }\r
+\r
+                               Thread.Sleep (10);\r
+                               \r
+                       }       \r
+                       allColsLoaded = true;\r
                }\r
                void pFps_mousemove(object sender, MouseMoveEventArgs e)\r
                {\r
@@ -154,7 +176,34 @@ namespace test
                        c.Top += e.YDelta;\r
                        c.registerForGraphicUpdate ();\r
                }\r
-\r
+               void onButClick(object send, MouseButtonEventArgs e)\r
+               {\r
+                       Color col = Color.ColorDic.ToArray () [i];\r
+                       HorizontalStack s = colors.addChild (new HorizontalStack () { Fit = true});\r
+                       s.HorizontalAlignment = HorizontalAlignment.Left;\r
+                       Border b = new Border () {\r
+                               Bounds = new Size (32, 20),\r
+                               CornerRadius = 5,\r
+                               Background = col,\r
+                               BorderWidth = 2,\r
+                               BorderColor = Color.Transparent,\r
+                               Focusable = true\r
+                       };\r
+                       b.MouseEnter += delegate(object sender, MouseMoveEventArgs ee) {\r
+                               (sender as Border).BorderColor = Color.White;\r
+                       };\r
+                       b.MouseLeave += delegate(object sender, MouseMoveEventArgs ee) {\r
+                               (sender as Border).BorderColor = Color.Transparent;\r
+                       };\r
+                       s.addChild (b);\r
+\r
+                       s.addChild (\r
+                               new Label (col.ToString ()){\r
+                                       Bounds=new Rectangle(0,0,-1,-1),\r
+                               }\r
+                       );\r
+                       i++;\r
+               }\r
                private int frameCpt = 0;\r
                protected override void OnUpdateFrame (FrameEventArgs e)\r
                {\r
@@ -162,6 +211,14 @@ namespace test
 \r
                        fps = (int)RenderFrequency;\r
 \r
+                       lock (mutex) {\r
+                               if (loadedCols.Count > 50 || allColsLoaded) {\r
+                                       while (loadedCols.Count > 0) {\r
+                                               colors.addChild (loadedCols[0]);\r
+                                               loadedCols.RemoveAt (0);\r
+                                       }\r
+                               }\r
+                       }\r
 \r
                        if (frameCpt > 200) {\r
                                resetFps ();\r
index baa85b6377b2b9e1a2de1f8a8694130718eed39d..91d026402efd7e96848a29264cb69cad954c17a7 100755 (executable)
@@ -1,22 +1,24 @@
 ï»¿<?xml version="1.0"?>\r
-<Container Name="MainGrp" Background="0,5;0,5;0,5;0,5"\r
-       Margin="10" Width="-1" Height="-1" Focusable="True" >\r
-               <VerticalStack Name="vsFps"  BorderWidth="1" Margin="5" Spacing="4" Fit="true">\r
-                       <HorizontalStack Height="-1">\r
-                               <Label Text="Update:" FontColor="White" />\r
-                               <Label Name="labUpdate" Text="{update}" FontSize="12" Background="DarkGreen"/>\r
-                       </HorizontalStack>\r
-                       <HorizontalStack Height="-1" Name="hsFps" Background="Mantis" >\r
-                               <Label Name="captionFps" Text="Fps:" />\r
-                               <Label Name="valueFps" Text="{fps}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>\r
-                       </HorizontalStack>\r
-                       <HorizontalStack Height="-1" Background="UniversityOfCaliforniaGold">\r
-                               <Label Text="Min:" Width = "30" />\r
-                               <Label Text="{fpsMin}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>\r
-                       </HorizontalStack>\r
-                       <HorizontalStack Height="-1" Background="Sienna" >\r
-                               <Label Text="Max:" Width = "30"/>\r
-                               <Label Text="{fpsMax}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>\r
-                       </HorizontalStack>\r
-               </VerticalStack>                                \r
-</Container>
\ No newline at end of file
+<Border Fit="true" CornerRadius="5" BorderWidth="1">\r
+       <Container Name="MainGrp" Background="0,5;0,5;0,5;0,4" Width="120" Fit="true"\r
+               Margin="10" Focusable="True" >\r
+                       <VerticalStack Fit="true" Name="vsFps"  Spacing="10" >\r
+                               <HorizontalStack Fit="true">\r
+                                       <Label Text="Update:" Width="50" TextAlignment="RightCenter"/>\r
+                                       <Label Name="labUpdate" Text="{update}" Font="droid,12" Background="AoEnglish" Width="50" TextAlignment="Center"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack Fit="true">\r
+                                       <Label Name="captionFps" Text="Fps:" Width="50" TextAlignment="RightCenter"/>\r
+                                       <Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack Fit="true">\r
+                                       <Label Text="Min:" Width="50" TextAlignment="RightCenter"/>\r
+                                       <Label Text="{fpsMin}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>\r
+                               </HorizontalStack>\r
+                               <HorizontalStack Fit="true">\r
+                                       <Label Text="Max:" Width="50" TextAlignment="RightCenter"/>\r
+                                       <Label Text="{fpsMax}" Font="droid , 12" Background="AoEnglish" Width="50" TextAlignment="Center"/>\r
+                               </HorizontalStack>\r
+                       </VerticalStack>                                \r
+       </Container>\r
+</Border>
\ No newline at end of file
index d2866bb6286b57d7958d12150dde64627e61fd0b..6bd2e14c68da7f52ea403b2ceda5835a83d2d996 100755 (executable)
                                        <VerticalStack Fit="true">                                      \r
                                                <Checkbox Name="chk1"/>\r
                                                <Checkbox Name="chk2" IsChecked="true"/>\r
-                                               <Checkbox Name="chk4" >\r
-                                                       <Template>\r
-                                                               <HorizontalStack Fit="True" Margin="0" Spacing="1">\r
-                                                                       <Image Name="Image" Width="20" Height="20" Path="#go.Images.Icons.checkbox.svg"/>\r
-                                                                       <Label Name="Caption" Height="-1" Width="-1" Foreground="Black" Background="Yellow"/>\r
-                                                               </HorizontalStack>\r
-                                                       </Template>\r
-                                               </Checkbox>\r
+\r
                                        </VerticalStack>\r
                                        <VerticalStack Fit="true">\r
                                                <RadioButton IsChecked="true"/>\r
                                                <RadioButton/>\r
-                                               <RadioButton>                                                   \r
-                                                       <Template>\r
-                                                               <HorizontalStack Fit="true" Background="Green" Margin="0" Spacing="1" Focusable="false">\r
-                                                                       <Image Name="Image" Width="20" Height="20" Path="#go.Images.Icons.radiobutton.svg"/>\r
-                                                                       <Label Name="Caption"/>\r
-                                                               </HorizontalStack>\r
-                                                       </Template>\r
-                                               </RadioButton>\r
+                                               <Button MouseClick="onButClick"/>\r
                                        </VerticalStack>\r
                                </HorizontalStack>\r
                                <TextBoxWidget Name="textbox1" TextAlignment="LeftCenter" Font="droid,14"                                               \r
                                <Scroller Name="scroller1" Background="DimGray" Width="-1"  \r
                                         Margin="5" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">\r
                                        <VerticalStack Name="colors" VerticalAlignment="Top" Margin="1" Fit="true">\r
-                                               <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
+<!--                                           <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
                                                                        BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>\r
                                                <ProgressBar Width="100" Height="20" Value="{fps}" BorderWidth="2"\r
-                                                       BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>                                                                                            \r
+                                                       BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>                                                                                            -->\r
                                        </VerticalStack>\r
                                </Scroller>\r
                                <Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}"\r
-                                       Orientation="Vertical" Width="16" />\r
+                                       Orientation="Vertical" Width="10" Height="0"/>\r
                        </HorizontalStack>\r
                </HorizontalStack>\r
 <!--           <HorizontalStack Name="hs0"\r
index a53e952571da092a785371f6ea49ef1f5cb2abb7..1c88e56087277c5c5336ba7d0e8826804f57cf94 100644 (file)
@@ -8,7 +8,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTests</StartupObject>
+    <StartupObject>test.GOLIBTest_4</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
@@ -42,9 +42,6 @@
       <HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
     </Reference>
     <Reference Include="Mono.Cairo" />
-    <Reference Include="golib">
-      <HintPath>..\bin\Release\golib.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="GOLIBTest_5.cs" />
   <ItemGroup>
     <EmbeddedResource Include="image\tetra.png" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\GOLib.csproj">
+      <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
+      <Name>GOLib</Name>
+    </ProjectReference>
+  </ItemGroup>
 </Project>
index 22585f95804b07440b1798d17231b87aa478425b..4b3a4448bb533b6b074e47e0de1732af550b7980 100644 (file)
@@ -426,7 +426,6 @@ namespace go
                        FieldInfo fiRefs = typeof(Interface).GetField("References");
                        il.Emit(OpCodes.Ldsfld, fiRefs);
                        il.Emit(OpCodes.Ldc_I4, dstIdx);
-
                        MethodInfo miGetRef = Interface.References.GetType().GetMethod("get_Item");
                        il.Emit(OpCodes.Callvirt, miGetRef);
                        il.Emit(OpCodes.Isinst, dstType);
index c9781f71273f07d2193f22173ef19cdb6041aec1..0204057011f569e5d6eafa0b61063fa83f83377e 100644 (file)
@@ -16,6 +16,7 @@ using System.ComponentModel;
 using System.Xml;\r
 using System.IO;\r
 using System.Collections;\r
+using System.Threading;\r
 \r
 namespace go\r
 {\r
@@ -146,40 +147,75 @@ namespace go
                                _list.registerForGraphicUpdate ();\r
                                if (data == null)\r
                                        return;\r
+                               if (SelectedIndex < 0)\r
+                                       return;\r
 \r
-                               #if DEBUG_LOAD_TIME\r
-                               Stopwatch loadingTime = new Stopwatch ();\r
-                               loadingTime.Start ();\r
-                               #endif\r
+                               //force raise of changes\r
+                               SelectedIndex = SelectedIndex;\r
 \r
-                               MemoryStream ms = new MemoryStream ();\r
-                               using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))                                      \r
-                                       stream.CopyTo (ms);\r
+                               pendingChildrenAddition = new Queue<GraphicObject> ();\r
+                               threadedLoadingFinished = false;\r
 \r
-                               Type t = Interface.GetTopContainerOfGOMLStream (ms);\r
+                               Thread t = new Thread (loadingThread);\r
+                               t.Start ();\r
 \r
-                               foreach (var item in data) {\r
-                                       ms.Seek(0,SeekOrigin.Begin);\r
-                                       GraphicObject g = Interface.Load (ms, t, item);\r
-                                       g.MouseClick += itemClick;\r
-                                       _list.addChild(g);\r
-                               }\r
+                       }\r
+               }\r
+               public override void UpdateLayout (LayoutingType layoutType)\r
+               {\r
+                       CheckPendingChildrenAddition ();\r
+                       base.UpdateLayout (layoutType);\r
+               }\r
+               internal void CheckPendingChildrenAddition()\r
+               {\r
+                       if (pendingChildrenAddition == null)\r
+                               return;\r
+                       lock (pendingChildrenAddition) {\r
+                               if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50)\r
+                                       return;\r
+                               while (pendingChildrenAddition.Count > 0)\r
+                                       _list.addChild (pendingChildrenAddition.Dequeue ());\r
+                       }\r
+               }\r
 \r
-                               ms.Dispose ();\r
+               volatile Queue<GraphicObject> pendingChildrenAddition;\r
+               volatile bool threadedLoadingFinished = false;\r
 \r
-                               if (SelectedIndex < 0)\r
-                                       return;\r
+               void loadingThread()\r
+               {\r
+                       #if DEBUG_LOAD_TIME\r
+                       Stopwatch loadingTime = new Stopwatch ();\r
+                       loadingTime.Start ();\r
+                       #endif\r
+\r
+                       MemoryStream ms = new MemoryStream ();\r
+                       lock (ItemTemplate) {\r
+                               using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))\r
+                                       stream.CopyTo (ms);\r
+                       }\r
 \r
-                               //force raise of changes\r
-                               SelectedIndex = SelectedIndex;\r
+                       Type t = Interface.GetTopContainerOfGOMLStream (ms);\r
+\r
+                       foreach (var item in data) {\r
+                               ms.Seek(0,SeekOrigin.Begin);\r
+                               GraphicObject g = Interface.Load (ms, t, item);\r
+                               g.MouseClick += itemClick;\r
 \r
-                               #if DEBUG_LOAD_TIME\r
-                               loadingTime.Stop ();\r
-                               Debug.WriteLine("Listbox Loading: {0} ticks \t, {1} ms",\r
-                                       loadingTime.ElapsedTicks,\r
-                                       loadingTime.ElapsedMilliseconds);\r
-                               #endif\r
+                               lock (pendingChildrenAddition) {\r
+                                       pendingChildrenAddition.Enqueue (g);\r
+                               }\r
                        }\r
+\r
+                       ms.Dispose ();                  \r
+\r
+                       threadedLoadingFinished = true;\r
+\r
+                       #if DEBUG_LOAD_TIME\r
+                       loadingTime.Stop ();\r
+                       Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",\r
+                       loadingTime.ElapsedTicks,\r
+                       loadingTime.ElapsedMilliseconds, this.ToString());\r
+                       #endif\r
                }\r
                public GraphicObject Overlay {\r
                        get { return _overlay; }\r
index c6260c6b8520d00c5d0fc505edad7e32ef8bd01d..f50a442781680ceee451868489523366fbca5e61 100644 (file)
@@ -100,6 +100,8 @@ namespace go
 \r
                public override void RegisterForLayouting (int layoutType)\r
                {                       \r
+                       if (Parent == null)\r
+                               return;\r
                        base.RegisterForLayouting (layoutType);\r
 \r
                        if ((layoutType & (int)LayoutingType.PositionChildren) > 0)\r
index 63d1012282bbfbdb6a251ac7eddc432fad3eabe5..0617e927e0649102798032f969b87302d4e3e3d6 100644 (file)
@@ -452,46 +452,46 @@ namespace go
                {\r
                        if (Parent == null)\r
                                return;\r
-                       \r
-                       Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
+                       lock (Interface.LayoutingQueue) {\r
+                               Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
 \r
-                       if ((layoutType & (int)LayoutingType.Width) > 0) {\r
+                               if ((layoutType & (int)LayoutingType.Width) > 0) {\r
 \r
-                               //force sizing to fit if parent is sizing on children and \r
-                               //this object has stretched size\r
-                               if (Parent.getBounds ().Width < 0 && Width == 0)\r
-                                       Width = -1;\r
+                                       //force sizing to fit if parent is sizing on children and \r
+                                       //this object has stretched size\r
+                                       if (Parent.getBounds ().Width < 0 && Width == 0)\r
+                                               Width = -1;\r
                                \r
-                               if (Bounds.Width == 0) //stretch in parent\r
+                                       if (Bounds.Width == 0) //stretch in parent\r
                                        Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
-                               else if (Bounds.Width < 0) //fit \r
-                                       Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);                         \r
-                               else\r
-                                       Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
-                       }\r
+                                       else if (Bounds.Width < 0) //fit \r
+                                       Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);\r
+                                       else\r
+                                               Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
+                               }\r
 \r
-                       if ((layoutType & (int)LayoutingType.Height) > 0) {\r
+                               if ((layoutType & (int)LayoutingType.Height) > 0) {\r
 \r
-                               //force sizing to fit if parent is sizing on children\r
-                               if (Parent.getBounds ().Height < 0 && Height == 0)\r
-                                       Height = -1;\r
+                                       //force sizing to fit if parent is sizing on children\r
+                                       if (Parent.getBounds ().Height < 0 && Height == 0)\r
+                                               Height = -1;\r
 \r
-                               if (Bounds.Height == 0) //stretch in parent\r
+                                       if (Bounds.Height == 0) //stretch in parent\r
                                        Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
-                               else if (Bounds.Height < 0) //fit \r
+                                       else if (Bounds.Height < 0) //fit \r
                                        Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);\r
-                               else\r
-                                       Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
-                       }\r
+                                       else\r
+                                               Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
+                               }\r
 \r
-                       if ((layoutType & (int)LayoutingType.X) > 0)\r
+                               if ((layoutType & (int)LayoutingType.X) > 0)\r
                                //for x positionning, sizing of parent and this have to be done\r
                                Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
 \r
-                       if ((layoutType & (int)LayoutingType.Y) > 0)\r
+                               if ((layoutType & (int)LayoutingType.Y) > 0)\r
                                //for x positionning, sizing of parent and this have to be done\r
                                Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
-                       \r
+                       }\r
                }\r
 \r
                /// <summary> trigger dependant sizing component update </summary>\r
@@ -629,10 +629,11 @@ namespace go
                                LastSlots.Height = Slot.Height;\r
                                break;\r
                        }\r
-\r
-                       //if no layouting remains in queue for item, registre for redraw\r
-                       if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp == null)\r
-                               this.RegisterForRedraw ();\r
+                       lock (Interface.LayoutingQueue) {\r
+                               //if no layouting remains in queue for item, registre for redraw\r
+                               if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp == null)\r
+                                       this.RegisterForRedraw ();\r
+                       }\r
                }\r
 \r
                /// <summary> This is the common overridable drawing routine to create new widget </summary>\r
index 9435ffbe9731f65ac3529a879184df0ed150c478..9f408b5a9f6af2194a1894b00c56a7b50849ea03 100644 (file)
@@ -26,6 +26,8 @@ using System.ComponentModel;
 using System.IO;
 using System.Diagnostics;
 using System.Xml;
+using System.Collections.Generic;
+using System.Threading;
 
 namespace go
 {
@@ -84,33 +86,65 @@ namespace go
                                if (data == null)
                                        return;
 
-                               #if DEBUG_LOAD_TIME
-                               Stopwatch loadingTime = new Stopwatch ();
-                               loadingTime.Start ();
-                               #endif
+                               pendingChildrenAddition = new Queue<GraphicObject> ();
+                               threadedLoadingFinished = false;
 
-                               MemoryStream ms = new MemoryStream ();
-                               using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))                                      
+                               Thread t = new Thread (loadingThread);
+                               t.Start ();
+
+                       }
+               }
+
+               internal void CheckPendingChildrenAddition()
+               {
+                       if (pendingChildrenAddition == null)
+                               return;
+                       lock (pendingChildrenAddition) {
+                               if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50)
+                                       return;
+                               while (pendingChildrenAddition.Count > 0)
+                                       _list.addChild (pendingChildrenAddition.Dequeue ());
+                       }
+               }
+
+               volatile Queue<GraphicObject> pendingChildrenAddition;
+               volatile bool threadedLoadingFinished = false;
+
+               void loadingThread()
+               {
+                       #if DEBUG_LOAD_TIME
+                       Stopwatch loadingTime = new Stopwatch ();
+                       loadingTime.Start ();
+                       #endif
+
+                       MemoryStream ms = new MemoryStream ();
+                       lock (ItemTemplate) {
+                               using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
                                        stream.CopyTo (ms);
-                                       
-                               Type t = Interface.GetTopContainerOfGOMLStream (ms);
-
-                               foreach (var item in data) {
-                                       ms.Seek(0,SeekOrigin.Begin);
-                                       GraphicObject g = Interface.Load (ms, t, item);
-                                       g.MouseClick += itemClick;
-                                       _list.addChild(g);
-                               }
+                       }
+
+                       Type t = Interface.GetTopContainerOfGOMLStream (ms);
 
-                               ms.Dispose ();
+                       foreach (var item in data) {
+                               ms.Seek(0,SeekOrigin.Begin);
+                               GraphicObject g = Interface.Load (ms, t, item);
+                               g.MouseClick += itemClick;
 
-                               #if DEBUG_LOAD_TIME
-                               loadingTime.Stop ();
-                               Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
-                                       loadingTime.ElapsedTicks,
-                                       loadingTime.ElapsedMilliseconds, this.ToString());
-                               #endif
+                               lock (pendingChildrenAddition) {
+                                       pendingChildrenAddition.Enqueue (g);
+                               }
                        }
+
+                       ms.Dispose ();                  
+
+                       threadedLoadingFinished = true;
+
+                       #if DEBUG_LOAD_TIME
+                       loadingTime.Stop ();
+                       Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
+                               loadingTime.ElapsedTicks,
+                               loadingTime.ElapsedMilliseconds, this.ToString());
+                       #endif
                }
 
                void itemClick(object sender, OpenTK.Input.MouseButtonEventArgs e){
index 7712b57708cbd49bebb5e0f2b7624bbc54fa0f1c..9dccd969ba82059f8073b0b58dd17a60263799ad 100644 (file)
@@ -424,6 +424,8 @@ namespace go
                        CurrentGOMLPath = "";
                }
 
+
+
                public static GraphicObject Load (Stream stream, Type type, object hostClass = null, bool resolve = true)
                {
                        #if DEBUG_LOAD_TIME
index b028fb83be76f7cce1169893a10c5a35b8829000..417a70ff7a54ac349871cc2b46260e26e9de0206 100644 (file)
@@ -31,6 +31,7 @@ namespace go
                Height = 0x08,
                Sizing = 0x0C,
                PositionChildren = 0x10,
+               ChildAddition = 0x20,
                All = 0xFF
        }
 
index ebe3735e4aa590e87f6abd613ec32217c3047608..fc6f9916f11d87ed3e9b3574ee5af72363ef01aa 100755 (executable)
@@ -260,9 +260,19 @@ namespace go
                        invGOList = invGOList.Reverse ().ToArray ();\r
 \r
                        //Debug.WriteLine ("======= Layouting queue start =======");\r
-                       while (Interface.LayoutingQueue.Count > 0) {\r
-                               LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();\r
-                               lqi.ProcessLayouting ();\r
+                       lock (Interface.LayoutingQueue) {                               \r
+                               while (Interface.LayoutingQueue.Count > 0) {\r
+//                                     Stopwatch lqiProcTime = new Stopwatch ();\r
+//                                     lqiProcTime.Start ();\r
+                                       LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();\r
+                                       lqi.ProcessLayouting ();\r
+//                                     lqiProcTime.Stop ();\r
+//                                     if (lqiProcTime.ElapsedMilliseconds > 10) {\r
+//                                             Debug.WriteLine("lqi {2}: {0} ticks \t, {1} ms",\r
+//                                                     updateTime.ElapsedTicks,\r
+//                                                     updateTime.ElapsedMilliseconds, lqi.ToString());\r
+//                                     }\r
+                               }\r
                        }\r
 \r
                        //Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");\r