aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-10-14 15:06:07 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-10-14 15:06:07 +0200
commitd57ae20644694ed4862785be98d3ead18100315f (patch)
tree48b5188d2c94ec19955b9714e5ae03fbaccb991d /src
parent6bedf8d5d0b78ba0705e37375d8dee016e87ebbb (diff)
debug threaded listbox
debug new binding system
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/Combobox.cs33
-rw-r--r--src/GraphicObjects/Group.cs12
-rw-r--r--src/GraphicObjects/ListBox.cs56
-rw-r--r--src/GraphicObjects/TemplatedControl.cs3
-rw-r--r--src/GraphicObjects/Window.cs7
-rw-r--r--src/Interface.cs1
-rwxr-xr-xsrc/OpenTKGameWindow.cs6
7 files changed, 82 insertions, 36 deletions
diff --git a/src/GraphicObjects/Combobox.cs b/src/GraphicObjects/Combobox.cs
index 3e841793..bed9f131 100644
--- a/src/GraphicObjects/Combobox.cs
+++ b/src/GraphicObjects/Combobox.cs
@@ -22,7 +22,7 @@ namespace go
{
[DefaultTemplate("#go.Templates.Combobox.goml")]
[DefaultOverlayTemplate("#go.Templates.ComboboxOverlay.goml")]
- public class Combobox : TemplatedControl
+ public class Combobox : TemplatedContainer
{
#region CTOR
public Combobox() : base(){ }
@@ -48,14 +48,14 @@ namespace go
base.loadTemplate (template);
loadOverlayTemplate (null);
}
-// public override GraphicObject Content {
-// get {
-// throw new NotImplementedException ();
-// }
-// set {
-// throw new NotImplementedException ();
-// }
-// }
+ public override GraphicObject Content {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
#endregion
protected virtual void loadOverlayTemplate(GraphicObject overlayTemplate)
@@ -84,7 +84,8 @@ namespace go
//TODO:reload list with new template?
_overlayTemplate = value;
- Overlay = Interface.Load (_overlayTemplate, this, !Interface.DontResoveGOML);
+ Overlay = Interface.Load (_overlayTemplate);
+ Overlay.ResolveBindings ();
_list = Overlay.FindByName ("List") as Group;
}
}
@@ -111,7 +112,7 @@ namespace go
Text = "";
else
Text = _selectedItem.ToString ();
- }
+ }
}
public object SelectedItem{
set {
@@ -159,6 +160,7 @@ namespace go
Thread t = new Thread (loadingThread);
t.Start ();
+ t.Join ();
}
}
@@ -226,6 +228,7 @@ namespace go
if (_overlay != null) {
_overlay.LayoutChanged -= _overlay_LayoutChanged;
_overlay.MouseLeave -= _overlay_MouseLeave;
+ _overlay.LogicalParent = null;
}
_overlay = value;
@@ -233,6 +236,7 @@ namespace go
if (_overlay == null)
return;
+ _overlay.LogicalParent = this;
_overlay.Focusable = true;
_overlay.LayoutChanged += _overlay_LayoutChanged;
_overlay.MouseLeave += _overlay_MouseLeave;
@@ -351,6 +355,11 @@ namespace go
base.ClearBinding ();
}
-
+ public override void ResolveBindings ()
+ {
+ base.ResolveBindings ();
+ if (Overlay != null)
+ Overlay.ResolveBindings ();
+ }
}
}
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 5c2b7df2..78378aa8 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -53,7 +53,17 @@ namespace go
Children.Remove(child);
this.RegisterForLayouting ((int)LayoutingType.Sizing);
}
-
+ public virtual void ClearChildren()
+ {
+ int lim = children.Count;
+ for (int i = 0; i < lim; i++) {
+ GraphicObject g = Children [0];
+ g.ClearBinding ();
+ g.Parent = null;
+ Children.Remove(g);
+ }
+ this.RegisterForLayouting ((int)LayoutingType.Sizing);
+ }
public void putWidgetOnTop(GraphicObject w)
{
if (Children.Contains(w))
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs
index 15752f80..5f2e5454 100644
--- a/src/GraphicObjects/ListBox.cs
+++ b/src/GraphicObjects/ListBox.cs
@@ -75,45 +75,60 @@ namespace go
get {
return data;
}
- set {
+ set {
+ if (loadingInProgress) {
+ thread.Join ();
+ Interface.LoadingLists.Remove (this);
+ pendingChildrenAddition = null;
+ loadingInProgress = false;
+ }
+
data = value;
- foreach (GraphicObject c in _list.Children) {
- c.ClearBinding ();
- }
- _list.Children.Clear ();
- _list.registerForGraphicUpdate ();
+ _list.ClearChildren ();
+
if (data == null)
return;
pendingChildrenAddition = new Queue<GraphicObject> ();
threadedLoadingFinished = false;
+ Interface.LoadingLists.Add (this);
- Thread t = new Thread (loadingThread);
- t.Start ();
- t.Join ();
-
+ thread = new Thread(loadingThread);
+ loadingInProgress = true;
+ thread.Start ();
}
}
- public override void UpdateLayout (LayoutingType layoutType)
- {
- CheckPendingChildrenAddition ();
- base.UpdateLayout (layoutType);
- }
+// public override void UpdateLayout (LayoutingType layoutType)
+// {
+// CheckPendingChildrenAddition ();
+// base.UpdateLayout (layoutType);
+// }
internal void CheckPendingChildrenAddition()
{
- if (pendingChildrenAddition == null)
+ if (!loadingInProgress)
return;
lock (pendingChildrenAddition) {
if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50)
return;
- while (pendingChildrenAddition.Count > 0)
- _list.addChild (pendingChildrenAddition.Dequeue ());
+ while (pendingChildrenAddition.Count > 0) {
+ GraphicObject tmp = pendingChildrenAddition.Dequeue ();
+ tmp.DataSource = tmp.Tag;
+ tmp.Tag = null;
+ _list.addChild (tmp);
+ }
+ if (threadedLoadingFinished) {
+ Interface.LoadingLists.Remove (this);
+ pendingChildrenAddition = null;
+ loadingInProgress = false;
+ }
}
}
- volatile Queue<GraphicObject> pendingChildrenAddition;
+ Queue<GraphicObject> pendingChildrenAddition;
volatile bool threadedLoadingFinished = false;
+ volatile bool loadingInProgress = false;
+ Thread thread;
void loadingThread()
{
@@ -133,9 +148,8 @@ namespace go
foreach (var item in data) {
ms.Seek(0,SeekOrigin.Begin);
GraphicObject g = Interface.Load (ms, t);
- g.DataSource = item;
+ g.Tag = item;
g.MouseClick += itemClick;
-
lock (pendingChildrenAddition) {
pendingChildrenAddition.Enqueue (g);
}
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index d6c7243d..de688d2c 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -116,9 +116,10 @@ namespace go
if (template == null) {
DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault();
this.SetChild (Interface.Load (dt.Path, this));
- this.child.ResolveBindings ();
}else
this.SetChild (template);
+
+ this.child.ResolveBindings ();
}
#region IXmlSerializable
diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs
index f9e3a54b..0af4c762 100644
--- a/src/GraphicObjects/Window.cs
+++ b/src/GraphicObjects/Window.cs
@@ -219,7 +219,12 @@ namespace go
TopContainer.DeleteWidget (parent as GraphicObject);
}
-
+ public override void ResolveBindings ()
+ {
+ base.ResolveBindings ();
+ if (Content != null)
+ Content.ResolveBindings ();
+ }
}
}
diff --git a/src/Interface.cs b/src/Interface.cs
index ddd2a008..1b6f2437 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -49,6 +49,7 @@ namespace go
/// </summary>
public static List<object> References = new List<object> ();
public static Queue<int> FreeRefIndices = new Queue<int> ();
+ public static List<ListBox> LoadingLists= new List<ListBox>();
public static void Unreference (Object o)
{
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index fc6f9916..6b16f157 100755
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -254,6 +254,12 @@ namespace go
surf = new ImageSurface(bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height,ClientRectangle.Width*4);
ctx = new Context(surf);
+ if (Interface.LoadingLists.Count > 0) {
+ ListBox[] loadings = new ListBox[Interface.LoadingLists.Count];
+ Interface.LoadingLists.CopyTo (loadings, 0);
+ for (int i = 0; i < loadings.Length; i++)
+ loadings [i].CheckPendingChildrenAddition ();
+ }
GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
GraphicObjects.CopyTo (invGOList,0);