]> O.S.I.I.S - jp/crow.git/commitdiff
stack
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 23 Apr 2016 17:45:04 +0000 (19:45 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 23 Apr 2016 17:45:04 +0000 (19:45 +0200)
12 files changed:
OTKCrow/OpenTKGameWindow.cs
Tests/GOLIBTestsOTK.cs
Tests/Interfaces/Stack/0h.crow [new file with mode: 0755]
Tests/Interfaces/Stack/1.crow
Tests/Interfaces/Stack/1h.crow [new file with mode: 0755]
Tests/Interfaces/Stack/2.crow
Tests/Interfaces/Stack/2h.crow [new file with mode: 0755]
Tests/Interfaces/Stack/3.crow
Tests/Interfaces/Stack/3h.crow [new file with mode: 0755]
Tests/Interfaces/Stack/4.crow [new file with mode: 0755]
Tests/Tests.csproj
src/GraphicObjects/GenericStack.cs

index 329f83fb6a01dd21a5fa50b935d522e459e51c11..60fa8b89e4e0d68620e1faa775f28c082f7182fa 100644 (file)
@@ -99,7 +99,7 @@ namespace Crow
                public OpenTKGameWindow(int _width, int _height, string _title="Crow")
                        : base(_width, _height, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 1),
                                _title,GameWindowFlags.Default,DisplayDevice.GetDisplay(DisplayIndex.Second),
-                               3,3,OpenTK.Graphics.GraphicsContextFlags.Debug)
+                               3,3,OpenTK.Graphics.GraphicsContextFlags.Default)
 //             public OpenTKGameWindow(int _width, int _height, string _title="golib")
 //                     : base(_width, _height, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), _title)
                {
@@ -131,7 +131,7 @@ namespace Crow
                        
                        while (true) {
                                CrowInterface.Update ();
-                               Thread.Sleep (5);
+                               Thread.Sleep (1);
                        }
                }
 
index bc0d4e03fff1294f2da6f9dc72aa65e54fb72f50..1383d029ecdbeaa28c193280c31a04e5b53b25c1 100644 (file)
@@ -91,12 +91,12 @@ namespace testOTK
                        //this.AddWidget(new test4());
                        KeyboardKeyDown += GOLIBTests_KeyboardKeyDown1;;
 
-                       testFiles = Directory.GetFiles(@"Interfaces/Group", "*.crow").ToArray();
+                       testFiles = Directory.GetFiles(@"Interfaces/Stack", "*.crow").ToArray();
                        //testFiles = Directory.GetFiles(@"Interfaces/Stack", "*.crow").ToArray();
                        //testFiles = Directory.GetFiles(@"Interfaces/GraphicObject", "*.crow").Concat(testFiles).ToArray();
 
                        //testFiles = Directory.GetFiles(@"Interfaces", "*.crow").Concat(testFiles).ToArray();
-
+                       this.Title = testFiles [idx];
                        GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]);
                        obj.DataSource = this;
 
@@ -168,7 +168,7 @@ namespace testOTK
                        if (idx == testFiles.Length)
                                idx = 0;
                        this.Title = testFiles [idx];
-                       GraphicObject obj = CrowInterface.LoadInterface("Interfaces/" + testFiles[idx]);
+                       GraphicObject obj = CrowInterface.LoadInterface(testFiles[2]);
                        obj.DataSource = this;
                }
 
diff --git a/Tests/Interfaces/Stack/0h.crow b/Tests/Interfaces/Stack/0h.crow
new file mode 100755 (executable)
index 0000000..9e31f04
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<HorizontalStack MinimumSize="50;50" Background="Onyx" Margin="10" Width="90%" Height="90%">
+       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="10;10"/>
+       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="10;10"/>
+       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="10;10"/>
+</HorizontalStack>
\ No newline at end of file
index c2423ef1d21efd88d64df21f9edeb82ac1c64c82..f8b287793b63fbfefa9d4bb4d15af31604f7b617 100755 (executable)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
 <VerticalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
-       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+       <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
                        MinimumSize="10;10"/>
-       <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
+       <GraphicObject Margin="10" Width="Stretched" Height="60%" Background="Mantis"
                        MinimumSize="10;10"/>
