]> O.S.I.I.S - jp/crow.git/commitdiff
Layouting queue test 2
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 28 Apr 2015 15:50:42 +0000 (17:50 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 28 Apr 2015 15:50:42 +0000 (17:50 +0200)
16 files changed:
Tests/GOLIBTest_0.cs
Tests/GOLIBTest_1.2.cs
Tests/Interfaces/test0.goml
Tests/Interfaces/test1.2.goml
Tests/Interfaces/test1.goml
Tests/Tests.csproj
src/GraphicObjects/Checkbox.cs [changed mode: 0755->0644]
src/GraphicObjects/Container.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/ILayoutable.cs
src/GraphicObjects/Scroller.cs
src/LayoutingQueue.cs
src/LayoutingQueueItem.cs
src/OpenTKGameWindow.cs

index 6d47921991abebee76acba8c6558f4b87c453c7d..8eaac7fac121898cd023b2afab8f616c304d7d42 100644 (file)
@@ -36,7 +36,25 @@ namespace test
                        base.OnRenderFrame (e);\r
                        SwapBuffers ();\r
                }\r
-\r
+               protected override void OnKeyDown (KeyboardKeyEventArgs e)\r
+               {\r
+                       switch (e.Key) {\r
+                       case Key.Left:\r
+                               g.Left++;\r
+                               break;\r
+                       case Key.Right:\r
+                               g.Left--;\r
+                               break;\r
+                       case Key.Up:\r
+                               g.Top--;\r
+                               break;\r
+                       case Key.Down:\r
+                               g.Top++;\r
+                               break;\r
+                       default:\r
+                               break;\r
+                       }\r
+               }\r
                protected override void OnUpdateFrame (FrameEventArgs e)\r
                {\r
                        base.OnUpdateFrame (e);\r
index 629b2995b8ced34fc299863c245e882e22343d3b..3337f06c10b31bf2342be518497b5acc6dae8aed 100644 (file)
@@ -22,7 +22,7 @@ namespace test
                        : base(1024, 600,"test")\r
                {}\r
 \r
-               VerticalStack g;\r
+               Container g;\r
 \r
                protected override void OnLoad (EventArgs e)\r
                {\r
index 102c1cac3faa972f6f05b331fff49098dde47d4d..18d1550fd7cae06190f37c0427a870b0d15f2ffc 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>\r
-<GraphicObject \r
-                       HorizontalAlignment="Right"\r
-                       VerticalAlignment="Bottom"\r
+<GraphicObject\r
+                       Width="100" Height="100"\r
+                       Top="200" Left="200" \r
                        Margin="10" Background="Green"/>\r
index c41135c9a2426334a1f978d1665b29f6d61b6d6a..1ccc51ec98258b459bbd1fbac121cccade32f3a4 100755 (executable)
@@ -1,4 +1,5 @@
 <?xml version="1.0"?>\r
+<Container>\r
 <VerticalStack>\r
        <Label Text="label11"/>\r
        <Label Text="label21"/>\r
@@ -15,4 +16,5 @@
        <Label Text="label43"/>\r
        <Label Text="label53"/>\r
 \r
-</VerticalStack>
\ No newline at end of file
+</VerticalStack>\r
+</Container>
\ No newline at end of file
index ff2707683ee18181964ff1c8d2d8d6c43d784260..9601a87be1be00528f7c43cdd590e16581ac79fb 100755 (executable)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>\r
-<Container Width="0" Height="-1"\r
-       Margin="100" Focusable="True" Background="Yellow">\r
+<Container Width="300" Height="-1"\r
+       Margin="20" Focusable="True" Background="Yellow">\r
 \r
        <Container Width="-1" Height="-1"\r
-               Margin="10" Focusable="True" Background="Green">\r
+               Margin="20" Focusable="True" Background="Green">\r
                        <Image VerticalAlignment="Bottom"                       \r
                                Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>\r
        </Container>\r
index 7d37271c9865a3ca0b14a2ba7dc1aeae3b4c949d..a0af8a64fa536443cb32ddf4b9d3628cfadf02e2 100644 (file)
@@ -8,7 +8,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_5</StartupObject>
+    <StartupObject>test.GOLIBTest_1</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
old mode 100755 (executable)
new mode 100644 (file)
index 91f8e45..3c25c74
@@ -67,7 +67,7 @@ namespace go
                 if (value == _CurrentState)\r
                     return;\r
                 _CurrentState = value;\r
-                registerForRedraw();\r
+                RegisterForRedraw();\r
             }\r
         }\r
 \r
