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. <br/>
709 /// This method is deprecated since API11 because EndActions property concept is not matched with Stop(). <br/>
710 /// Use <see cref="EndAction"/> property instead.
712 /// <param name="action">The end action can be set.</param>
713 /// <since_tizen> 3 </since_tizen>
714 [Obsolete("Deprecated in API11, will be removed in API13. Use EndAction property instead.")]
715 public void Stop(EndActions action)
717 SetEndAction(action);
718 Interop.Animation.Stop(SwigCPtr);
719 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
723 /// Animates a property value by a relative amount.<br />
725 /// <param name="target">The target animatable object to animate.</param>
726 /// <param name="property">The target property to animate.</param>
727 /// <param name="relativeValue">The property value will change by this amount.</param>
728 /// <param name="alphaFunction">The alpha function to apply.</param>
729 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
730 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
731 /// This will not be public opened.
732 [EditorBrowsable(EditorBrowsableState.Never)]
733 public void AnimateBy(Animatable target, string property, object relativeValue, AlphaFunction alphaFunction = null)
737 throw new ArgumentNullException(nameof(target));
739 if (property == null)
741 throw new ArgumentNullException(nameof(property));
743 if (relativeValue == null)
745 throw new ArgumentNullException(nameof(relativeValue));
748 using (var result = PropertyHelper.Search(target, property))
752 throw new ArgumentException("string property is invalid");
755 var current = result;
756 while (current != null)
759 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
760 if (targetValueIntPtr == global::System.IntPtr.Zero)
762 throw new ArgumentException("Invalid " + nameof(relativeValue));
764 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction);
765 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
766 current = current.NextResult;
772 /// Animates a property value by a relative amount.<br />
774 /// <param name="target">The target animatable object to animate.</param>
775 /// <param name="property">The target property to animate.</param>
776 /// <param name="relativeValue">The property value will change by this amount.</param>
777 /// <param name="startTime">The start time of the animation.</param>
778 /// <param name="endTime">The end time of the animation.</param>
779 /// <param name="alphaFunction">The alpha function to apply.</param>
780 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
781 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
782 /// This will not be public opened.
783 [EditorBrowsable(EditorBrowsableState.Never)]
784 public void AnimateBy(Animatable target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
788 throw new ArgumentNullException(nameof(target));
790 if (property == null)
792 throw new ArgumentNullException(nameof(property));
794 if (relativeValue == null)
796 throw new ArgumentNullException(nameof(relativeValue));
799 using (var result = PropertyHelper.Search(target, property))
803 throw new ArgumentException("string property is invalid");
806 var current = result;
807 using (var time = new TimePeriod(startTime, endTime - startTime))
808 while (current != null)
811 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
812 if (targetValueIntPtr == global::System.IntPtr.Zero)
814 throw new ArgumentException("Invalid " + nameof(relativeValue));
816 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
817 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
818 current = current.NextResult;
824 /// Animates a property value by a relative amount.<br />
826 /// <param name="target">The target object to animate.</param>
827 /// <param name="property">The target property to animate.</param>
828 /// <param name="relativeValue">The property value will change by this amount.</param>
829 /// <param name="alphaFunction">The alpha function to apply.</param>
830 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
831 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
832 /// <since_tizen> 3 </since_tizen>
833 public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
835 AnimateBy(target as Animatable, property, relativeValue, alphaFunction);
839 /// Animates a property value by a relative amount.<br />
841 /// <param name="target">The target object to animate.</param>
842 /// <param name="property">The target property to animate.</param>
843 /// <param name="relativeValue">The property value will change by this amount.</param>
844 /// <param name="startTime">The start time of the animation.</param>
845 /// <param name="endTime">The end time of the animation.</param>
846 /// <param name="alphaFunction">The alpha function to apply.</param>
847 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
848 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
849 /// <since_tizen> 3 </since_tizen>
850 public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
852 AnimateBy(target as Animatable, property, relativeValue, startTime, endTime, alphaFunction);
856 /// Animates a property to a destination value.<br />
858 /// <param name="target">The target animatable object to animate.</param>
859 /// <param name="property">The target property to animate.</param>
860 /// <param name="destinationValue">The destination value.</param>
861 /// <param name="alphaFunction">The alpha function to apply.</param>
862 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
863 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
864 /// This will not be public opened.
865 [EditorBrowsable(EditorBrowsableState.Never)]
866 public void AnimateTo(Animatable target, string property, object destinationValue, AlphaFunction alphaFunction = null)
870 throw new ArgumentNullException(nameof(target));
872 if (property == null)
874 throw new ArgumentNullException(nameof(property));
876 if (destinationValue == null)
878 throw new ArgumentNullException(nameof(destinationValue));
881 using (var result = PropertyHelper.Search(target, property))
885 throw new ArgumentException("string property is invalid");
888 var current = result;
889 while (current != null)
892 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
893 if (targetValueIntPtr == global::System.IntPtr.Zero)
895 throw new ArgumentException("Invalid " + nameof(destinationValue));
897 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction);
898 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
899 current = current.NextResult;
905 /// Animates a property to a destination value.<br />
907 /// <param name="target">The target animatable object to animate.</param>
908 /// <param name="property">The target property to animate.</param>
909 /// <param name="destinationValue">The destination value.</param>
910 /// <param name="startTime">The start time of the animation.</param>
911 /// <param name="endTime">The end time of the animation.</param>
912 /// <param name="alphaFunction">The alpha function to apply.</param>
913 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
914 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
915 /// This will not be public opened.
916 [EditorBrowsable(EditorBrowsableState.Never)]
917 public void AnimateTo(Animatable target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
921 throw new ArgumentNullException(nameof(target));
923 if (property == null)
925 throw new ArgumentNullException(nameof(property));
927 if (destinationValue == null)
929 throw new ArgumentNullException(nameof(destinationValue));
932 using (var result = PropertyHelper.Search(target, property))
936 throw new ArgumentException("string property is invalid");
939 var current = result;
940 using (var time = new TimePeriod(startTime, endTime - startTime))
941 while (current != null)
943 #if NUI_ANIMATION_PROPERTY_CHANGE_1
944 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
945 if (targetValueIntPtr == global::System.IntPtr.Zero)
947 throw new ArgumentException("Invalid " + nameof(destinationValue));
949 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
950 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
952 var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
953 AnimateTo(current.Property, targetValue, alphaFunction, time);
954 targetValue.Dispose();
956 current = current.NextResult;
962 /// Animates a property to a destination value.<br />
964 /// <param name="target">The target object to animate.</param>
965 /// <param name="property">The target property to animate.</param>
966 /// <param name="destinationValue">The destination value.</param>
967 /// <param name="alphaFunction">The alpha function to apply.</param>
968 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
969 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
970 /// <since_tizen> 3 </since_tizen>
971 public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
973 AnimateTo(target as Animatable, property, destinationValue, alphaFunction);
977 /// Animates a property to a destination value.<br />
979 /// <param name="target">The target object to animate.</param>
980 /// <param name="property">The target property to animate.</param>
981 /// <param name="destinationValue">The destination value.</param>
982 /// <param name="startTime">The start time of the animation.</param>
983 /// <param name="endTime">The end time of the animation.</param>
984 /// <param name="alphaFunction">The alpha function to apply.</param>
985 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
986 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
987 /// <since_tizen> 3 </since_tizen>
988 public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
990 AnimateTo(target as Animatable, property, destinationValue, startTime, endTime, alphaFunction);
994 /// Animates one or more properties to a destination value.<br />
996 /// <param name="target">The target object to animate.</param>
997 /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
998 public void PlayAnimateTo(View target)
1002 throw new ArgumentNullException(nameof(target));
1007 if (null != propertyList && null != destValueList && null != startTimeList && null != endTimeList)
1009 if (propertyList.Count == destValueList.Count
1011 startTimeList.Count == endTimeList.Count
1013 propertyList.Count == startTimeList.Count)
1015 int count = propertyList.Count;
1016 for (int index = 0; index < count; index++)
1018 var elementType = target.GetType();
1019 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == propertyList[index]);
1021 if (propertyInfo != null)
1023 object destinationValue = ConvertTo(destValueList[index], propertyInfo.PropertyType);
1025 if (destinationValue != null)
1027 AnimateTo(target, propertyList[index], destinationValue, startTimeList[index], endTimeList[index]);
1036 if (properties.Length == destValue.Length && startTime.Length == endTime.Length && properties.Length == startTime.Length)
1038 int length = properties.Length;
1039 for (int index = 0; index < length; index++)
1041 //object destinationValue = _destValue[index];
1042 var elementType = target.GetType();
1043 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == properties[index]);
1044 //var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
1045 if (propertyInfo != null)
1047 object destinationValue = ConvertTo(destValue[index], propertyInfo.PropertyType);
1049 if (destinationValue != null)
1051 AnimateTo(target, properties[index], destinationValue, startTime[index], endTime[index]);
1061 /// Animates a property between keyframes.
1063 /// <param name="target">The target animatable object to animate.</param>
1064 /// <param name="property">The target property to animate.</param>
1065 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
1066 /// <param name="interpolation">The method used to interpolate between values.</param>
1067 /// <param name="alphaFunction">The alpha function to apply.</param>
1068 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1069 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1070 /// This will not be public opened.
1071 [EditorBrowsable(EditorBrowsableState.Never)]
1072 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1076 throw new ArgumentNullException(nameof(target));
1078 if (property == null)
1080 throw new ArgumentNullException(nameof(property));
1082 if (keyFrames == null)
1084 throw new ArgumentNullException(nameof(keyFrames));
1087 using (var result = PropertyHelper.Search(target, property))
1091 throw new ArgumentException("string property is invalid");
1094 var current = result;
1095 while (current != null)
1097 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1098 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, interpolation);
1099 current = current.NextResult;
1105 /// Animates a property between keyframes.
1107 /// <param name="target">The target animatable object to animate</param>
1108 /// <param name="property">The target property to animate</param>
1109 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1110 /// <param name="startTime">The start time of animation in milliseconds.</param>
1111 /// <param name="endTime">The end time of animation in milliseconds.</param>
1112 /// <param name="interpolation">The method used to interpolate between values.</param>
1113 /// <param name="alphaFunction">The alpha function to apply.</param>
1114 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1115 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1116 /// This will not be public opened.
1117 [EditorBrowsable(EditorBrowsableState.Never)]
1118 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1122 throw new ArgumentNullException(nameof(target));
1124 if (property == null)
1126 throw new ArgumentNullException(nameof(property));
1128 if (keyFrames == null)
1130 throw new ArgumentNullException(nameof(keyFrames));
1133 using (var result = PropertyHelper.Search(target, property))
1137 throw new ArgumentException("string property is invalid");
1140 var current = result;
1141 using (var time = new TimePeriod(startTime, endTime - startTime))
1142 while (current != null)
1144 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1145 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, time, interpolation);
1146 current = current.NextResult;
1152 /// Animates a property between keyframes.
1154 /// <param name="target">The target object to animate.</param>
1155 /// <param name="property">The target property to animate.</param>
1156 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
1157 /// <param name="interpolation">The method used to interpolate between values.</param>
1158 /// <param name="alphaFunction">The alpha function to apply.</param>
1159 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1160 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1161 /// <since_tizen> 3 </since_tizen>
1162 public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1164 AnimateBetween(target as Animatable, property, keyFrames, interpolation, alphaFunction);
1168 /// Animates a property between keyframes.
1170 /// <param name="target">The target object to animate</param>
1171 /// <param name="property">The target property to animate</param>
1172 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1173 /// <param name="startTime">The start time of animation in milliseconds.</param>
1174 /// <param name="endTime">The end time of animation in milliseconds.</param>
1175 /// <param name="interpolation">The method used to interpolate between values.</param>
1176 /// <param name="alphaFunction">The alpha function to apply.</param>
1177 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1178 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1179 /// <since_tizen> 3 </since_tizen>
1180 public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1182 AnimateBetween(target as Animatable, property, keyFrames, startTime, endTime, interpolation, alphaFunction);
1186 /// Animates the view's position and orientation through a predefined path.<br />
1187 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1188 /// If forward is the zero vector then no rotation will happen.<br />
1190 /// <param name="view">The view to animate.</param>
1191 /// <param name="path">It defines position and orientation.</param>
1192 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1193 /// <param name="alphaFunction">The alpha function to apply.</param>
1194 /// <since_tizen> 3 </since_tizen>
1195 public void AnimatePath(View view, Path path, Vector3 forward, AlphaFunction alphaFunction = null)
1197 if (alphaFunction == null)
1199 Animate(view, path, forward);
1203 Animate(view, path, forward, alphaFunction);
1208 /// Animates the view's position and orientation through a predefined path.<br />
1209 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1210 /// If forward is the zero vector then no rotation will happen.<br />
1212 /// <param name="view">The view to animate.</param>
1213 /// <param name="path">It defines position and orientation.</param>
1214 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1215 /// <param name="startTime">The start time of the animation.</param>
1216 /// <param name="endTime">The end time of the animation.</param>
1217 /// <param name="alphaFunction">The alpha function to apply.</param>
1218 /// <since_tizen> 3 </since_tizen>
1219 public void AnimatePath(View view, Path path, Vector3 forward, int startTime, int endTime, AlphaFunction alphaFunction = null)
1221 TimePeriod time = new TimePeriod(startTime, endTime - startTime);
1222 if (alphaFunction == null)
1224 Animate(view, path, forward, time);
1228 Animate(view, path, forward, alphaFunction, time);
1234 /// Creates an initialized animation.<br />
1235 /// The animation will not loop.<br />
1236 /// The default end action is "Cancel".<br />
1237 /// The default alpha function is linear.<br />
1239 /// <since_tizen> 3 </since_tizen>
1240 public Animation() : this(Interop.Animation.New(0.0f), true)
1242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1246 /// Plays the animation.
1248 /// <since_tizen> 3 </since_tizen>
1251 Interop.Animation.Play(SwigCPtr);
1252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1254 if (DisableAnimation == true)
1255 Stop(EndActions.StopFinal);
1259 /// Plays the animation from a given point.<br />
1260 /// The progress must be in the 0-1 interval or in the play range interval if defined,
1261 /// otherwise, it will be ignored.<br />
1263 /// <param name="progress">A value between [0,1], or between the play range if specified, from where the animation should start playing.</param>
1264 /// <since_tizen> 3 </since_tizen>
1265 public void PlayFrom(float progress)
1267 Interop.Animation.PlayFrom(SwigCPtr, progress);
1268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1272 /// Plays the animation after a given delay time.<br/>
1273 /// The delay time is not included in the looping time.<br/>
1274 /// When the delay time is a negative value, it would treat as play immediately.<br/>
1276 /// <param name="delayMilliseconds">The delay time.</param>
1277 /// <since_tizen> 4 </since_tizen>
1278 public void PlayAfter(int delayMilliseconds)
1280 Interop.Animation.PlayAfter(SwigCPtr, MilliSecondsToSeconds(delayMilliseconds));
1281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1285 /// Pauses the animation.
1287 /// <since_tizen> 3 </since_tizen>
1290 Interop.Animation.Pause(SwigCPtr);
1291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295 /// Stops the animation.
1297 /// <since_tizen> 3 </since_tizen>
1300 Interop.Animation.Stop(SwigCPtr);
1301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1305 /// Clears the animation.<br />
1306 /// This disconnects any objects that were being animated, effectively stopping the animation.<br />
1308 /// <since_tizen> 3 </since_tizen>
1311 Interop.Animation.Clear(SwigCPtr);
1312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1315 internal object ConvertTo(object value, Type toType)
1317 Func<object> getConverter = () =>
1319 string converterTypeName = GetTypeConverterTypeName(toType.GetTypeInfo().CustomAttributes);
1320 if (converterTypeName == null)
1323 Type convertertype = Type.GetType(converterTypeName);
1324 return Activator.CreateInstance(convertertype);
1327 return ConvertTo(value, toType, getConverter);
1330 internal object ConvertTo(object value, Type toType, Func<object> getConverter)
1335 var str = value as string;
1338 //If there's a [TypeConverter], use it
1339 object converter = getConverter?.Invoke();
1340 var xfTypeConverter = converter as Tizen.NUI.Binding.TypeConverter;
1341 if (xfTypeConverter != null)
1342 return value = xfTypeConverter.ConvertFromInvariantString(str);
1343 var converterType = converter?.GetType();
1344 if (converterType != null)
1346 var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString",
1347 new[] { typeof(string) });
1348 if (convertFromStringInvariant != null)
1349 return value = convertFromStringInvariant.Invoke(converter, new object[] { str });
1352 //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
1353 if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>))
1354 toType = Nullable.GetUnderlyingType(toType);
1356 //Obvious Built-in conversions
1357 if (toType.GetTypeInfo().IsEnum)
1358 return Enum.Parse(toType, str, true);
1359 if (toType == typeof(SByte))
1360 return SByte.Parse(str, CultureInfo.InvariantCulture);
1361 if (toType == typeof(Int16))
1362 return Int16.Parse(str, CultureInfo.InvariantCulture);
1363 if (toType == typeof(Int32))
1364 return Int32.Parse(str, CultureInfo.InvariantCulture);
1365 if (toType == typeof(Int64))
1366 return Int64.Parse(str, CultureInfo.InvariantCulture);
1367 if (toType == typeof(Byte))
1368 return Byte.Parse(str, CultureInfo.InvariantCulture);
1369 if (toType == typeof(UInt16))
1370 return UInt16.Parse(str, CultureInfo.InvariantCulture);
1371 if (toType == typeof(UInt32))
1372 return UInt32.Parse(str, CultureInfo.InvariantCulture);
1373 if (toType == typeof(UInt64))
1374 return UInt64.Parse(str, CultureInfo.InvariantCulture);
1375 if (toType == typeof(Single))
1376 return Single.Parse(str, CultureInfo.InvariantCulture);
1377 if (toType == typeof(Double))
1378 return Double.Parse(str, CultureInfo.InvariantCulture);
1379 if (toType == typeof(Boolean))
1380 return Boolean.Parse(str);
1381 if (toType == typeof(TimeSpan))
1382 return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
1383 if (toType == typeof(DateTime))
1384 return DateTime.Parse(str, CultureInfo.InvariantCulture);
1385 if (toType == typeof(Char))
1388 _ = Char.TryParse(str, out c);
1391 if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
1392 return str.Substring(2);
1393 if (toType == typeof(String))
1395 if (toType == typeof(Decimal))
1396 return Decimal.Parse(str, CultureInfo.InvariantCulture);
1399 //if the value is not assignable and there's an implicit conversion, convert
1400 if (value != null && !toType.IsAssignableFrom(value.GetType()))
1402 var opImplicit = GetImplicitConversionOperator(value.GetType(), value.GetType(), toType)
1403 ?? GetImplicitConversionOperator(toType, value.GetType(), toType);
1404 //var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
1405 // ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
1407 if (opImplicit != null)
1409 value = opImplicit.Invoke(null, new[] { value });
1417 internal string GetTypeConverterTypeName(IEnumerable<CustomAttributeData> attributes)
1419 var converterAttribute =
1420 attributes.FirstOrDefault(cad => Tizen.NUI.Binding.TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
1421 if (converterAttribute == null)
1423 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(string))
1424 return (string)converterAttribute.ConstructorArguments[0].Value;
1425 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(Type))
1426 return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
1430 internal MethodInfo GetImplicitConversionOperator(Type onType, Type fromType, Type toType)
1433 var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
1435 var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
1436 var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
1438 if (mi == null) return null;
1439 if (!mi.IsSpecialName) return null;
1440 if (!mi.IsPublic) return null;
1441 if (!mi.IsStatic) return null;
1442 if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
1447 internal Animation(float durationSeconds) : this(Interop.Animation.New(durationSeconds), true)
1449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1453 internal Animation(Animation handle) : this(Interop.Animation.NewAnimation(Animation.getCPtr(handle)), true)
1455 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1458 internal Animation Assign(Animation rhs)
1460 Animation ret = new Animation(Interop.Animation.Assign(SwigCPtr, Animation.getCPtr(rhs)), false);
1461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1465 internal void SetDuration(float seconds)
1467 Interop.Animation.SetDuration(SwigCPtr, seconds);
1468 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1471 internal float GetDuration()
1473 float ret = Interop.Animation.GetDuration(SwigCPtr);
1474 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1478 internal void SetLooping(bool looping)
1480 Interop.Animation.SetLooping(SwigCPtr, looping);
1481 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1484 internal void SetLoopCount(int count)
1486 Interop.Animation.SetLoopCount(SwigCPtr, count);
1487 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1490 internal int GetLoopCount()
1492 int ret = Interop.Animation.GetLoopCount(SwigCPtr);
1493 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1497 internal int GetCurrentLoop()
1499 int ret = Interop.Animation.GetCurrentLoop(SwigCPtr);
1500 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1504 internal bool IsLooping()
1506 bool ret = Interop.Animation.IsLooping(SwigCPtr);
1507 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1511 internal void SetEndAction(Animation.EndActions action)
1513 Interop.Animation.SetEndAction(SwigCPtr, (int)action);
1514 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1517 internal Animation.EndActions GetEndAction()
1519 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetEndAction(SwigCPtr);
1520 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1524 internal void SetDisconnectAction(Animation.EndActions disconnectAction)
1526 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)disconnectAction);
1527 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1530 internal Animation.EndActions GetDisconnectAction()
1532 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
1533 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1537 internal void SetDefaultAlphaFunction(AlphaFunction alpha)
1539 Interop.Animation.SetDefaultAlphaFunction(SwigCPtr, AlphaFunction.getCPtr(alpha));
1540 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1543 internal AlphaFunction GetDefaultAlphaFunction()
1545 AlphaFunction ret = new AlphaFunction(Interop.Animation.GetDefaultAlphaFunction(SwigCPtr), true);
1546 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1550 internal void SetCurrentProgress(float progress)
1552 Interop.Animation.SetCurrentProgress(SwigCPtr, progress);
1553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1556 internal float GetCurrentProgress()
1558 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
1559 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1563 internal void SetSpeedFactor(float factor)
1565 Interop.Animation.SetSpeedFactor(SwigCPtr, factor);
1566 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1569 internal float GetSpeedFactor()
1571 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
1572 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1576 internal void SetPlayRange(Vector2 range)
1578 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(range));
1579 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1582 internal Vector2 GetPlayRange()
1584 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
1585 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1589 internal Animation.States GetState()
1591 Animation.States ret = (Animation.States)Interop.Animation.GetState(SwigCPtr);
1592 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1596 internal AnimationSignal FinishedSignal()
1598 AnimationSignal ret = new AnimationSignal(Interop.Animation.FinishedSignal(SwigCPtr), false);
1599 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1603 internal AnimationSignal ProgressReachedSignal()
1605 AnimationSignal ret = new AnimationSignal(Interop.Animation.ProgressReachedSignal(SwigCPtr), false);
1606 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1610 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha)
1614 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));
1618 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha));
1620 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1623 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha, TimePeriod period)
1627 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), TimePeriod.getCPtr(period));
1631 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1633 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1636 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha)
1640 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue));
1644 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha));
1646 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1649 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha, TimePeriod period)
1653 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), TimePeriod.getCPtr(period));
1657 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1663 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha)
1667 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr);
1671 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha));
1673 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1676 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha, TimePeriod period)
1680 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, TimePeriod.getCPtr(period));
1684 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1686 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1689 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha)
1693 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr);
1697 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha));
1699 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1702 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha, TimePeriod period)
1706 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, TimePeriod.getCPtr(period));
1710 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1712 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1715 internal void AnimateBetween(Property target, KeyFrames keyFrames)
1717 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames));
1718 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1721 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
1723 Interop.Animation.AnimateBetweenAlphaFunction(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha));
1724 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1727 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
1731 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), (int)interpolation);
1735 Interop.Animation.AnimateBetweenAlphaFunctionInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), (int)interpolation);
1737 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1740 internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
1742 Interop.Animation.AnimateBetweenTimePeriod(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period));
1743 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1746 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
1748 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1749 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1752 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
1756 Interop.Animation.AnimateBetweenTimePeriodInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period), (int)interpolation);
1760 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period), (int)interpolation);
1762 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1765 internal void Animate(View view, Path path, Vector3 forward)
1767 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward));
1768 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1771 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha)
1773 Interop.Animation.AnimateAlphaFunction(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha));
1774 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1777 internal void Animate(View view, Path path, Vector3 forward, TimePeriod period)
1779 Interop.Animation.AnimateTimePeriod(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), TimePeriod.getCPtr(period));
1780 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1783 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha, TimePeriod period)
1785 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1786 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1789 internal void Show(View view, float delaySeconds)
1791 Interop.Animation.Show(SwigCPtr, View.getCPtr(view), delaySeconds);
1792 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1795 internal void Hide(View view, float delaySeconds)
1797 Interop.Animation.Hide(SwigCPtr, View.getCPtr(view), delaySeconds);
1798 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1802 /// To make animation instance be disposed.
1804 /// <since_tizen> 3 </since_tizen>
1805 protected override void Dispose(DisposeTypes type)
1812 if (animationFinishedEventHandler != null)
1814 AnimationSignal finishedSignal = FinishedSignal();
1815 finishedSignal?.Disconnect(finishedCallbackOfNative);
1816 finishedSignal?.Dispose();
1817 animationFinishedEventHandler = null;
1820 if (animationProgressReachedEventCallback != null)
1822 AnimationSignal progressReachedSignal = ProgressReachedSignal();
1823 progressReachedSignal?.Disconnect(animationProgressReachedEventCallback);
1824 progressReachedSignal?.Dispose();
1825 animationProgressReachedEventCallback = null;
1831 /// This will not be public opened.
1832 [EditorBrowsable(EditorBrowsableState.Never)]
1833 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1835 if (swigCPtr.Handle == IntPtr.Zero || Disposed)
1837 Tizen.Log.Fatal("NUI", $"[ERROR] Animation ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} Disposed={Disposed}");
1840 Interop.Animation.DeleteAnimation(swigCPtr);
1843 private void OnFinished(IntPtr data)
1845 if (animationFinishedEventHandler != null)
1847 //here we send all data to user event handlers
1848 animationFinishedEventHandler(this, null);
1852 private void OnProgressReached(IntPtr data)
1854 if (animationProgressReachedEventHandler != null)
1856 //here we send all data to user event handlers
1857 animationProgressReachedEventHandler(this, null);
1861 private float MilliSecondsToSeconds(int millisec)
1863 return (float)millisec / 1000.0f;
1866 private int SecondsToMilliSeconds(float sec)
1868 return (int)(sec * 1000);