-       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+       <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
                        MinimumSize="10;10"/>
 </VerticalStack>
\ No newline at end of file
diff --git a/Tests/Interfaces/Stack/1h.crow b/Tests/Interfaces/Stack/1h.crow
new file mode 100755 (executable)
index 0000000..b86b77a
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
+       <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+                       MinimumSize="10;10"/>
+       <GraphicObject Margin="10" Width="Stretched" Height="60%" Background="Mantis"
+                       MinimumSize="10;10"/>
+       <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+                       MinimumSize="10;10"/>
+</HorizontalStack>
\ No newline at end of file
index 5f23a7d4f2ad2d91db07a05394a7bf114590a77c..ebf1d1e97816b660bf0f13f16b4aad4ed288916f 100755 (executable)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
-<VerticalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
-       <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+<VerticalStack Background="Onyx" Margin="10" Width="90%" Height="100%">
+       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
                        MinimumSize="10;10"/>
-       <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+       <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
                        MinimumSize="10;10"/>
-       <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
                        MinimumSize="10;10"/>
 </VerticalStack>
\ No newline at end of file
diff --git a/Tests/Interfaces/Stack/2h.crow b/Tests/Interfaces/Stack/2h.crow
new file mode 100755 (executable)
index 0000000..dc05fc0
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="100%">
+       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="10;10"/>
+       <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
+                       MinimumSize="10;10"/>
+       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="10;10"/>
+</HorizontalStack>
\ No newline at end of file
index 0c3987fabc784a41aa53ab5e00d33acd20d7d414..a5ec06ad7c34ec0f45a1337f376768bc285f8572 100755 (executable)
@@ -1,9 +1,45 @@
 <?xml version="1.0"?>
 <VerticalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
-       <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
-                       MinimumSize="10;10"/>
-       <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
-                       MinimumSize="10;10"/>
-       <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
-                       MinimumSize="10;10"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
 </VerticalStack>
\ No newline at end of file
diff --git a/Tests/Interfaces/Stack/3h.crow b/Tests/Interfaces/Stack/3h.crow
new file mode 100755 (executable)
index 0000000..a675876
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+       <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+                       MinimumSize="2;2"/>
+</HorizontalStack>
\ No newline at end of file
diff --git a/Tests/Interfaces/Stack/4.crow b/Tests/Interfaces/Stack/4.crow
new file mode 100755 (executable)
index 0000000..8e1f757
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<VerticalStack>
+       <HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="20%">
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Width="100%" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+       </HorizontalStack>
+       <HorizontalStack Background="Onyx" Margin="10" Width="Fit" Height="20%">
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Width="100%" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+               <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+       </HorizontalStack>
+</VerticalStack>
\ No newline at end of file
index 24042c9f63dce020b6a2df68b5b1705bfa1bab2b..328511d12214a14d33add0090c375ff8d5d54717 100644 (file)
     <None Include="Interfaces\Group\3.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="Interfaces\Group\3 %28copier%29.crow">
+    <None Include="Interfaces\Group\4.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Stack\0h.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Stack\1h.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Stack\2h.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Stack\3h.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\Stack\4.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
index dd385201ed06f49e89a3c1c924625d87d8f5579c..d5ff81c6329b1ec68f6f4051d589e8b7e82c9bbc 100644 (file)
@@ -1,14 +1,10 @@
-using System;
+using System.ComponentModel;
 using System.Diagnostics;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Xml.Serialization;
