invGOList = invGOList.Reverse ().ToArray ();
//Debug.WriteLine ("======= Layouting queue start =======");
- while (Interface.LayoutingQueue.Count > 0) {
+ while (Interface.LayoutingQueue.First != null) {
// Stopwatch lqiProcTime = new Stopwatch ();
// lqiProcTime.Start ();
LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
void deleteLQI(int lt){
LayoutingQueueItem[] lqis = this.RegisteredLQIs.Where (lq => (lt & (int)lq.LayoutType) > 0).ToArray ();
for (int i = 0; i < lqis.Length; i++) {
- Interface.LayoutingQueue.Remove (lqis [i]);
+ Interface.LayoutingQueue.Remove (lqis [i].Node);
lqis [i].DeleteLayoutableRef();
}
}
Debug.WriteLine ("RegisterForLayouting => {1}->{0}", layoutType, this.ToString());
#endif
- deleteLQI (layoutType);
- if ((layoutType & (int)LayoutingType.Width) > 0) {
- if (Bounds.Width == 0) //stretch in parent
+ deleteLQI (layoutType);
+ if ((layoutType & (int)LayoutingType.Width) > 0) {
+ if (Bounds.Width == 0) //stretch in parent
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);
- else if (Bounds.Width < 0) //fit
+ else if (Bounds.Width < 0) //fit
Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);
- else
- Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
+ else {
+ LayoutingQueueItem lqi = new LayoutingQueueItem (LayoutingType.Width, this);
+ lqi.Node = Interface.LayoutingQueue.AddFirst (lqi);
}
+ }
- if ((layoutType & (int)LayoutingType.Height) > 0) {
- if (Bounds.Height == 0) //stretch in parent
+ if ((layoutType & (int)LayoutingType.Height) > 0) {
+ 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{
+ LayoutingQueueItem lqi = new LayoutingQueueItem (LayoutingType.Height, this);
+ lqi.Node = Interface.LayoutingQueue.AddFirst (lqi);
}
+ }
- 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>
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Diagnostics;
namespace Crow
{
- public class LayoutingQueue : List<LayoutingQueueItem>
+ public class LayoutingQueue : LinkedList<LayoutingQueueItem>
{
public LayoutingQueue ()
{
}
public void Enqueue(LayoutingType _lt, ILayoutable _object)
{
- this.Add (new LayoutingQueueItem (_lt, _object));
+ LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object);
+ lqi.Node = this.AddLast (lqi);
}
LayoutingQueueItem searchLqi(ILayoutable go, LayoutingType lt){
return go.RegisteredLQIs.Where(lq => lq.LayoutType == lt).LastOrDefault();
LayoutingQueueItem parentLqi = searchLqi (_object.Parent, _lt);
if (parentLqi == null)
- this.Insert (0, lqi);
+ lqi.Node = this.AddFirst (lqi);
else
- this.Insert (this.IndexOf (parentLqi) + 1, lqi);
+ lqi.Node = this.AddAfter (parentLqi.Node, lqi);
}
public void EnqueueBeforeParentSizing (LayoutingType _lt, ILayoutable _object)
{
LayoutingQueueItem parentLqi = searchLqi (_object.Parent, _lt);
if (parentLqi == null)
- this.Add (lqi);
+ lqi.Node = this.AddLast (lqi);
else
- this.Insert (this.IndexOf (parentLqi), lqi);
+ lqi.Node = this.AddBefore (parentLqi.Node, lqi);
}
public void EnqueueAfterThisAndParentSizing (LayoutingType _lt, ILayoutable _object)
{
LayoutingQueueItem parentLqi = searchLqi (_object.Parent, sizing);
LayoutingQueueItem thisLqi = searchLqi (_object, sizing);
- int idx = -1;
if (parentLqi == null) {
if (thisLqi != null)
- idx = this.IndexOf (thisLqi);
+ lqi.Node = this.AddAfter (thisLqi.Node, lqi);
+ else
+ lqi.Node = this.AddLast (lqi);
} else {
if (thisLqi == null)
- idx = this.IndexOf (parentLqi);
- else
- idx = Math.Max(this.IndexOf (parentLqi), this.IndexOf (thisLqi));
+ lqi.Node = this.AddAfter (parentLqi.Node, lqi);
+ else {
+ switch (sizing) {
+ case LayoutingType.Width:
+ if (_object.Parent.getBounds().Width<0)
+ lqi.Node = this.AddAfter (parentLqi.Node, lqi);
+ else
+ lqi.Node = this.AddAfter (thisLqi.Node, lqi);
+ break;
+ case LayoutingType.Height:
+ if (_object.Parent.getBounds().Height<0)
+ lqi.Node = this.AddAfter (parentLqi.Node, lqi);
+ else
+ lqi.Node = this.AddAfter (thisLqi.Node, lqi);
+ break;
+ }
+ }
}
-
- this.Insert (idx + 1, lqi);
}
public LayoutingQueueItem Dequeue()
{
- LayoutingQueueItem tmp = this [0];
+ LayoutingQueueItem tmp = this.First.Value;
tmp.DeleteLayoutableRef ();
- this.RemoveAt (0);
+ this.RemoveFirst ();
return tmp;
}
}
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Diagnostics;
+using System.Collections.Generic;
namespace Crow
{
public class LayoutingQueueItem
{
-
+ public LinkedListNode<LayoutingQueueItem> Node;
public ILayoutable GraphicObject;
public LayoutingType LayoutType;
#endif
//Debug.WriteLine ("======= Layouting queue start =======");
- while (Interface.LayoutingQueue.Count > 0) {
+ while (Interface.LayoutingQueue.First != null) {
// Stopwatch lqiProcTime = new Stopwatch ();
// lqiProcTime.Start ();
LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();