[NUI] Change setter of property
authorhuiyu.eun <huiyu.eun@samsung.com>
Tue, 24 Nov 2020 02:12:18 +0000 (11:12 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 1 Dec 2020 08:56:39 +0000 (17:56 +0900)
- Setter is deprecated in API8.(Size/Scale/Color/Position)
- An unnecessary log comes out and causes performance degradation.

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI.Components/Controls/DropDown.cs
src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewLayoutManager.cs
src/Tizen.NUI.Components/Controls/Popup.cs
src/Tizen.NUI.Components/Controls/Tab.cs
src/Tizen.NUI.Components/Controls/Toast.cs
src/Tizen.NUI.Wearable/src/public/CircularPagination.cs
src/Tizen.NUI.Wearable/src/public/Title.cs
src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/Color.cs
src/Tizen.NUI/src/public/VisualMaps.cs

index 5dc75be..0ac99c9 100755 (executable)
@@ -564,7 +564,7 @@ namespace Tizen.NUI.Components
             }
             float fitWidth = (Button.Icon.Size?.Width ?? 48) + dropDownStyle.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
             fitWidth += (button.IconPadding.Start + button.IconPadding.End);
-            button.Size.Width = Math.Max(button.Size.Width, fitWidth);
+            button.SizeWidth = Math.Max(button.Size.Width, fitWidth);
             RelayoutRequest();
 
             int numberOfItemsToAdd = adapter.GetItemCount();
index f1c7a7e..1384b94 100755 (executable)
@@ -760,7 +760,6 @@ namespace Tizen.NUI.Components
          */
         private Vector2 GetRectOfVisibleChildScrollAmount(FlexibleView parent, FlexibleViewViewHolder child)
         {
-            Vector2 ret = new Vector2(0, 0);
             int parentLeft = PaddingLeft;
             int parentTop = PaddingTop;
             int parentRight = (int)Width - PaddingRight;
@@ -776,13 +775,9 @@ namespace Tizen.NUI.Components
             var offsetBottom = Math.Max(0, childBottom - parentBottom);
 
             int dx = offsetStart != 0 ? offsetStart : Math.Min(childLeft - parentLeft, offsetEnd);
-
             int dy = offsetTop != 0 ? offsetTop : Math.Min(childTop - parentTop, offsetBottom);
 
-            ret.X = -dx;
-            ret.Y = -dy;
-
-            return ret;
+            return new Vector2(-dx, -dy);
         }
 
         private void OnScrollAnimationFinished(object sender, EventArgs e)
index 8c39603..f52f1e8 100755 (executable)
@@ -37,7 +37,7 @@ namespace Tizen.NUI.Components
             var instance = (Popup)bindable;
             if (newValue != null && instance?.popupStyle?.Buttons?.Size != null)
             {
-                instance.popupStyle.Buttons.Size.Height = (int)newValue;
+                instance.popupStyle.Buttons.SizeHeight = (int)newValue;
                 instance.btGroup.Itemheight = (int)newValue;
                 instance.UpdateView();
             }
@@ -488,7 +488,7 @@ namespace Tizen.NUI.Components
             {
                 if (popupStyle?.Title?.Size != null)
                 {
-                    popupStyle.Title.Size.Height = value;
+                    popupStyle.Title.SizeHeight = value;
                 }
             }
         }
index 6872689..6a8d716 100755 (executable)
@@ -527,8 +527,8 @@ namespace Tizen.NUI.Components
                     for (int i = 0; i < totalNum; i++)
                     {
                         preW = (itemList[i].TextItem.NaturalSize2D != null ? itemList[i].TextItem.NaturalSize2D.Width : 0);
-                        itemList[i].Position2D.X = preX;
-                        itemList[i].Size2D.Width = preW;
+                        itemList[i].PositionX = preX;
+                        itemList[i].SizeWidth = preW;
                         preX = itemList[i].Position2D.X + preW + itemSpace;
                         itemList[i].Index = i;
                     }
@@ -538,8 +538,8 @@ namespace Tizen.NUI.Components
                     preW = (Size2D.Width - (int)tabStyle?.ItemPadding.Start - (int)tabStyle?.ItemPadding.End) / totalNum;
                     for (int i = 0; i < totalNum; i++)
                     {
-                        itemList[i].Position2D.X = preX;
-                        itemList[i].Size2D.Width = preW;
+                        itemList[i].PositionX = preX;
+                        itemList[i].SizeWidth = preW;
                         preX = itemList[i].Position2D.X + preW + itemSpace;
                         itemList[i].Index = i;
                     }