-using System.ComponentModel;
 
 namespace Crow
 {
-    public class GenericStack : Group
+       public class GenericStack : Group
     {
                #region CTOR
                public GenericStack()
@@ -54,41 +50,13 @@ namespace Crow
                }
                protected override int measureRawSize (LayoutingType lt)
                {
-                       int tmp = 0;
-                       switch (lt) {
-                       case LayoutingType.Width:
-                               if (Orientation == Orientation.Horizontal) {
-                                       if (Children.Count > 0) {
-                                               foreach (GraphicObject c in Children) {
-                                                       if (!c.Visible)
-                                                               continue;
-                                                       if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
-                                                               return -1;
-                                                       tmp += c.Slot.Width + Spacing;
-                                               }
-                                               tmp -= Spacing;
-                                       }
-                                       break;
-                               } 
-                               return base.measureRawSize (lt);                                
-                       case LayoutingType.Height:
-                               if (Orientation == Orientation.Vertical) {
-                                       if (Children.Count > 0) {
-                                               foreach (GraphicObject c in Children) {
-                                                       if (!c.Visible)
-                                                               continue;
-                                                       if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
-                                                               return -1;
-                                                       tmp += c.Slot.Height + Spacing;
-                                               }
-                                               tmp -= Spacing;
-                                       }
-                                       break;
-                               }
-                               return base.measureRawSize (lt);
-                       }
-
-                       return tmp + 2 * Margin;
+                       if (lt == LayoutingType.Width) {
+                               if (Orientation == Orientation.Horizontal)
+                                       return contentSize.Width + (Children.Count - 1) * Spacing + 2 * Margin;
+                       }else if (Orientation == Orientation.Vertical)
+                               return contentSize.Height + (Children.Count - 1) * Spacing + 2 * Margin;                                                        
+                       
+                       return base.measureRawSize (lt);
                }
                public virtual void ComputeChildrenPositions()
                {
@@ -99,7 +67,6 @@ namespace Crow
                                                continue;
                                        c.Slot.X = d;
                                        d += c.Slot.Width + Spacing;
-                                       c.RegisterForLayouting (LayoutingType.Y);
                                }
                        } else {
                                foreach (GraphicObject c in Children) {
@@ -107,12 +74,11 @@ namespace Crow
                                                continue;                                       
                                        c.Slot.Y = d;
                                        d += c.Slot.Height + Spacing;
-                                       c.RegisterForLayouting (LayoutingType.X);
                                }
                        }
                        bmp = null;
                }
