[NUI] Add RedrawInScalingDown in LottieAnimationView
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / LottieAnimationView.cs
index 82aabb3..095c96a 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@ using System.Collections.Generic;
 
 namespace Tizen.NUI.BaseComponents
 {
-    #if (NUI_DEBUG_ON)
+#if (NUI_DEBUG_ON)
     using tlog = Tizen.Log;
-    #endif
+#endif
 
     /// <summary>
     /// LottieAnimationView renders an animated vector image (Lottie file).
@@ -62,6 +62,7 @@ namespace Tizen.NUI.BaseComponents
             currentStates.changed = false;
             currentStates.totalFrame = -1;
             currentStates.scale = scale;
+            currentStates.redrawInScalingDown = true;
             SetVisible(shown);
         }
 
@@ -303,7 +304,7 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// Sets or gets the loop count. 
+        /// Sets or gets the loop count.
         /// </summary>
         /// <remarks>
         /// The minus value means the infinite loop count.
@@ -401,6 +402,50 @@ namespace Tizen.NUI.BaseComponents
                 return currentStates.stopEndAction;
             }
         }
+
+        /// <summary>
+        /// Whether to redraw the image when the visual is scaled down.
+        /// </summary>
+        /// <remarks>
+        /// Inhouse API.
+        /// It is used in the AnimatedVectorImageVisual.The default is true.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool RedrawInScalingDown
+        {
+            set
+            {
+                currentStates.changed = true;
+                currentStates.redrawInScalingDown = value;
+                tlog.Fatal(tag, $"<[{GetId()}]SET currentStates.redrawInScalingDown={currentStates.redrawInScalingDown}>");
+                PropertyMap map = new PropertyMap();
+                map.Add(ImageVisualProperty.RedrawInScalingDown, new PropertyValue(currentStates.redrawInScalingDown));
+                DoAction(ImageView.Property.IMAGE, (int)actionType.updateProperty, new PropertyValue(map));
+            }
+            get
+            {
+                PropertyMap map = base.Image;
+                var ret = true;
+                if (map != null)
+                {
+                    PropertyValue val = map.Find(ImageVisualProperty.RedrawInScalingDown);
+                    if (val != null)
+                    {
+                        if (val.Get(out ret))
+                        {
+                            if (ret != currentStates.redrawInScalingDown)
+                            {
+                                tlog.Fatal(tag, $"<[ERROR][{GetId()}](LottieAnimationView) different redrawInScalingDown! gotten={ret}, redrawInScalingDown={currentStates.redrawInScalingDown}>");
+                            }
+                            currentStates.redrawInScalingDown = ret;
+                            return currentStates.redrawInScalingDown;
+                        }
+                    }
+                }
+                Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get redrawInScalingDown from dali currentStates.redrawInScalingDown={currentStates.redrawInScalingDown}>");
+                return currentStates.redrawInScalingDown;
+            }
+        }
         #endregion Property
 
 
@@ -514,7 +559,7 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// A marker has its start frame and end frame. 
+        /// A marker has its start frame and end frame.
         /// Animation will play between the start frame and the end frame of the marker if one marker is specified.
         /// Or animation will play between the start frame of the first marker and the end frame of the second marker if two markers are specified.   *
         /// </summary>
@@ -761,6 +806,7 @@ namespace Tizen.NUI.BaseComponents
             internal PlayStateType playState;
             internal List<Tuple<string, int, int>> contentInfo;
             internal string mark1, mark2;
+            internal bool redrawInScalingDown;
         };
         private states currentStates;
 
@@ -824,8 +870,9 @@ namespace Tizen.NUI.BaseComponents
         private void debugPrint()
         {
             tlog.Fatal(tag, $"===================================");
-            tlog.Fatal(tag, $"<[{GetId()}] get currentStates : url={currentStates.url}, loopCount={currentStates.loopCount}, framePlayRangeMin/Max({currentStates.framePlayRangeMin},{currentStates.framePlayRangeMax}) ");
-            tlog.Fatal(tag, $"  get from Property : StopBehavior={StopBehavior}, LoopMode={LoopingMode}, LoopCount={LoopCount}, PlayState={PlayState} >");
+            tlog.Fatal(tag, $"<[{GetId()}] get currentStates : url={currentStates.url}, loopCount={currentStates.loopCount}, \nframePlayRangeMin/Max({currentStates.framePlayRangeMin},{currentStates.framePlayRangeMax}) ");
+            tlog.Fatal(tag, $"  get from Property : StopBehavior={StopBehavior}, LoopMode={LoopingMode}, LoopCount={LoopCount}, PlayState={PlayState}");
+            tlog.Fatal(tag, $"  RedrawInScalingDown={RedrawInScalingDown} >");
             tlog.Fatal(tag, $"===================================");
         }
         #endregion Private
@@ -972,7 +1019,7 @@ namespace Tizen.NUI.BaseComponents
         private bool BeReadyToShow(LottieAnimationView lottieView)
         {
             // Validate input lottieView
-            if (null== lottieView || lottieView.PlayState == LottieAnimationView.PlayStateType.Invalid)
+            if (null == lottieView || lottieView.PlayState == LottieAnimationView.PlayStateType.Invalid)
             {
                 return false;
             }