@@ -554,8 +554,8 @@ namespace Tizen.NUI.Components
                     for (int i = 0; i < totalNum; i++)
                     {
                         preW = (itemList[i].NaturalSize2D != null ? itemList[i].NaturalSize2D.Width : 0);
-                        itemList[i].Position2D.X = w - preW - preX;
-                        itemList[i].Size2D.Width = preW;
+                        itemList[i].PositionX = w - preW - preX;
+                        itemList[i].SizeWidth = preW;
                         preX = w - itemList[i].Position2D.X + itemSpace;
                         itemList[i].Index = i;
                     }
@@ -565,8 +565,8 @@ namespace Tizen.NUI.Components
                     preW = (Size2D.Width - (int)tabStyle?.ItemPadding.Start - (int)tabStyle?.ItemPadding.End) / totalNum;
                     for (int i = totalNum - 1; i >= 0; i--)
                     {
-                        itemList[i].Position2D.X = preX;
-                        itemList[i].Size2D.Width = preW;
+                        itemList[i].PositionX = preX;
+                        itemList[i].SizeWidth = preW;
                         preX = itemList[i].Position2D.X + preW + itemSpace;
                         itemList[i].Index = i;
                     }
@@ -599,8 +599,8 @@ namespace Tizen.NUI.Components
             item.TextItem.ApplyStyle(tabStyle.Text);
 
             item.Text = itemData.Text;
-            item.Size2D.Height = Size2D.Height - h - topSpace;
-            item.Position2D.Y = topSpace;
+            item.SizeHeight = SizeHeight - h - topSpace;
+            item.PositionY = topSpace;
             item.TouchEvent += ItemTouchEvent;
             Add(item);
 
@@ -648,7 +648,7 @@ namespace Tizen.NUI.Components
                 return;
             }
 
-            Underline.Size.Width = itemList[curIndex].Size2D.Width;
+            Underline.SizeWidth = itemList[curIndex].Size2D.Width;
 
             underline.Size2D = new Size2D(itemList[curIndex].Size2D.Width, (int)Underline.Size.Height);
             underline.BackgroundColor = tabStyle.UnderLine.BackgroundColor.All;
@@ -665,7 +665,7 @@ namespace Tizen.NUI.Components
             }
             else
             {
-                underline.Position2D.X = itemList[curIndex].Position2D.X;
+                underline.PositionX = itemList[curIndex].PositionX;
                 isNeedAnimation = true;
             }
 
index 58d09be..a6faffd 100755 (executable)
@@ -237,8 +237,8 @@ namespace Tizen.NUI.Components
         {
             window = win;
             window.Add(this);
-            this.Position.X = (window.Size.Width - this.Size.Width) / 2;
-            this.Position.Y = (window.Size.Height - this.Size.Height) / 2;
+            this.PositionX = (window.Size.Width - this.Size.Width) / 2;
+            this.PositionY = (window.Size.Height - this.Size.Height) / 2;
             timer.Start();
         }
 
index c7217fa..a49ed6e 100755 (executable)
@@ -487,6 +487,10 @@ namespace Tizen.NUI.Wearable
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual void SetIndicatorPosition(int index, Position position)
         {
+            if (position == null)
+            {
+                throw new ArgumentNullException(nameof(position));
+            }
             // Update odd / even Array and List by each converted index.
             if (isOddNumber)
             {
@@ -498,14 +502,12 @@ namespace Tizen.NUI.Wearable
                 {
                     oddArray[(middleIndex - leftIndicatorCount) + index] = position;
                 }
-                indicatorList[index].Position.X = position.X;
-                indicatorList[index].Position.Y = position.Y;
+                indicatorList[index].Position = new Vector2(position.X, position.Y);
             }
             else // Only symmetry circular pagination can be even number.
             {
                 evenArray[(middleIndex - (indicatorCount / 2) + index)] = position;
-                indicatorList[index].Position.X = position.X;
-                indicatorList[index].Position.Y = position.Y;
+                indicatorList[index].Position = new Vector2(position.X, position.Y);
             }
             UpdateVisual();
         }
