[NUI] Fix SetMinMaxFrameByMarker()'s not working issue in AnimatedVectorImageView...
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / AnimatedVectorImageView.cs
index 5ef4c82..a0efb42 100755 (executable)
 
 using global::System;
 using System.ComponentModel;
-#if (NUI_DEBUG_ON)
-using tlog = Tizen.Log;
-#endif
 
 namespace Tizen.NUI.BaseComponents
 {
+    #if (NUI_DEBUG_ON)
+    using tlog = Tizen.Log;
+    #endif
+
     /// <summary>
     /// AnimatedVectorImageView is a class for displaying a vector resource.
     /// </summary>
@@ -38,7 +39,7 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public AnimatedVectorImageView() : base()
         {
-            tlog.Fatal(tag,  $"[VAV START[ constuctor objId={GetId()} ]VAV END]");
+            tlog.Fatal(tag, $"[VAV START[ constuctor objId={GetId()} ]VAV END]");
         }
 
         /// <summary>
@@ -49,7 +50,7 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public AnimatedVectorImageView(float scale) : base(scale)
         {
-            tlog.Fatal(tag,  $"[VAV START[ constuctor scale={scale}) objId={GetId()} ]VAV END]");
+            tlog.Fatal(tag, $"[VAV START[ constuctor scale={scale}) objId={GetId()} ]VAV END]");
         }
 
         /// <summary>
@@ -64,7 +65,7 @@ namespace Tizen.NUI.BaseComponents
             {
                 return;
             }
-            tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] type={type})");
+            tlog.Fatal(tag, $"[VAV START[ [{GetId()}] type={type})");
 
             //Release your own unmanaged resources here.
             //You should not access any managed member here except static instance.
@@ -72,7 +73,7 @@ namespace Tizen.NUI.BaseComponents
 
             base.Dispose(type);
 
-            tlog.Fatal(tag,  $"]VAV END]");
+            tlog.Fatal(tag, $"]VAV END]");
         }
         #endregion Constructor, Distructor, Dispose
 
@@ -87,23 +88,44 @@ namespace Tizen.NUI.BaseComponents
         {
             set
             {
-                tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] ResourceURL SET");
+                tlog.Fatal(tag, $"[VAV START[ [{GetId()}] ResourceURL SET");
 
                 if (value == mResourceURL)
                 {
-                    tlog.Fatal(tag,  $"set same URL! ");
+                    tlog.Fatal(tag, $"set same URL! ");
                     return;
                 }
                 mResourceURL = (value == null) ? "" : value;
                 URL = mResourceURL;
-                mIsMinMaxSet = false;
+                mIsMinMaxSet = minMaxSetTypes.NotSetByUser;
                 mTotalFrameNum = base.TotalFrame;
-                tlog.Fatal(tag,  $" [{GetId()}] mResourceURL={mResourceURL}) ]VAV END]");
+                tlog.Fatal(tag, $" [{GetId()}] mResourceURL={mResourceURL}) ]VAV END]");
             }
             get => mResourceURL;
         }
 
         /// <summary>
+        /// Set Resource URL
+        /// </summary>
+        // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public new string ResourceUrl
+        {
+            set
+            {
+                tlog.Fatal(tag, $"[VAV START[ [{GetId()}] ResourceUrl SET");
+                this.ResourceURL = value;
+                tlog.Fatal(tag, $" [{GetId()}] value={value}) ]VAV END]");
+            }
+            get
+            {
+                tlog.Fatal(tag, $"[VAV [ [{GetId()}] ResourceUrl GET");
+                return this.ResourceURL;
+            }
+        }
+
+
+        /// <summary>
         /// RepeatCount of animation.
         /// The repeat count is 0 by default.
         /// If the RepeatCount is 0, the animation is never repeated.
