From: jpbruyere Date: Tue, 28 Apr 2015 15:50:42 +0000 (+0200) Subject: Layouting queue test 2 X-Git-Tag: 0.2~98^2~1 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=c88d3c2e0b3e9e69df5f1879b9d8935d3ae0d390;p=jp%2Fcrow.git Layouting queue test 2 --- diff --git a/Tests/GOLIBTest_0.cs b/Tests/GOLIBTest_0.cs index 6d479219..8eaac7fa 100644 --- a/Tests/GOLIBTest_0.cs +++ b/Tests/GOLIBTest_0.cs @@ -36,7 +36,25 @@ namespace test base.OnRenderFrame (e); SwapBuffers (); } - + protected override void OnKeyDown (KeyboardKeyEventArgs e) + { + switch (e.Key) { + case Key.Left: + g.Left++; + break; + case Key.Right: + g.Left--; + break; + case Key.Up: + g.Top--; + break; + case Key.Down: + g.Top++; + break; + default: + break; + } + } protected override void OnUpdateFrame (FrameEventArgs e) { base.OnUpdateFrame (e); diff --git a/Tests/GOLIBTest_1.2.cs b/Tests/GOLIBTest_1.2.cs index 629b2995..3337f06c 100644 --- a/Tests/GOLIBTest_1.2.cs +++ b/Tests/GOLIBTest_1.2.cs @@ -22,7 +22,7 @@ namespace test : base(1024, 600,"test") {} - VerticalStack g; + Container g; protected override void OnLoad (EventArgs e) { diff --git a/Tests/Interfaces/test0.goml b/Tests/Interfaces/test0.goml index 102c1cac..18d1550f 100755 --- a/Tests/Interfaces/test0.goml +++ b/Tests/Interfaces/test0.goml @@ -1,5 +1,5 @@  - diff --git a/Tests/Interfaces/test1.2.goml b/Tests/Interfaces/test1.2.goml index c41135c9..1ccc51ec 100755 --- a/Tests/Interfaces/test1.2.goml +++ b/Tests/Interfaces/test1.2.goml @@ -1,4 +1,5 @@  + \ No newline at end of file + + \ No newline at end of file diff --git a/Tests/Interfaces/test1.goml b/Tests/Interfaces/test1.goml index ff270768..9601a87b 100755 --- a/Tests/Interfaces/test1.goml +++ b/Tests/Interfaces/test1.goml @@ -1,9 +1,9 @@  - + + Margin="20" Focusable="True" Background="Green"> diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 7d37271c..a0af8a64 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -8,7 +8,7 @@ Exe Tests Tests - test.GOLIBTest_5 + test.GOLIBTest_1 v4.5 ..\bin\$(configuration) obj\$(configuration) diff --git a/src/GraphicObjects/Checkbox.cs b/src/GraphicObjects/Checkbox.cs old mode 100755 new mode 100644 index 91f8e451..3c25c741 --- a/src/GraphicObjects/Checkbox.cs +++ b/src/GraphicObjects/Checkbox.cs @@ -67,7 +67,7 @@ namespace go if (value == _CurrentState) return; _CurrentState = value; - registerForRedraw(); + RegisterForRedraw(); } } diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index 1971f00b..862f7947 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -3,6 +3,7 @@ using System.Xml.Serialization; using System.Reflection; using OpenTK.Input; using System.ComponentModel; +using System.Linq; namespace go { @@ -24,13 +25,17 @@ namespace go public T setChild(T _child) { - if (child != null) - child.Parent = null; + if (child != null) { + this.RegisterForLayouting ((int)LayoutingType.Sizing); + child.Parent = null; + } child = _child as GraphicObject; - if (child != null) - child.Parent = this; + if (child != null) { + child.Parent = this; + child.RegisterForLayouting ((int)LayoutingType.Sizing); + } return (T)_child; } @@ -43,19 +48,6 @@ namespace go get { return base.Focusable; } set { base.Focusable = value; } } - [XmlIgnore]public override bool LayoutIsValid - { - get - { - if (!Visible) - return true; - - return !base.LayoutIsValid || child == null ? - base.LayoutIsValid : - child.LayoutIsValid; - } - set { base.LayoutIsValid = value; } - } public override GraphicObject FindByName (string nameToFind) { @@ -69,45 +61,112 @@ namespace go return child == goToFind ? true : child == null ? false : child.Contains(goToFind); } - public override void InvalidateLayout() - { - base.InvalidateLayout(); - - if (child != null) - 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 () - { - base.RegisterForLayouting (); - if (child != null) - child.RegisterForLayouting (); + public override void UpdateLayout (LayoutingType layoutType) + { + { + switch (layoutType) { + case LayoutingType.X: + if (Bounds.X == 0) { + switch (HorizontalAlignment) { + case HorizontalAlignment.Left: + Slot.X = 0; + break; + case HorizontalAlignment.Right: + Slot.X = Parent.ClientRectangle.Width - Slot.Width; + break; + case HorizontalAlignment.Center: + Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2; + break; + } + } else + Slot.X = Bounds.X; + if (LastSlots.X == Slot.X) + break; + //register layouting here for objects depending on this.x + LastSlots.X = Slot.X; + break; + case LayoutingType.Y: + if (Bounds.Y == 0) { + switch (VerticalAlignment) { + case VerticalAlignment.Top: + Slot.Y = 0; + break; + case VerticalAlignment.Bottom: + Slot.Y = Parent.ClientRectangle.Height - Slot.Height; + break; + case VerticalAlignment.Center: + Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2; + break; + } + }else + Slot.Y = Bounds.Y; + if (LastSlots.Y == Slot.Y) + break; + //register layouting here for objects depending on this.x + LastSlots.Y = Slot.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; + + if (LastSlots.Width == Slot.Width) + break; + + if (Parent.getBounds ().Width < 0) + this.Parent.RegisterForLayouting ((int)LayoutingType.Width); + else if (Width != 0) //update position in parent + this.RegisterForLayouting ((int)LayoutingType.X); + + if (child != null) { + if (child.getBounds ().Width == 0) + child.RegisterForLayouting ((int)LayoutingType.Width); + else + child.RegisterForLayouting ((int)LayoutingType.X); + } + LastSlots.Width = Slot.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; + + if (LastSlots.Height == Slot.Height) + break; + + if (Parent.getBounds().Height < 0) + this.Parent.RegisterForLayouting((int)LayoutingType.Height); + else if (Height != 0) //update position in parent + this.RegisterForLayouting ((int)LayoutingType.Y); + + if (child != null) { + if (child.getBounds ().Height == 0) + child.RegisterForLayouting ((int)LayoutingType.Height); + else + child.RegisterForLayouting ((int)LayoutingType.Y); + } + + 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) + this.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 36d41f99..04e63d15 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -22,6 +22,17 @@ namespace go Orientation _orientation; #endregion + public override T addChild (T child) + { + this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + return base.addChild (child); + } + public override void removeChild (GraphicObject child) + { + base.removeChild (child); + this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + } + #region Public Properties [XmlAttributeAttribute()][DefaultValue(2)] public int Spacing @@ -85,23 +96,30 @@ namespace go } } } - public override void RegisterForLayouting () - { - base.RegisterForLayouting (); +// public void RegisterForLayouting () +// { +// base.RegisterForLayouting (); +// +// 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 RegisterForLayouting (int layoutType) + { + base.RegisterForLayouting (layoutType); - 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)); + if ((layoutType & (int)LayoutingType.PositionChildren) > 0) + Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this); } public override void UpdateLayout (LayoutingType layoutType) { if (layoutType == LayoutingType.PositionChildren) ComputeChildrenPositions (); - - base.UpdateLayout(layoutType); + else + base.UpdateLayout(layoutType); } #endregion diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index c6756db2..9317f409 100755 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -190,8 +190,7 @@ namespace go Bounds.X = value; - LayoutIsValid = false; - registerForGraphicUpdate (); + Interface.LayoutingQueue.Enqueue (LayoutingType.X, this); } } [XmlAttributeAttribute()][DefaultValue(0)] @@ -203,8 +202,7 @@ namespace go Bounds.Y = value; - LayoutIsValid = false; - registerForGraphicUpdate (); + Interface.LayoutingQueue.Enqueue (LayoutingType.Y, this); } } [XmlAttributeAttribute()][DefaultValue(0)] @@ -373,63 +371,96 @@ namespace go public virtual void registerForGraphicUpdate () { bmp = null; - RegisterForLayouting (); + if (TopContainer != null) + TopContainer.gobjsToRedraw.Add (this); + //RegisterForLayouting (); //registerForRedraw (); //Interface.registerForGraphicUpdate(this); } /// /// Add clipping region in redraw list of interface, dont update cached object content /// - public virtual void registerForRedraw () + public virtual void RegisterForRedraw () { - if (Visible && TopContainer != null) - TopContainer.gobjsToRedraw.Add (this); + bmp = null; + TopContainer.gobjsToRedraw.Add (this); } + + public Rectangle LastSlots; + public virtual void registerClipRect() { TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot)); } protected virtual Size measureRawSize () - { + { return Bounds.Size; } - public virtual void RegisterForLayouting() + + public virtual void RegisterForLayouting(int layoutType) { - //clear previous layouting for item - Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this); + Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0); - 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) + if ((layoutType & (int)LayoutingType.Width) > 0) { + if (Bounds.Width == 0) //stretch in parent + Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this); + else //fit ou fixed 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 (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) + + if ((layoutType & (int)LayoutingType.Height) > 0) { + if (Bounds.Height == 0) //stretch in parent + Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this); + else//fit ou fixed Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this)); - else - 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)); } + 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) + //for x positionning, sizing of parent and this have to be done + Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this); + } +// public virtual void RegisterForLayouting() +// { +// //clear previous layouting for item +// Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this); +// +// 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 (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 +// 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)); +// } +// } +// public virtual void UpdateLayout (LayoutingType layoutType) { switch (layoutType) { @@ -446,9 +477,12 @@ namespace go Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2; break; } + } else + Slot.X = Bounds.X; + if (LastSlots.X == Slot.X) break; - } - Slot.X = Bounds.X; + //register layouting here for objects depending on this.x + LastSlots.X = Slot.X; break; case LayoutingType.Y: if (Bounds.Y == 0) { @@ -463,9 +497,12 @@ namespace go Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2; break; } + }else + Slot.Y = Bounds.Y; + if (LastSlots.Y == Slot.Y) break; - } - Slot.Y = Bounds.Y; + //register layouting here for objects depending on this.x + LastSlots.Y = Slot.Y; break; case LayoutingType.Width: if (Width > 0) @@ -474,6 +511,16 @@ namespace go Slot.Width = measureRawSize ().Width; else Slot.Width = Parent.ClientRectangle.Width; + + if (LastSlots.Width == Slot.Width) + break; + + if (Parent.getBounds().Width < 0) + this.Parent.RegisterForLayouting((int)LayoutingType.Width); + else if (Width != 0) //update position in parent + this.RegisterForLayouting ((int)LayoutingType.X); + + LastSlots.Width = Slot.Width; break; case LayoutingType.Height: if (Height > 0) @@ -482,12 +529,24 @@ namespace go Slot.Height = measureRawSize ().Height; else Slot.Height = Parent.ClientRectangle.Height; + + if (LastSlots.Height == Slot.Height) + break; + + if (Parent.getBounds().Height < 0) + this.Parent.RegisterForLayouting((int)LayoutingType.Height); + else if (Height != 0) //update position in parent + this.RegisterForLayouting ((int)LayoutingType.Y); + + 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) - this.registerForRedraw (); + if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0) + this.RegisterForRedraw (); } + protected virtual void onDraw(Context gr) { Rectangle rBack = new Rectangle (Slot.Size); diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 8056f06f..e1639533 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -36,15 +36,15 @@ namespace go { GraphicObject g = child as GraphicObject; Children.Add(g); - g.Parent = this as GraphicObject; - LayoutIsValid = false; + g.Parent = this as GraphicObject; + g.RegisterForLayouting ((int)LayoutingType.Sizing); return (T)child; } - public void removeChild(GraphicObject child) + public virtual void removeChild(GraphicObject child) { Children.Remove(child); child.Parent = null; - LayoutIsValid = false; + this.RegisterForLayouting ((int)LayoutingType.Sizing); } public void putWidgetOnTop(GraphicObject w) { @@ -81,26 +81,6 @@ namespace go return true; } } - [XmlIgnore]public override bool LayoutIsValid - { - get - { - if (!Visible) - return true; - - if (!base.LayoutIsValid) - return false; - else//le layout n'est valide que si tous les enfents sont validés aussi - { - foreach (GraphicObject w in Children) - if (!w.LayoutIsValid) - return false; - } - - return true; - } - set { base.LayoutIsValid = value; } - } public override GraphicObject FindByName (string nameToFind) { @@ -144,13 +124,7 @@ namespace go return tmp; } - public override void RegisterForLayouting () - { - base.RegisterForLayouting (); - foreach (GraphicObject g in Children) - g.RegisterForLayouting (); - } // public override void UpdateLayout (LayoutingType layoutType) // { // if (LayoutIsValid) diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index 088a4e83..f732a2ca 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -12,7 +12,7 @@ namespace go IGOLibHost TopContainer { get; } - void InvalidateLayout (); + void RegisterForLayouting(int layoutType); void UpdateLayout(LayoutingType layoutType); diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index 74e26c72..6855e924 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -72,7 +72,7 @@ namespace go if (VerticalScrolling ) { //add redraw call with old bounds to errase old position - registerForRedraw(); + RegisterForRedraw(); scrollY += e.Delta * ScrollSpeed; @@ -85,7 +85,7 @@ namespace go if (HorizontalScrolling ) { //add redraw call with old bounds to errase old position - registerForRedraw(); + RegisterForRedraw(); scrollX += e.Delta * ScrollSpeed; @@ -97,7 +97,7 @@ namespace go //renderBounds.Y = -scrollY; - registerForRedraw(); + RegisterForRedraw(); //Parent.registerForGraphicUpdate (); } #endregion diff --git a/src/LayoutingQueue.cs b/src/LayoutingQueue.cs index 90152497..142a3079 100644 --- a/src/LayoutingQueue.cs +++ b/src/LayoutingQueue.cs @@ -20,6 +20,7 @@ // along with this program. If not, see . using System; using System.Collections.Generic; +using System.Linq; namespace go { @@ -28,7 +29,34 @@ namespace go public LayoutingQueue () { } - + public void Enqueue(LayoutingType _lt, ILayoutable _object) + { + Interface.LayoutingQueue.RemoveAll(lq => lq.GraphicObject == _object && lq.LayoutType == _lt); + Interface.LayoutingQueue.Add (new LayoutingQueueItem (_lt, _object)); + } + + public void EnqueueAfterParentSizing (LayoutingType _lt, ILayoutable _object) + { + LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object); + int idxParentSz = Interface.LayoutingQueue.IndexOf + (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == _object.Parent && lq.LayoutType == _lt).LastOrDefault()); + + Interface.LayoutingQueue.Insert (idxParentSz + 1, lqi); + } + public void EnqueueAfterThisAndParentSizing (LayoutingType _lt, ILayoutable _object) + { + LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object); + LayoutingType sizing = LayoutingType.Width; + + if (_lt == LayoutingType.Y) + sizing = LayoutingType.Height; + + int idxW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where + (lq => (lq.GraphicObject == _object.Parent || lq.GraphicObject == _object) && lq.LayoutType == sizing).LastOrDefault()); + + Interface.LayoutingQueue.Insert (idxW + 1, lqi); + } + public LayoutingQueueItem Dequeue() { LayoutingQueueItem tmp = this [0]; diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index 4005f71e..e1d21792 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -25,11 +25,13 @@ namespace go { public enum LayoutingType { - X, - Y, - Width, - Height, - PositionChildren + X = 0x01, + Y = 0x02, + Width = 0x04, + Height = 0x08, + Sizing = 0x0C, + PositionChildren = 0x10, + All = 0xFF } public class LayoutingQueueItem @@ -63,7 +65,7 @@ namespace go } public override string ToString () { - return string.Format ("{0}->{1}", LayoutType,GraphicObject.ToString()); + return string.Format ("{1}->{0}", LayoutType,GraphicObject.ToString()); } } } diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 2d491b20..86d8d312 100755 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -79,7 +79,7 @@ namespace go g.Parent = this; GraphicObjects.Add (g); - g.RegisterForLayouting (); + g.RegisterForLayouting ((int)LayoutingType.Sizing); } public void DeleteWidget(GraphicObject g) { @@ -463,6 +463,11 @@ namespace go #region ILayoutable implementation + public void RegisterForLayouting (int layoutType) + { + throw new NotImplementedException (); + } + public void UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); @@ -524,79 +529,7 @@ namespace go return ClientRectangle; } - public bool WIsValid { - get { - return true; - } - set { - throw new NotImplementedException (); - } - } - public bool HIsValid { - get { - return true; - } - set { - throw new NotImplementedException (); - } - } - public bool XIsValid { - get { - return true; - } - set { - throw new NotImplementedException (); - } - } - public bool YIsValid { - get { - return true; - } - set { - throw new NotImplementedException (); - } - } - public virtual void InvalidateLayout () - { -// foreach (GraphicObject g in GraphicObjects) { -// g.InvalidateLayout (); -// } - } -// public Rectangle rectInScreenCoord (Rectangle r) -// { -// throw new NotImplementedException (); -// } -// public Rectangle renderBoundsInContextCoordonate { -// get { return ClientRectangle; } -// } -// public Rectangle ClientBoundsInContextCoordonate { -// get { -// throw new NotImplementedException (); -// } -// } -// public Rectangle renderBoundsInBackendSurfaceCoordonate { -// get { return ClientRectangle; } -// } -// public Rectangle ClientBoundsInBackendSurfaceCoordonate { -// get { -// throw new NotImplementedException (); -// } -// set { -// throw new NotImplementedException (); -// } -// } -// public Rectangle ScreenCoordBounds { -// get { return ClientRectangle; } -// } -// public Rectangle ScreenCoordClientBounds { -// get { -// throw new NotImplementedException (); -// } -// set { -// throw new NotImplementedException (); -// } -// } #endregion } } \ No newline at end of file