index c6f7265..c03dbbb 100755 (executable)
@@ -183,8 +183,8 @@ namespace Tizen.NUI.Components
 
         private void UpdateImage()
         {
-            leftImage.Size.Width = fadeOutWidth;
-            rightImage.Size.Width = fadeOutWidth;
+            leftImage.SizeWidth = fadeOutWidth;
+            rightImage.SizeWidth = fadeOutWidth;
 
             if (fadeOutWidth > 0)
             {
index 56974f7..b254945 100755 (executable)
@@ -327,9 +327,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.size == null)
                 {
                     if ((float)newValue == 0) return;
-                    viewStyle.size = new Size();
                 }
-                viewStyle.size.Width = (float)newValue;
+                viewStyle.size = new Size((float)newValue, viewStyle.size?.Height ?? 0);
             }
         },
         defaultValueCreator: (bindable) =>
@@ -346,9 +345,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.size == null)
                 {
                     if ((float)newValue == 0) return;
-                    viewStyle.size = new Size();
                 }
-                viewStyle.size.Height = (float)newValue;
+                viewStyle.size = new Size(viewStyle.size?.Width ?? 0, (float)newValue);
             }
         },
         defaultValueCreator: (bindable) =>
@@ -381,9 +379,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.position == null)
                 {
                     if ((float)newValue == 0) return;
-                    viewStyle.position = new Position();
                 }
-                viewStyle.position.X = (float)newValue;
+                viewStyle.position = new Position((float)newValue, viewStyle.position?.Y ?? 0);
             }
         },
         defaultValueCreator: (bindable) =>
@@ -400,9 +397,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.position == null)
                 {
                     if ((float)newValue == 0) return;
-                    viewStyle.position = new Position();
                 }
-                viewStyle.position.Y = (float)newValue;
+                viewStyle.position = new Position(viewStyle.position?.X ?? 0, (float)newValue);
             }
         },
         defaultValueCreator: (bindable) =>
@@ -419,9 +415,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.position == null)
                 {
                     if ((float)newValue == 0) return;
-                    viewStyle.position = new Position();
                 }
-                viewStyle.position.Z = (float)newValue;
+                viewStyle.position = new Position(viewStyle.Position?.X ?? 0, viewStyle.Position?.Y ?? 0, (float)newValue);
             }
         },
         defaultValueCreator: (bindable) =>
@@ -463,9 +458,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.scale == null)
                 {
                     if ((float)newValue == 1.0f) return;
-                    viewStyle.scale = new Vector3();
                 }
-                viewStyle.scale.X = (float)newValue;
+                viewStyle.scale = new Vector3((float)newValue, viewStyle.scale?.Y ?? 0, viewStyle.scale?.Z ?? 0);
             }
         },
         defaultValueCreator: (bindable) =>
@@ -482,9 +476,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.scale == null)
                 {
                     if ((float)newValue == 1.0f) return;
-                    viewStyle.scale = new Vector3();
                 }
-                viewStyle.scale.Y = (float)newValue;
+                viewStyle.scale = new Vector3(viewStyle.scale?.X ?? 0, (float)newValue, viewStyle.scale?.Z ?? 0);
             }
         },
         defaultValueCreator: (bindable) =>
@@ -501,9 +494,8 @@ namespace Tizen.NUI.BaseComponents
                 if (viewStyle.scale == null)
                 {
                     if ((float)newValue == 1.0f) return;
-                    viewStyle.scale = new Vector3();
                 }
-                viewStyle.scale.Z = (float)newValue;
+                viewStyle.scale = new Vector3(viewStyle.scale?.X ?? 0, viewStyle.scale?.Y ?? 0, (float)newValue);
             }
         },
         defaultValueCreator: (bindable) =>