index 1971f00baf495fa1bfb67942606003ec63c5e2f3..862f7947c269945a6179964470d4f60088eccfc9 100644 (file)
@@ -3,6 +3,7 @@ using System.Xml.Serialization;
 using System.Reflection;\r
 using OpenTK.Input;\r
 using System.ComponentModel;\r
+using System.Linq;\r
 \r
 namespace go\r
 {\r
@@ -24,13 +25,17 @@ namespace go
         public T setChild<T>(T _child)\r
         {\r
 \r
-            if (child != null)\r
-                child.Parent = null;\r
+                       if (child != null) {\r
+                               this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
+                               child.Parent = null;\r
+                       }\r
 \r
             child = _child as GraphicObject;\r
 \r
-            if (child != null)\r
-                child.Parent = this;\r
+                       if (child != null) {\r
+                               child.Parent = this;\r
+                               child.RegisterForLayouting ((int)LayoutingType.Sizing);\r
+                       }\r
 \r
             return (T)_child;\r
         }\r
@@ -43,19 +48,6 @@ namespace go
                        get { return base.Focusable; }\r
                        set { base.Focusable = value; }\r
                }\r
-               [XmlIgnore]public override bool LayoutIsValid\r
-               {\r
-                       get\r
-                       {\r
-                               if (!Visible)\r
-                                       return true;\r
-\r
-                               return !base.LayoutIsValid || child == null ?\r
-                                       base.LayoutIsValid :\r
-                                       child.LayoutIsValid;\r
-                       }\r
-                       set { base.LayoutIsValid = value; }\r
-               }\r
 \r
                public override GraphicObject FindByName (string nameToFind)\r
                {\r
@@ -69,45 +61,112 @@ namespace go
                        return child == goToFind ? true : \r
                                child == null ? false : child.Contains(goToFind);\r
                }\r
-        public override void InvalidateLayout()\r
-        {\r
-            base.InvalidateLayout();\r
-\r
-            if (child != null)\r
-                child.InvalidateLayout();\r
-        }\r
                protected override Size measureRawSize ()\r
                {                       \r
                        return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * (Margin),child.Slot.Height + 2 * (Margin));\r
                }\r
