aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-06 07:11:22 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-06 07:11:22 +0100
commit643d44f381962d6814d3676cee322c41018406eb (patch)
tree313429713063c06ec57e675682e7a6c176e62e22 /src
parent27c400b4aa2195ee0ea17af803919ae677b9fff7 (diff)
2 step, 1=> Simple Register, 2=> Enqueue with priority checking
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GenericStack.cs7
-rw-r--r--src/GraphicObjects/GraphicObject.cs19
-rw-r--r--src/GraphicObjects/Grid.cs6
-rw-r--r--src/Interface.cs1
-rw-r--r--src/LayoutingQueueItem.cs1
-rw-r--r--src/OpenTKGameWindow.cs16
6 files changed, 29 insertions, 21 deletions
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index d4e3ae5d..e2bdcf7a 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -108,16 +108,15 @@ namespace Crow
bmp = null;
}
- public override void RegisterForLayouting (int layoutType)
+ public override void EnqueueForLayouting ()
{
if (Parent == null)
return;
- base.RegisterForLayouting (layoutType);
+ base.EnqueueForLayouting ();
- if ((layoutType & (int)LayoutingType.PositionChildren) > 0)
+ if (RegisteredLayoutings.HasFlag(LayoutingType.PositionChildren))
Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);
-
}
public override void UpdateLayout (LayoutingType layoutType)
{
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 53dee9cc..97afaa7e 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -509,9 +509,16 @@ namespace Crow
RegisteredLQINodes.Remove (lqis [i]);
}
}
+ public LayoutingType RegisteredLayoutings = 0;
+
+ public virtual void RegisterForLayouting(int layoutType){
+ if (RegisteredLayoutings == LayoutingType.None)
+ Interface.RegisteredGOForLayouting.Enqueue (this);
+ RegisteredLayoutings |= (LayoutingType)layoutType;
+ }
/// <summary> clear current layoutingQueue items for object and
/// trigger a new layouting pass for a layoutType </summary>
- public virtual void RegisterForLayouting(int layoutType)
+ public virtual void EnqueueForLayouting()
{
if (Parent == null)
return;
@@ -519,8 +526,8 @@ namespace Crow
Debug.WriteLine ("RegisterForLayouting => {1}->{0}", layoutType, this.ToString());
#endif
- deleteLQI (layoutType);
- if ((layoutType & (int)LayoutingType.Width) > 0) {
+ //deleteLQI (RegisteredLayoutings);
+ if (RegisteredLayoutings.HasFlag(LayoutingType.Width)) {
if (Bounds.Width == 0) //stretch in parent
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);
else if (Bounds.Width < 0) //fit
@@ -531,7 +538,7 @@ namespace Crow
new LayoutingQueueItem (LayoutingType.Width, this)));
}
- if ((layoutType & (int)LayoutingType.Height) > 0) {
+ if (RegisteredLayoutings.HasFlag(LayoutingType.Height)) {
if (Bounds.Height == 0) //stretch in parent
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);
else if (Bounds.Height < 0) //fit
@@ -544,11 +551,11 @@ namespace Crow
}
}
- if ((layoutType & (int)LayoutingType.X) > 0)
+ if (RegisteredLayoutings.HasFlag(LayoutingType.X))
//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 (RegisteredLayoutings.HasFlag(LayoutingType.Y))
//for x positionning, sizing of parent and this have to be done
Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);
}
diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs
index 1981fc60..571fdc0f 100644
--- a/src/GraphicObjects/Grid.cs
+++ b/src/GraphicObjects/Grid.cs
@@ -125,11 +125,11 @@ namespace Crow
}
}
- public override void RegisterForLayouting (int layoutType)
+ public override void EnqueueForLayouting ()
{
- base.RegisterForLayouting (layoutType);
+ base.EnqueueForLayouting ();
- if ((layoutType & (int)LayoutingType.PositionChildren) > 0)
+ if (RegisteredLayoutings.HasFlag(LayoutingType.PositionChildren))
Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);
}
public override void UpdateLayout (LayoutingType layoutType)
diff --git a/src/Interface.cs b/src/Interface.cs
index c96dffa0..cf86ecf3 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -54,6 +54,7 @@ namespace Crow
public static int BorderThreshold = 5;
public static LayoutingQueue LayoutingQueue = new LayoutingQueue ();
+ public static Queue<GraphicObject> RegisteredGOForLayouting = new Queue<GraphicObject>();
#region Load/Save
//internal static List<DynAttribute> Bindings;
diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs
index 80d04dc6..7153429b 100644
--- a/src/LayoutingQueueItem.cs
+++ b/src/LayoutingQueueItem.cs
@@ -26,6 +26,7 @@ namespace Crow
{
public enum LayoutingType
{
+ None = 0x00,
X = 0x01,
Y = 0x02,
Width = 0x04,
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index 89df8ee4..23d3e814 100644
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -261,18 +261,18 @@ namespace Crow
#endif
//Debug.WriteLine ("======= Layouting queue start =======");
+ while (Interface.RegisteredGOForLayouting.Count > 0){
+ while (Interface.RegisteredGOForLayouting.Count > 0){
+ GraphicObject go = Interface.RegisteredGOForLayouting.Dequeue ();
+ go.EnqueueForLayouting ();
+ go.RegisteredLayoutings = LayoutingType.None;
+ }
while (Interface.LayoutingQueue.First != null) {
-// Stopwatch lqiProcTime = new Stopwatch ();
-// lqiProcTime.Start ();
LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
lqi.ProcessLayouting ();
-// lqiProcTime.Stop ();
-// if (lqiProcTime.ElapsedMilliseconds > 10) {
-// Debug.WriteLine("lqi {2}: {0} ticks \t, {1} ms",
-// updateTime.ElapsedTicks,
-// updateTime.ElapsedMilliseconds, lqi.ToString());
-// }
}
+ }
+
#if MEASURE_TIME
layoutTime.Stop ();
#endif