index 0d2e569..ec44f55 100755 (executable)
@@ -787,14 +787,16 @@ namespace Tizen.NUI.BaseComponents
             get
             {
                 Size2D temp = (Size2D)GetValue(Size2DProperty);
+                int width = temp.Width;
+                int height = temp.Height;
 
                 if (this.Layout == null)
                 {
-                    if (temp.Width < 0) { temp.Width = 0; }
-                    if (temp.Height < 0) { temp.Height = 0; }
+                    if (width < 0) { width = 0; }
+                    if (height < 0) { height = 0; }
                 }
 
-                return new Size2D(OnSize2DChanged, temp.Width, temp.Height);
+                return new Size2D(OnSize2DChanged, width, height);
             }
             set
             {
index 84e110d..15f3919 100755 (executable)
@@ -484,46 +484,52 @@ namespace Tizen.NUI
 
         internal static Color ValueCheck(Color color)
         {
-            if (color.R < 0.0f)
+            float r = color.R;
+            float g = color.G;
+            float b = color.B;
+            float a = color.A;
+
+            if (r < 0.0f)
             {
-                color.R = 0.0f;
+                r = 0.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
-            else if (color.R > 1.0f)
+            else if (r > 1.0f)
             {
-                color.R = 1.0f;
+                r = 1.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
-            if (color.G < 0.0f)
+            if (g < 0.0f)
             {
-                color.G = 0.0f;
+                g = 0.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
-            else if (color.G > 1.0f)
+            else if (g > 1.0f)
             {
-                color.G = 1.0f;
+                g = 1.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
-            if (color.B < 0.0f)
+            if (b < 0.0f)
             {
-                color.B = 0.0f;
+                b = 0.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
-            else if (color.B > 1.0f)
+            else if (b > 1.0f)
             {
-                color.B = 1.0f;
+                b = 1.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
-            if (color.A < 0.0f)
+            if (a < 0.0f)
             {
-                color.A = 0.0f;
+                a = 0.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
-            else if (color.A > 1.0f)
+            else if (a > 1.0f)
             {
-                color.A = 1.0f;
+                a = 1.0f;
                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
             }
+            color = new Color(r, g, b, a);
             return color;
         }
 
index c5d63a3..6ee9e4a 100755 (executable)
@@ -236,23 +236,21 @@ namespace Tizen.NUI
             }
             set
             {
-                if (_visualOffsetPolicy == null)
-                {
-                    _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
-                }
+                float x = 0.0f;
 
                 switch (value)
                 {
                     case VisualTransformPolicyType.Relative:
-                        _visualOffsetPolicy.X = 0.0f;
+                        x = 0.0f;
                         break;
                     case VisualTransformPolicyType.Absolute:
-                        _visualOffsetPolicy.X = 1.0f;
+                        x = 1.0f;
                         break;
                     default:
-                        _visualOffsetPolicy.X = 0.0f;
+                        x = 0.0f;
                         break;
                 }
+                _visualOffsetPolicy = new Vector2(x, _visualOffsetPolicy?.Y ?? 0);
 
                 UpdateVisual();
             }
@@ -277,23 +275,21 @@ namespace Tizen.NUI
             }
             set
             {
-                if (_visualOffsetPolicy == null)
-                {
-                    _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
-                }
+                float y = 0.0f;
 
                 switch (value)
                 {
                     case VisualTransformPolicyType.Relative:
-                        _visualOffsetPolicy.Y = 0.0f;
+                        y = 0.0f;
                         break;
                     case VisualTransformPolicyType.Absolute:
-                        _visualOffsetPolicy.Y = 1.0f;
+                        y = 1.0f;
                         break;
                     default:
-                        _visualOffsetPolicy.Y = 0.0f;
+                        y = 0.0f;
                         break;
                 }
+                _visualOffsetPolicy = new Vector2(_visualOffsetPolicy?.X ?? 0, y);
                 UpdateVisual();
             }
         }
@@ -353,23 +349,21 @@ namespace Tizen.NUI
             }
             set
             {
-                if (_visualSizePolicy == null)
-                {
-                    _visualSizePolicy = new Vector2(0.0f, 0.0f);
-                }
-
+                float width = 0.0f;
                 switch (value)
                 {
                     case VisualTransformPolicyType.Relative:
-                        _visualSizePolicy.Width = 0.0f;
+                        width = 0.0f;
                         break;
                     case VisualTransformPolicyType.Absolute:
-                        _visualSizePolicy.Width = 1.0f;
+                        width = 1.0f;
                         break;
                     default:
-                        _visualSizePolicy.Width = 0.0f;
+                        width = 0.0f;
                         break;
                 }
+
+                _visualSizePolicy = new Vector2(width, _visualSizePolicy?.Height ?? 0);
                 UpdateVisual();
             }
         }
@@ -393,23 +387,21 @@ namespace Tizen.NUI
             }
             set
             {
-                if (_visualSizePolicy == null)
-                {
-                    _visualSizePolicy = new Vector2(0.0f, 0.0f);
-                }
+                float height = 0.0f;
 
                 switch (value)
                 {
                     case VisualTransformPolicyType.Relative:
-                        _visualSizePolicy.Height = 0.0f;
+                        height = 0.0f;
                         break;
                     case VisualTransformPolicyType.Absolute:
-                        _visualSizePolicy.Height = 1.0f;
+                        height = 1.0f;
                         break;
                     default:
-                        _visualSizePolicy.Height = 0.0f;
+                        height = 0.0f;
                         break;
                 }
+                _visualSizePolicy = new Vector2(_visualSizePolicy?.Width ?? 0, height);
                 UpdateVisual();
             }
         }