]> O.S.I.I.S - jp/crow.git/commitdiff
force first child of group in Fit to Fit if no other child could be sized
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 17 Feb 2016 00:18:24 +0000 (01:18 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 17 Feb 2016 00:18:24 +0000 (01:18 +0100)
src/GraphicObjects/Group.cs

index 2a960029ac7549d2762608aed5a1b434280b4ba4..6e2417a978f5c1b758e34897384a7cb2f9343253 100644 (file)
@@ -127,17 +127,26 @@ namespace Crow
                }
                protected override int measureRawSize (LayoutingType lt)
                {
+                       if (Children.Count == 0)
+                               return base.measureRawSize (lt);
+                       
                        if (lt == LayoutingType.Width) {
                                if (largestChild == null)
                                        searchLargestChild ();
-                               if (largestChild == null)//if still null, not possible to determine a width
-                                       return -1;
+                               if (largestChild == null){
+                                       //if still null, not possible to determine a width
+                                       //because all children are stretched, force first one to fit
+                                       Children[0].Width = -1;
+                                       return -1;//cancel actual sizing to let child computation take place
+                               }
                                return maxChildrenWidth + 2 * Margin;
                        }else{
                                if (tallestChild == null)
                                        searchTallestChild ();
-                               if (tallestChild == null)
+                               if (tallestChild == null) {
+                                       Children[0].Height = -1;
                                        return -1;
+                               }
                                return maxChildrenHeight + 2 * Margin;
                        }
                }