[NUI] Fix padding issue
authorhuiyu.eun <huiyu.eun@samsung.com>
Tue, 16 Mar 2021 10:18:54 +0000 (19:18 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 18 Mar 2021 10:16:51 +0000 (19:16 +0900)
If Layout is a LayoutItem then it could be a View that handles it's own padding.
Let the View keeps it's padding. Still store Padding in Layout to reduce code paths.

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/View.cs

index 0867448..46d0020 100755 (executable)
@@ -2456,24 +2456,26 @@ 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 (false == (this is TextLabel))
+                        if (Margin.Top != 0 || Margin.Bottom != 0 || Margin.Start != 0 || Margin.End != 0)
                         {
-                            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 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 (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;
+
+                            // If Layout is a LayoutItem then it could be a View that handles it's own padding.
+                            // Let the View keeps it's padding.  Still store Padding in Layout to reduce code paths.
+                            if (typeof(LayoutGroup).IsAssignableFrom(Layout.GetType()))
                             {
-                                // 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();
                             }
-
                         }
                     }
                 }