[NUI] Create TextLayout when parent has layout
authorhuiyu.eun <huiyu.eun@samsung.com>
Mon, 22 Feb 2021 05:03:42 +0000 (14:03 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 25 Feb 2021 08:24:58 +0000 (17:24 +0900)
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs

index d83c4e7..615f421 100755 (executable)
@@ -89,14 +89,12 @@ namespace Tizen.NUI.BaseComponents
         public TextLabel() : this(Interop.TextLabel.New(), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            Layout = new TextLayout();
         }
 
         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
         [EditorBrowsable(EditorBrowsableState.Never)]
         public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(), true, viewStyle)
         {
-            Layout = new TextLayout();
         }
 
         /// <summary>
@@ -108,7 +106,6 @@ namespace Tizen.NUI.BaseComponents
         public TextLabel(bool shown) : this(Interop.TextLabel.New(), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            Layout = new TextLayout();
             SetVisible(shown);
         }
 
@@ -120,7 +117,6 @@ namespace Tizen.NUI.BaseComponents
         public TextLabel(string text) : this(Interop.TextLabel.New(text), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            Layout = new TextLayout();
         }
 
         /// <summary>
@@ -133,7 +129,6 @@ namespace Tizen.NUI.BaseComponents
         public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            Layout = new TextLayout();
             SetVisible(shown);
         }
 
@@ -164,6 +159,14 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Create internal layout of TextLabel
+        /// </summary>
+        internal LayoutItem CreateTextLayout()
+        {
+            return new TextLayout();
+        }
+
+        /// <summary>
         /// The TranslatableText property.<br />
         /// The text can set the SID value.<br />
         /// </summary>
index c41b61d..03edab5 100755 (executable)
@@ -2262,20 +2262,24 @@ namespace Tizen.NUI.BaseComponents
                     // Do not try to set Margins or Padding on a null Layout (when a layout is being removed from a View)
                     if (value != null)
                     {
-                        if (Margin.Top != 0 || Margin.Bottom != 0 || Margin.Start != 0 || Margin.End != 0)
+                        if (false == (this is TextLabel))
                         {
-                            // If View already has a margin set then store it in Layout instead.
-                            value.Margin = Margin;
-                            SetValue(MarginProperty, new Extents(0, 0, 0, 0));
-                            NotifyPropertyChanged();
-                        }
+                            if (Margin.Top != 0 || Margin.Bottom != 0 || Margin.Start != 0 || Margin.End != 0)
+                            {
+                                // If View already has a margin set then store it in Layout instead.
+                                value.Margin = Margin;
+                                SetValue(MarginProperty, new Extents(0, 0, 0, 0));
+                                NotifyPropertyChanged();
+                            }
+
+                            if (Padding.Top != 0 || Padding.Bottom != 0 || Padding.Start != 0 || Padding.End != 0)
+                            {
+                                // If View already has a padding set then store it in Layout instead.
+                                value.Padding = Padding;
+                                SetValue(PaddingProperty, new Extents(0, 0, 0, 0));
+                                NotifyPropertyChanged();
+                            }
 
-                        if (Padding.Top != 0 || Padding.Bottom != 0 || Padding.Start != 0 || Padding.End != 0)
-                        {
-                            // If View already has a padding set then store it in Layout instead.
-                            value.Padding = Padding;
-                            SetValue(PaddingProperty, new Extents(0, 0, 0, 0));
-                            NotifyPropertyChanged();
                         }
                     }
                 }
index 1ec6c48..d71cd6c 100755 (executable)
@@ -188,7 +188,7 @@ namespace Tizen.NUI
                 {
                     // If child of this layout is a pure View then assign it a LayoutGroup
                     // If the child is derived from a View then it may be a legacy or existing container hence will do layouting itself.
-                    child.Layout = new AbsoluteLayout();
+                    child.Layout = (child as TextLabel)?.CreateTextLayout() ?? new AbsoluteLayout();
                 }
             }
             else
@@ -492,6 +492,10 @@ namespace Tizen.NUI
             // Layout takes ownership of it's owner's children.
             foreach (View view in Owner.Children)
             {
+                if (view is TextLabel)
+                {
+                    view.Layout = (view as TextLabel)?.CreateTextLayout();
+                }
                 AddChildToLayoutGroup(view);
             }