-               public override void RegisterForLayouting ()\r
-               {\r
-                       base.RegisterForLayouting ();\r
 \r
-                       if (child != null)\r
-                               child.RegisterForLayouting ();\r
+               public override void UpdateLayout (LayoutingType layoutType)\r
+               {\r
+                       {                       \r
+                               switch (layoutType) {\r
+                               case LayoutingType.X:\r
+                                       if (Bounds.X == 0) {\r
+                                               switch (HorizontalAlignment) {\r
+                                               case HorizontalAlignment.Left:\r
+                                                       Slot.X = 0;\r
+                                                       break;\r
+                                               case HorizontalAlignment.Right:\r
+                                                       Slot.X = Parent.ClientRectangle.Width - Slot.Width;\r
+                                                       break;\r
+                                               case HorizontalAlignment.Center:\r
+                                                       Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;\r
+                                                       break;\r
+                                               }\r
+                                       } else\r
+                                               Slot.X = Bounds.X;\r
+                                       if (LastSlots.X == Slot.X)\r
+                                               break;\r
+                                       //register layouting here for objects depending on this.x\r
+                                       LastSlots.X = Slot.X;\r
+                                       break;\r
+                               case LayoutingType.Y:\r
+                                       if (Bounds.Y == 0) {\r
+                                               switch (VerticalAlignment) {\r
+                                               case VerticalAlignment.Top:\r
+                                                       Slot.Y = 0;\r
+                                                       break;\r
+                                               case VerticalAlignment.Bottom:\r
+                                                       Slot.Y = Parent.ClientRectangle.Height - Slot.Height;\r
+                                                       break;\r
+                                               case VerticalAlignment.Center:\r
+                                                       Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;\r
+                                                       break;\r
+                                               }\r
+                                       }else\r
+                                               Slot.Y = Bounds.Y;\r
+                                       if (LastSlots.Y == Slot.Y)\r
+                                               break;\r
+                                       //register layouting here for objects depending on this.x\r
+                                       LastSlots.Y = Slot.Y;\r
+                                       break;\r
+                               case LayoutingType.Width:                               \r
+                                       if (Width > 0)\r
+                                               Slot.Width = Width;\r
+                                       else if (Width < 0)\r
+                                               Slot.Width = measureRawSize ().Width;\r
+                                       else\r
+                                               Slot.Width = Parent.ClientRectangle.Width;\r
+\r
+                                       if (LastSlots.Width == Slot.Width)\r
+                                               break;\r
+\r
+                                       if (Parent.getBounds ().Width < 0)\r
+                                               this.Parent.RegisterForLayouting ((int)LayoutingType.Width);\r
+                                       else if (Width != 0) //update position in parent\r
+                                               this.RegisterForLayouting ((int)LayoutingType.X);\r
+\r
+                                       if (child != null) {\r
+                                               if (child.getBounds ().Width == 0)\r
+                                                       child.RegisterForLayouting ((int)LayoutingType.Width);\r
+                                               else\r
+                                                       child.RegisterForLayouting ((int)LayoutingType.X);\r
+                                       }\r
+                                       LastSlots.Width = Slot.Width;\r
+                                       break;\r
+                               case LayoutingType.Height:\r
+                                       if (Height > 0)\r
+                                               Slot.Height = Height;\r
+                                       else if (Height < 0)\r
+                                               Slot.Height = measureRawSize ().Height;\r
+                                       else\r
+                                               Slot.Height = Parent.ClientRectangle.Height;\r
+\r
+                                       if (LastSlots.Height == Slot.Height)\r
+                                               break;\r
+\r
+                                       if (Parent.getBounds().Height < 0)\r
+                                               this.Parent.RegisterForLayouting((int)LayoutingType.Height);\r
+                                       else if (Height != 0) //update position in parent\r
+                                               this.RegisterForLayouting ((int)LayoutingType.Y);\r
+\r
+                                       if (child != null) {\r
+                                               if (child.getBounds ().Height == 0)\r
+                                                       child.RegisterForLayouting ((int)LayoutingType.Height);\r
+                                               else\r
+                                                       child.RegisterForLayouting ((int)LayoutingType.Y);\r
+                                       }\r
+\r
+                                       LastSlots.Height = Slot.Height;\r
+                                       break;\r
+                               }\r
+\r
+                               //if no layouting remains in queue for item, registre for redraw\r
+                               if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0)\r
+                                       this.RegisterForRedraw ();\r
+                       }               \r
                }\r
-//             public override void UpdateLayout (LayoutingType layoutType)\r
-//        {\r
-//\r
-////                   if (Width < 0 && child.Width == 0)\r
-////                           child.Width = -1;\r
-////                   if (Height < 0 && child.Height == 0)\r
-////                           child.Height = -1;\r
-////\r
-////                   if (!(base.LayoutIsValid))\r
-////                           base.UpdateLayout();\r
-////                           \r
-////            if (child != null)\r
-////            {\r
-////                           if (!child.LayoutIsValid) {\r
-////                                   child.UpdateLayout ();\r
-////                           }\r
-////            }\r
-////\r
-////            if (LayoutIsValid)\r
-////                registerForRedraw();\r
-//        }\r
+\r
                public override Rectangle ContextCoordinates (Rectangle r)\r
                {\r
                        return\r
index 36d41f99e15383a7e15433bacad50df79631dd39..04e63d15b2553a3c08fc81796134cf388b02192e 100644 (file)
@@ -22,6 +22,17 @@ namespace go
         Orientation _orientation;\r
                #endregion\r
 \r
+               public override T addChild<T> (T child)\r
+               {\r
+                       this.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+                       return base.addChild (child);\r
+               }\r
+               public override void removeChild (GraphicObject child)\r
+               {\r
+                       base.removeChild (child);\r
+                       this.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+               }\r
+\r
                #region Public Properties\r
         [XmlAttributeAttribute()][DefaultValue(2)]\r
         public int Spacing\r
@@ -85,23 +96,30 @@ namespace go
                                }\r
                        }\r
                }\r