-                       
+               GraphicObject stretchedGO = null;
                public override bool UpdateLayout (LayoutingType layoutType)
         {
                        RegisteredLayoutings &= (~layoutType);
@@ -122,86 +88,6 @@ namespace Crow
                                //this child will occupy remaining space
                                //if stack size policy is Fit, no child may have stretch enabled
                                //in the direction of stacking.
-                               if (Orientation == Orientation.Horizontal) {
-                                       GraphicObject stretchedGO = null;
-                                       int tmpWidth = Slot.Width;
-                                       int cptChildren = 0;
-                                       for (int i = 0; i < Children.Count; i++) {
-                                               if (!Children [i].Visible)
-                                                       continue;
-                                               //requeue Positionning if child is not layouted
-                                               if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
-                                                       return false;
-                                               cptChildren++;
-                                               if (Children [i].Width == Measure.Stretched) {
-                                                       if (!(stretchedGO == null && Width != Measure.Fit)) {
-                                                               //change size policy of other stretched children
-                                                               Children [i].Width = Measure.Fit;
-                                                               return false;
-                                                       }
-                                                       stretchedGO = Children [i];
-                                                       if (i < Children.Count - 1)
-                                                               tmpWidth -= Spacing;
-                                                       continue;
-                                               }
-                                               tmpWidth -= Children [i].Slot.Width + Spacing;
-                                       }
-                                       if (stretchedGO != null && Width != Measure.Fit) {
-                                               tmpWidth += (Spacing - 2 * Margin);
-                                               if (tmpWidth < MinimumSize.Width)
-                                                       tmpWidth = MinimumSize.Width;
-                                               else if (tmpWidth > MaximumSize.Width && MaximumSize.Width > 0)
-                                                       tmpWidth = MaximumSize.Width;
-                                               if (stretchedGO.LastSlots.Width != tmpWidth) {
-                                                       stretchedGO.Slot.Width = tmpWidth;
-                                                       stretchedGO.bmp = null;
-                                                       #if DEBUG_LAYOUTING
-                                                       Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
-                                                       #endif
-                                                       stretchedGO.OnLayoutChanges (LayoutingType.Width);
-                                                       stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
-                                               }
-                                       }
-                               } else {
-                                       GraphicObject stretchedGO = null;
-                                       int tmpHeight = Slot.Height;
-                                       int cptChildren = 0;
-                                       for (int i = 0; i < Children.Count; i++) {
-                                               if (!Children [i].Visible)
-                                                       continue;
-                                               if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
-                                                       return false;
-                                               cptChildren++;
-                                               if (Children [i].Height == Measure.Stretched) {
-                                                       if (!(stretchedGO == null && Height != Measure.Fit)){
-                                                               Children [i].Height = Measure.Fit;
-                                                               return false;
-                                                       }
-                                                       stretchedGO = Children [i];
-                                                       if (i < Children.Count - 1)
-                                                               tmpHeight -= Spacing;
-                                                       continue;
-                                               }
-                                               tmpHeight -= Children[i].Slot.Height + Spacing;
-                                       }
-                                       if (stretchedGO != null && Height != Measure.Fit) {
-                                               tmpHeight += (Spacing - 2 * Margin);
-                                               if (tmpHeight < MinimumSize.Height)
-                                                       tmpHeight = MinimumSize.Height;
-                                               else if (tmpHeight > MaximumSize.Height && MaximumSize.Height > 0)
-                                                       tmpHeight = MaximumSize.Height;
-                                               if (stretchedGO.LastSlots.Height != tmpHeight) {
-                                                       stretchedGO.Slot.Height = tmpHeight;
-                                                       stretchedGO.bmp = null;
-                                                       #if DEBUG_LAYOUTING
-                                                       Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
-                                                       #endif
-                                                       stretchedGO.OnLayoutChanges (LayoutingType.Height);
-                                                       stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
-                                               }
-                                       }
-                               }
-
                                ComputeChildrenPositions ();
 
                                //if no layouting remains in queue for item, registre for redraw
@@ -216,26 +102,75 @@ namespace Crow
 
                public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
                {
-                       base.OnChildLayoutChanges (sender, arg);
-
                        GraphicObject go = sender as GraphicObject;
-
+                       Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString());
                        switch (arg.LayoutType) {
                        case LayoutingType.Width:
                                if (Orientation == Orientation.Horizontal) {
+                                       if (go.Width == Measure.Stretched) {
+                                               if (stretchedGO == null && Width != Measure.Fit)
+                                                       stretchedGO = go;
+                                               else if (stretchedGO != go) {
+                                                       go.Slot.Width = 0;
+                                                       go.Width = Measure.Fit;
+                                                       return;
+                                               }
+                                       } else
+                                               contentSize.Width += go.Slot.Width - go.LastSlots.Width;
+
+                                       if (stretchedGO != null) {
+                                               stretchedGO.Slot.Width = this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1);
+                                               stretchedGO.bmp = null;
+#if DEBUG_LAYOUTING
+                                       Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+#endif
+                                               stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+                                               stretchedGO.OnLayoutChanges (LayoutingType.Width);
+                                               stretchedGO.LayoutChanged += OnChildLayoutChanges;
+                                               stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
+                                       }
+                                       
                                        if (Width == Measure.Fit)
                                                this.RegisterForLayouting (LayoutingType.Width);
+                                       
                                        this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+                                       return;
                                }
                                break;
                        case LayoutingType.Height:
                                if (Orientation == Orientation.Vertical) {
+                                       if (go.Height == Measure.Stretched) {
+                                               if (stretchedGO == null && Height != Measure.Fit)
+                                                       stretchedGO = go;
+                                               else if (stretchedGO != go){
+                                                       go.Slot.Height = 0;
+                                                       go.Height = Measure.Fit;
+                                                       return;
+                                               }
+                                       } else
+                                               contentSize.Height += go.Slot.Height - go.LastSlots.Height;
+                                       
+                                       if (stretchedGO != null) {
+                                               stretchedGO.Slot.Height = this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count -1);
+                                               stretchedGO.bmp = null;
+#if DEBUG_LAYOUTING
+                                       Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+#endif
+                                               stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+                                               stretchedGO.OnLayoutChanges (LayoutingType.Height);
+                                               stretchedGO.LayoutChanged += OnChildLayoutChanges;
+                                               stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
+                                       }
+
                                        if (Height == Measure.Fit)
                                                this.RegisterForLayouting (LayoutingType.Height);
+
                                        this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+                                       return;
                                }
                                break;
                        }
+                       base.OnChildLayoutChanges (sender, arg);
                }
                #endregion