diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-10-14 15:06:07 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-10-14 15:06:07 +0200 |
| commit | d57ae20644694ed4862785be98d3ead18100315f (patch) | |
| tree | 48b5188d2c94ec19955b9714e5ae03fbaccb991d /src/GraphicObjects | |
| parent | 6bedf8d5d0b78ba0705e37375d8dee016e87ebbb (diff) | |
debug threaded listbox
debug new binding system
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/Combobox.cs | 33 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 12 | ||||
| -rw-r--r-- | src/GraphicObjects/ListBox.cs | 56 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/Window.cs | 7 |
5 files changed, 75 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 (); + } } } |