2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
21 using tlog = Tizen.Log;
24 namespace Tizen.NUI.BaseComponents
27 /// VectorAnimationView is a class for displaying a vector resource.
29 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
30 [EditorBrowsable(EditorBrowsableState.Never)]
31 public class VectorAnimationViewTBD : AnimatedVectorImageView
33 #region Constructor, Distructor, Dispose
35 /// Construct VectorAnimationView.
37 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
38 [EditorBrowsable(EditorBrowsableState.Never)]
39 public VectorAnimationViewTBD() : base()
41 tlog.Fatal(tag, $"<<< VectorAnimationView() constuctor objId={GetId()} >>>");
45 /// Construct VectorAnimationView.
47 /// <param name="scale">Set scaling factor for Vector Animation, while creating.</param>
48 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
49 [EditorBrowsable(EditorBrowsableState.Never)]
50 public VectorAnimationViewTBD(float scale) : base(scale)
52 tlog.Fatal(tag, $"<<< VectorAnimationView(scale={scale}) constuctor objId={GetId()}>>>");
56 /// You can override it to clean-up your own resources
58 /// <param name="type">DisposeTypes</param>
59 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
60 [EditorBrowsable(EditorBrowsableState.Never)]
61 protected override void Dispose(DisposeTypes type)
67 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.Dispose(type={type})");
69 if (type == DisposeTypes.Explicit)
72 //Release your own managed resources here.
73 //You should release all of your own disposable objects here.
76 //Release your own unmanaged resources here.
77 //You should not access any managed member here except static instance.
78 //because the execution order of Finalizes is non-deterministic.
82 tlog.Fatal(tag, $"[{GetId()}] VectorAnimationView.Dispose() >>>");
84 #endregion Constructor, Distructor, Dispose
91 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
92 [EditorBrowsable(EditorBrowsableState.Never)]
93 public string ResourceURL
97 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.ResourceURL SET");
99 if (value == mResourceURL)
101 tlog.Fatal(tag, $"set same URL! ");
104 mResourceURL = (value == null) ? "" : value;
106 mIsMinMaxSet = false;
108 tlog.Fatal(tag, $" [{GetId()}] VectorAnimationView.ResourceURL SET mResourceURL={mResourceURL}) >>>");
114 /// RepeatCount of animation.
115 /// The repeat count is 0 by default.
116 /// If the RepeatCount is 0, the animation is never repeated.
117 /// If the RepeatCount is greater than 0, the repeat mode will be taken into account.
118 /// If RepeatCount is -1, animation is infinite loops.
120 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
121 [EditorBrowsable(EditorBrowsableState.Never)]
122 public int RepeatCount
126 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.RepeatCount SET");
128 mRepeatCount = (value < -1) ? -1 : value;
129 //LoopCount = mRepeatCount;
130 LoopCount = (mRepeatCount < 0) ? mRepeatCount : mRepeatCount + 1;
132 tlog.Fatal(tag, $"[{GetId()}] VectorAnimationView.RepeatCount SET mRepeatCount={mRepeatCount} >>>");
138 /// CurrentFrame of animation.
140 /// <returns> Returns user set value for the current frame. Cannot provide actual playing current frame. </returns>
141 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public int CurrentFrame
147 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.CurrentFrame SET");
149 if (mResourceURL == null || mResourceURL == String.Empty)
151 throw new InvalidOperationException("Resource Url not yet Set");
154 mFrameCount = TotalFrameNumber;
160 else if (value >= mFrameCount)
162 value = mFrameCount - 1;
165 mCurrentFrame = value;
166 AnimationState = AnimationStates.Paused;
168 SetPlayRange(mCurrentFrame, mCurrentFrame);
169 CurrentFrameNumber = mCurrentFrame;
171 tlog.Fatal(tag, $" [{GetId()}] VectorAnimationView.CurrentFrame SET mCurrentFrame={mCurrentFrame}) >>>");
173 get => mCurrentFrame;
177 /// RepeatMode of animation.
179 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
180 [EditorBrowsable(EditorBrowsableState.Never)]
181 public RepeatModes RepeatMode
185 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.RepeatMode SET");
190 case RepeatModes.Restart:
191 LoopMode = LoopingModeType.Restart;
193 case RepeatModes.Reverse:
194 LoopMode = LoopingModeType.AutoReverse;
197 LoopMode = LoopingModeType.Restart;
201 tlog.Fatal(tag, $" [{GetId()}] VectorAnimationView.RepeatMode SET mRepeatMode={mRepeatMode}) >>>");
207 /// Get state of animation.
209 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
210 [EditorBrowsable(EditorBrowsableState.Never)]
211 public AnimationStates AnimationState
221 /// Set minimum frame and maximum frame
223 /// <param name="minFrame">minimum frame.</param>
224 /// <param name="maxFrame">maximum frame.</param>
225 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
226 [EditorBrowsable(EditorBrowsableState.Never)]
227 public void SetMinAndMaxFrame(int minFrame, int maxFrame)
229 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.SetMinAndMaxFrame({minFrame}, {maxFrame})");
231 mMinFrame = (minFrame) > 0 ? minFrame : 0;
232 mMaxFrame = (maxFrame) > 0 ? maxFrame : 0;
234 mFrameCount = TotalFrameNumber;
236 if (mMinFrame >= mFrameCount)
238 mMinFrame = mFrameCount - 1;
241 if (mMaxFrame >= mFrameCount)
243 mMaxFrame = mFrameCount - 1;
246 if (mMinFrame > mMaxFrame)
252 SetPlayRange(mMinFrame, mMaxFrame);
253 CurrentFrameNumber = mMinFrame;
255 tlog.Fatal(tag, $" [{GetId()}] VectorAnimationView.SetMinAndMaxFrame(m: {mMinFrame}, {mMaxFrame}) >>>");
261 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
262 [EditorBrowsable(EditorBrowsableState.Never)]
263 public new void Play()
265 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.Play()");
267 if (mResourceURL == null || mResourceURL == String.Empty)
269 throw new InvalidOperationException("Resource Url not yet Set");
274 //if(mRepeatCount > 0 )
276 // StopBehavior = StopBehaviorType.FirstFrame;
278 SetPlayRange(mMinFrame, mMaxFrame);
282 //SetPlayRange(0, TotalFrameNumber - 1);
286 AnimationState = AnimationStates.Playing;
288 tlog.Fatal(tag, $" [{GetId()}] VectorAnimationView.Play(mIsMinMaxSet={mIsMinMaxSet}) >>>");
294 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
295 [EditorBrowsable(EditorBrowsableState.Never)]
296 public new void Pause()
298 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.Pause() AnimationState={AnimationState}");
300 if (mResourceURL == null || mResourceURL == String.Empty)
302 throw new InvalidOperationException("Resource Url not yet Set");
306 AnimationState = AnimationStates.Paused;
308 tlog.Fatal(tag, $" [{GetId()}] VectorAnimationView.Pause() >>>");
314 /// <param name="endAction">Defines, what should be behaviour after cancel operation
315 /// End action is Cancel, Animation Stops at the Current Frame.
316 /// End action is Discard, Animation Stops at the Min Frame
317 /// End action is StopFinal, Animation Stops at the Max Frame
319 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
320 [EditorBrowsable(EditorBrowsableState.Never)]
321 public void Stop(EndActions endAction = EndActions.Cancel)
323 tlog.Fatal(tag, $"<<< [{GetId()}] VectorAnimationView.Stop({endAction})");
325 if (mResourceURL == null || mResourceURL == String.Empty)
327 throw new InvalidOperationException("Resource Url not yet Set");
330 if (AnimationState == AnimationStates.Stopped)
335 if (mEndAction != endAction)
337 mEndAction = endAction;
340 case EndActions.Cancel:
341 StopBehavior = StopBehaviorType.CurrentFrame;
343 case EndActions.Discard:
344 StopBehavior = StopBehaviorType.FirstFrame;
346 case EndActions.StopFinal:
347 StopBehavior = StopBehaviorType.LastFrame;
350 tlog.Fatal(tag, $" [{GetId()}] no endAction : default set");
354 //if (endAction == EndActions.Discard)
356 // CurrentFrame = mMinFrame;
358 //else if (endAction == EndActions.StopFinal)
360 // CurrentFrame = mMaxFrame;
362 AnimationState = AnimationStates.Stopped;
366 tlog.Fatal(tag, $" [{GetId()}] VectorAnimationView.Stop(endaction={endAction}) >>>");
371 #region Event, Enum, Struct, ETC
373 /// RepeatMode of animation.
375 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
376 [EditorBrowsable(EditorBrowsableState.Never)]
377 public enum RepeatModes
380 /// When the animation reaches the end and RepeatCount is nonZero, the animation restarts from the beginning.
382 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
383 [EditorBrowsable(EditorBrowsableState.Never)]
384 Restart = LoopModes.Forward,
386 /// When the animation reaches the end and RepeatCount nonZero, the animation reverses direction on every animation cycle.
388 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
389 [EditorBrowsable(EditorBrowsableState.Never)]
390 Reverse = LoopModes.Backward
394 /// EndActions of animation.
396 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
397 [EditorBrowsable(EditorBrowsableState.Never)]
398 public enum EndActions
400 /// <summary> End action is Cancel, Animation Stops at the Current Frame.</summary>
401 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
402 [EditorBrowsable(EditorBrowsableState.Never)]
404 /// <summary> End action is Discard, Animation Stops at the Min Frame</summary>
405 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
406 [EditorBrowsable(EditorBrowsableState.Never)]
408 /// <summary> End action is StopFinal, Animation Stops at the Max Frame</summary>
409 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
410 [EditorBrowsable(EditorBrowsableState.Never)]
415 /// AnimationStates of animation.
417 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
418 [EditorBrowsable(EditorBrowsableState.Never)]
419 public enum AnimationStates
421 /// <summary> The animation has stopped.</summary>
422 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
423 [EditorBrowsable(EditorBrowsableState.Never)]
424 Stopped = PlayStateType.Stopped,
425 /// <summary> The animation is playing.</summary>
426 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
427 [EditorBrowsable(EditorBrowsableState.Never)]
428 Playing = PlayStateType.Playing,
429 /// <summary> The animation is paused.</summary>
430 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
431 [EditorBrowsable(EditorBrowsableState.Never)]
432 Paused = PlayStateType.Paused
434 #endregion Event, Enum, Struct, ETC
442 private string mResourceURL = null;
443 private int mRepeatCount = 0;
444 private int mFrameCount = 0;
445 private RepeatModes mRepeatMode = RepeatModes.Restart;
446 private int mMinFrame = -1, mMaxFrame = -1;
447 private bool mIsMinMaxSet = false;
448 private int mCurrentFrame = -1;
449 private EndActions mEndAction = EndActions.Cancel;
451 private string tag = "NUITEST";