2 * Copyright(c) 2021 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.
21 using System.ComponentModel;
22 using System.Runtime.InteropServices;
23 using System.Collections.Generic;
25 using System.Reflection;
26 using System.Globalization;
27 using System.Diagnostics.CodeAnalysis;
29 using Tizen.NUI.BaseComponents;
32 /// Animation can be used to animate the properties of any number of objects, typically view.<br />
33 /// If the "Finished" event is connected to a member function of an object, it must be disconnected before the object is destroyed.<br />
34 /// This is typically done in the object destructor, and requires either the animation handle to be stored.<br />
35 /// The overall animation time is superseded by the values given in the animation time used when calling the AnimateTo(), AnimateBy(), AnimateBetween() and AnimatePath() methods.<br />
36 /// If any of the individual calls to those functions exceeds the overall animation time (Duration), then the overall animation time is automatically extended.<br />
38 /// <since_tizen> 3 </since_tizen>
39 public class Animation : BaseHandle
41 private static bool? disableAnimation = null;
43 private AnimationFinishedEventCallbackType animationFinishedEventCallback;
44 private System.IntPtr finishedCallbackOfNative;
46 private AnimationProgressReachedEventCallbackType animationProgressReachedEventCallback;
48 private string[] properties = null;
49 private string[] destValue = null;
50 private int[] startTime = null;
51 private int[] endTime = null;
53 private List<string> propertyList = null;
54 private List<string> destValueList = null;
55 private List<int> startTimeList = null;
56 private List<int> endTimeList = null;
59 /// Creates an initialized animation.<br />
60 /// The animation will not loop.<br />
61 /// The default end action is "Cancel".<br />
62 /// The default alpha function is linear.<br />
64 /// <remarks>DurationmSeconds must be greater than zero.</remarks>
65 /// <param name="durationMilliSeconds">The duration in milliseconds.</param>
66 /// <since_tizen> 3 </since_tizen>
67 public Animation(int durationMilliSeconds) : this(Interop.Animation.New((float)durationMilliSeconds / 1000.0f), true)
69 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 internal Animation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
74 animationFinishedEventCallback = OnFinished;
75 finishedCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(animationFinishedEventCallback);
78 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79 private delegate void AnimationFinishedEventCallbackType(IntPtr data);
81 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82 private delegate void AnimationProgressReachedEventCallbackType(IntPtr data);
84 private event EventHandler animationFinishedEventHandler;
87 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler.<br />
88 /// The finished signal is emitted when an animation's animations have finished.<br />
90 /// <since_tizen> 3 </since_tizen>
91 public event EventHandler Finished
95 if (animationFinishedEventHandler == null && disposed == false)
97 AnimationSignal finishedSignal = FinishedSignal();
98 finishedSignal.Connect(finishedCallbackOfNative);
99 finishedSignal.Dispose();
101 animationFinishedEventHandler += value;
105 animationFinishedEventHandler -= value;
107 AnimationSignal finishedSignal = FinishedSignal();
108 if (animationFinishedEventHandler == null && finishedSignal.Empty() == false)
110 finishedSignal.Disconnect(finishedCallbackOfNative);
112 finishedSignal.Dispose();
116 private event EventHandler animationProgressReachedEventHandler;
119 /// Event for the ProgressReached signal, which can be used to subscribe or unsubscribe the event handler.<br />
120 /// The ProgressReached signal is emitted when the animation has reached a given progress percentage, this is set in the api SetProgressNotification.<br />
123 /// This value only be applied if animation state is Stopped.
125 /// <since_tizen> 3 </since_tizen>
126 public event EventHandler ProgressReached
130 if (animationProgressReachedEventHandler == null)
132 animationProgressReachedEventCallback = OnProgressReached;
133 AnimationSignal progressReachedSignal = ProgressReachedSignal();
134 progressReachedSignal?.Connect(animationProgressReachedEventCallback);
135 progressReachedSignal?.Dispose();
138 animationProgressReachedEventHandler += value;
142 animationProgressReachedEventHandler -= value;
144 AnimationSignal progressReachedSignal = ProgressReachedSignal();
145 if (animationProgressReachedEventHandler == null && progressReachedSignal?.Empty() == false)
147 progressReachedSignal?.Disconnect(animationProgressReachedEventCallback);
149 progressReachedSignal.Dispose();
154 /// Enumeration for what to do when the animation ends, stopped, or destroyed.
156 /// <since_tizen> 3 </since_tizen>
157 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
158 public enum EndActions
161 /// When the animation ends, the animated property values are saved.
165 /// When the animation ends, the animated property values are forgotten.
169 /// If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like cancel.
175 /// Enumeration for what interpolation method to use on key-frame animations.
177 /// <since_tizen> 3 </since_tizen>
178 public enum Interpolation
181 /// Values in between key frames are interpolated using a linear polynomial. (Default)
185 /// Values in between key frames are interpolated using a cubic polynomial.
191 /// Enumeration for what state the animation is in.
193 /// <remarks>Calling Reset() on this class will not reset the animation. It will call the BaseHandle.Reset() which drops the object handle.</remarks>
194 /// <since_tizen> 3 </since_tizen>
195 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
199 /// The animation has stopped.
203 /// The animation is playing.
207 /// The animation is paused.
213 /// Enumeration for what looping mode is in.
215 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
216 [EditorBrowsable(EditorBrowsableState.Never)]
217 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
218 public enum LoopingModes
221 /// When the animation arrives at the end in looping mode, the animation restarts from the beginning. (Default)
223 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
224 [EditorBrowsable(EditorBrowsableState.Never)]
227 /// When the animation arrives at the end in looping mode, the animation reverses direction and runs backwards again.
229 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
230 [EditorBrowsable(EditorBrowsableState.Never)]
235 /// Gets or sets the duration in milliseconds of the animation.
236 /// This duration is applied to the animations are added after the Duration is set.
240 /// animation.AnimateTo(actor, "position", destination);
241 /// animation.Duration = 500; // This duration 500 is only applied to the size animation.
242 /// animation.AnimateTo(actor, "size", size);
245 /// <since_tizen> 3 </since_tizen>
250 SetDuration(MilliSecondsToSeconds(value));
254 return SecondsToMilliSeconds(GetDuration());
259 /// Gets or sets the default alpha function for the animation.
260 /// This DefaultAlphaFunction is only applied to the animations are added after the DefaultAlphaFunction is set.
264 /// animation.AnimateTo(actor, "position", destination);
265 /// animation.DefaultAlphaFunction = newAlphaFunction; // This newAlphaFunction is applied only for the size animation.
266 /// animation.AnimateTo(actor, "size", size);
269 /// <since_tizen> 3 </since_tizen>
270 public AlphaFunction DefaultAlphaFunction
274 SetDefaultAlphaFunction(value);
278 AlphaFunction ret = GetDefaultAlphaFunction();
284 /// Queries the state of the animation.
286 /// <since_tizen> 3 </since_tizen>
296 /// Set: Enables looping for a specified number of repeats. A zero is the same as Looping = true; i.e., repeat forever.<br />
297 /// This property resets the looping value and should not be used with the Looping property.<br />
298 /// Setting this parameter does not cause the animation to Play().<br />
299 /// Get: Gets the loop count. A zero is the same as Looping = true; i.e., repeat forever.<br />
300 /// The loop count is initially 1 for play once.<br />
302 /// <since_tizen> 3 </since_tizen>
311 int ret = GetLoopCount();
317 /// Gets or sets the status of whether the animation will loop.<br />
318 /// This property resets the loop count and should not be used with the LoopCount property.<br />
319 /// Setting this parameter does not cause the animation to Play().<br />
321 /// <since_tizen> 3 </since_tizen>
330 bool ret = IsLooping();
337 /// Gets or sets the end action of the animation.<br />
338 /// This action is performed when the animation ends or if it is stopped.<br />
339 /// The default end action is EndActions.Cancel.<br />
342 /// Change the action value from EndActions.Discard, or to EndActions.Discard during animation is playing / paused will not works well.
344 /// <since_tizen> 3 </since_tizen>
345 public EndActions EndAction
353 return GetEndAction();
358 /// Gets the current loop count.<br />
359 /// A value 0 indicating the current loop count when looping.<br />
361 /// <since_tizen> 3 </since_tizen>
362 public int CurrentLoop
366 return GetCurrentLoop();
371 /// Gets or sets the disconnect action.<br />
372 /// If any of the animated property owners are disconnected from the stage while the animation is being played, then this action is performed.<br />
373 /// The default action is EndActions.StopFinal.<br />
375 /// <since_tizen> 3 </since_tizen>
376 public EndActions DisconnectAction
380 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)value);
381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
393 /// Gets or sets the progress of the animation.<br />
394 /// The animation will play (or continue playing) from this point.<br />
395 /// The progress must be in the 0-1 interval or in the play range interval if defined<br />
396 /// otherwise, it will be ignored.<br />
398 /// <since_tizen> 3 </since_tizen>
399 public float CurrentProgress
403 Interop.Animation.SetCurrentProgress(SwigCPtr, value);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
415 /// Gets or sets specifications of a speed factor for the animation.<br />
416 /// The speed factor is a multiplier of the normal velocity of the animation.<br />
417 /// Values between [0, 1] will slow down the animation and values above one will speed up the animation.<br />
418 /// It is also possible to specify a negative multiplier to play the animation in reverse.<br />
420 /// <since_tizen> 3 </since_tizen>
421 public float SpeedFactor
425 Interop.Animation.SetSpeedFactor(SwigCPtr, value);
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
431 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
437 /// Gets or sets the playing range.<br />
438 /// Animation will play between the values specified. Both values (range.x and range.y ) should be between 0-1,
439 /// otherwise they will be ignored. If the range provided is not in proper order (minimum, maximum ), it will be reordered.<br />
441 /// <since_tizen> 3 </since_tizen>
442 public RelativeVector2 PlayRange
446 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(value));
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
452 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
459 /// Gets or sets the progress notification marker which triggers the ProgressReachedSignal.<br />
460 /// Percentage of animation progress should be greater than 0 and less than 1, for example, 0.3 for 30%<br />
461 /// One notification can be set on each animation.
464 /// This value only be applied if animation state is Stopped.
466 /// <since_tizen> 3 </since_tizen>
467 public float ProgressNotification
471 Interop.Animation.SetProgressNotification(SwigCPtr, value);
472 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 float ret = Interop.Animation.GetProgressNotification(SwigCPtr);
477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
483 /// Enumeration for what looping mode is in.
485 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
486 [EditorBrowsable(EditorBrowsableState.Never)]
487 public LoopingModes LoopingMode
491 Interop.Animation.SetLoopingMode(SwigCPtr, (int)value);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496 Animation.LoopingModes ret = (Animation.LoopingModes)Interop.Animation.GetLoopingMode(SwigCPtr);
497 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
503 /// Sets and Gets the blend point to interpolate animate property
505 /// BlendPoint is a value between [0,1], If the value of the keyframe whose progress is 0 is different from the current value,
506 /// the property is animated as it smoothly blends until the progress reaches the blendPoint.
509 /// The blend point only affects animation registered with AnimateBetween. Other animations operate the same as when Play() is called.
510 /// And the blend point needs to be set before this animation plays. If the blend point changes after playback, animation continuity cannot be guaranteed.
513 /// In the case of a looping animation, the animation is blended only in the first loop.
515 [EditorBrowsable(EditorBrowsableState.Never)]
516 public float BlendPoint
520 Interop.Animation.SetBlendPoint(SwigCPtr, value);
521 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
525 float ret = Interop.Animation.GetBlendPoint(SwigCPtr);
526 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
532 /// Gets or sets the properties of the animation.
534 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use PropertyList instead")]
535 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
536 public string[] Properties
549 /// Gets or sets the destination value for each property of the animation.
551 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use DestValueList instead")]
552 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
553 public string[] DestValue
566 /// Gets or sets the start time for each property of the animation.
568 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use StartTimeList instead")]
569 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
570 public int[] StartTime
583 /// Gets or sets the end time for each property of the animation.
585 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use EndTimeList instead")]
586 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
600 /// Get the list of the properties of the animation.
602 [EditorBrowsable(EditorBrowsableState.Never)]
603 public IList<string> PropertyList
607 if (null == propertyList)
609 propertyList = new List<string>();
617 /// Get the list of the destination value for each property of the animation.
619 [EditorBrowsable(EditorBrowsableState.Never)]
620 public IList<string> DestValueList
624 if (null == destValueList)
626 destValueList = new List<string>();
629 return destValueList;
634 /// Get the list of the start time for each property of the animation.
636 [EditorBrowsable(EditorBrowsableState.Never)]
637 public IList<int> StartTimeList
641 if (null == startTimeList)
643 startTimeList = new List<int>();
646 return startTimeList;
651 /// Get the list of end time for each property of the animation.
653 [EditorBrowsable(EditorBrowsableState.Never)]
654 public IList<int> EndTimeList
658 if (null == endTimeList)
660 endTimeList = new List<int>();
667 private bool DisableAnimation
671 if (disableAnimation.HasValue == false)
673 string type = Environment.GetEnvironmentVariable("PlatformSmartType");
675 disableAnimation = true;
677 disableAnimation = false;
679 return disableAnimation.Value;
684 /// Downcasts a handle to animation handle.<br />
685 /// If handle points to an animation object, the downcast produces a valid handle.<br />
686 /// If not, the returned handle is left uninitialized.<br />
688 /// <param name="handle">Handle to an object.</param>
689 /// <returns>Handle to an animation object or an uninitialized handle.</returns>
690 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
691 internal static Animation DownCast(BaseHandle handle)
695 throw new ArgumentNullException(nameof(handle));
697 Animation ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Animation;
698 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
703 /// Stops the animation. It will change this animation's EndAction property.
706 /// Change the value from EndActions.Discard, or to EndActions.Discard during animation is playing / paused will not works well.<br />
707 /// If you want to stop by EndActions.Discard, EndAction property also should be EndActions.Discard before Play API called.
709 /// <param name="action">The end action can be set.</param>
710 /// <since_tizen> 3 </since_tizen>
711 public void Stop(EndActions action)
713 SetEndAction(action);
714 Interop.Animation.Stop(SwigCPtr);
715 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719 /// Animates a property value by a relative amount.<br />
721 /// <param name="target">The target animatable object to animate.</param>
722 /// <param name="property">The target property to animate.</param>
723 /// <param name="relativeValue">The property value will change by this amount.</param>
724 /// <param name="alphaFunction">The alpha function to apply.</param>
725 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
726 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
727 /// This will not be public opened.
728 [EditorBrowsable(EditorBrowsableState.Never)]
729 public void AnimateBy(Animatable target, string property, object relativeValue, AlphaFunction alphaFunction = null)
733 throw new ArgumentNullException(nameof(target));
735 if (property == null)
737 throw new ArgumentNullException(nameof(property));
739 if (relativeValue == null)
741 throw new ArgumentNullException(nameof(relativeValue));
744 using (var result = PropertyHelper.Search(target, property))
748 throw new ArgumentException("string property is invalid");
751 var current = result;
752 while (current != null)
755 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
756 if (targetValueIntPtr == global::System.IntPtr.Zero)
758 throw new ArgumentException("Invalid " + nameof(relativeValue));
760 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction);
761 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
762 current = current.NextResult;
768 /// Animates a property value by a relative amount.<br />
770 /// <param name="target">The target animatable object to animate.</param>
771 /// <param name="property">The target property to animate.</param>
772 /// <param name="relativeValue">The property value will change by this amount.</param>
773 /// <param name="startTime">The start time of the animation.</param>
774 /// <param name="endTime">The end time of the animation.</param>
775 /// <param name="alphaFunction">The alpha function to apply.</param>
776 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
777 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
778 /// This will not be public opened.
779 [EditorBrowsable(EditorBrowsableState.Never)]
780 public void AnimateBy(Animatable target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
784 throw new ArgumentNullException(nameof(target));
786 if (property == null)
788 throw new ArgumentNullException(nameof(property));
790 if (relativeValue == null)
792 throw new ArgumentNullException(nameof(relativeValue));
795 using (var result = PropertyHelper.Search(target, property))
799 throw new ArgumentException("string property is invalid");
802 var current = result;
803 using (var time = new TimePeriod(startTime, endTime - startTime))
804 while (current != null)
807 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
808 if (targetValueIntPtr == global::System.IntPtr.Zero)
810 throw new ArgumentException("Invalid " + nameof(relativeValue));
812 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
813 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
814 current = current.NextResult;
820 /// Animates a property value by a relative amount.<br />
822 /// <param name="target">The target object to animate.</param>
823 /// <param name="property">The target property to animate.</param>
824 /// <param name="relativeValue">The property value will change by this amount.</param>
825 /// <param name="alphaFunction">The alpha function to apply.</param>
826 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
827 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
828 /// <since_tizen> 3 </since_tizen>
829 public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
831 AnimateBy(target as Animatable, property, relativeValue, alphaFunction);
835 /// Animates a property value by a relative amount.<br />
837 /// <param name="target">The target object to animate.</param>
838 /// <param name="property">The target property to animate.</param>
839 /// <param name="relativeValue">The property value will change by this amount.</param>
840 /// <param name="startTime">The start time of the animation.</param>
841 /// <param name="endTime">The end time of the animation.</param>
842 /// <param name="alphaFunction">The alpha function to apply.</param>
843 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
844 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
845 /// <since_tizen> 3 </since_tizen>
846 public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
848 AnimateBy(target as Animatable, property, relativeValue, startTime, endTime, alphaFunction);
852 /// Animates a property to a destination value.<br />
854 /// <param name="target">The target animatable object to animate.</param>
855 /// <param name="property">The target property to animate.</param>
856 /// <param name="destinationValue">The destination value.</param>
857 /// <param name="alphaFunction">The alpha function to apply.</param>
858 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
859 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
860 /// This will not be public opened.
861 [EditorBrowsable(EditorBrowsableState.Never)]
862 public void AnimateTo(Animatable target, string property, object destinationValue, AlphaFunction alphaFunction = null)
866 throw new ArgumentNullException(nameof(target));
868 if (property == null)
870 throw new ArgumentNullException(nameof(property));
872 if (destinationValue == null)
874 throw new ArgumentNullException(nameof(destinationValue));
877 using (var result = PropertyHelper.Search(target, property))
881 throw new ArgumentException("string property is invalid");
884 var current = result;
885 while (current != null)
888 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
889 if (targetValueIntPtr == global::System.IntPtr.Zero)
891 throw new ArgumentException("Invalid " + nameof(destinationValue));
893 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction);
894 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
895 current = current.NextResult;
901 /// Animates a property to a destination value.<br />
903 /// <param name="target">The target animatable object to animate.</param>
904 /// <param name="property">The target property to animate.</param>
905 /// <param name="destinationValue">The destination value.</param>
906 /// <param name="startTime">The start time of the animation.</param>
907 /// <param name="endTime">The end time of the animation.</param>
908 /// <param name="alphaFunction">The alpha function to apply.</param>
909 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
910 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
911 /// This will not be public opened.
912 [EditorBrowsable(EditorBrowsableState.Never)]
913 public void AnimateTo(Animatable target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
917 throw new ArgumentNullException(nameof(target));
919 if (property == null)
921 throw new ArgumentNullException(nameof(property));
923 if (destinationValue == null)
925 throw new ArgumentNullException(nameof(destinationValue));
928 using (var result = PropertyHelper.Search(target, property))
932 throw new ArgumentException("string property is invalid");
935 var current = result;
936 using (var time = new TimePeriod(startTime, endTime - startTime))
937 while (current != null)
939 #if NUI_ANIMATION_PROPERTY_CHANGE_1
940 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
941 if (targetValueIntPtr == global::System.IntPtr.Zero)
943 throw new ArgumentException("Invalid " + nameof(destinationValue));
945 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
946 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
948 var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
949 AnimateTo(current.Property, targetValue, alphaFunction, time);
950 targetValue.Dispose();
952 current = current.NextResult;
958 /// Animates a property to a destination value.<br />
960 /// <param name="target">The target object to animate.</param>
961 /// <param name="property">The target property to animate.</param>
962 /// <param name="destinationValue">The destination value.</param>
963 /// <param name="alphaFunction">The alpha function to apply.</param>
964 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
965 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
966 /// <since_tizen> 3 </since_tizen>
967 public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
969 AnimateTo(target as Animatable, property, destinationValue, alphaFunction);
973 /// Animates a property to a destination value.<br />
975 /// <param name="target">The target object to animate.</param>
976 /// <param name="property">The target property to animate.</param>
977 /// <param name="destinationValue">The destination value.</param>
978 /// <param name="startTime">The start time of the animation.</param>
979 /// <param name="endTime">The end time of the animation.</param>
980 /// <param name="alphaFunction">The alpha function to apply.</param>
981 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
982 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
983 /// <since_tizen> 3 </since_tizen>
984 public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
986 AnimateTo(target as Animatable, property, destinationValue, startTime, endTime, alphaFunction);
990 /// Animates one or more properties to a destination value.<br />
992 /// <param name="target">The target object to animate.</param>
993 /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
994 public void PlayAnimateTo(View target)
998 throw new ArgumentNullException(nameof(target));
1003 if (null != propertyList && null != destValueList && null != startTimeList && null != endTimeList)
1005 if (propertyList.Count == destValueList.Count
1007 startTimeList.Count == endTimeList.Count
1009 propertyList.Count == startTimeList.Count)
1011 int count = propertyList.Count;
1012 for (int index = 0; index < count; index++)
1014 var elementType = target.GetType();
1015 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == propertyList[index]);
1017 if (propertyInfo != null)
1019 object destinationValue = ConvertTo(destValueList[index], propertyInfo.PropertyType);
1021 if (destinationValue != null)
1023 AnimateTo(target, propertyList[index], destinationValue, startTimeList[index], endTimeList[index]);
1032 if (properties.Length == destValue.Length && startTime.Length == endTime.Length && properties.Length == startTime.Length)
1034 int length = properties.Length;
1035 for (int index = 0; index < length; index++)
1037 //object destinationValue = _destValue[index];
1038 var elementType = target.GetType();
1039 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == properties[index]);
1040 //var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
1041 if (propertyInfo != null)
1043 object destinationValue = ConvertTo(destValue[index], propertyInfo.PropertyType);
1045 if (destinationValue != null)
1047 AnimateTo(target, properties[index], destinationValue, startTime[index], endTime[index]);
1057 /// Animates a property between keyframes.
1059 /// <param name="target">The target animatable object to animate.</param>
1060 /// <param name="property">The target property to animate.</param>
1061 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
1062 /// <param name="interpolation">The method used to interpolate between values.</param>
1063 /// <param name="alphaFunction">The alpha function to apply.</param>
1064 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1065 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1066 /// This will not be public opened.
1067 [EditorBrowsable(EditorBrowsableState.Never)]
1068 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1072 throw new ArgumentNullException(nameof(target));
1074 if (property == null)
1076 throw new ArgumentNullException(nameof(property));
1078 if (keyFrames == null)
1080 throw new ArgumentNullException(nameof(keyFrames));
1083 using (var result = PropertyHelper.Search(target, property))
1087 throw new ArgumentException("string property is invalid");
1090 var current = result;
1091 while (current != null)
1093 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1094 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, interpolation);
1095 current = current.NextResult;
1101 /// Animates a property between keyframes.
1103 /// <param name="target">The target animatable object to animate</param>
1104 /// <param name="property">The target property to animate</param>
1105 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1106 /// <param name="startTime">The start time of animation in milliseconds.</param>
1107 /// <param name="endTime">The end time of animation in milliseconds.</param>
1108 /// <param name="interpolation">The method used to interpolate between values.</param>
1109 /// <param name="alphaFunction">The alpha function to apply.</param>
1110 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1111 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1112 /// This will not be public opened.
1113 [EditorBrowsable(EditorBrowsableState.Never)]
1114 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1118 throw new ArgumentNullException(nameof(target));
1120 if (property == null)
1122 throw new ArgumentNullException(nameof(property));
1124 if (keyFrames == null)
1126 throw new ArgumentNullException(nameof(keyFrames));
1129 using (var result = PropertyHelper.Search(target, property))
1133 throw new ArgumentException("string property is invalid");
1136 var current = result;
1137 using (var time = new TimePeriod(startTime, endTime - startTime))
1138 while (current != null)
1140 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1141 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, time, interpolation);
1142 current = current.NextResult;
1148 /// Animates a property between keyframes.
1150 /// <param name="target">The target object to animate.</param>
1151 /// <param name="property">The target property to animate.</param>
1152 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
1153 /// <param name="interpolation">The method used to interpolate between values.</param>
1154 /// <param name="alphaFunction">The alpha function to apply.</param>
1155 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1156 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1157 /// <since_tizen> 3 </since_tizen>
1158 public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1160 AnimateBetween(target as Animatable, property, keyFrames, interpolation, alphaFunction);
1164 /// Animates a property between keyframes.
1166 /// <param name="target">The target object to animate</param>
1167 /// <param name="property">The target property to animate</param>
1168 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1169 /// <param name="startTime">The start time of animation in milliseconds.</param>
1170 /// <param name="endTime">The end time of animation in milliseconds.</param>
1171 /// <param name="interpolation">The method used to interpolate between values.</param>
1172 /// <param name="alphaFunction">The alpha function to apply.</param>
1173 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1174 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1175 /// <since_tizen> 3 </since_tizen>
1176 public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1178 AnimateBetween(target as Animatable, property, keyFrames, startTime, endTime, interpolation, alphaFunction);
1182 /// Animates the view's position and orientation through a predefined path.<br />
1183 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1184 /// If forward is the zero vector then no rotation will happen.<br />
1186 /// <param name="view">The view to animate.</param>
1187 /// <param name="path">It defines position and orientation.</param>
1188 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1189 /// <param name="alphaFunction">The alpha function to apply.</param>
1190 /// <since_tizen> 3 </since_tizen>
1191 public void AnimatePath(View view, Path path, Vector3 forward, AlphaFunction alphaFunction = null)
1193 if (alphaFunction == null)
1195 Animate(view, path, forward);
1199 Animate(view, path, forward, alphaFunction);
1204 /// Animates the view's position and orientation through a predefined path.<br />
1205 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1206 /// If forward is the zero vector then no rotation will happen.<br />
1208 /// <param name="view">The view to animate.</param>
1209 /// <param name="path">It defines position and orientation.</param>
1210 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1211 /// <param name="startTime">The start time of the animation.</param>
1212 /// <param name="endTime">The end time of the animation.</param>
1213 /// <param name="alphaFunction">The alpha function to apply.</param>
1214 /// <since_tizen> 3 </since_tizen>
1215 public void AnimatePath(View view, Path path, Vector3 forward, int startTime, int endTime, AlphaFunction alphaFunction = null)
1217 TimePeriod time = new TimePeriod(startTime, endTime - startTime);
1218 if (alphaFunction == null)
1220 Animate(view, path, forward, time);
1224 Animate(view, path, forward, alphaFunction, time);
1230 /// Creates an initialized animation.<br />
1231 /// The animation will not loop.<br />
1232 /// The default end action is "Cancel".<br />
1233 /// The default alpha function is linear.<br />
1235 /// <since_tizen> 3 </since_tizen>
1236 public Animation() : this(Interop.Animation.New(0.0f), true)
1238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1242 /// Plays the animation.
1244 /// <since_tizen> 3 </since_tizen>
1247 Interop.Animation.Play(SwigCPtr);
1248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1250 if (DisableAnimation == true)
1251 Stop(EndActions.StopFinal);
1255 /// Plays the animation from a given point.<br />
1256 /// The progress must be in the 0-1 interval or in the play range interval if defined,
1257 /// otherwise, it will be ignored.<br />
1259 /// <param name="progress">A value between [0,1], or between the play range if specified, from where the animation should start playing.</param>
1260 /// <since_tizen> 3 </since_tizen>
1261 public void PlayFrom(float progress)
1263 Interop.Animation.PlayFrom(SwigCPtr, progress);
1264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1268 /// Plays the animation after a given delay time.<br/>
1269 /// The delay time is not included in the looping time.<br/>
1270 /// When the delay time is a negative value, it would treat as play immediately.<br/>
1272 /// <param name="delayMilliseconds">The delay time.</param>
1273 /// <since_tizen> 4 </since_tizen>
1274 public void PlayAfter(int delayMilliseconds)
1276 Interop.Animation.PlayAfter(SwigCPtr, MilliSecondsToSeconds(delayMilliseconds));
1277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1281 /// Pauses the animation.
1283 /// <since_tizen> 3 </since_tizen>
1286 Interop.Animation.Pause(SwigCPtr);
1287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1291 /// Stops the animation.
1293 /// <since_tizen> 3 </since_tizen>
1296 Interop.Animation.Stop(SwigCPtr);
1297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1301 /// Clears the animation.<br />
1302 /// This disconnects any objects that were being animated, effectively stopping the animation.<br />
1304 /// <since_tizen> 3 </since_tizen>
1307 Interop.Animation.Clear(SwigCPtr);
1308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1311 internal object ConvertTo(object value, Type toType)
1313 Func<object> getConverter = () =>
1315 string converterTypeName = GetTypeConverterTypeName(toType.GetTypeInfo().CustomAttributes);
1316 if (converterTypeName == null)
1319 Type convertertype = Type.GetType(converterTypeName);
1320 return Activator.CreateInstance(convertertype);
1323 return ConvertTo(value, toType, getConverter);
1326 internal object ConvertTo(object value, Type toType, Func<object> getConverter)
1331 var str = value as string;
1334 //If there's a [TypeConverter], use it
1335 object converter = getConverter?.Invoke();
1336 var xfTypeConverter = converter as Tizen.NUI.Binding.TypeConverter;
1337 if (xfTypeConverter != null)
1338 return value = xfTypeConverter.ConvertFromInvariantString(str);
1339 var converterType = converter?.GetType();
1340 if (converterType != null)
1342 var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString",
1343 new[] { typeof(string) });
1344 if (convertFromStringInvariant != null)
1345 return value = convertFromStringInvariant.Invoke(converter, new object[] { str });
1348 //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
1349 if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>))
1350 toType = Nullable.GetUnderlyingType(toType);
1352 //Obvious Built-in conversions
1353 if (toType.GetTypeInfo().IsEnum)
1354 return Enum.Parse(toType, str, true);
1355 if (toType == typeof(SByte))
1356 return SByte.Parse(str, CultureInfo.InvariantCulture);
1357 if (toType == typeof(Int16))
1358 return Int16.Parse(str, CultureInfo.InvariantCulture);
1359 if (toType == typeof(Int32))
1360 return Int32.Parse(str, CultureInfo.InvariantCulture);
1361 if (toType == typeof(Int64))
1362 return Int64.Parse(str, CultureInfo.InvariantCulture);
1363 if (toType == typeof(Byte))
1364 return Byte.Parse(str, CultureInfo.InvariantCulture);
1365 if (toType == typeof(UInt16))
1366 return UInt16.Parse(str, CultureInfo.InvariantCulture);
1367 if (toType == typeof(UInt32))
1368 return UInt32.Parse(str, CultureInfo.InvariantCulture);
1369 if (toType == typeof(UInt64))
1370 return UInt64.Parse(str, CultureInfo.InvariantCulture);
1371 if (toType == typeof(Single))
1372 return Single.Parse(str, CultureInfo.InvariantCulture);
1373 if (toType == typeof(Double))
1374 return Double.Parse(str, CultureInfo.InvariantCulture);
1375 if (toType == typeof(Boolean))
1376 return Boolean.Parse(str);
1377 if (toType == typeof(TimeSpan))
1378 return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
1379 if (toType == typeof(DateTime))
1380 return DateTime.Parse(str, CultureInfo.InvariantCulture);
1381 if (toType == typeof(Char))
1384 _ = Char.TryParse(str, out c);
1387 if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
1388 return str.Substring(2);
1389 if (toType == typeof(String))
1391 if (toType == typeof(Decimal))
1392 return Decimal.Parse(str, CultureInfo.InvariantCulture);
1395 //if the value is not assignable and there's an implicit conversion, convert
1396 if (value != null && !toType.IsAssignableFrom(value.GetType()))
1398 var opImplicit = GetImplicitConversionOperator(value.GetType(), value.GetType(), toType)
1399 ?? GetImplicitConversionOperator(toType, value.GetType(), toType);
1400 //var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
1401 // ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
1403 if (opImplicit != null)
1405 value = opImplicit.Invoke(null, new[] { value });
1413 internal string GetTypeConverterTypeName(IEnumerable<CustomAttributeData> attributes)
1415 var converterAttribute =
1416 attributes.FirstOrDefault(cad => Tizen.NUI.Binding.TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
1417 if (converterAttribute == null)
1419 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(string))
1420 return (string)converterAttribute.ConstructorArguments[0].Value;
1421 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(Type))
1422 return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
1426 internal MethodInfo GetImplicitConversionOperator(Type onType, Type fromType, Type toType)
1429 var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
1431 var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
1432 var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
1434 if (mi == null) return null;
1435 if (!mi.IsSpecialName) return null;
1436 if (!mi.IsPublic) return null;
1437 if (!mi.IsStatic) return null;
1438 if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
1443 internal Animation(float durationSeconds) : this(Interop.Animation.New(durationSeconds), true)
1445 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1449 internal Animation(Animation handle) : this(Interop.Animation.NewAnimation(Animation.getCPtr(handle)), true)
1451 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1454 internal Animation Assign(Animation rhs)
1456 Animation ret = new Animation(Interop.Animation.Assign(SwigCPtr, Animation.getCPtr(rhs)), false);
1457 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1461 internal void SetDuration(float seconds)
1463 Interop.Animation.SetDuration(SwigCPtr, seconds);
1464 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1467 internal float GetDuration()
1469 float ret = Interop.Animation.GetDuration(SwigCPtr);
1470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1474 internal void SetLooping(bool looping)
1476 Interop.Animation.SetLooping(SwigCPtr, looping);
1477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1480 internal void SetLoopCount(int count)
1482 Interop.Animation.SetLoopCount(SwigCPtr, count);
1483 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1486 internal int GetLoopCount()
1488 int ret = Interop.Animation.GetLoopCount(SwigCPtr);
1489 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1493 internal int GetCurrentLoop()
1495 int ret = Interop.Animation.GetCurrentLoop(SwigCPtr);
1496 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1500 internal bool IsLooping()
1502 bool ret = Interop.Animation.IsLooping(SwigCPtr);
1503 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1507 internal void SetEndAction(Animation.EndActions action)
1509 Interop.Animation.SetEndAction(SwigCPtr, (int)action);
1510 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1513 internal Animation.EndActions GetEndAction()
1515 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetEndAction(SwigCPtr);
1516 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1520 internal void SetDisconnectAction(Animation.EndActions disconnectAction)
1522 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)disconnectAction);
1523 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1526 internal Animation.EndActions GetDisconnectAction()
1528 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
1529 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1533 internal void SetDefaultAlphaFunction(AlphaFunction alpha)
1535 Interop.Animation.SetDefaultAlphaFunction(SwigCPtr, AlphaFunction.getCPtr(alpha));
1536 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1539 internal AlphaFunction GetDefaultAlphaFunction()
1541 AlphaFunction ret = new AlphaFunction(Interop.Animation.GetDefaultAlphaFunction(SwigCPtr), true);
1542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1546 internal void SetCurrentProgress(float progress)
1548 Interop.Animation.SetCurrentProgress(SwigCPtr, progress);
1549 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1552 internal float GetCurrentProgress()
1554 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
1555 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1559 internal void SetSpeedFactor(float factor)
1561 Interop.Animation.SetSpeedFactor(SwigCPtr, factor);
1562 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1565 internal float GetSpeedFactor()
1567 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
1568 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1572 internal void SetPlayRange(Vector2 range)
1574 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(range));
1575 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1578 internal Vector2 GetPlayRange()
1580 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
1581 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1585 internal Animation.States GetState()
1587 Animation.States ret = (Animation.States)Interop.Animation.GetState(SwigCPtr);
1588 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1592 internal AnimationSignal FinishedSignal()
1594 AnimationSignal ret = new AnimationSignal(Interop.Animation.FinishedSignal(SwigCPtr), false);
1595 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1599 internal AnimationSignal ProgressReachedSignal()
1601 AnimationSignal ret = new AnimationSignal(Interop.Animation.ProgressReachedSignal(SwigCPtr), false);
1602 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1606 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha)
1610 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));
1614 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha));
1616 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1619 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha, TimePeriod period)
1623 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), TimePeriod.getCPtr(period));
1627 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1629 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1632 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha)
1636 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue));
1640 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha));
1642 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1645 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha, TimePeriod period)
1649 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), TimePeriod.getCPtr(period));
1653 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1655 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1659 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha)
1663 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr);
1667 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha));
1669 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1672 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha, TimePeriod period)
1676 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, TimePeriod.getCPtr(period));
1680 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1682 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1685 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha)
1689 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr);
1693 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha));
1695 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1698 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha, TimePeriod period)
1702 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, TimePeriod.getCPtr(period));
1706 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1708 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1711 internal void AnimateBetween(Property target, KeyFrames keyFrames)
1713 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames));
1714 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1717 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
1719 Interop.Animation.AnimateBetweenAlphaFunction(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha));
1720 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1723 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
1727 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), (int)interpolation);
1731 Interop.Animation.AnimateBetweenAlphaFunctionInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), (int)interpolation);
1733 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1736 internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
1738 Interop.Animation.AnimateBetweenTimePeriod(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period));
1739 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1742 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
1744 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1745 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1748 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
1752 Interop.Animation.AnimateBetweenTimePeriodInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period), (int)interpolation);
1756 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period), (int)interpolation);
1758 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1761 internal void Animate(View view, Path path, Vector3 forward)
1763 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward));
1764 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1767 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha)
1769 Interop.Animation.AnimateAlphaFunction(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha));
1770 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1773 internal void Animate(View view, Path path, Vector3 forward, TimePeriod period)
1775 Interop.Animation.AnimateTimePeriod(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), TimePeriod.getCPtr(period));
1776 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1779 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha, TimePeriod period)
1781 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1782 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1785 internal void Show(View view, float delaySeconds)
1787 Interop.Animation.Show(SwigCPtr, View.getCPtr(view), delaySeconds);
1788 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1791 internal void Hide(View view, float delaySeconds)
1793 Interop.Animation.Hide(SwigCPtr, View.getCPtr(view), delaySeconds);
1794 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1798 /// To make animation instance be disposed.
1800 /// <since_tizen> 3 </since_tizen>
1801 protected override void Dispose(DisposeTypes type)
1808 if (animationFinishedEventHandler != null)
1810 AnimationSignal finishedSignal = FinishedSignal();
1811 finishedSignal?.Disconnect(finishedCallbackOfNative);
1812 finishedSignal?.Dispose();
1813 animationFinishedEventHandler = null;
1816 if (animationProgressReachedEventCallback != null)
1818 AnimationSignal progressReachedSignal = ProgressReachedSignal();
1819 progressReachedSignal?.Disconnect(animationProgressReachedEventCallback);
1820 progressReachedSignal?.Dispose();
1821 animationProgressReachedEventCallback = null;
1827 /// This will not be public opened.
1828 [EditorBrowsable(EditorBrowsableState.Never)]
1829 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1831 if (swigCPtr.Handle == IntPtr.Zero || Disposed)
1833 Tizen.Log.Fatal("NUI", $"[ERROR] Animation ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} Disposed={Disposed}");
1836 Interop.Animation.DeleteAnimation(swigCPtr);
1839 private void OnFinished(IntPtr data)
1841 if (animationFinishedEventHandler != null)
1843 //here we send all data to user event handlers
1844 animationFinishedEventHandler(this, null);
1848 private void OnProgressReached(IntPtr data)
1850 if (animationProgressReachedEventHandler != null)
1852 //here we send all data to user event handlers
1853 animationProgressReachedEventHandler(this, null);
1857 private float MilliSecondsToSeconds(int millisec)
1859 return (float)millisec / 1000.0f;
1862 private int SecondsToMilliSeconds(float sec)
1864 return (int)(sec * 1000);