[NUI] Add CreateDefaultLayout function
authorhuiyu.eun <huiyu.eun@samsung.com>
Fri, 17 Sep 2021 08:30:28 +0000 (17:30 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 27 Sep 2021 08:27:23 +0000 (17:27 +0900)
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs

index 526a005..b4b36c8 100755 (executable)
@@ -127,14 +127,6 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
-        /// <summary>
-        /// Create internal layout of ImageView
-        /// </summary>
-        internal static LayoutItem CreateImageLayout()
-        {
-            return new ImageLayout();
-        }
-
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void ResourceReadyEventCallbackType(IntPtr data);
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
@@ -730,6 +722,11 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        internal override LayoutItem CreateDefaultLayout()
+        {
+            return new ImageLayout();
+        }
+
         /// <summary>
         /// Gets or sets fitting options used when resizing images to fit.<br />
         /// If not supplied, the default is FittingModeType.Fill.<br />
index d2d5efd..d095dcb 100755 (executable)
@@ -163,14 +163,6 @@ 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>
@@ -1328,6 +1320,11 @@ namespace Tizen.NUI.BaseComponents
             return new TextLabelStyle();
         }
 
+        internal override LayoutItem CreateDefaultLayout()
+        {
+            return new TextLayout();
+        }
+
         /// <summary>
         /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
         /// </summary>
index c6427c0..e25aa9f 100755 (executable)
@@ -45,6 +45,10 @@ namespace Tizen.NUI.BaseComponents
                 return mergedStyle;
             }
         }
+        internal virtual LayoutItem CreateDefaultLayout()
+        {
+            return new AbsoluteLayout();
+        }
 
         internal class ThemeData
         {
index 9750ec8..14a91d1 100755 (executable)
@@ -168,40 +168,29 @@ namespace Tizen.NUI
         // Attaches to View ChildAdded signal so called when a View is added to a view.
         private void AddChildToLayoutGroup(View child)
         {
+            if (View.LayoutingDisabled)
+            {
+                return;
+            }
             // Only give children a layout if their parent is an explicit container or a pure View.
             // Pure View meaning not derived from a View, e.g a Legacy container.
             // layoutSet flag is true when the View became a layout using the set Layout API opposed to automatically due to it's parent.
             // First time the set Layout API is used by any View the Window no longer has layoutingDisabled.
 
             // If child already has a Layout then don't change it.
-            if (!View.LayoutingDisabled && (null == child.Layout))
+            if (null == child.Layout)
             {
                 // Only wrap View with a Layout if a child a pure View or Layout explicitly set on this Layout
                 if ((true == Owner.LayoutSet || GetType() == typeof(View)))
                 {
                     // 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.
-                    if (child is TextLabel textLabel)
-                    {
-                        child.Layout = textLabel.CreateTextLayout();
-                    }
-                    else if (child is ImageView imageView)
-                    {
-                        child.Layout = ImageView.CreateImageLayout();
-                    }
-                    else
-                    {
-                        child.Layout = new AbsoluteLayout();
-                    }
+                    child.Layout = child.CreateDefaultLayout();
                 }
             }
             else
             {
-                // Add child layout to this LayoutGroup (Setting parent in the process)
-                if (child.Layout != null)
-                {
-                    Add(child.Layout);
-                }
+                Add(child.Layout);
             }
             // Parent transitions are not attached to children.
         }
@@ -500,10 +489,6 @@ 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);
             }