-               public override void RegisterForLayouting ()\r
-               {\r
-                       base.RegisterForLayouting ();\r
+//             public void RegisterForLayouting ()\r
+//             {\r
+//                     base.RegisterForLayouting ();\r
+//\r
+//                     int idx = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where (lq => lq.GraphicObject.Parent == this).LastOrDefault ());\r
+//                     if (idx < 0)\r
+//                             return;\r
+//                     Interface.LayoutingQueue.Insert (\r
+//                             idx+1,\r
+//                             new LayoutingQueueItem (LayoutingType.PositionChildren, this));\r
+//             }\r
+               public override void RegisterForLayouting (int layoutType)\r
+               {                       \r
+                       base.RegisterForLayouting (layoutType);\r
 \r
-                       int idx = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where (lq => lq.GraphicObject.Parent == this).LastOrDefault ());\r
-                       if (idx < 0)\r
-                               return;\r
-                       Interface.LayoutingQueue.Insert (\r
-                               idx+1,\r
-                               new LayoutingQueueItem (LayoutingType.PositionChildren, this));\r
+                       if ((layoutType & (int)LayoutingType.PositionChildren) > 0)\r
+                               Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);\r
                }\r
                public override void UpdateLayout (LayoutingType layoutType)\r
         {            \r
                        if (layoutType == LayoutingType.PositionChildren)\r
                                ComputeChildrenPositions ();\r
-\r
-                       base.UpdateLayout(layoutType);\r
+                       else\r
+                               base.UpdateLayout(layoutType);\r
         }\r
                #endregion\r
 \r
index c6756db2027a722c3a25dccc0fe27b17db4c0f54..9317f409830d1d87982024b60346155405d0ad42 100755 (executable)
@@ -190,8 +190,7 @@ namespace go
 \r
                                Bounds.X = value;\r
 \r
-                               LayoutIsValid = false;\r
-                               registerForGraphicUpdate ();\r
+                               Interface.LayoutingQueue.Enqueue (LayoutingType.X, this);\r
                        }\r
                }\r
                [XmlAttributeAttribute()][DefaultValue(0)]\r
@@ -203,8 +202,7 @@ namespace go
 \r
                                Bounds.Y = value;\r
 \r
-                               LayoutIsValid = false;\r
-                               registerForGraphicUpdate ();\r
+                               Interface.LayoutingQueue.Enqueue (LayoutingType.Y, this);\r
                        }\r
                }\r
                [XmlAttributeAttribute()][DefaultValue(0)]\r
@@ -373,63 +371,96 @@ namespace go
                public virtual void registerForGraphicUpdate ()\r
                {\r
                        bmp = null;\r
-                       RegisterForLayouting ();\r
+                       if (TopContainer != null)\r
+                               TopContainer.gobjsToRedraw.Add (this);\r
+                       //RegisterForLayouting ();\r
                        //registerForRedraw ();\r
                        //Interface.registerForGraphicUpdate(this);\r
                }\r
                /// <summary>\r
                /// Add clipping region in redraw list of interface, dont update cached object content\r
                /// </summary>\r
-               public virtual void registerForRedraw ()\r
+               public virtual void RegisterForRedraw ()\r
                {\r
-                       if (Visible && TopContainer != null)\r
-                               TopContainer.gobjsToRedraw.Add (this);\r
+                       bmp = null;\r
+                       TopContainer.gobjsToRedraw.Add (this);\r
                }\r
+\r
+               public Rectangle LastSlots;\r
+\r
                public virtual void registerClipRect()\r
                {\r
                        TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
                }\r
                protected virtual Size measureRawSize ()\r
-               {\r
+               {                       \r
                        return Bounds.Size;\r
                }\r
-               public virtual void RegisterForLayouting()\r
+\r
+               public virtual void RegisterForLayouting(int layoutType)\r
                {\r
-                       //clear previous layouting for item\r
-                       Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this);\r
+                       Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
 \r
-                       if (Bounds.Width == 0) { //stretch in parent\r
-                               int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
-                               if (idxParentW < 0)\r
+                       if ((layoutType & (int)LayoutingType.Width) > 0) {\r
+                               if (Bounds.Width == 0) //stretch in parent\r
+                                       Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
+                               else //fit ou fixed\r
                                        Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
-                               else//insert after parent sizing\r
-                                       Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.Width, this));\r
-                       } else {//fit ou fixed\r
-                               Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
-                               //for x positionning, sizing of obj and parent have to be done\r
-                               int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
-                               if (idxParentW < 0)\r
-                                       Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.X, this));\r
-                               else//insert after parent sizing\r
-                                       Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.X, this));\r
                        }\r
