diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-04-27 14:58:27 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-04-27 14:58:27 +0200 |
| commit | 7b8ff62e3ee75e19d9eeeabd31bedef371215554 (patch) | |
| tree | f58ee90791028768b69921841cd604e20a3a5c02 /src | |
| parent | 79224ffe3efe06a99cb5dfb183f16a5427504b2a (diff) | |
Layouting queue
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/Container.cs | 60 | ||||
| -rw-r--r-- | src/GraphicObjects/GenericStack.cs | 103 | ||||
| -rwxr-xr-x | src/GraphicObjects/GraphicObject.cs | 133 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 93 | ||||
| -rw-r--r-- | src/GraphicObjects/ILayoutable.cs | 9 | ||||
| -rw-r--r-- | src/GraphicObjects/Scroller.cs | 28 | ||||
| -rw-r--r-- | src/Interface.cs | 2 | ||||
| -rw-r--r-- | src/LayoutingQueue.cs | 40 | ||||
| -rw-r--r-- | src/LayoutingQueueItem.cs | 70 | ||||
| -rwxr-xr-x | src/OpenTKGameWindow.cs | 27 |
10 files changed, 309 insertions, 256 deletions
diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index c1134ec5..1971f00b 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -77,41 +77,37 @@ namespace go child.InvalidateLayout();
}
protected override Size measureRawSize ()
+ {
+ return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * (Margin),child.Slot.Height + 2 * (Margin));
+ }
+ public override void RegisterForLayouting ()
{
- Size raw = Bounds.Size;
-
- if (child != null) {
- if (Bounds.Width < 0 && child.WIsValid)
- raw.Width = child.Slot.Width + 2 * (Margin);
- if (Bounds.Height < 0 && child.HIsValid)
- raw.Height = child.Slot.Height + 2 * (Margin);
- }
+ base.RegisterForLayouting ();
- return raw;
+ if (child != null)
+ child.RegisterForLayouting ();
}
- public override void UpdateLayout()
- {
- if (LayoutIsValid)
- return;
-
- if (Width < 0 && child.Width == 0)
- child.Width = -1;
- if (Height < 0 && child.Height == 0)
- child.Height = -1;
-
- if (!(base.LayoutIsValid))
- base.UpdateLayout();
-
- if (child != null)
- {
- if (!child.LayoutIsValid) {
- child.UpdateLayout ();
- }
- }
-
- if (LayoutIsValid)
- registerForRedraw();
- }
+// public override void UpdateLayout (LayoutingType layoutType)
+// {
+//
+//// if (Width < 0 && child.Width == 0)
+//// child.Width = -1;
+//// if (Height < 0 && child.Height == 0)
+//// child.Height = -1;
+////
+//// if (!(base.LayoutIsValid))
+//// base.UpdateLayout();
+////
+//// if (child != null)
+//// {
+//// if (!child.LayoutIsValid) {
+//// child.UpdateLayout ();
+//// }
+//// }
+////
+//// if (LayoutIsValid)
+//// registerForRedraw();
+// }
public override Rectangle ContextCoordinates (Rectangle r)
{
return
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index a36cd7b1..36d41f99 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -18,7 +18,6 @@ namespace go #endregion
#region Private fields
- bool childrenArePositionned = false;
int _spacing;
Orientation _orientation;
#endregion
@@ -49,49 +48,25 @@ namespace go get { return base.Height; }
set { base.Height = value; }
}
- [XmlIgnore]public override bool LayoutIsValid {
- get { return childrenArePositionned && base.LayoutIsValid; }
- set { base.LayoutIsValid = value; }
- }
- public override void InvalidateLayout ()
- {
- childrenArePositionned = false;
- base.InvalidateLayout ();
- }
protected override Size measureRawSize ()
{
- Size raw = Bounds.Size;
Size tmp = new Size ();
- if (raw.Width >= 0 && raw.Height >= 0)
- return raw;
-
- foreach (GraphicObject c in Children) {
- if (raw.Width < 0) {
- if (c.WIsValid) {
- if (Orientation == Orientation.Horizontal && c.Bounds.Width != 0)
- tmp.Width += c.Slot.Width + Spacing;
- else
- tmp.Width = Math.Max (tmp.Width, c.Slot.Right);
- }else
- return raw;
+ if (Orientation == Orientation.Horizontal) {
+ foreach (GraphicObject c in Children) {
+ tmp.Width += c.Slot.Width + Spacing;
+ tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);
}
- if (raw.Height < 0) {
- if (c.HIsValid) {
- if (Orientation == Orientation.Vertical && c.Bounds.Height != 0)
- tmp.Height += c.Slot.Height + Spacing;
- else
- tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);
- }else
- return raw;
+ } else {
+ foreach (GraphicObject c in Children) {
+ tmp.Width = Math.Max (tmp.Width, c.Slot.Right);
+ tmp.Height += c.Slot.Height + Spacing;
}
}
- if (raw.Width < 0)
- tmp.Width += 2*Margin;
- if (raw.Height < 0)
- tmp.Height += 2*Margin;
+ tmp.Width += 2*Margin;
+ tmp.Height += 2*Margin;
return tmp;
}
@@ -100,66 +75,36 @@ namespace go int d = 0;
if (Orientation == Orientation.Horizontal) {
foreach (GraphicObject c in Children) {
- if (c.Bounds.Width == 0)
- continue;
-
c.Slot.X = d;
- c.XIsValid = true;
d += c.Slot.Width + Spacing;
}
} else {
foreach (GraphicObject c in Children) {
- if (c.Bounds.Height == 0)
- continue;
-
c.Slot.Y = d;
- c.YIsValid = true;
d += c.Slot.Height + Spacing;
}
}
- childrenArePositionned = true;
}
+ public override void RegisterForLayouting ()
+ {
+ base.RegisterForLayouting ();
- public override void UpdateLayout()
+ int idx = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where (lq => lq.GraphicObject.Parent == this).LastOrDefault ());
+ if (idx < 0)
+ return;
+ Interface.LayoutingQueue.Insert (
+ idx+1,
+ new LayoutingQueueItem (LayoutingType.PositionChildren, this));
+ }
+ public override void UpdateLayout (LayoutingType layoutType)
{
- base.UpdateLayout();
-
- ComputeChildrenPositions ();
+ if (layoutType == LayoutingType.PositionChildren)
+ ComputeChildrenPositions ();
- if (LayoutIsValid)
- registerForRedraw();
+ base.UpdateLayout(layoutType);
}
#endregion
- //
-// bool enoughtSpaceForWidget(GraphicObject w)
-// {
-// if (!SizeToContent)
-// {
-// int nextXForWidget = 0;
-// int nextYForWidget = 0;
-//
-// if (Orientation == Orientation.Horizontal)
-// nextXForWidget = currentXForWidget + w.Slot.Width;
-// else
-// nextYForWidget = nextYForWidget + w.Slot.Height;
-//
-//
-// if (nextXForWidget > ClientRectangle.Right )
-// return false;
-// if (currentYForWidget > ClientRectangle.Bottom )
-// return false;
-// }
-// return true;
-// }
-// void advance(GraphicObject w)
-// {
-// if (Orientation == Orientation.Horizontal)
-// currentXForWidget = currentXForWidget + WidgetSpacing + w.Slot.Width;
-// else
-// currentYForWidget = currentYForWidget + WidgetSpacing + w.Slot.Height;
-//
-// }
}
}
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 3ffda14a..c6756db2 100755 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -117,7 +117,7 @@ namespace go }
}
[XmlIgnore]public virtual IGOLibHost TopContainer {
- get { return Parent.TopContainer; }
+ get { return Parent == null ? null : Parent.TopContainer; }
}
public virtual void InvalidateLayout ()
{
@@ -373,7 +373,8 @@ namespace go public virtual void registerForGraphicUpdate ()
{
bmp = null;
- registerForRedraw ();
+ RegisterForLayouting ();
+ //registerForRedraw ();
//Interface.registerForGraphicUpdate(this);
}
/// <summary>
@@ -381,7 +382,7 @@ namespace go /// </summary>
public virtual void registerForRedraw ()
{
- if (LayoutIsValid && Visible)
+ if (Visible && TopContainer != null)
TopContainer.gobjsToRedraw.Add (this);
}
public virtual void registerClipRect()
@@ -392,50 +393,48 @@ namespace go {
return Bounds.Size;
}
-
- protected virtual void ComputeSize()
+ public virtual void RegisterForLayouting()
{
- Size rawSize = measureRawSize ();
+ //clear previous layouting for item
+ Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this);
- if (!wIsValid) {
- wIsValid = true;
- if (Width > 0)
- Slot.Width = Width;
- else if (Width < 0) {
- if (rawSize.Width > 0)
- Slot.Width = rawSize.Width;
- else
- wIsValid = false;
- } else if (Parent.WIsValid)
- Slot.Width = Parent.ClientRectangle.Width;
- else
- wIsValid = false;
+ if (Bounds.Width == 0) { //stretch in parent
+ int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());
+ if (idxParentW < 0)
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
+ else//insert after parent sizing
+ Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.Width, this));
+ } else {//fit ou fixed
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
+ //for x positionning, sizing of obj and parent have to be done
+ int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());
+ if (idxParentW < 0)
+ Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.X, this));
+ else//insert after parent sizing
+ Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.X, this));
}
-
- if (!hIsValid) {
- hIsValid = true;
- if (Height > 0)
- Slot.Height = Height;
- else if (Height < 0) {
- if (rawSize.Height > 0)
- Slot.Height = rawSize.Height;
- else
- hIsValid = false;
- } else if (Parent.HIsValid)
- Slot.Height = Parent.ClientRectangle.Height;
+ if (Bounds.Height == 0) { //stretch
+ int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());
+ if (idxParentH < 0)
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));
else
- hIsValid = false;
+ Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Height, this));
+ } else {
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));
+ int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());
+ if (idxParentH < 0)
+ Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.Y, this));
+ else//insert after parent sizing
+ Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Y, this));
}
+
}
- protected virtual void ComputePosition()
- {
- if (!xIsValid) {
- xIsValid = true;
- if (Width == 0)
- Slot.X = 0;
- else if (Left != 0)
- Slot.X = Left;
- else if (Parent.WIsValid && WIsValid) {
+
+ public virtual void UpdateLayout (LayoutingType layoutType)
+ {
+ switch (layoutType) {
+ case LayoutingType.X:
+ if (Bounds.X == 0) {
switch (HorizontalAlignment) {
case HorizontalAlignment.Left:
Slot.X = 0;
@@ -447,17 +446,12 @@ namespace go Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
break;
}
- } else// if (Parent.getBounds().Width>=0)
- xIsValid = false;
- }
-
- if (!yIsValid) {
- yIsValid = true;
- if (Height== 0)
- Slot.Y = 0;
- else if (Top != 0)
- Slot.Y = Top;
- else if (Parent.HIsValid && HIsValid) {
+ break;
+ }
+ Slot.X = Bounds.X;
+ break;
+ case LayoutingType.Y:
+ if (Bounds.Y == 0) {
switch (VerticalAlignment) {
case VerticalAlignment.Top:
Slot.Y = 0;
@@ -469,19 +463,30 @@ namespace go Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
break;
}
- } else// if (Parent.getBounds().Height>=0)
- yIsValid = false;
+ break;
+ }
+ Slot.Y = Bounds.Y;
+ break;
+ case LayoutingType.Width:
+ if (Width > 0)
+ Slot.Width = Width;
+ else if (Width < 0)
+ Slot.Width = measureRawSize ().Width;
+ else
+ Slot.Width = Parent.ClientRectangle.Width;
+ break;
+ case LayoutingType.Height:
+ if (Height > 0)
+ Slot.Height = Height;
+ else if (Height < 0)
+ Slot.Height = measureRawSize ().Height;
+ else
+ Slot.Height = Parent.ClientRectangle.Height;
+ break;
}
- }
- public virtual void UpdateLayout ()
- {
- if (!SizeIsValid)
- ComputeSize ();
- if (!PositionIsValid)
- ComputePosition ();
- if (LayoutIsValid)
- registerForRedraw ();
-
+ //if no layouting remains in queue for item, registre for redraw
+ if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count() <= 0)
+ this.registerForRedraw ();
}
protected virtual void onDraw(Context gr)
{
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index d2c48904..8056f06f 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -132,67 +132,58 @@ namespace go }
protected override Size measureRawSize ()
{
- Size raw = Bounds.Size;
Size tmp = new Size ();
- if (raw.Width >= 0 && raw.Height >= 0)
- return raw;
-
foreach (GraphicObject c in Children) {
- if (raw.Width < 0) {
- if (c.WIsValid)
- tmp.Width = Math.Max (tmp.Width, c.Slot.Right);
- else
- return raw;
- }
- if (raw.Height < 0) {
- if (c.HIsValid)
- tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);
- else
- return raw;
- }
+ tmp.Width = Math.Max (tmp.Width, c.Slot.Right);
+ tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);
}
- if (raw.Width < 0)
- tmp.Width += 2*Margin;
- if (raw.Height < 0)
- tmp.Height += 2*Margin;
+ tmp.Width += 2*Margin;
+ tmp.Height += 2*Margin;
return tmp;
}
- public override void UpdateLayout()
+ public override void RegisterForLayouting ()
{
- if (LayoutIsValid)
- return;
-
- bool atLeastOneChildHasWNotDependingOnParent = false;
- bool atLeastOneChildHasHNotDependingOnParent = false;
-
- foreach (GraphicObject c in Children) {
- if (c.LayoutIsValid)
- continue;
+ base.RegisterForLayouting ();
- if (Width < 0 && c.WIsValid) {
- if (!atLeastOneChildHasWNotDependingOnParent && !(this is GenericStack))
- c.XIsValid = true;
- atLeastOneChildHasWNotDependingOnParent = true;
- }
- if (Height < 0 && c.HIsValid) {
- if (!atLeastOneChildHasHNotDependingOnParent && !(this is GenericStack))
- c.YIsValid = true;
- atLeastOneChildHasHNotDependingOnParent = true;
- }
-
- c.UpdateLayout ();
- }
-
-// if (Width < 0 && !atLeastOneChildHasWNotDependingOnParent)
-// Debug.WriteLine ("ERROR: no child has fixed width and parent width is set to content!");
-// if (Height < 0 && !atLeastOneChildHasHNotDependingOnParent)
-// Debug.WriteLine ("ERROR: no child has fixed height and parent height is set to content!");
-
- base.UpdateLayout ();
+ foreach (GraphicObject g in Children)
+ g.RegisterForLayouting ();
}
+// public override void UpdateLayout (LayoutingType layoutType)
+// {
+// if (LayoutIsValid)
+// return;
+//
+// bool atLeastOneChildHasWNotDependingOnParent = false;
+// bool atLeastOneChildHasHNotDependingOnParent = false;
+//
+//// foreach (GraphicObject c in Children) {
+//// if (c.LayoutIsValid)
+//// continue;
+////
+//// if (Width < 0 && c.WIsValid) {
+//// if (!atLeastOneChildHasWNotDependingOnParent && !(this is GenericStack))
+//// c.XIsValid = true;
+//// atLeastOneChildHasWNotDependingOnParent = true;
+//// }
+//// if (Height < 0 && c.HIsValid) {
+//// if (!atLeastOneChildHasHNotDependingOnParent && !(this is GenericStack))
+//// c.YIsValid = true;
+//// atLeastOneChildHasHNotDependingOnParent = true;
+//// }
+////
+//// c.UpdateLayout ();
+//// }
+//
+//// if (Width < 0 && !atLeastOneChildHasWNotDependingOnParent)
+//// Debug.WriteLine ("ERROR: no child has fixed width and parent width is set to content!");
+//// if (Height < 0 && !atLeastOneChildHasHNotDependingOnParent)
+//// Debug.WriteLine ("ERROR: no child has fixed height and parent height is set to content!");
+//
+// //base.UpdateLayout ();
+// }
public override Rectangle ContextCoordinates(Rectangle r){
return r + ClientRectangle.Position;
@@ -212,7 +203,7 @@ namespace go public override void Paint(ref Context ctx, Rectangles clip = null)
{
- if ( !(Visible&LayoutIsValid) )
+ if ( !(Visible) )
return;
// ctx.Save ();
diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index 1107f825..088a4e83 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -6,14 +6,6 @@ namespace go { ILayoutable Parent { get; set; } - bool SizeIsValid { get; set; } - bool WIsValid { get; set; } - bool HIsValid { get; set; } - bool PositionIsValid { get; set; } - bool XIsValid { get; set; } - bool YIsValid { get; set; } - bool LayoutIsValid { get; set; } - Rectangle ClientRectangle { get; } Rectangle getSlot(); Rectangle getBounds(); @@ -21,6 +13,7 @@ namespace go IGOLibHost TopContainer { get; } void InvalidateLayout (); + void UpdateLayout(LayoutingType layoutType); Rectangle ContextCoordinates(Rectangle r); diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index 45a8a8b3..74e26c72 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -115,21 +115,21 @@ namespace go {
TopContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));
}
- public override void UpdateLayout ()
+ public override void UpdateLayout (LayoutingType layoutType)
{
- base.UpdateLayout ();
-
- if (!LayoutIsValid)
- return;
-
- //override child positionning inside scroller in the
- //scrolling direction
- if (child == null)
- return;
- if (VerticalScrolling)
- child.Slot.Y = 0;
- if (HorizontalScrolling)
- child.Slot.X = 0;
+// base.UpdateLayout ();
+//
+// if (!LayoutIsValid)
+// return;
+//
+// //override child positionning inside scroller in the
+// //scrolling direction
+// if (child == null)
+// return;
+// if (VerticalScrolling)
+// child.Slot.Y = 0;
+// if (HorizontalScrolling)
+// child.Slot.X = 0;
}
public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)
{
diff --git a/src/Interface.cs b/src/Interface.cs index 8f862381..8684d851 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -35,6 +35,8 @@ namespace go public static bool ReplaceTabsWithSpace = false; public static bool DesignerMode = false; + public static LayoutingQueue LayoutingQueue = new LayoutingQueue(); + #region Load/Save internal static List<EventSource> EventsToResolve; diff --git a/src/LayoutingQueue.cs b/src/LayoutingQueue.cs new file mode 100644 index 00000000..90152497 --- /dev/null +++ b/src/LayoutingQueue.cs @@ -0,0 +1,40 @@ +// +// LayoutingQueue.cs +// +// Author: +// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> +// +// Copyright (c) 2015 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +using System; +using System.Collections.Generic; + +namespace go +{ + public class LayoutingQueue : List<LayoutingQueueItem> + { + public LayoutingQueue () + { + } + + public LayoutingQueueItem Dequeue() + { + LayoutingQueueItem tmp = this [0]; + this.RemoveAt (0); + return tmp; + } + } +} + diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs new file mode 100644 index 00000000..4005f71e --- /dev/null +++ b/src/LayoutingQueueItem.cs @@ -0,0 +1,70 @@ +// +// LayoutingQueueItem.cs +// +// Author: +// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> +// +// Copyright (c) 2015 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +using System; +using System.Diagnostics; + +namespace go +{ + public enum LayoutingType + { + X, + Y, + Width, + Height, + PositionChildren + } + + public class LayoutingQueueItem + { + + public ILayoutable GraphicObject; + public LayoutingType LayoutType; + + public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject) + { + LayoutType = _layoutType; + GraphicObject = _graphicObject; + } + public void ProcessLayouting() + { + Debug.WriteLine ("Layouting => " + this.ToString ()); + try { + GraphicObject.UpdateLayout (LayoutType); + } catch (Exception ex) { + Debug.WriteLine ("Layouting error: " + ex.ToString ()); + } + } + + public static implicit operator GraphicObject(LayoutingQueueItem queueItem) + { + return queueItem.GraphicObject as GraphicObject; + } + public static implicit operator LayoutingType(LayoutingQueueItem lqi) + { + return lqi.LayoutType; + } + public override string ToString () + { + return string.Format ("{0}->{1}", LayoutType,GraphicObject.ToString()); + } + } +} + diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 644c65c8..2d491b20 100755 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -78,6 +78,8 @@ namespace go {
g.Parent = this;
GraphicObjects.Add (g);
+
+ g.RegisterForLayouting ();
}
public void DeleteWidget(GraphicObject g)
{
@@ -224,14 +226,18 @@ namespace go GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
GraphicObjects.CopyTo (invGOList,0);
invGOList = invGOList.Reverse ().ToArray ();
-
- foreach (GraphicObject p in invGOList) {
- if (p.Visible) {
- layoutTime.Start ();
- while(!p.LayoutIsValid)
- p.UpdateLayout ();
- layoutTime.Stop ();
- }
+//
+// foreach (GraphicObject p in invGOList) {
+// if (p.Visible) {
+// layoutTime.Start ();
+// while(!p.LayoutIsValid)
+// p.UpdateLayout ();
+// layoutTime.Stop ();
+// }
+// }
+ while (Interface.LayoutingQueue.Count > 0) {
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ lqi.ProcessLayouting ();
}
//Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");
@@ -457,6 +463,11 @@ namespace go #region ILayoutable implementation
+ public void UpdateLayout (LayoutingType layoutType)
+ {
+ throw new NotImplementedException ();
+ }
+
public Rectangle ContextCoordinates (Rectangle r)
{
return r;
|