@@ -116,12 +138,12 @@ namespace Tizen.NUI.BaseComponents
         {
             set
             {
-                tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] RepeatCount SET");
+                tlog.Fatal(tag, $"[VAV START[ [{GetId()}] RepeatCount SET");
 
                 mRepeatCount = (value < -1) ? -1 : value;
                 LoopCount = (mRepeatCount < 0) ? mRepeatCount : mRepeatCount + 1;
 
-                tlog.Fatal(tag,  $"[{GetId()}] mRepeatCount={mRepeatCount} ]VAV END]");
+                tlog.Fatal(tag, $"[{GetId()}] mRepeatCount={mRepeatCount} ]VAV END]");
             }
             get => mRepeatCount;
         }
@@ -146,7 +168,7 @@ namespace Tizen.NUI.BaseComponents
         {
             set
             {
-                tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] CurrentFrame SET");
+                tlog.Fatal(tag, $"[VAV START[ [{GetId()}] CurrentFrame SET");
 
                 if (mResourceURL == null || mResourceURL == String.Empty)
                 {
@@ -165,10 +187,10 @@ namespace Tizen.NUI.BaseComponents
                 mCurrentFrame = value;
                 AnimationState = AnimationStates.Paused;
 
-                SetMinMaxFrame(0, mTotalFrameNum - 1);
+                base.SetMinMaxFrame(0, mTotalFrameNum - 1);
                 base.CurrentFrame = mCurrentFrame;
 
-                tlog.Fatal(tag,  $" [{GetId()}] mCurrentFrame={mCurrentFrame}) ]VAV END]");
+                tlog.Fatal(tag, $" [{GetId()}] mCurrentFrame={mCurrentFrame}) ]VAV END]");
             }
             get => mCurrentFrame;
         }
@@ -182,7 +204,7 @@ namespace Tizen.NUI.BaseComponents
         {
             set
             {
-                tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] RepeatMode SET");
+                tlog.Fatal(tag, $"[VAV START[ [{GetId()}] RepeatMode SET");
                 mRepeatMode = value;
 
                 switch (mRepeatMode)
@@ -198,7 +220,7 @@ namespace Tizen.NUI.BaseComponents
                         break;
                 }
 
-                tlog.Fatal(tag,  $" [{GetId()}] mRepeatMode={mRepeatMode}) ]VAV END]");
+                tlog.Fatal(tag, $" [{GetId()}] mRepeatMode={mRepeatMode}) ]VAV END]");
             }
             get => mRepeatMode;
         }
@@ -226,11 +248,11 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void SetMinAndMaxFrame(int minFrame, int maxFrame)
         {
-            tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] SetMinAndMaxFrame({minFrame}, {maxFrame})");
+            tlog.Fatal(tag, $"[VAV START[ [{GetId()}] SetMinAndMaxFrame({minFrame}, {maxFrame})");
 
             mMinFrame = (minFrame) > 0 ? minFrame : 0;
             mMaxFrame = (maxFrame) > 0 ? maxFrame : 0;
-            mIsMinMaxSet = true;
+            mIsMinMaxSet = minMaxSetTypes.SetByMinAndMaxFrameMethod;
 
             if (mMinFrame >= mTotalFrameNum)
             {
@@ -247,7 +269,51 @@ namespace Tizen.NUI.BaseComponents
                 return;
             }
 
-            tlog.Fatal(tag,  $" [{GetId()}] mMinFrame:{mMinFrame}, mMaxFrame:{mMaxFrame}) ]VAV END]");
+            tlog.Fatal(tag, $" [{GetId()}] mMinFrame:{mMinFrame}, mMaxFrame:{mMaxFrame}) ]VAV END]");
+        }
+
+        /// <summary>
+        /// SetMinMaxFrame(int startFrame, int endFrame)
+        /// </summary>
+        /// <param name="minFrame"></param>
+        /// <param name="maxFrame"></param>
+        // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public new void SetMinMaxFrame(int minFrame, int maxFrame)
+        {
+            tlog.Fatal(tag, $"SetMinMaxFrame({minFrame}, {maxFrame})!!!");
+
+            mMinFrame = (minFrame) > 0 ? minFrame : 0;
+            mMaxFrame = (maxFrame) > 0 ? maxFrame : 0;
+            mIsMinMaxSet = minMaxSetTypes.SetByBaseSetMinMaxFrameMethod;
+
+            if (mMinFrame >= mTotalFrameNum)
+            {
+                mMinFrame = mTotalFrameNum - 1;
+            }
+
+            if (mMaxFrame >= mTotalFrameNum)
+            {
+                mMaxFrame = mTotalFrameNum - 1;
+            }
+
+            base.SetMinMaxFrame(mMinFrame, mMaxFrame);
+        }
+
+        /// <summary>
+        /// 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>
+        /// <param name="marker1">First marker</param>
+        /// <param name="marker2">Second marker</param>
+        // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public new void SetMinMaxFrameByMarker(string marker1, string marker2 = null)
+        {
+            tlog.Fatal(tag, $"SetMinMaxFrameByMarker({marker1}, {marker2})");
+            mIsMinMaxSet = minMaxSetTypes.SetByMarker;
+            base.SetMinMaxFrameByMarker(marker1, marker2);
         }
 
         /// <summary>