-                       if (Bounds.Height == 0) { //stretch\r
-                               int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
-                               if (idxParentH < 0)\r
+\r
+                       if ((layoutType & (int)LayoutingType.Height) > 0) {\r
+                               if (Bounds.Height == 0) //stretch in parent\r
+                                       Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
+                               else//fit ou fixed\r
                                        Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
-                               else\r
-                                       Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Height, this));\r
-                       } else {\r
-                               Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
-                               int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
-                               if (idxParentH < 0)\r
-                                       Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.Y, this));\r
-                               else//insert after parent sizing\r
-                                       Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Y, this));\r
                        }\r
 \r
+                       if ((layoutType & (int)LayoutingType.X) > 0)\r
+                               //for x positionning, sizing of parent and this have to be done\r
+                               Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
+\r
+                       if ((layoutType & (int)LayoutingType.Y) > 0)\r
+                               //for x positionning, sizing of parent and this have to be done\r
+                               Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
+                       \r
                }\r
 \r
+//             public virtual void RegisterForLayouting()\r
+//             {\r
+//                     //clear previous layouting for item\r
+//                     Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this);\r
+//\r
+//                     if (Bounds.Width == 0) { //stretch in parent\r
+//                             int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
+//                             if (idxParentW < 0)\r
+//                                     Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
+//                             else//insert after parent sizing\r
+//                                     Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.Width, this));\r
+//                     } else {//fit ou fixed\r
+//                             Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
+//                             //for x positionning, sizing of obj and parent have to be done\r
+////                           int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
+////                           if (idxParentW < 0)\r
+////                                   Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.X, this));\r
+////                           else//insert after parent sizing\r
+////                                   Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.X, this));\r
+//                     }\r
+//                     if (Bounds.Height == 0) { //stretch\r
+//                             int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
+//                             if (idxParentH < 0)\r
+//                                     Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
+//                             else\r
+//                                     Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Height, this));\r
+//                     } else {\r
+//                             Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
+////                           int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
+////                           if (idxParentH < 0)\r
+////                                   Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.Y, this));\r
+////                           else//insert after parent sizing\r
+////                                   Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Y, this));\r
+//                     }\r
+//             }\r
+//\r
                public virtual void UpdateLayout (LayoutingType layoutType)\r
                {                       \r
                        switch (layoutType) {\r
@@ -446,9 +477,12 @@ namespace go
                                                Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;\r
                                                break;\r
                                        }\r
+                               } else\r
+                                       Slot.X = Bounds.X;\r
+                               if (LastSlots.X == Slot.X)\r
                                        break;\r
-                               }\r
-                               Slot.X = Bounds.X;\r
+                               //register layouting here for objects depending on this.x\r
+                               LastSlots.X = Slot.X;\r
                                break;\r
                        case LayoutingType.Y:\r
                                if (Bounds.Y == 0) {\r
@@ -463,9 +497,12 @@ namespace go
                                                Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;\r
                                                break;\r
                                        }\r
+                               }else\r
+                                       Slot.Y = Bounds.Y;\r
+                               if (LastSlots.Y == Slot.Y)\r
                                        break;\r
-                               }\r
-                               Slot.Y = Bounds.Y;\r
+                               //register layouting here for objects depending on this.x\r
+                               LastSlots.Y = Slot.Y;\r
                                break;\r
                        case LayoutingType.Width:                               \r
                                if (Width > 0)\r
@@ -474,6 +511,16 @@ namespace go
                                        Slot.Width = measureRawSize ().Width;\r
                                else\r
                                        Slot.Width = Parent.ClientRectangle.Width;\r
