[NUI] fixed bug about set desired size
authorJoogab Yun <joogab.yun@samsung.com>
Wed, 18 Nov 2020 07:06:18 +0000 (16:06 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 15 Dec 2020 06:33:59 +0000 (15:33 +0900)
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs

index 5cd074a..00c7258 100755 (executable)
@@ -892,8 +892,11 @@ namespace Tizen.NUI.BaseComponents
             }
             set
             {
-                UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
-                _desired_width = value;
+                if (_desired_width != value)
+                {
+                    _desired_width = value;
+                    UpdateImage(0, null);
+                }
             }
         }
 
@@ -917,8 +920,11 @@ namespace Tizen.NUI.BaseComponents
             }
             set
             {
-                UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
-                _desired_height = value;
+                if (_desired_height != value)
+                {
+                    _desired_height = value;
+                    UpdateImage(0, null);
+                }
             }
         }
 
@@ -1142,21 +1148,22 @@ namespace Tizen.NUI.BaseComponents
                 {
                     Size2D imageSize = ImageLoading.GetOriginalImageSize(_resourceUrl);
 
-                    int ret_width, ret_height;
-                    if (imageSize.Width > imageSize.Height)
+                    int adjustedDesiredWidth, adjustedDesiredHeight;
+                    float aspectOfDesiredSize = (float)_desired_height / (float)_desired_width;
+                    float aspectOfImageSize = (float)imageSize.Height / (float)imageSize.Width;
+                    if( aspectOfImageSize > aspectOfDesiredSize)
                     {
-                        ret_width = _desired_width;
-                        ret_height = imageSize.Height * _desired_height / (imageSize.Width);
+                        adjustedDesiredWidth = _desired_width;
+                        adjustedDesiredHeight = imageSize.Height * _desired_width / imageSize.Width;
                     }
                     else
                     {
-                        ret_width = imageSize.Width * _desired_width / (imageSize.Height);
-                        ret_height = _desired_height;
-
+                        adjustedDesiredWidth = imageSize.Width * _desired_height/ imageSize.Height;
+                        adjustedDesiredHeight = _desired_height;
                     }
-                    temp.Insert(ImageVisualProperty.DesiredWidth, new PropertyValue((int)ret_width));
-                    temp.Insert(ImageVisualProperty.DesiredHeight, new PropertyValue((int)ret_height));
-                    temp.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int)FittingModeType.ShrinkToFit));
+                    temp.Insert(ImageVisualProperty.DesiredWidth, new PropertyValue(adjustedDesiredWidth));
+                    temp.Insert(ImageVisualProperty.DesiredHeight, new PropertyValue(adjustedDesiredHeight));
+                    temp.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int)FittingModeType.ScaleToFill));
                 }
             }