@@ -257,22 +323,30 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public new void Play()
         {
-            tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] AnimationState={AnimationState}, PlayState={PlayState}");
+            tlog.Fatal(tag, $"[VAV START[ [{GetId()}] AnimationState={AnimationState}, PlayState={PlayState}");
 
             if (mResourceURL == null || mResourceURL == String.Empty)
             {
                 throw new InvalidOperationException("Resource Url not yet Set");
             }
 
-            if (mIsMinMaxSet)
-            {
-                SetMinMaxFrame(mMinFrame, mMaxFrame);
-                base.CurrentFrame = mMinFrame;
-            }
-            else
+            switch (mIsMinMaxSet)
             {
-                SetMinMaxFrame(0, mTotalFrameNum - 1);
-                base.CurrentFrame = 0;
+                case minMaxSetTypes.NotSetByUser:
+                    base.SetMinMaxFrame(0, mTotalFrameNum - 1);
+                    base.CurrentFrame = 0;
+                    break;
+
+                case minMaxSetTypes.SetByMinAndMaxFrameMethod:
+                    base.SetMinMaxFrame(mMinFrame, mMaxFrame);
+                    base.CurrentFrame = mMinFrame;
+                    break;
+
+                case minMaxSetTypes.SetByMarker:
+                case minMaxSetTypes.SetByBaseSetMinMaxFrameMethod:
+                default:
+                    //do nothing!
+                    break;
             }
 
             //temporal fix
@@ -282,7 +356,7 @@ namespace Tizen.NUI.BaseComponents
             base.Play();
             AnimationState = AnimationStates.Playing;
 
-            tlog.Fatal(tag,  $" [{GetId()}] mIsMinMaxSet={mIsMinMaxSet}) ]VAV END]");
+            tlog.Fatal(tag, $" [{GetId()}] mIsMinMaxSet={mIsMinMaxSet}) ]VAV END]");
         }
 
         /// <summary>
@@ -292,7 +366,7 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public new void Pause()
         {
-            tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] AnimationState={AnimationState}, PlayState={PlayState}");
+            tlog.Fatal(tag, $"[VAV START[ [{GetId()}] AnimationState={AnimationState}, PlayState={PlayState}");
 
             if (mResourceURL == null || mResourceURL == String.Empty)
             {
@@ -302,7 +376,7 @@ namespace Tizen.NUI.BaseComponents
             base.Pause();
             AnimationState = AnimationStates.Paused;
 
-            tlog.Fatal(tag,  $" [{GetId()}] ]VAV END]");
+            tlog.Fatal(tag, $" [{GetId()}] ]VAV END]");
         }
 
         /// <summary>
@@ -317,7 +391,7 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void Stop(EndActions endAction = EndActions.Cancel)
         {
-            tlog.Fatal(tag,  $"[VAV START[ [{GetId()}] endAction:({endAction}), PlayState={PlayState}");
+            tlog.Fatal(tag, $"[VAV START[ [{GetId()}] endAction:({endAction}), PlayState={PlayState}");
 
             if (mResourceURL == null || mResourceURL == String.Empty)
             {
@@ -344,7 +418,7 @@ namespace Tizen.NUI.BaseComponents
                         StopBehavior = StopBehaviorType.MaximumFrame;
                         break;
                     default:
-                        tlog.Fatal(tag,  $" [{GetId()}] no endAction : default set");
+                        tlog.Fatal(tag, $" [{GetId()}] no endAction : default set");
                         break;
                 }
             }