+\r
+                               if (LastSlots.Width == Slot.Width)\r
+                                       break;\r
+                               \r
+                               if (Parent.getBounds().Width < 0)\r
+                                       this.Parent.RegisterForLayouting((int)LayoutingType.Width);\r
+                               else if (Width != 0) //update position in parent\r
+                                       this.RegisterForLayouting ((int)LayoutingType.X);\r
+\r
+                               LastSlots.Width = Slot.Width;\r
                                break;\r
                        case LayoutingType.Height:\r
                                if (Height > 0)\r
@@ -482,12 +529,24 @@ namespace go
                                        Slot.Height = measureRawSize ().Height;\r
                                else\r
                                        Slot.Height = Parent.ClientRectangle.Height;\r
+\r
+                               if (LastSlots.Height == Slot.Height)\r
+                                       break;\r
+\r
+                               if (Parent.getBounds().Height < 0)\r
+                                       this.Parent.RegisterForLayouting((int)LayoutingType.Height);\r
+                               else if (Height != 0) //update position in parent\r
+                                       this.RegisterForLayouting ((int)LayoutingType.Y);\r
+\r
+                               LastSlots.Height = Slot.Height;\r
                                break;\r
                        }\r
+\r
                        //if no layouting remains in queue for item, registre for redraw\r
-                       if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count() <= 0)\r
-                               this.registerForRedraw ();\r
+                       if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0)\r
+                               this.RegisterForRedraw ();\r
                }\r
+\r
                protected virtual void onDraw(Context gr)\r
                {\r
                        Rectangle rBack = new Rectangle (Slot.Size);\r
index 8056f06f791298150ab6a3a8900a8f2e88776929..e1639533c064041cf915cf79872e5e3251ddf1e4 100644 (file)
@@ -36,15 +36,15 @@ namespace go
         {\r
                        GraphicObject g = child as GraphicObject;\r
             Children.Add(g);\r
-            g.Parent = this as GraphicObject;\r
-            LayoutIsValid = false;\r
+            g.Parent = this as GraphicObject;            \r
+                       g.RegisterForLayouting ((int)LayoutingType.Sizing);\r
             return (T)child;\r
         }\r
-        public void removeChild(GraphicObject child)        \r
+        public virtual void removeChild(GraphicObject child)        \r
                {\r
             Children.Remove(child);\r
             child.Parent = null;\r
-            LayoutIsValid = false;\r
+                       this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
         }\r
                public void putWidgetOnTop(GraphicObject w)\r
                {\r
@@ -81,26 +81,6 @@ namespace go
                                return true;\r
                        }\r
                }\r
-               [XmlIgnore]public override bool LayoutIsValid\r
-               {\r
-                       get\r
-                       {\r
-                               if (!Visible)\r
-                                       return true;\r
-\r
-                               if (!base.LayoutIsValid)\r
-                                       return false;\r
-                               else//le layout n'est valide que si tous les enfents sont validés aussi\r
-                               {\r
-                                       foreach (GraphicObject w in Children)\r
-                                               if (!w.LayoutIsValid)\r
-                                                       return false;\r
-                               }\r
-\r
-                               return true;\r
-                       }\r
-                       set { base.LayoutIsValid = value; }\r
-               }\r
 \r
                public override GraphicObject FindByName (string nameToFind)\r
                {\r
@@ -144,13 +124,7 @@ namespace go
 \r
                        return tmp;\r
                }\r
-               public override void RegisterForLayouting ()\r
-               {\r
-                       base.RegisterForLayouting ();\r
 \r
-                       foreach (GraphicObject g in Children)\r
-                               g.RegisterForLayouting ();                      \r
-               }\r
 //             public override void UpdateLayout (LayoutingType layoutType)\r
 //             {\r
 //                     if (LayoutIsValid)\r
index 088a4e83742a8a3d037b8ebf48368229a5eaecfb..f732a2ca142c73d925e6f31082d9a8027eb81e93 100644 (file)
@@ -12,7 +12,7 @@ namespace go
 
                IGOLibHost TopContainer { get; }
 
-               void InvalidateLayout ();
+               void RegisterForLayouting(int layoutType);
                void UpdateLayout(LayoutingType layoutType);
 
 
