2 * Copyright(c) 2020 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 global::System.Runtime.InteropServices;
20 using System.ComponentModel;
21 using System.Collections.Generic;
22 using System.Globalization;
24 namespace Tizen.NUI.BaseComponents
27 /// LottieAnimationView renders an animated vector image (Lottie file).
29 /// <since_tizen> 7 </since_tizen>
30 public class LottieAnimationView : ImageView
32 #region Constructor, Destructor, Dispose
34 /// LottieAnimationView constructor
36 /// <param name="scale">The factor of scaling image, default : 1.0f</param>
37 /// <param name="shown">false : not displayed (hidden), true : displayed (shown), default : true</param>
39 /// If the shown parameter is false, the animation is not visible even if the LottieAnimationView instance is created.
43 /// LottieAnimationView myLottie = new LottieAnimationView();
44 /// LottieAnimationView myLottie2 = new LottieAnimationView(2.0f);
45 /// LottieAnimationView myLottie3 = new LottieAnimationView(1.0f, false);
48 /// <since_tizen> 7 </since_tizen>
49 public LottieAnimationView(float scale = 1.0f, bool shown = true) : base()
51 ActionPlay = Interop.LottieAnimationView.AnimatedVectorImageVisualActionPlayGet();
52 ActionPause = Interop.LottieAnimationView.AnimatedVectorImageVisualActionPauseGet();
53 ActionStop = Interop.LottieAnimationView.AnimatedVectorImageVisualActionStopGet();
55 NUILog.Debug($"< constructor GetId={GetId()} >");
56 currentStates.url = "";
57 currentStates.frame = -1;
58 currentStates.loopCount = 1;
59 currentStates.loopMode = LoopingModeType.Restart;
60 currentStates.stopEndAction = StopBehaviorType.CurrentFrame;
61 currentStates.framePlayRangeMin = -1;
62 currentStates.framePlayRangeMax = -1;
63 currentStates.changed = false;
64 currentStates.totalFrame = -1;
65 currentStates.scale = scale;
66 currentStates.redrawInScalingDown = true;
71 /// Dispose(DisposeTypes type)
73 /// <param name="type"></param>
74 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
75 [EditorBrowsable(EditorBrowsableState.Never)]
76 protected override void Dispose(DisposeTypes type)
83 //Release your own unmanaged resources here.
84 //You should not access any managed member here except static instance.
85 //because the execution order of Finalizes is non-deterministic.
87 //disconnect event signal
88 if (finishedEventHandler != null && visualEventSignalCallback != null)
90 VisualEventSignal().Disconnect(visualEventSignalCallback);
91 finishedEventHandler = null;
92 NUILog.Debug($"disconnect event signal");
97 #endregion Constructor, Destructor, Dispose
102 /// Set or Get resource URL of Lottie file.
104 /// <since_tizen> 7 </since_tizen>
109 string ret = (value == null ? "" : value);
110 currentStates.url = ret;
111 currentStates.changed = true;
113 NUILog.Debug($"<[{GetId()}]SET url={currentStates.url}");
115 PropertyMap map = new PropertyMap();
116 map.Add(Visual.Property.Type, new PropertyValue((int)DevelVisual.Type.AnimatedVectorImage))
117 .Add(ImageVisualProperty.URL, new PropertyValue(currentStates.url))
118 .Add(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount))
119 .Add(ImageVisualProperty.StopBehavior, new PropertyValue((int)currentStates.stopEndAction))
120 .Add(ImageVisualProperty.LoopingMode, new PropertyValue((int)currentStates.loopMode));
123 currentStates.contentInfo = null;
125 if (currentStates.scale != 1.0f)
127 Scale = new Vector3(currentStates.scale, currentStates.scale, 0.0f);
129 NUILog.Debug($"<[{GetId()}]>");
133 string ret = currentStates.url;
134 NUILog.Debug($"<[{GetId()}] GET");
136 PropertyMap map = Image;
139 PropertyValue val = map.Find(ImageVisualProperty.URL);
142 if (val.Get(out ret))
144 NUILog.Debug($"gotten url={ret} >");
149 Tizen.Log.Error(tag, $" [ERROR][{GetId()}](LottieAnimationView) Fail to get URL from dali >");
155 /// Gets the playing state
157 /// <since_tizen> 7 </since_tizen>
158 public PlayStateType PlayState
162 NUILog.Debug($"< Get!");
163 PropertyMap map = base.Image;
167 PropertyValue val = map.Find(ImageVisualProperty.PlayState);
170 if (val.Get(out ret))
172 currentStates.playState = (PlayStateType)ret;
173 NUILog.Debug($"gotten play state={ret} >");
179 Tizen.Log.Error(tag, $"<[ERROR][{GetId()}]Fail to get PlayState from dali currentStates.playState={currentStates.playState}>");
181 return currentStates.playState;
186 /// Get the number of total frames
188 /// <since_tizen> 7 </since_tizen>
189 public int TotalFrame
194 PropertyMap map = Image;
197 PropertyValue val = map.Find(ImageVisualProperty.TotalFrameNumber);
200 if (val.Get(out ret))
202 //NUILog.Debug( $"TotalFrameNumber get! ret={ret}");
203 currentStates.totalFrame = ret;
208 Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get TotalFrameNumber from dali>");
214 /// Set or get the current frame. When setting a specific frame, it is displayed as a still image.
217 /// Gets the value set by a user. If the setting value is out-ranged, it is reset as a minimum frame or a maximum frame.
220 /// We assume that the animation in myLottie.json file has 100 frames originally. If so, its frame index will be 0 - 99.
222 /// LottieAnimationView myLottie = new LottieAnimationView();
223 /// myLottie.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "myLottie.json"; //myLottie.json's total frame is 100 (frame: 0~99)
224 /// NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(myLottie);
225 /// myLottie.CurrentFrame = 200; //display 99 frame
226 /// myLottie.SetMinMaxFrame(10, 20);
227 /// myLottie.CurrentFrame = 15; //display 15 frame
228 /// myLottie.CurrentFrame = 50; //display 20 frame, because the MinMax is set (10,20) above
231 /// <since_tizen> 7 </since_tizen>
232 public int CurrentFrame
236 currentStates.frame = value;
237 NUILog.Debug($"<[{GetId()}]SET frame={currentStates.frame}>");
238 DoAction(ImageView.Property.IMAGE, ActionJumpTo, new PropertyValue(currentStates.frame));
243 PropertyMap map = Image;
246 PropertyValue val = map.Find(ImageVisualProperty.CurrentFrameNumber);
249 if (val.Get(out ret))
251 //NUILog.Debug( $"CurrentFrameNumber get! val={ret}");
256 Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get CurrentFrameNumber from dali!! ret={ret}>");
262 /// Sets or gets the looping mode of Lottie animation.
264 /// <since_tizen> 7 </since_tizen>
265 public LoopingModeType LoopingMode
269 currentStates.loopMode = (LoopingModeType)value;
270 currentStates.changed = true;
272 NUILog.Debug($"<[{GetId()}] SET loopMode={currentStates.loopMode}>");
273 PropertyMap map = new PropertyMap();
274 map.Add(ImageVisualProperty.LoopingMode, new PropertyValue((int)currentStates.loopMode));
275 DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map));
279 //NUILog.Debug( $"LoopMode get!");
280 PropertyMap map = base.Image;
284 PropertyValue val = map.Find(ImageVisualProperty.LoopingMode);
287 if (val.Get(out ret))
289 //NUILog.Debug( $"gotten LoopMode={ret}");
290 if (ret != (int)currentStates.loopMode && ret > 0)
292 NUILog.Debug($" [ERROR][{GetId()}](LottieAnimationView) different LoopMode! gotten={ret}, loopMode={currentStates.loopMode}");
294 currentStates.loopMode = (LoopingModeType)ret;
295 return (LoopingModeType)ret;
299 Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get loopMode from dali>");
300 return currentStates.loopMode;
305 /// Sets or gets the loop count.
308 /// The minus value means the infinite loop count.
312 /// LottieAnimationView myLottie = new LottieAnimationView();
313 /// myLottie.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "myLottie.json"; //myLottie.json's total frame is 100 (frame: 0~99)
314 /// NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(myLottie);
315 /// myLottie.LoopCount = -1; //infinite loop
317 /// myLottie.Stop(); //it plays continuously unless Stop() is called
318 /// myLottie.LoopCount = 2;
319 /// myLottie.Play(); //it plays only 2 times and stops automatically
322 /// <since_tizen> 7 </since_tizen>
327 currentStates.changed = true;
328 currentStates.loopCount = value;
329 NUILog.Debug($"<[{GetId()}]SET currentStates.loopCount={currentStates.loopCount}>");
330 PropertyMap map = new PropertyMap();
331 map.Add(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount));
332 DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map));
336 //NUILog.Debug( $"LoopCount get!");
337 PropertyMap map = base.Image;
341 PropertyValue val = map.Find(ImageVisualProperty.LoopCount);
344 if (val.Get(out ret))
346 //NUILog.Debug( $"gotten loop count={ret}");
347 if (ret != currentStates.loopCount && ret > 0)
349 NUILog.Debug($"<[ERROR][{GetId()}](LottieAnimationView) different loop count! gotten={ret}, loopCount={currentStates.loopCount}>");
351 currentStates.loopCount = ret;
352 return currentStates.loopCount;
356 Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get LoopCount from dali currentStates.loopCount={currentStates.loopCount}>");
357 return currentStates.loopCount;
362 /// Sets or gets the stop behavior.
364 /// <since_tizen> 7 </since_tizen>
365 public StopBehaviorType StopBehavior
369 currentStates.stopEndAction = (StopBehaviorType)value;
370 currentStates.changed = true;
372 NUILog.Debug($"<[{GetId()}]SET val={currentStates.stopEndAction}>");
373 PropertyMap map = new PropertyMap();
374 map.Add(ImageVisualProperty.StopBehavior, new PropertyValue((int)currentStates.stopEndAction));
375 DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map));
379 //NUILog.Debug( $"StopBehavior get!");
380 PropertyMap map = base.Image;
384 PropertyValue val = map.Find(ImageVisualProperty.StopBehavior);
387 if (val.Get(out ret))
389 //NUILog.Debug( $"gotten StopBehavior={ret}");
390 if (ret != (int)currentStates.stopEndAction)
392 NUILog.Debug($"<[ERROR][{GetId()}](LottieAnimationView) different StopBehavior! gotten={ret}, StopBehavior={currentStates.stopEndAction}>");
394 currentStates.stopEndAction = (StopBehaviorType)ret;
395 return (StopBehaviorType)ret;
399 Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get StopBehavior from dali>");
400 return currentStates.stopEndAction;
405 /// Whether to redraw the image when the visual is scaled down.
409 /// It is used in the AnimatedVectorImageVisual.The default is true.
411 [EditorBrowsable(EditorBrowsableState.Never)]
412 public bool RedrawInScalingDown
416 currentStates.changed = true;
417 currentStates.redrawInScalingDown = value;
418 NUILog.Debug($"<[{GetId()}]SET currentStates.redrawInScalingDown={currentStates.redrawInScalingDown}>");
419 PropertyMap map = new PropertyMap();
420 map.Add(ImageVisualProperty.RedrawInScalingDown, new PropertyValue(currentStates.redrawInScalingDown));
421 DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map));
425 PropertyMap map = base.Image;
429 PropertyValue val = map.Find(ImageVisualProperty.RedrawInScalingDown);
432 if (val.Get(out ret))
434 if (ret != currentStates.redrawInScalingDown)
436 NUILog.Debug($"<[ERROR][{GetId()}](LottieAnimationView) different redrawInScalingDown! gotten={ret}, redrawInScalingDown={currentStates.redrawInScalingDown}>");
438 currentStates.redrawInScalingDown = ret;
439 return currentStates.redrawInScalingDown;
443 Tizen.Log.Error(tag, $"<[ERROR][{GetId()}](LottieAnimationView) Fail to get redrawInScalingDown from dali currentStates.redrawInScalingDown={currentStates.redrawInScalingDown}>");
444 return currentStates.redrawInScalingDown;
450 /// Actions property value to Jump to the specified frame.
451 /// This property can be redefined by child class if it use different value.
453 [EditorBrowsable(EditorBrowsableState.Never)]
454 protected int ActionJumpTo { get; set; } = Interop.LottieAnimationView.AnimatedVectorImageVisualActionJumpToGet();
460 /// Set the minimum and the maximum frame.
462 /// <param name="minFrame">minimum frame</param>
463 /// <param name="maxFrame">maximum frame</param>
464 /// <since_tizen> 7 </since_tizen>
465 public void SetMinMaxFrame(int minFrame, int maxFrame)
467 NUILog.Debug($"< [{GetId()}] SetPlayRange({minFrame}, {maxFrame})");
469 currentStates.changed = true;
470 currentStates.framePlayRangeMin = minFrame;
471 currentStates.framePlayRangeMax = maxFrame;
473 PropertyArray array = new PropertyArray();
474 array.PushBack(new PropertyValue(currentStates.framePlayRangeMin));
475 array.PushBack(new PropertyValue(currentStates.framePlayRangeMax));
477 PropertyMap map = new PropertyMap();
478 map.Add(ImageVisualProperty.PlayRange, new PropertyValue(array));
479 DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map));
480 NUILog.Debug($" [{GetId()}] currentStates.min:({currentStates.framePlayRangeMin}, max:{currentStates.framePlayRangeMax})>");
486 /// <since_tizen> 7 </since_tizen>
487 public new void Play()
489 NUILog.Debug($"<[{GetId()}] Play()");
492 NUILog.Debug($"[{GetId()}]>");
498 /// <since_tizen> 7 </since_tizen>
499 public new void Pause()
501 NUILog.Debug($"<[{GetId()}] Pause()>");
504 NUILog.Debug($"[{GetId()}]>");
510 /// <since_tizen> 7 </since_tizen>
511 public new void Stop()
513 NUILog.Debug($"<[{GetId()}] Stop()");
516 NUILog.Debug($"[{GetId()}]>");
520 /// Get the list of layers' information such as the start frame and the end frame in the Lottie file.
522 /// <returns>List of Tuple (string of layer name, integer of start frame, integer of end frame)</returns>
523 /// <since_tizen> 7 </since_tizen>
524 public List<Tuple<string, int, int>> GetContentInfo()
527 if (currentStates.contentInfo != null)
529 return currentStates.contentInfo;
532 PropertyMap imageMap = base.Image;
533 PropertyMap contentMap = new PropertyMap();
534 if (imageMap != null)
536 PropertyValue val = imageMap.Find(ImageVisualProperty.ContentInfo);
539 if (val.Get(contentMap))
541 currentStates.contentInfo = new List<Tuple<string, int, int>>();
542 for (uint i = 0; i < contentMap.Count(); i++)
544 string key = contentMap.GetKeyAt(i).StringKey;
545 PropertyArray arr = new PropertyArray();
546 contentMap.GetValue(i).Get(arr);
549 int startFrame, endFrame;
550 arr.GetElementAt(0).Get(out startFrame);
551 arr.GetElementAt(1).Get(out endFrame);
553 NUILog.Debug($"[{i}] layer name={key}, startFrame={startFrame}, endFrame={endFrame}");
555 Tuple<string, int, int> item = new Tuple<string, int, int>(key, startFrame, endFrame);
557 currentStates.contentInfo?.Add(item);
564 return currentStates.contentInfo;
568 /// A marker has its start frame and end frame.
569 /// Animation will play between the start frame and the end frame of the marker if one marker is specified.
570 /// 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. *
572 /// <param name="marker1">First marker</param>
573 /// <param name="marker2">Second marker</param>
574 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
575 [EditorBrowsable(EditorBrowsableState.Never)]
576 public void SetMinMaxFrameByMarker(string marker1, string marker2 = null)
578 NUILog.Debug($"< [{GetId()}] SetMinMaxFrameByMarker({marker1}, {marker2})");
580 currentStates.changed = true;
581 currentStates.mark1 = marker1;
582 currentStates.mark2 = marker2;
584 PropertyArray array = new PropertyArray();
585 array.PushBack(new PropertyValue(currentStates.mark1));
588 array.PushBack(new PropertyValue(currentStates.mark2));
591 PropertyMap map = new PropertyMap();
592 map.Add(ImageVisualProperty.PlayRange, new PropertyValue(array));
593 DoAction(ImageView.Property.IMAGE, Interop.Visual.GetActionUpdateProperty(), new PropertyValue(map));
594 NUILog.Debug($" [{GetId()}] currentStates.mark1:{currentStates.mark1}, mark2:{currentStates.mark2} >");
600 /// <returns>Tuple of Min and Max frames</returns>
601 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
602 [EditorBrowsable(EditorBrowsableState.Never)]
603 public Tuple<int, int> GetMinMaxFrame()
605 NUILog.Debug($"< [{GetId()}] GetMinMaxFrame()! total frame={currentStates.totalFrame}");
607 PropertyMap map = Image;
610 PropertyValue val = map.Find(ImageVisualProperty.PlayRange);
613 PropertyArray array = new PropertyArray();
616 uint cnt = array.Count();
617 int item1 = -1, item2 = -1;
618 for (uint i = 0; i < cnt; i++)
620 PropertyValue v = array.GetElementAt(i);
622 if (v.Get(out intRet))
624 NUILog.Debug($"Got play range of string [{i}]: {intRet}");
636 Tizen.Log.Error("NUI", $"[ERR] fail to get play range from dali! case#1");
639 NUILog.Debug($" [{GetId()}] GetMinMaxFrame(min:{item1}, max:{item2})! >");
640 return new Tuple<int, int>(item1, item2);
644 Tizen.Log.Error("NUI", $"[ERR] fail to get play range from dali! case#2");
645 return new Tuple<int, int>(-1, -1);
650 #region Event, Enum, Struct, ETC
652 /// Animation finished event.
654 /// <since_tizen> 7 </since_tizen>
655 public event EventHandler Finished
659 if (finishedEventHandler == null)
661 NUILog.Debug($"<[{GetId()}] Finished eventhandler added>");
662 visualEventSignalCallback = onVisualEventSignal;
663 VisualEventSignal().Connect(visualEventSignalCallback);
665 finishedEventHandler += value;
669 NUILog.Debug($"<[{GetId()}] Finished eventhandler removed>");
670 finishedEventHandler -= value;
671 if (finishedEventHandler == null && visualEventSignalCallback != null)
673 VisualEventSignal().Disconnect(visualEventSignalCallback);
679 /// Enumeration for what state the vector animation is in
681 /// <since_tizen> 7 </since_tizen>
682 public enum PlayStateType
687 /// <since_tizen> 7 </since_tizen>
690 /// Vector Animation has stopped
692 /// <since_tizen> 7 </since_tizen>
695 /// The vector animation is playing
697 /// <since_tizen> 7 </since_tizen>
700 /// The vector animation is paused
702 /// <since_tizen> 7 </since_tizen>
707 /// Enumeration for what to do when the animation is stopped.
709 /// <since_tizen> 7 </since_tizen>
710 public enum StopBehaviorType
713 /// When the animation is stopped, the current frame is shown.
715 /// <since_tizen> 7 </since_tizen>
718 /// When the animation is stopped, the min frame (first frame) is shown.
720 /// <since_tizen> 7 </since_tizen>
723 /// When the animation is stopped, the max frame (last frame) is shown.
725 /// <since_tizen> 7 </since_tizen>
730 /// Enumeration for what looping mode is in.
732 /// <since_tizen> 7 </since_tizen>
733 public enum LoopingModeType
736 /// When the animation arrives at the end in looping mode, the animation restarts from the beginning.
738 /// <since_tizen> 7 </since_tizen>
741 /// When the animation arrives at the end in looping mode, the animation reverses direction and runs backwards again.
743 /// <since_tizen> 7 </since_tizen>
746 #endregion Event, Enum, Struct, ETC
750 internal class VisualEventSignalArgs : EventArgs
752 public int VisualIndex
764 internal event EventHandler<VisualEventSignalArgs> VisualEvent
768 if (visualEventSignalHandler == null)
770 visualEventSignalCallback = onVisualEventSignal;
771 VisualEventSignal().Connect(visualEventSignalCallback);
773 visualEventSignalHandler += value;
777 visualEventSignalHandler -= value;
778 if (visualEventSignalHandler == null && VisualEventSignal().Empty() == false)
780 VisualEventSignal().Disconnect(visualEventSignalCallback);
785 internal void EmitVisualEventSignal(int visualIndex, int signalId)
787 VisualEventSignal().Emit(this, visualIndex, signalId);
790 internal VisualEventSignal VisualEventSignal()
792 VisualEventSignal ret = new VisualEventSignal(Interop.VisualEventSignal.NewWithView(View.getCPtr(this)), false);
793 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
800 private struct states
804 internal int loopCount;
805 internal LoopingModeType loopMode;
806 internal StopBehaviorType stopEndAction;
807 internal int framePlayRangeMin;
808 internal int framePlayRangeMax;
809 internal bool changed;
810 internal int totalFrame;
811 internal float scale;
812 internal PlayStateType playState;
813 internal List<Tuple<string, int, int>> contentInfo;
814 internal string mark1, mark2;
815 internal bool redrawInScalingDown;
817 private states currentStates;
819 private struct DevelVisual
823 AnimatedGradient = Visual.Type.AnimatedImage + 1,
824 AnimatedVectorImage = Visual.Type.AnimatedImage + 2,
828 private const string tag = "NUITEST";
829 private event EventHandler finishedEventHandler;
831 private void OnFinished()
833 NUILog.Debug($"<[{GetId()}] OnFinished()>");
834 finishedEventHandler?.Invoke(this, null);
837 private void onVisualEventSignal(IntPtr targetView, int visualIndex, int signalId)
841 if (targetView != IntPtr.Zero)
843 View v = Registry.GetManagedBaseHandleFromNativePtr(targetView) as View;
846 NUILog.Debug($"targetView is not null! name={v.Name}");
850 NUILog.Debug($"target is something created from dali");
853 VisualEventSignalArgs e = new VisualEventSignalArgs();
854 e.VisualIndex = visualIndex;
855 e.SignalId = signalId;
856 visualEventSignalHandler?.Invoke(this, e);
858 NUILog.Debug($"<[{GetId()}] onVisualEventSignal()! visualIndex={visualIndex}, signalId={signalId}>");
861 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
862 private delegate void VisualEventSignalCallbackType(IntPtr targetView, int visualIndex, int signalId);
864 private VisualEventSignalCallbackType visualEventSignalCallback;
865 private EventHandler<VisualEventSignalArgs> visualEventSignalHandler;
867 private void debugPrint()
869 NUILog.Debug($"===================================");
870 NUILog.Debug($"<[{GetId()}] get currentStates : url={currentStates.url}, loopCount={currentStates.loopCount}, \nframePlayRangeMin/Max({currentStates.framePlayRangeMin},{currentStates.framePlayRangeMax}) ");
871 NUILog.Debug($" get from Property : StopBehavior={StopBehavior}, LoopMode={LoopingMode}, LoopCount={LoopCount}, PlayState={PlayState}");
872 NUILog.Debug($" RedrawInScalingDown={RedrawInScalingDown} >");
873 NUILog.Debug($"===================================");
879 /// A class containing frame informations for a LottieAnimationView.
881 [EditorBrowsable(EditorBrowsableState.Never)]
882 public class LottieFrameInfo : ICloneable
885 /// Creates a new instance with a playing range.
887 [EditorBrowsable(EditorBrowsableState.Never)]
888 public LottieFrameInfo(int startFrame, int endFrame)
890 StartFrame = startFrame;
895 /// Creates a new instance with a still image frame.
897 [EditorBrowsable(EditorBrowsableState.Never)]
898 public LottieFrameInfo(int stillImageFrame) : this(stillImageFrame, stillImageFrame)
903 /// Create a new instance from a pair notation.
905 [EditorBrowsable(EditorBrowsableState.Never)]
906 public static implicit operator LottieFrameInfo((int, int) pair)
908 return new LottieFrameInfo(pair.Item1, pair.Item2);
912 /// Create a new instance from an int value.
914 [EditorBrowsable(EditorBrowsableState.Never)]
915 public static implicit operator LottieFrameInfo(int stillImageFrame)
917 return new LottieFrameInfo(stillImageFrame);
921 /// Create a new instance from string.
922 /// Possible input : "0, 10", "10"
924 [EditorBrowsable(EditorBrowsableState.Never)]
925 public static implicit operator LottieFrameInfo(string pair)
932 string[] parts = pair.Split(',');
933 if (parts.Length == 1)
935 return new LottieFrameInfo(Int32.Parse(parts[0].Trim(), CultureInfo.InvariantCulture));
937 else if (parts.Length == 2)
939 return new LottieFrameInfo(Int32.Parse(parts[0].Trim(), CultureInfo.InvariantCulture), Int32.Parse(parts[1].Trim(), CultureInfo.InvariantCulture));
942 Tizen.Log.Error("NUI", $"Can not convert string {pair} to LottieFrameInfo");
947 /// The start frame of the lottie animation.
949 [EditorBrowsable(EditorBrowsableState.Never)]
950 public int StartFrame { get; }
953 /// The end frame of the lottie animation.
955 [EditorBrowsable(EditorBrowsableState.Never)]
956 public int EndFrame { get; }
959 /// Create LottieFrameInfo struct with animation range information
961 [EditorBrowsable(EditorBrowsableState.Never)]
962 public static LottieFrameInfo CreateAnimationRange(int startFrame, int endFrame)
964 return new LottieFrameInfo(startFrame, endFrame);
968 /// Create LottieFrameInfo struct with still image information
970 [EditorBrowsable(EditorBrowsableState.Never)]
971 public static LottieFrameInfo CreateStillImage(int stillImageFrame)
973 return new LottieFrameInfo(stillImageFrame, stillImageFrame);
978 /// Whether this LottieFrameInfo represents one frame or more.
980 [EditorBrowsable(EditorBrowsableState.Never)]
981 public bool IsStillImage()
983 return StartFrame == EndFrame;
988 /// Play specified LottieAnimationView with this frame information.
990 /// <param name="lottieView">The target LottieAnimationView to play.</param>
991 /// <param name="noPlay">Whether go direct to the EndFrame. It is false by default.</param>
992 [EditorBrowsable(EditorBrowsableState.Never)]
993 public void Show(LottieAnimationView lottieView, bool noPlay = false)
995 if (!BeReadyToShow(lottieView))
1000 lottieView.SetMinMaxFrame(StartFrame, Math.Min(EndFrame, lottieView.TotalFrame - 1));
1002 if (IsStillImage() || noPlay)
1004 lottieView.CurrentFrame = EndFrame;
1008 lottieView.CurrentFrame = StartFrame;
1014 [EditorBrowsable(EditorBrowsableState.Never)]
1015 public object Clone() => new LottieFrameInfo(StartFrame, EndFrame);
1017 private bool BeReadyToShow(LottieAnimationView lottieView)
1019 // Validate input lottieView
1020 if (null == lottieView || lottieView.PlayState == LottieAnimationView.PlayStateType.Invalid)
1025 // Stop if it was playing
1026 if (lottieView.PlayState == LottieAnimationView.PlayStateType.Playing)