[NUI] Prevent Height and Width specs being overwritten (#1142)
authoragnelovaz <agnelo.vaz@samsung.com>
Mon, 25 Nov 2019 01:11:54 +0000 (01:11 +0000)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 25 Nov 2019 01:11:54 +0000 (10:11 +0900)
When setting the WidthSpecification or HeightSpecification with an exact value
the Size.Width or Size.Height is set but this in turns triggers a callback which
sets Size(width,height) but uses the stored height or width value which may not be
the set Width or Height Specification hence sets them to 0;

Change-Id: I80a4e1166f35e4c09c116916262ac965de54b048

src/Tizen.NUI/src/public/BaseComponents/View.cs

index e66ea35..1de9de7 100755 (executable)
@@ -1778,8 +1778,18 @@ namespace Tizen.NUI.BaseComponents
                 if (_widthPolicy >= 0)
                 {
                     _measureSpecificationWidth = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
-                    Size2D.Width = _widthPolicy;
 
+                    if(_heightPolicy>=0) // Policy an exact value
+                    {
+                        Size2D.Width = _widthPolicy;
+                    }
+                    else
+                    {
+                        // Store _heightPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
+                        // Size2D height will store the specification value (negative number) this will then be applied to the
+                        // HeightSpecification when the Size2D callback is invoked.
+                        Size2D = new Size2D(_widthPolicy,_heightPolicy);
+                    }
                 }
                 _layout?.RequestLayout();
             }
@@ -1801,7 +1811,18 @@ namespace Tizen.NUI.BaseComponents
                 if (_heightPolicy >= 0)
                 {
                     _measureSpecificationHeight = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
-                    Size2D.Height = _heightPolicy;
+
+                    if(_widthPolicy>=0) // Policy an exact value
+                    {
+                        Size2D.Height = _heightPolicy;
+                    }
+                    else
+                    {
+                        // Store widthPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
+                        // Size2D height will store the specification value (negative number) this will then be applied to the
+                        // HeightSpecification when the Size2D callback is invoked.
+                        Size2D = new Size2D(_widthPolicy,_heightPolicy);
+                    }
 
                 }
                _layout?.RequestLayout();