index 74e26c720b045cacb6ff48780db6646f3437f37f..6855e9246019bdab8d3a001153b6f35347324b60 100644 (file)
@@ -72,7 +72,7 @@ namespace go
                        if (VerticalScrolling )\r
             {\r
                 //add redraw call with old bounds to errase old position\r
-                registerForRedraw();\r
+                RegisterForRedraw();\r
 \r
                                scrollY += e.Delta * ScrollSpeed;\r
 \r
@@ -85,7 +85,7 @@ namespace go
             if (HorizontalScrolling )\r
             {\r
                 //add redraw call with old bounds to errase old position\r
-                registerForRedraw();\r
+                RegisterForRedraw();\r
 \r
                                scrollX += e.Delta * ScrollSpeed;\r
 \r
@@ -97,7 +97,7 @@ namespace go
 \r
 \r
             //renderBounds.Y = -scrollY;\r
-            registerForRedraw();\r
+            RegisterForRedraw();\r
                        //Parent.registerForGraphicUpdate ();\r
         }\r
                #endregion\r
index 90152497dfff5206379a84c858425d5fe4217e98..142a30794066202a78e79aad8c5a8b31aef496a9 100644 (file)
@@ -20,6 +20,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 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];
index 4005f71e732ce996c7ee5f099c98a33b022930e0..e1d21792790b0f06f05b01b68a79d8b6e351815e 100644 (file)
@@ -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());
                }
        }
 }
index 2d491b207d8493fd392490a777229fed0235e3cd..86d8d3124c8fb5f9d55972d4e694c098f5a0a009 100755 (executable)
@@ -79,7 +79,7 @@ namespace go
                        g.Parent = this;\r
                        GraphicObjects.Add (g);\r
 \r
-                       g.RegisterForLayouting ();\r
+                       g.RegisterForLayouting ((int)LayoutingType.Sizing);\r
                }\r
                public void DeleteWidget(GraphicObject g)\r
                {\r
@@ -463,6 +463,11 @@ namespace go
 \r
                #region ILayoutable implementation\r
 \r
+               public void RegisterForLayouting (int layoutType)\r
+               {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
                public void UpdateLayout (LayoutingType layoutType)\r
                {\r
                        throw new NotImplementedException ();\r
@@ -524,79 +529,7 @@ namespace go
                        return ClientRectangle;\r
                }\r
 \r
-               public bool WIsValid {\r
-                       get {\r
-                               return true;\r
-                       }\r
-                       set {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-               }\r
-               public bool HIsValid {\r
-                       get {\r
-                               return true;\r
-                       }\r
-                       set {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-               }\r
-               public bool XIsValid {\r
-                       get {\r
-                               return true;\r
-                       }\r
-                       set {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-               }\r
-               public bool YIsValid {\r
-                       get {\r
-                               return true;\r
-                       }\r
-                       set {\r
-                               throw new NotImplementedException ();\r
-                       }\r
-               }\r
 \r
-               public virtual void InvalidateLayout ()\r
-               {\r
-//                     foreach (GraphicObject g in GraphicObjects) {\r
-//                             g.InvalidateLayout ();\r
-//                     }\r
-               }\r
-//             public Rectangle rectInScreenCoord (Rectangle r)\r
-//             {\r
-//                     throw new NotImplementedException ();\r
-//             }\r
-//             public Rectangle renderBoundsInContextCoordonate {\r
-//                     get { return ClientRectangle; }\r
-//             }\r
-//             public Rectangle ClientBoundsInContextCoordonate {\r
-//                     get {\r
-//                             throw new NotImplementedException ();\r
-//                     }\r
-//             }\r
-//             public Rectangle renderBoundsInBackendSurfaceCoordonate {\r
-//                     get { return ClientRectangle; }\r
-//             }\r
-//             public Rectangle ClientBoundsInBackendSurfaceCoordonate {\r
-//                     get {\r
-//                             throw new NotImplementedException ();\r
-//                     }\r
-//                     set {\r
-//                             throw new NotImplementedException ();\r
-//                     }\r
-//             }\r
-//             public Rectangle ScreenCoordBounds {\r
-//                     get { return ClientRectangle; }\r
-//             }\r
-//             public Rectangle ScreenCoordClientBounds {\r
-//                     get {\r
-//                             throw new NotImplementedException ();\r
-//                     }\r
-//                     set {\r
-//                             throw new NotImplementedException ();\r
-//                     }\r
-//             }\r
                #endregion\r
     }\r
 }
\ No newline at end of file