@@ -354,27 +428,33 @@ namespace Tizen.NUI.BaseComponents
 
             if (endAction == EndActions.StopFinal)
             {
-                if (mIsMinMaxSet)
+                switch (mIsMinMaxSet)
                 {
-                    if (base.CurrentFrame != mMaxFrame)
-                    {
-                        tlog.Fatal(tag,  $"mIsMinMaxSet:{mIsMinMaxSet}, CurrentFrameNumber:{base.CurrentFrame}, mMaxFrame:{ mMaxFrame}");
-                        base.CurrentFrame = mMaxFrame;
-                        tlog.Fatal(tag,  $"set CurrentFrameNumber({base.CurrentFrame}) as mMaxFrame({mMaxFrame})!!!");
-                    }
-                }
-                else
-                {
-                    if (base.CurrentFrame != mTotalFrameNum - 1)
-                    {
-                        tlog.Fatal(tag,  $"mIsMinMaxSet:{mIsMinMaxSet}, CurrentFrameNumber:{base.CurrentFrame}, mTotalFrameNum:{ mTotalFrameNum}");
-                        base.CurrentFrame = mTotalFrameNum - 1;
-                        tlog.Fatal(tag,  $"set CurrentFrameNumber({base.CurrentFrame}) as mTotalFrameNum({mMaxFrame}) - 1 !");
-                    }
+                    case minMaxSetTypes.NotSetByUser:
+                        if (base.CurrentFrame != mTotalFrameNum - 1)
+                        {
+                            tlog.Fatal(tag, $"mIsMinMaxSet:{mIsMinMaxSet}, CurrentFrameNumber:{base.CurrentFrame}, mTotalFrameNum:{ mTotalFrameNum}");
+                            base.CurrentFrame = mTotalFrameNum - 1;
+                            tlog.Fatal(tag, $"set CurrentFrameNumber({base.CurrentFrame}) as mTotalFrameNum({mMaxFrame}) - 1 !");
+                        }
+                        break;
+
+                    case minMaxSetTypes.SetByMinAndMaxFrameMethod:
+                        if (base.CurrentFrame != mMaxFrame)
+                        {
+                            tlog.Fatal(tag, $"mIsMinMaxSet:{mIsMinMaxSet}, CurrentFrameNumber:{base.CurrentFrame}, mMaxFrame:{ mMaxFrame}");
+                            base.CurrentFrame = mMaxFrame;
+                            tlog.Fatal(tag, $"set CurrentFrameNumber({base.CurrentFrame}) as mMaxFrame({mMaxFrame})!!!");
+                        }
+                        break;
+                    case minMaxSetTypes.SetByBaseSetMinMaxFrameMethod:
+                    case minMaxSetTypes.SetByMarker:
+                    default:
+                        //do nothing!
+                        break;
                 }
             }
-
-            tlog.Fatal(tag,  $" [{GetId()}] ]VAV END]");
+            tlog.Fatal(tag, $" [{GetId()}] ]VAV END]");
         }
         #endregion Method
 
@@ -455,9 +535,16 @@ namespace Tizen.NUI.BaseComponents
         private int mTotalFrameNum = 0;
         private RepeatModes mRepeatMode = RepeatModes.Restart;
         private int mMinFrame = -1, mMaxFrame = -1;
-        private bool mIsMinMaxSet = false;
+        private minMaxSetTypes mIsMinMaxSet = minMaxSetTypes.NotSetByUser;
         private int mCurrentFrame = -1;
         private EndActions mEndAction = EndActions.Cancel;
+        private enum minMaxSetTypes
+        {
+            NotSetByUser,
+            SetByMinAndMaxFrameMethod,
+            SetByMarker,
+            SetByBaseSetMinMaxFrameMethod,
+        }
 
         private string tag = "NUITEST";
         #endregion Private