]> O.S.I.I.S - jp/crow.git/commitdiff
2 step, 1=> Simple Register, 2=> Enqueue with priority checking
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Feb 2016 06:11:22 +0000 (07:11 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Feb 2016 06:11:22 +0000 (07:11 +0100)
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Grid.cs
src/Interface.cs
src/LayoutingQueueItem.cs
src/OpenTKGameWindow.cs

index d4e3ae5d1186c4c05d4f1819975643d36d87c225..e2bdcf7ac935f106f18b6d8c324c9d8557b7d278 100644 (file)
@@ -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)
         {            
index 53dee9cc286c1a4c1d5782936bb6686f956e120e..97afaa7e0a79f739dc709c867481a3ac65d4b974 100644 (file)
@@ -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);
                }
index 1981fc6033a2fe70fa29d382f7f50c1d8bb3c8ef..571fdc0fd42cb31a38b2105ab407e26a287acf2f 100644 (file)
@@ -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)
index c96dffa02e86315a8aa813e2c637c85479bfe29c..cf86ecf3039f09a8064d581a60f8d267f2ac0fe8 100644 (file)
@@ -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;
index 80d04dc6d361bba0da4f2edf4b68730be00e3c4d..7153429b2a2d560416a7904c9d8d594243ebd68c 100644 (file)
@@ -26,6 +26,7 @@ namespace Crow
 {
        public enum LayoutingType
        {
+               None = 0x00,
                X = 0x01,
                Y = 0x02,
                Width = 0x04,
index 89df8ee4e5c490e75044a3a5279bf3257d557a2e..23d3e81466281c4dd2fb891e04058cd4477b1983 100644 (file)
@@ -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