[NUI] Measure whole child in GridLayout (#1363)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Wed, 5 Feb 2020 01:55:27 +0000 (10:55 +0900)
committerGitHub <noreply@github.com>
Wed, 5 Feb 2020 01:55:27 +0000 (10:55 +0900)
Currently, GridLayout measures only first child for calculation so other child cannot layout its children.
Now, GridLayout measures whole child so they can layout its children.

Co-authored-by: agnelovaz <vaz.agnelo@gmail.com>
src/Tizen.NUI/src/public/Layouting/GridLayout.cs

index fe1729d..d886faf 100755 (executable)
@@ -122,20 +122,24 @@ namespace Tizen.NUI
             var childCount = LayoutChildren.Count;
 
             // WIDTH SPECIFICATIONS
-
-            // measure first child and use it's dimensions for layout measurement
-
             if (childCount > 0)
             {
-                LayoutItem childLayoutItem = LayoutChildren[0];
-                View childOwner = childLayoutItem.Owner;
+                foreach( LayoutItem childLayout in LayoutChildren )
+                {
+                    if( childLayout != null )
+                    {
+                        MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
+                    }
+                }
+
+                // Use first child's dimensions for layout measurement
+                View childOwner = LayoutChildren[0].Owner;
 
-                MeasureChild( childLayoutItem, widthMeasureSpec, heightMeasureSpec );
-                desiredChildHeight = (int)childLayoutItem.MeasuredHeight.Size.AsRoundedValue();
-                desiredChildWidth = (int)childLayoutItem.MeasuredWidth.Size.AsRoundedValue();
+                desiredChildHeight = (int)LayoutChildren[0].MeasuredHeight.Size.AsRoundedValue();
+                desiredChildWidth = (int)LayoutChildren[0].MeasuredWidth.Size.AsRoundedValue();
 
                 // If child has a margin then add it to desired size
-                Extents childMargin = childLayoutItem.Margin;
+                Extents childMargin = LayoutChildren[0].Margin;
                 desiredChildHeight += childMargin.Top + childMargin.Bottom;
                 desiredChildWidth += childMargin.Start + childMargin.End;