aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-10-05 12:08:56 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-10-05 12:08:57 +0200
commit4c15030701964aee1c1dc908d6fa4dcdbec16a12 (patch)
treeabc69bdd9cd0713d795a924d329b4466e31bbac6
parent8dcac53903c37878d54d59066eb7f80da1d62bc7 (diff)
threaded combo, Monodevelop addin improve
-rw-r--r--GOLib.csproj2
-rw-r--r--MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml3
-rw-r--r--MonoDevelop.GOLib/MonoDevelop.GOLib.csproj25
-rw-r--r--MonoDevelop.GOLib/src/DisplayBinding.cs2
-rw-r--r--MonoDevelop.GOLib/src/GOLibGtkHost.cs104
-rw-r--r--MonoDevelop.GOLib/src/GOLibNodeExtension.cs55
-rw-r--r--MonoDevelop.GOLib/src/GOLibView.cs89
-rw-r--r--Tests/GOLIBTest_4.cs71
-rwxr-xr-xTests/Interfaces/fps.goml44
-rwxr-xr-xTests/Interfaces/test4.goml24
-rw-r--r--Tests/Tests.csproj11
-rw-r--r--src/CompilerServices/CompilerServices.cs1
-rw-r--r--src/GraphicObjects/Combobox.cs86
-rw-r--r--src/GraphicObjects/GenericStack.cs2
-rw-r--r--src/GraphicObjects/GraphicObject.cs59
-rw-r--r--src/GraphicObjects/ListBox.cs76
-rw-r--r--src/Interface.cs2
-rw-r--r--src/LayoutingQueueItem.cs1
-rwxr-xr-xsrc/OpenTKGameWindow.cs16
19 files changed, 467 insertions, 206 deletions
diff --git a/GOLib.csproj b/GOLib.csproj
index 989740d6..2cd31f89 100644
--- a/GOLib.csproj
+++ b/GOLib.csproj
@@ -46,7 +46,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug</OutputPath>
- <DefineConstants>TRACE;DEBUG;__linux__;DEBUG_LOAD_TIME</DefineConstants>
+ <DefineConstants>TRACE;DEBUG;__linux__;DEBUG_LOAD_TIME=1</DefineConstants>
</PropertyGroup>
<!-- <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">
<DefineConstants>__linux__</DefineConstants>
diff --git a/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml b/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml
index 5dcac153..fe15b3e9 100644
--- a/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml
+++ b/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml
@@ -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
diff --git a/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj b/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
index 4dfac2d9..b2099b5a 100644
--- a/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
+++ b/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
@@ -13,15 +13,12 @@
<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>
@@ -57,6 +54,13 @@
<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>
@@ -73,15 +77,14 @@
<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>
diff --git a/MonoDevelop.GOLib/src/DisplayBinding.cs b/MonoDevelop.GOLib/src/DisplayBinding.cs
index 55c6e78a..1898f16b 100644
--- a/MonoDevelop.GOLib/src/DisplayBinding.cs
+++ b/MonoDevelop.GOLib/src/DisplayBinding.cs
@@ -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)
{
diff --git a/MonoDevelop.GOLib/src/GOLibGtkHost.cs b/MonoDevelop.GOLib/src/GOLibGtkHost.cs
index f2a0bfa9..d041bba7 100644
--- a/MonoDevelop.GOLib/src/GOLibGtkHost.cs
+++ b/MonoDevelop.GOLib/src/GOLibGtkHost.cs
@@ -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)
diff --git a/MonoDevelop.GOLib/src/GOLibNodeExtension.cs b/MonoDevelop.GOLib/src/GOLibNodeExtension.cs
index 3388c579..8c68d4cf 100644
--- a/MonoDevelop.GOLib/src/GOLibNodeExtension.cs
+++ b/MonoDevelop.GOLib/src/GOLibNodeExtension.cs
@@ -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
+// }
}
diff --git a/MonoDevelop.GOLib/src/GOLibView.cs b/MonoDevelop.GOLib/src/GOLibView.cs
index 650cfd09..a7cc3713 100644
--- a/MonoDevelop.GOLib/src/GOLibView.cs
+++ b/MonoDevelop.GOLib/src/GOLibView.cs
@@ -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 ();
+// }
}
}
diff --git a/Tests/GOLIBTest_4.cs b/Tests/GOLIBTest_4.cs
index a5cdbb49..62b9d257 100644
--- a/Tests/GOLIBTest_4.cs
+++ b/Tests/GOLIBTest_4.cs
@@ -82,6 +82,11 @@ namespace test
new ClsItem("string 1"),
new ClsItem("string 2")
});
+ int i = 0;
+ Color[] colorsArray;
+ volatile List<GraphicObject> loadedCols = new List<GraphicObject>();
+ volatile bool allColsLoaded = false;
+ private static readonly object mutex = new object();
protected override void OnLoad (EventArgs e)
{
@@ -114,9 +119,18 @@ namespace test
// };
- int i = 0;
- foreach (Color col in Color.ColorDic) {
- HorizontalStack s = colors.addChild (new HorizontalStack () { Fit = true});
+ colorsArray = Color.ColorDic.ToArray ();
+
+ Thread t = new Thread (loadingThread);
+ t.Start ();
+
+// ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));
+ }
+
+ void loadingThread()
+ {
+ foreach (Color col in colorsArray) {
+ HorizontalStack s = new HorizontalStack () { Fit = true};
s.HorizontalAlignment = HorizontalAlignment.Left;
Border b = new Border () {
Bounds = new Size (32, 20),
@@ -140,10 +154,18 @@ namespace test
}
);
i++;
- if (i > 150)
- break;
- }
-// ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));
+
+ while(true){
+ lock (mutex) {
+ loadedCols.Add (s);
+ break;
+ }
+ }
+
+ Thread.Sleep (10);
+
+ }
+ allColsLoaded = true;
}
void pFps_mousemove(object sender, MouseMoveEventArgs e)
{
@@ -154,7 +176,34 @@ namespace test
c.Top += e.YDelta;
c.registerForGraphicUpdate ();
}
+ void onButClick(object send, MouseButtonEventArgs e)
+ {
+ Color col = Color.ColorDic.ToArray () [i];
+ HorizontalStack s = colors.addChild (new HorizontalStack () { Fit = true});
+ s.HorizontalAlignment = HorizontalAlignment.Left;
+ Border b = new Border () {
+ Bounds = new Size (32, 20),
+ CornerRadius = 5,
+ Background = col,
+ BorderWidth = 2,
+ BorderColor = Color.Transparent,
+ Focusable = true
+ };
+ b.MouseEnter += delegate(object sender, MouseMoveEventArgs ee) {
+ (sender as Border).BorderColor = Color.White;
+ };
+ b.MouseLeave += delegate(object sender, MouseMoveEventArgs ee) {
+ (sender as Border).BorderColor = Color.Transparent;
+ };
+ s.addChild (b);
+ s.addChild (
+ new Label (col.ToString ()){
+ Bounds=new Rectangle(0,0,-1,-1),
+ }
+ );
+ i++;
+ }
private int frameCpt = 0;
protected override void OnUpdateFrame (FrameEventArgs e)
{
@@ -162,6 +211,14 @@ namespace test
fps = (int)RenderFrequency;
+ lock (mutex) {
+ if (loadedCols.Count > 50 || allColsLoaded) {
+ while (loadedCols.Count > 0) {
+ colors.addChild (loadedCols[0]);
+ loadedCols.RemoveAt (0);
+ }
+ }
+ }
if (frameCpt > 200) {
resetFps ();
diff --git a/Tests/Interfaces/fps.goml b/Tests/Interfaces/fps.goml
index baa85b63..91d02640 100755
--- a/Tests/Interfaces/fps.goml
+++ b/Tests/Interfaces/fps.goml
@@ -1,22 +1,24 @@
<?xml version="1.0"?>
-<Container Name="MainGrp" Background="0,5;0,5;0,5;0,5"
- Margin="10" Width="-1" Height="-1" Focusable="True" >
- <VerticalStack Name="vsFps" BorderWidth="1" Margin="5" Spacing="4" Fit="true">
- <HorizontalStack Height="-1">
- <Label Text="Update:" FontColor="White" />
- <Label Name="labUpdate" Text="{update}" FontSize="12" Background="DarkGreen"/>
- </HorizontalStack>
- <HorizontalStack Height="-1" Name="hsFps" Background="Mantis" >
- <Label Name="captionFps" Text="Fps:" />
- <Label Name="valueFps" Text="{fps}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>
- </HorizontalStack>
- <HorizontalStack Height="-1" Background="UniversityOfCaliforniaGold">
- <Label Text="Min:" Width = "30" />
- <Label Text="{fpsMin}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>
- </HorizontalStack>
- <HorizontalStack Height="-1" Background="Sienna" >
- <Label Text="Max:" Width = "30"/>
- <Label Text="{fpsMax}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>
- </HorizontalStack>
- </VerticalStack>
-</Container> \ No newline at end of file
+<Border Fit="true" CornerRadius="5" BorderWidth="1">
+ <Container Name="MainGrp" Background="0,5;0,5;0,5;0,4" Width="120" Fit="true"
+ Margin="10" Focusable="True" >
+ <VerticalStack Fit="true" Name="vsFps" Spacing="10" >
+ <HorizontalStack Fit="true">
+ <Label Text="Update:" Width="50" TextAlignment="RightCenter"/>
+ <Label Name="labUpdate" Text="{update}" Font="droid,12" Background="AoEnglish" Width="50" TextAlignment="Center"/>
+ </HorizontalStack>
+ <HorizontalStack Fit="true">
+ <Label Name="captionFps" Text="Fps:" Width="50" TextAlignment="RightCenter"/>
+ <Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ <HorizontalStack Fit="true">
+ <Label Text="Min:" Width="50" TextAlignment="RightCenter"/>
+ <Label Text="{fpsMin}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ <HorizontalStack Fit="true">
+ <Label Text="Max:" Width="50" TextAlignment="RightCenter"/>
+ <Label Text="{fpsMax}" Font="droid , 12" Background="AoEnglish" Width="50" TextAlignment="Center"/>
+ </HorizontalStack>
+ </VerticalStack>
+ </Container>
+</Border> \ No newline at end of file
diff --git a/Tests/Interfaces/test4.goml b/Tests/Interfaces/test4.goml
index d2866bb6..6bd2e14c 100755
--- a/Tests/Interfaces/test4.goml
+++ b/Tests/Interfaces/test4.goml
@@ -30,26 +30,12 @@
<VerticalStack Fit="true">
<Checkbox Name="chk1"/>
<Checkbox Name="chk2" IsChecked="true"/>
- <Checkbox Name="chk4" >
- <Template>
- <HorizontalStack Fit="True" Margin="0" Spacing="1">
- <Image Name="Image" Width="20" Height="20" Path="#go.Images.Icons.checkbox.svg"/>
- <Label Name="Caption" Height="-1" Width="-1" Foreground="Black" Background="Yellow"/>
- </HorizontalStack>
- </Template>
- </Checkbox>
+
</VerticalStack>
<VerticalStack Fit="true">
<RadioButton IsChecked="true"/>
<RadioButton/>
- <RadioButton>
- <Template>
- <HorizontalStack Fit="true" Background="Green" Margin="0" Spacing="1" Focusable="false">
- <Image Name="Image" Width="20" Height="20" Path="#go.Images.Icons.radiobutton.svg"/>
- <Label Name="Caption"/>
- </HorizontalStack>
- </Template>
- </RadioButton>
+ <Button MouseClick="onButClick"/>
</VerticalStack>
</HorizontalStack>
<TextBoxWidget Name="textbox1" TextAlignment="LeftCenter" Font="droid,14"
@@ -111,14 +97,14 @@
<Scroller Name="scroller1" Background="DimGray" Width="-1"
Margin="5" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">
<VerticalStack Name="colors" VerticalAlignment="Top" Margin="1" Fit="true">
- <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"
+<!-- <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"
BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>
<ProgressBar Width="100" Height="20" Value="{fps}" BorderWidth="2"
- BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>
+ BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/> -->
</VerticalStack>
</Scroller>
<Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}"
- Orientation="Vertical" Width="16" />
+ Orientation="Vertical" Width="10" Height="0"/>
</HorizontalStack>
</HorizontalStack>
<!-- <HorizontalStack Name="hs0"
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index a53e9525..1c88e560 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -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" />
@@ -189,4 +186,10 @@
<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>
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs
index 22585f95..4b3a4448 100644
--- a/src/CompilerServices/CompilerServices.cs
+++ b/src/CompilerServices/CompilerServices.cs
@@ -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);
diff --git a/src/GraphicObjects/Combobox.cs b/src/GraphicObjects/Combobox.cs
index c9781f71..02040570 100644
--- a/src/GraphicObjects/Combobox.cs
+++ b/src/GraphicObjects/Combobox.cs
@@ -16,6 +16,7 @@ using System.ComponentModel;
using System.Xml;
using System.IO;
using System.Collections;
+using System.Threading;
namespace go
{
@@ -146,40 +147,75 @@ namespace go
_list.registerForGraphicUpdate ();
if (data == null)
return;
+ if (SelectedIndex < 0)
+ return;
- #if DEBUG_LOAD_TIME
- Stopwatch loadingTime = new Stopwatch ();
- loadingTime.Start ();
- #endif
+ //force raise of changes
+ SelectedIndex = SelectedIndex;
- MemoryStream ms = new MemoryStream ();
- using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
- stream.CopyTo (ms);
+ pendingChildrenAddition = new Queue<GraphicObject> ();
+ threadedLoadingFinished = false;
- Type t = Interface.GetTopContainerOfGOMLStream (ms);
+ Thread t = new Thread (loadingThread);
+ t.Start ();
- foreach (var item in data) {
- ms.Seek(0,SeekOrigin.Begin);
- GraphicObject g = Interface.Load (ms, t, item);
- g.MouseClick += itemClick;
- _list.addChild(g);
- }
+ }
+ }
+ public override void UpdateLayout (LayoutingType layoutType)
+ {
+ CheckPendingChildrenAddition ();
+ base.UpdateLayout (layoutType);
+ }
+ internal void CheckPendingChildrenAddition()
+ {
+ if (pendingChildrenAddition == null)
+ return;
+ lock (pendingChildrenAddition) {
+ if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50)
+ return;
+ while (pendingChildrenAddition.Count > 0)
+ _list.addChild (pendingChildrenAddition.Dequeue ());
+ }
+ }
- ms.Dispose ();
+ volatile Queue<GraphicObject> pendingChildrenAddition;
+ volatile bool threadedLoadingFinished = false;
- if (SelectedIndex < 0)
- return;
+ void loadingThread()
+ {
+ #if DEBUG_LOAD_TIME
+ Stopwatch loadingTime = new Stopwatch ();
+ loadingTime.Start ();
+ #endif
- //force raise of changes
- SelectedIndex = SelectedIndex;
+ MemoryStream ms = new MemoryStream ();
+ lock (ItemTemplate) {
+ using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
+ stream.CopyTo (ms);
+ }
+
+ Type t = Interface.GetTopContainerOfGOMLStream (ms);
- #if DEBUG_LOAD_TIME
- loadingTime.Stop ();
- Debug.WriteLine("Listbox Loading: {0} ticks \t, {1} ms",
- loadingTime.ElapsedTicks,
- loadingTime.ElapsedMilliseconds);
- #endif
+ foreach (var item in data) {
+ ms.Seek(0,SeekOrigin.Begin);
+ GraphicObject g = Interface.Load (ms, t, item);
+ g.MouseClick += itemClick;
+
+ 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
}
public GraphicObject Overlay {
get { return _overlay; }
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index c6260c6b..f50a4427 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -100,6 +100,8 @@ namespace go
public override void RegisterForLayouting (int layoutType)
{
+ if (Parent == null)
+ return;
base.RegisterForLayouting (layoutType);
if ((layoutType & (int)LayoutingType.PositionChildren) > 0)
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 63d10122..0617e927 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -452,46 +452,46 @@ namespace go
{
if (Parent == null)
return;
-
- Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);
+ lock (Interface.LayoutingQueue) {
+ Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);
- if ((layoutType & (int)LayoutingType.Width) > 0) {
+ if ((layoutType & (int)LayoutingType.Width) > 0) {
- //force sizing to fit if parent is sizing on children and
- //this object has stretched size
- if (Parent.getBounds ().Width < 0 && Width == 0)
- Width = -1;
+ //force sizing to fit if parent is sizing on children and
+ //this object has stretched size
+ if (Parent.getBounds ().Width < 0 && Width == 0)
+ Width = -1;
- if (Bounds.Width == 0) //stretch in parent
+ if (Bounds.Width == 0) //stretch in parent
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);
- else if (Bounds.Width < 0) //fit
- Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);
- else
- Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
- }
+ else if (Bounds.Width < 0) //fit
+ Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);
+ else
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
+ }
- if ((layoutType & (int)LayoutingType.Height) > 0) {
+ if ((layoutType & (int)LayoutingType.Height) > 0) {
- //force sizing to fit if parent is sizing on children
- if (Parent.getBounds ().Height < 0 && Height == 0)
- Height = -1;
+ //force sizing to fit if parent is sizing on children
+ if (Parent.getBounds ().Height < 0 && Height == 0)
+ Height = -1;
- if (Bounds.Height == 0) //stretch in parent
+ if (Bounds.Height == 0) //stretch in parent
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);
- else if (Bounds.Height < 0) //fit
+ else if (Bounds.Height < 0) //fit
Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);
- else
- Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));
- }
+ else
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));
+ }
- if ((layoutType & (int)LayoutingType.X) > 0)
+ if ((layoutType & (int)LayoutingType.X) > 0)
//for x positionning, sizing of parent and this have to be done
Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);
- if ((layoutType & (int)LayoutingType.Y) > 0)
+ if ((layoutType & (int)LayoutingType.Y) > 0)
//for x positionning, sizing of parent and this have to be done
Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);
-
+ }
}
/// <summary> trigger dependant sizing component update </summary>
@@ -629,10 +629,11 @@ namespace go
LastSlots.Height = Slot.Height;
break;
}
-
- //if no layouting remains in queue for item, registre for redraw
- if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp == null)
- this.RegisterForRedraw ();
+ lock (Interface.LayoutingQueue) {
+ //if no layouting remains in queue for item, registre for redraw
+ if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp == null)
+ this.RegisterForRedraw ();
+ }
}
/// <summary> This is the common overridable drawing routine to create new widget </summary>
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs
index 9435ffbe..9f408b5a 100644
--- a/src/GraphicObjects/ListBox.cs
+++ b/src/GraphicObjects/ListBox.cs
@@ -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){
diff --git a/src/Interface.cs b/src/Interface.cs
index 7712b577..9dccd969 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -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
diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs
index b028fb83..417a70ff 100644
--- a/src/LayoutingQueueItem.cs
+++ b/src/LayoutingQueueItem.cs
@@ -31,6 +31,7 @@ namespace go
Height = 0x08,
Sizing = 0x0C,
PositionChildren = 0x10,
+ ChildAddition = 0x20,
All = 0xFF
}
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index ebe3735e..fc6f9916 100755
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -260,9 +260,19 @@ namespace go
invGOList = invGOList.Reverse ().ToArray ();
//Debug.WriteLine ("======= Layouting queue start =======");
- while (Interface.LayoutingQueue.Count > 0) {
- LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
- lqi.ProcessLayouting ();
+ lock (Interface.LayoutingQueue) {
+ while (Interface.LayoutingQueue.Count > 0) {
+// Stopwatch lqiProcTime = new Stopwatch ();
+// lqiProcTime.Start ();
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ lqi.ProcessLayouting ();
+// lqiProcTime.Stop ();
+// if (lqiProcTime.ElapsedMilliseconds > 10) {
+// Debug.WriteLine("lqi {2}: {0} ticks \t, {1} ms",
+// updateTime.ElapsedTicks,
+// updateTime.ElapsedMilliseconds, lqi.ToString());
+// }
+ }
}
//Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");