[NUI] Fix issue when LottieAnimationView use DesiredSize
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 8 Aug 2023 11:20:07 +0000 (20:20 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 9 Aug 2023 07:58:31 +0000 (16:58 +0900)
Since #5350 patch will reset previous whole informations
when we use ResourceUrl.

So, If user set ResourceUrl set DesiredSize, the desired size
informatins disapeared.

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs

index 26ec494..3dc9f55 100755 (executable)
@@ -59,6 +59,8 @@ namespace Tizen.NUI.BaseComponents
             currentStates.totalFrame = -1;
             currentStates.scale = scale;
             currentStates.redrawInScalingDown = true;
+            currentStates.desiredWidth = 0;
+            currentStates.desiredHeight = 0;
 
             // Set changed flag as true when initalized state.
             // After some properties change, LottieAnimationView.UpdateImage will apply these inital values.
@@ -173,6 +175,18 @@ namespace Tizen.NUI.BaseComponents
                     .Add(ImageVisualProperty.StopBehavior, stopAction)
                     .Add(ImageVisualProperty.LoopingMode, loopMode)
                     .Add(ImageVisualProperty.RedrawInScalingDown, redrawInScalingDown);
+
+                if (currentStates.desiredWidth > 0)
+                {
+                    using PropertyValue desiredWidth = new PropertyValue((int)currentStates.desiredWidth);
+                    map.Add(ImageVisualProperty.DesiredWidth, desiredWidth);
+                }
+                if (currentStates.desiredHeight > 0)
+                {
+                    using PropertyValue desiredHeight = new PropertyValue((int)currentStates.desiredHeight);
+                    map.Add(ImageVisualProperty.DesiredHeight, desiredHeight);
+                }
+
                 Image = map;
 
                 // All states applied well.
@@ -194,6 +208,40 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Gets or sets the desired image width for LottieAnimationView<br />
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public new int DesiredWidth
+        {
+            get
+            {
+                return currentStates.desiredWidth;
+            }
+            set
+            {
+                currentStates.desiredWidth = value;
+                base.DesiredWidth = currentStates.desiredWidth;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the desired image height for LottieAnimationView<br />
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public new int DesiredHeight
+        {
+            get
+            {
+                return currentStates.desiredHeight;
+            }
+            set
+            {
+                currentStates.desiredHeight = value;
+                base.DesiredHeight = currentStates.desiredHeight;
+            }
+        }
+
+        /// <summary>
         /// Gets the playing state
         /// </summary>
         /// <since_tizen> 7 </since_tizen>
@@ -1089,6 +1137,7 @@ namespace Tizen.NUI.BaseComponents
             internal List<Tuple<string, int, int>> contentInfo;
             internal string mark1, mark2;
             internal bool redrawInScalingDown;
+            internal int desiredWidth, desiredHeight;
             internal bool changed;
         };
         private states currentStates;