nui 0.2.39 release
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / Animation.cs
1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 //
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 // Some have been manually changed
18
19 namespace Tizen.NUI
20 {
21
22     using System;
23     using System.Runtime.InteropServices;
24     using Tizen.NUI.BaseComponents;
25
26     /// <summary>
27     /// Animation can be used to animate the properties of any number of objects, typically View.<br>
28     /// If the "Finished" event is connected to a member function of an object, it must be disconnected before the object is destroyed.<br>
29     /// This is typically done in the object destructor, and requires either the Animation handle to be stored.<br>
30     /// 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>
31     /// If any of the individual calls to those functions exceeds the overall animation time(Duration), then the overall animation time is automatically extended.<br>
32     /// </summary>
33     public class Animation : BaseHandle
34     {
35         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
36
37         internal Animation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Animation_SWIGUpcast(cPtr), cMemoryOwn)
38         {
39             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40         }
41
42         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Animation obj)
43         {
44             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45         }
46
47         /// <summary>
48         /// To make Animation instance be disposed.
49         /// </summary>
50         public override void Dispose()
51         {
52             if (!Window.IsInstalled())
53             {
54                 DisposeQueue.Instance.Add(this);
55                 return;
56             }
57
58             lock (this)
59             {
60                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
61                 {
62                     if (swigCMemOwn)
63                     {
64                         swigCMemOwn = false;
65                         NDalicPINVOKE.delete_Animation(swigCPtr);
66                     }
67                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
68                 }
69                 global::System.GC.SuppressFinalize(this);
70                 base.Dispose();
71             }
72         }
73
74         /// <summary>
75         /// Create an initialized Animation.<br>
76         /// The animation will not loop.<br>
77         /// The default end action is "Cancel".<br>
78         /// The default Alpha function is linear.<br>
79         /// </summary>
80         /// <remarks>DurationmSeconds must be greater than zero.</remarks>
81         /// <param name="durationMilliSeconds">The duration in milli seconds.</param>
82         public Animation(int durationMilliSeconds) : this(NDalicPINVOKE.Animation_New((float)durationMilliSeconds / 1000.0f), true)
83         {
84             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85         }
86
87         private AnimationFinishedEventCallbackType _animationFinishedEventCallback;
88         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
89         private delegate void AnimationFinishedEventCallbackType(IntPtr data);
90         private event EventHandler _animationFinishedEventHandler;
91         /**
92         * @brief Event for Finished signal which can be used to subscribe/unsubscribe the event handler.
93         * Finished signal is emitted when an Animation's animations have finished.
94         */
95         public event EventHandler Finished
96         {
97             add
98             {
99                 if (_animationFinishedEventHandler == null)
100                 {
101 #if DEBUG_ON
102                     Tizen.Log.Debug("NUI", "con1) FinishedSignal().Empty = " + FinishedSignal().Empty());
103                     Tizen.Log.Debug("NUI", "con2) FinishedSignal().GetConnectionCount = " + FinishedSignal().GetConnectionCount());
104 #endif
105                     _animationFinishedEventCallback = OnFinished;
106                     FinishedSignal().Connect(_animationFinishedEventCallback);
107 #if DEBUG_ON
108                     Tizen.Log.Debug("NUI", "con3) FinishedSignal().Empty = " + FinishedSignal().Empty());
109                     Tizen.Log.Debug("NUI", "con4) FinishedSignal().GetConnectionCount = " + FinishedSignal().GetConnectionCount());
110 #endif
111                 }
112
113                 _animationFinishedEventHandler += value;
114             }
115             remove
116             {
117                 _animationFinishedEventHandler -= value;
118
119                 if (_animationFinishedEventHandler == null && FinishedSignal().Empty() == false)
120                 {
121 #if DEBUG_ON
122                     Tizen.Log.Debug("NUI", "discon1) FinishedSignal().Empty = " + FinishedSignal().Empty());
123                     Tizen.Log.Debug("NUI", "discon2) FinishedSignal().GetConnectionCount = " + FinishedSignal().GetConnectionCount());
124 #endif
125                     FinishedSignal().Disconnect(_animationFinishedEventCallback);
126 #if DEBUG_ON
127                     Tizen.Log.Debug("NUI", "discon3) FinishedSignal().Empty = " + FinishedSignal().Empty());
128                     Tizen.Log.Debug("NUI", "discon4) FinishedSignal().GetConnectionCount = " + FinishedSignal().GetConnectionCount());
129 #endif
130                 }
131             }
132         }
133         private void OnFinished(IntPtr data)
134         {
135             if (_animationFinishedEventHandler != null)
136             {
137                 //here we send all data to user event handlers
138                 _animationFinishedEventHandler(this, null);
139             }
140         }
141
142
143         internal static Animation GetAnimationFromPtr(global::System.IntPtr cPtr)
144         {
145             Animation ret = new Animation(cPtr, false);
146             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147             return ret;
148         }
149
150         private float MilliSecondsToSeconds(int millisec)
151         {
152             return (float)millisec / 1000.0f;
153         }
154
155         private int SecondsToMilliSeconds(float sec)
156         {
157             return (int)(sec * 1000);
158         }
159
160
161         /// <summary>
162         /// Gets/Sets the duration in milli seconds of the animation.
163         /// </summary>
164         public int Duration
165         {
166             set
167             {
168                 SetDuration(MilliSecondsToSeconds(value));
169             }
170             get
171             {
172                 return SecondsToMilliSeconds(GetDuration());
173             }
174         }
175
176         /// <summary>
177         ///  Gets/Sets the default alpha function for the animation.
178         /// </summary>
179         public AlphaFunction DefaultAlphaFunction
180         {
181             set
182             {
183                 SetDefaultAlphaFunction(value);
184             }
185             get
186             {
187                 AlphaFunction ret = GetDefaultAlphaFunction();
188                 return ret;
189             }
190         }
191
192         /// <summary>
193         /// Queries the state of the animation.
194         /// </summary>
195         public States State
196         {
197             get
198             {
199                 return GetState();
200             }
201         }
202
203         /// <summary>
204         /// Set : Enables looping for 'count' repeats. A zero is the same as Looping = true; i.e.repeat forever.<br>
205         /// If Play() Stop() or 'count' loops is reached, the loop counter will reset.<br>
206         /// Setting this parameter does not cause the animation to Play().<br>
207         /// Get : Gets the loop count. A zero is the same as Looping = true; ie repeat forever.<br>
208         /// The loop count is initially 1 for play once.<br>
209         /// </summary>
210         public int LoopCount
211         {
212             set
213             {
214                 SetLoopCount(value);
215             }
216             get
217             {
218                 int ret = GetLoopCount();
219                 return ret;
220             }
221         }
222
223         /// <summary>
224         /// Gets/Sets the status of whether the animation will loop.<br>
225         /// This property resets the loop count and should not be used with LoopCount property.<br>
226         /// Setting this parameter does not cause the animation to Play().<br>
227         /// </summary>
228         public bool Looping
229         {
230             set
231             {
232                 SetLooping(value);
233             }
234             get
235             {
236                 bool ret = IsLooping();
237                 return ret;
238             }
239         }
240
241
242         /// <summary>
243         /// Gets/Sets the end action of the animation.<br>
244         /// This action is performed when the animation ends or if it is stopped.<br>
245         /// Default end action is Cancel.<br>
246         /// </summary>
247         public EndActions EndAction
248         {
249             set
250             {
251                 SetEndAction(value);
252             }
253             get
254             {
255                 return GetEndAction();
256             }
257         }
258
259
260         /// <summary>
261         /// Stops the animation.
262         /// </summary>
263         /// <param name="action">end action can be set</param>
264         public void Stop(EndActions action = EndActions.Cancel)
265         {
266             SetEndAction(action);
267             NDalicPINVOKE.Animation_Stop(swigCPtr);
268             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269         }
270
271         /// <summary>
272         /// Gets the current loop count.<br>
273         /// A value 0 indicating the current loop count when looping.<br>
274         /// </summary>
275         public int CurrentLoop
276         {
277             get
278             {
279                 return GetCurrentLoop();
280             }
281         }
282
283         /// <summary>
284         /// Gets/Sets the disconnect action.<br>
285         /// If any of the animated property owners are disconnected from the stage while the animation is being played, then this action is performed.<br>
286         /// Default action is to Cancel.<br>
287         /// </summary>
288         public EndActions DisconnectAction
289         {
290             set
291             {
292                 NDalicPINVOKE.Animation_SetDisconnectAction(swigCPtr, (int)value);
293                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
294             }
295             get
296             {
297                 Animation.EndActions ret = (Animation.EndActions)NDalicPINVOKE.Animation_GetDisconnectAction(swigCPtr);
298                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299                 return ret;
300             }
301         }
302
303
304         /// <summary>
305         /// Gets/Sets the progress of the animation.<br>
306         /// The animation will play(or continue playing) from this point.<br>
307         /// The progress must be in the 0-1 interval or in the play range interval if defined.<br>
308         /// otherwise, it will be ignored.<br>
309         /// </summary>
310         public float CurrentProgress
311         {
312             set
313             {
314                 NDalicPINVOKE.Animation_SetCurrentProgress(swigCPtr, value);
315                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316             }
317             get
318             {
319                 float ret = NDalicPINVOKE.Animation_GetCurrentProgress(swigCPtr);
320                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321                 return ret;
322             }
323         }
324
325         /// <summary>
326         /// Gets/Sets Specifies a speed factor for the animation.<br>
327         /// The speed factor is a multiplier of the normal velocity of the animation.<br>
328         /// Values between[0, 1] will slow down the animation and values above one will speed up the animation.<br>
329         /// It is also possible to specify a negative multiplier to play the animation in reverse.<br>
330         /// </summary>
331         public float SpeedFactor
332         {
333             set
334             {
335                 NDalicPINVOKE.Animation_SetSpeedFactor(swigCPtr, value);
336                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
337             }
338             get
339             {
340                 float ret = NDalicPINVOKE.Animation_GetSpeedFactor(swigCPtr);
341                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342                 return ret;
343             }
344         }
345
346         /// <summary>
347         /// Gets/Sets the playing range.<br>
348         /// Animation will play between the values specified. Both values(range.x and range.y ) should be between 0-1,
349         /// otherwise they will be ignored.If the range provided is not in proper order(minimum, maximum ), it will be reordered.<br>
350         /// </summary>
351         public RelativeVector2 PlayRange
352         {
353             set
354             {
355                 NDalicPINVOKE.Animation_SetPlayRange(swigCPtr, Vector2.getCPtr(value));
356                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357             }
358             get
359             {
360                 Vector2 ret = new Vector2(NDalicPINVOKE.Animation_GetPlayRange(swigCPtr), true);
361                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362                 return ret;
363             }
364         }
365
366         /// <summary>
367         /// Animates a property value by a relative amount.<br>
368         /// </summary>
369         /// <param name="target">The target object to animate</param>
370         /// <param name="property">The target property to animate</param>
371         /// <param name="relativeValue">The property value will change by this amount</param>
372         /// <param name="alphaFunction">The alpha function to apply</param>
373         public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
374         {
375             string _str1 = property.Substring(0, 1);
376             string _str2 = property.Substring(1);
377             string _str = _str1.ToLower() + _str2;
378
379             Property _prop = new Property(target, _str);
380             if (_prop.propertyIndex == Property.INVALID_INDEX)
381             {
382                 throw new System.ArgumentException("second argument string property is invalid parameter!");
383             }
384
385             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
386             if(propertyType.Equals(PropertyType.Float))
387             {
388                 System.Type type = relativeValue.GetType();
389                 if (type.Equals(typeof(System.Int32)) || type.Equals(typeof(int)))
390                 {
391                     int num = (int)relativeValue;
392                     relativeValue = (float)num;
393                 }
394             }
395
396             PropertyValue val = PropertyValue.CreateFromObject(relativeValue);
397
398             if (alphaFunction != null)
399             {
400                 AnimateBy(_prop, val, alphaFunction);
401             }
402             else
403             {
404                 AnimateBy(_prop, val);
405             }
406         }
407
408         /// <summary>
409         /// Animates a property value by a relative amount.<br>
410         /// </summary>
411         /// <param name="target">The target object to animate</param>
412         /// <param name="property">The target property to animate</param>
413         /// <param name="relativeValue">The property value will change by this amount</param>
414         /// <param name="startTime">Start time of animation</param>
415         /// <param name="endTime">End time of animation</param>
416         /// <param name="alphaFunction">The alpha function to apply</param>
417         public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
418         {
419             string _str1 = property.Substring(0, 1);
420             string _str2 = property.Substring(1);
421             string _str = _str1.ToLower() + _str2;
422
423             Property _prop = new Property(target, _str);
424             if (_prop.propertyIndex == Property.INVALID_INDEX)
425             {
426                 throw new System.ArgumentException("second argument string property is invalid parameter!");
427             }
428
429             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
430             if(propertyType.Equals(PropertyType.Float))
431             {
432                 System.Type type = relativeValue.GetType();
433                 if (type.Equals(typeof(System.Int32)) || type.Equals(typeof(int)))
434                 {
435                     int num = (int)relativeValue;
436                     relativeValue = (float)num;
437                 }
438             }
439
440             PropertyValue val = PropertyValue.CreateFromObject(relativeValue);
441
442             if (alphaFunction != null)
443             {
444                 Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
445                 AnimateBy(_prop, val, alphaFunction, time);
446             }
447             else
448             {
449                 Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
450                 AnimateBy(_prop, val, time);
451             }
452         }
453
454         /// <summary>
455         /// Animates a property to a destination value.<br>
456         /// </summary>
457         /// <param name="target">The target object to animate</param>
458         /// <param name="property">The target property to animate</param>
459         /// <param name="destinationValue">The destination value</param>
460         /// <param name="alphaFunction">The alpha function to apply</param>
461         public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
462         {
463             string _str1 = property.Substring(0, 1);
464             string _str2 = property.Substring(1);
465             string _str = _str1.ToLower() + _str2;
466
467             Property _prop = new Property(target, _str);
468             if (_prop.propertyIndex == Property.INVALID_INDEX)
469             {
470                 throw new System.ArgumentException("second argument string property is invalid parameter!");
471             }
472
473             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
474             if(propertyType.Equals(PropertyType.Float))
475             {
476                 System.Type type = destinationValue.GetType();
477                 if (type.Equals(typeof(System.Int32)) || type.Equals(typeof(int)))
478                 {
479                     int num = (int)destinationValue;
480                     destinationValue = (float)num;
481                 }
482             }
483
484             PropertyValue val = PropertyValue.CreateFromObject(destinationValue);
485
486             if (alphaFunction != null)
487             {
488                 AnimateTo(_prop, val, alphaFunction);
489             }
490             else
491             {
492                 AnimateTo(_prop, val);
493             }
494         }
495
496         /// <summary>
497         /// Animates a property to a destination value.<br>
498         /// </summary>
499         /// <param name="target">The target object to animate</param>
500         /// <param name="property">The target property to animate</param>
501         /// <param name="destinationValue">The destination value</param>
502         /// <param name="alphaFunction">The alpha function to apply</param>
503         /// <param name="startTime">Start time of animation</param>
504         /// <param name="endTime">End time of animation</param>
505         /// <param name="alphaFunction">The alpha function to apply</param>
506         public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
507         {
508             string _str1 = property.Substring(0, 1);
509             string _str2 = property.Substring(1);
510             string _str = _str1.ToLower() + _str2;
511
512             Property _prop = new Property(target, _str);
513             if (_prop.propertyIndex == Property.INVALID_INDEX)
514             {
515                 throw new System.ArgumentException("second argument string property is invalid parameter!");
516             }
517
518             PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex);
519             if(propertyType.Equals(PropertyType.Float))
520             {
521                 System.Type type = destinationValue.GetType();
522                 if (type.Equals(typeof(System.Int32)) || type.Equals(typeof(int)))
523                 {
524                     int num = (int)destinationValue;
525                     destinationValue = (float)num;
526                 }
527             }
528
529             PropertyValue val = PropertyValue.CreateFromObject(destinationValue);
530
531             if (alphaFunction != null)
532             {
533                 Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
534                 AnimateTo(_prop, val, alphaFunction, time);
535             }
536             else
537             {
538                 Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
539                 AnimateTo(_prop, val, time);
540             }
541         }
542
543         /// <summary>
544         /// Animates a property between keyframes.
545         /// </summary>
546         /// <param name="target">The target object to animate</param>
547         /// <param name="property">The target property to animate</param>
548         /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
549         /// <param name="interpolation">The method used to interpolate between values</param>
550         /// <param name="alphaFunction">The alpha function to apply</param>
551         public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
552         {
553             string _str1 = property.Substring(0, 1);
554             string _str2 = property.Substring(1);
555             string _str = _str1.ToLower() + _str2;
556
557             Property _prop = new Property(target, _str);
558             if (_prop.propertyIndex == Property.INVALID_INDEX)
559             {
560                 throw new System.ArgumentException("second argument string property is invalid parameter!");
561             }
562
563             if (alphaFunction != null)
564             {
565                 AnimateBetween(_prop, keyFrames, alphaFunction, interpolation);
566             }
567             else
568             {
569                 AnimateBetween(_prop, keyFrames, interpolation);
570             }
571         }
572
573
574         /// <summary>
575         /// Animates a property between keyframes.
576         /// </summary>
577         /// <param name="target">The target object to animate</param>
578         /// <param name="property">The target property to animate</param>
579         /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
580         /// <param name="startTime">Start time of animation in milli seconds</param>
581         /// <param name="endTime">End time of animation in milli seconds</param>
582         /// <param name="interpolation">The method used to interpolate between values</param>
583         /// <param name="alphaFunction">The alpha function to apply</param>
584         public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
585         {
586             string _str1 = property.Substring(0, 1);
587             string _str2 = property.Substring(1);
588             string _str = _str1.ToLower() + _str2;
589
590             Property _prop = new Property(target, _str);
591             if (_prop.propertyIndex == Property.INVALID_INDEX)
592             {
593                 throw new System.ArgumentException("second argument string property is invalid parameter!");
594             }
595
596             Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
597             if (alphaFunction != null)
598             {
599                 AnimateBetween(_prop, keyFrames, alphaFunction, time, interpolation);
600             }
601             else
602             {
603                 AnimateBetween(_prop, keyFrames, time, interpolation);
604             }
605         }
606
607         /// <summary>
608         /// Animates an view's position and orientation through a predefined path.<br>
609         /// The view will rotate to orient the supplied forward vector with the path's tangent.<br>
610         /// If forward is the zero vector then no rotation will happen.<br>
611         /// </summary>
612         /// <param name="view">The view to animate</param>
613         /// <param name="path">It defines position and orientation</param>
614         /// <param name="forward">The vector (in local space coordinate system) that will be oriented with the path's tangent direction</param>
615         /// <param name="alphaFunction">The alpha function to apply</param>
616         public void AnimatePath(View view, Path path, Vector3 forward, AlphaFunction alphaFunction = null)
617         {
618             if (alphaFunction == null)
619             {
620                 Animate(view, path, forward);
621             }
622             else
623             {
624                 Animate(view, path, forward, alphaFunction);
625             }
626         }
627
628         /// <summary>
629         /// Animates an view's position and orientation through a predefined path.<br>
630         /// The view will rotate to orient the supplied forward vector with the path's tangent.<br>
631         /// If forward is the zero vector then no rotation will happen.<br>
632         /// </summary>
633         /// <param name="view">The view to animate</param>
634         /// <param name="path">It defines position and orientation</param>
635         /// <param name="forward">The vector (in local space coordinate system) that will be oriented with the path's tangent direction</param>
636         /// <param name="startTime">Start time of animation</param>
637         /// <param name="endTime">End time of animation</param>
638         /// <param name="alphaFunction">The alpha function to apply</param>
639         public void AnimatePath(View view, Path path, Vector3 forward, int startTime, int endTime, AlphaFunction alphaFunction = null)
640         {
641             TimePeriod time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
642             if (alphaFunction == null)
643             {
644                 Animate(view, path, forward, time);
645             }
646             else
647             {
648                 Animate(view, path, forward, alphaFunction, time);
649             }
650         }
651
652         /// <summary>
653         /// Creates an initialized Animation.<br>
654         /// The animation will not loop.<br>
655         /// The default end action is "Cancel".<br>
656         /// The default alpha function is linear.<br>
657         /// </summary>
658         public Animation() : this(NDalicPINVOKE.Animation_New(0.0f), true)
659         {
660             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661         }
662
663         internal Animation(float durationSeconds) : this(NDalicPINVOKE.Animation_New(durationSeconds), true)
664         {
665             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
666
667         }
668
669         /// <summary>
670         /// Downcasts a handle to Animation handle.<br>
671         /// If handle points to an Animation object, the downcast produces valid handle.<br>
672         /// If not, the returned handle is left uninitialized.<br>
673         /// </summary>
674         /// <param name="handle">Handle to an object</param>
675         /// <returns>Handle to an Animation object or an uninitialized handle</returns>
676         public static Animation DownCast(BaseHandle handle)
677         {
678             Animation ret = new Animation(NDalicPINVOKE.Animation_DownCast(BaseHandle.getCPtr(handle)), true);
679             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
680             return ret;
681         }
682
683         internal Animation(Animation handle) : this(NDalicPINVOKE.new_Animation__SWIG_1(Animation.getCPtr(handle)), true)
684         {
685             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
686         }
687
688         internal Animation Assign(Animation rhs)
689         {
690             Animation ret = new Animation(NDalicPINVOKE.Animation_Assign(swigCPtr, Animation.getCPtr(rhs)), false);
691             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692             return ret;
693         }
694
695         internal void SetDuration(float seconds)
696         {
697             NDalicPINVOKE.Animation_SetDuration(swigCPtr, seconds);
698             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699         }
700
701         internal float GetDuration()
702         {
703             float ret = NDalicPINVOKE.Animation_GetDuration(swigCPtr);
704             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
705             return ret;
706         }
707
708         internal void SetLooping(bool looping)
709         {
710             NDalicPINVOKE.Animation_SetLooping(swigCPtr, looping);
711             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
712         }
713
714         internal void SetLoopCount(int count)
715         {
716             NDalicPINVOKE.Animation_SetLoopCount(swigCPtr, count);
717             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718         }
719
720         internal int GetLoopCount()
721         {
722             int ret = NDalicPINVOKE.Animation_GetLoopCount(swigCPtr);
723             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
724             return ret;
725         }
726
727         internal int GetCurrentLoop()
728         {
729             int ret = NDalicPINVOKE.Animation_GetCurrentLoop(swigCPtr);
730             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
731             return ret;
732         }
733
734         internal bool IsLooping()
735         {
736             bool ret = NDalicPINVOKE.Animation_IsLooping(swigCPtr);
737             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
738             return ret;
739         }
740
741         internal void SetEndAction(Animation.EndActions action)
742         {
743             NDalicPINVOKE.Animation_SetEndAction(swigCPtr, (int)action);
744             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
745         }
746
747         internal Animation.EndActions GetEndAction()
748         {
749             Animation.EndActions ret = (Animation.EndActions)NDalicPINVOKE.Animation_GetEndAction(swigCPtr);
750             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
751             return ret;
752         }
753
754         internal void SetDisconnectAction(Animation.EndActions disconnectAction)
755         {
756             NDalicPINVOKE.Animation_SetDisconnectAction(swigCPtr, (int)disconnectAction);
757             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758         }
759
760         internal Animation.EndActions GetDisconnectAction()
761         {
762             Animation.EndActions ret = (Animation.EndActions)NDalicPINVOKE.Animation_GetDisconnectAction(swigCPtr);
763             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
764             return ret;
765         }
766
767         internal void SetDefaultAlphaFunction(AlphaFunction alpha)
768         {
769             NDalicPINVOKE.Animation_SetDefaultAlphaFunction(swigCPtr, AlphaFunction.getCPtr(alpha));
770             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
771         }
772
773         internal AlphaFunction GetDefaultAlphaFunction()
774         {
775             AlphaFunction ret = new AlphaFunction(NDalicPINVOKE.Animation_GetDefaultAlphaFunction(swigCPtr), true);
776             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
777             return ret;
778         }
779
780         internal void SetCurrentProgress(float progress)
781         {
782             NDalicPINVOKE.Animation_SetCurrentProgress(swigCPtr, progress);
783             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
784         }
785
786         internal float GetCurrentProgress()
787         {
788             float ret = NDalicPINVOKE.Animation_GetCurrentProgress(swigCPtr);
789             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
790             return ret;
791         }
792
793         internal void SetSpeedFactor(float factor)
794         {
795             NDalicPINVOKE.Animation_SetSpeedFactor(swigCPtr, factor);
796             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
797         }
798
799         internal float GetSpeedFactor()
800         {
801             float ret = NDalicPINVOKE.Animation_GetSpeedFactor(swigCPtr);
802             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
803             return ret;
804         }
805
806         internal void SetPlayRange(Vector2 range)
807         {
808             NDalicPINVOKE.Animation_SetPlayRange(swigCPtr, Vector2.getCPtr(range));
809             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
810         }
811
812         internal Vector2 GetPlayRange()
813         {
814             Vector2 ret = new Vector2(NDalicPINVOKE.Animation_GetPlayRange(swigCPtr), true);
815             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
816             return ret;
817         }
818
819         /// <summary>
820         /// Plays the animation.
821         /// </summary>
822         public void Play()
823         {
824             NDalicPINVOKE.Animation_Play(swigCPtr);
825             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
826 #if DISABLE_ANIMATION
827             Stop(EndActions.StopFinal);
828 #endif
829         }
830
831         /// <summary>
832         /// Plays the animation from a given point.<br>
833         /// The progress must be in the 0-1 interval or in the play range interval if defined,
834         /// otherwise, it will be ignored.<br>
835         /// </summary>
836         /// <param name="progress">A value between [0,1], or between the play range if specified, from where the animation should start playing</param>
837         public void PlayFrom(float progress)
838         {
839             NDalicPINVOKE.Animation_PlayFrom(swigCPtr, progress);
840             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
841         }
842
843         /// <summary>
844         /// Pauses the animation.
845         /// </summary>
846         public void Pause()
847         {
848             NDalicPINVOKE.Animation_Pause(swigCPtr);
849             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
850         }
851
852         internal Animation.States GetState()
853         {
854             Animation.States ret = (Animation.States)NDalicPINVOKE.Animation_GetState(swigCPtr);
855             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
856             return ret;
857         }
858
859         /// <summary>
860         /// Stops the animation.
861         /// </summary>
862         public void Stop()
863         {
864             NDalicPINVOKE.Animation_Stop(swigCPtr);
865             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
866         }
867
868         /// <summary>
869         /// Clears the animation.<br>
870         /// This disconnects any objects that were being animated, effectively stopping the animation.<br>
871         /// </summary>
872         public void Clear()
873         {
874             NDalicPINVOKE.Animation_Clear(swigCPtr);
875             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876         }
877
878         internal AnimationSignal FinishedSignal()
879         {
880             AnimationSignal ret = new AnimationSignal(NDalicPINVOKE.Animation_FinishedSignal(swigCPtr), false);
881             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
882             return ret;
883         }
884
885         internal void AnimateBy(Property target, PropertyValue relativeValue)
886         {
887             NDalicPINVOKE.Animation_AnimateBy__SWIG_0(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));
888             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
889         }
890
891         internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha)
892         {
893             NDalicPINVOKE.Animation_AnimateBy__SWIG_1(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha));
894             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
895         }
896
897         internal void AnimateBy(Property target, PropertyValue relativeValue, TimePeriod period)
898         {
899             NDalicPINVOKE.Animation_AnimateBy__SWIG_2(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), TimePeriod.getCPtr(period));
900             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901         }
902
903         internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha, TimePeriod period)
904         {
905             NDalicPINVOKE.Animation_AnimateBy__SWIG_3(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
906             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
907         }
908
909         internal void AnimateTo(Property target, PropertyValue destinationValue)
910         {
911             NDalicPINVOKE.Animation_AnimateTo__SWIG_0(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue));
912             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
913         }
914
915         internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha)
916         {
917             NDalicPINVOKE.Animation_AnimateTo__SWIG_1(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha));
918             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
919         }
920
921         internal void AnimateTo(Property target, PropertyValue destinationValue, TimePeriod period)
922         {
923             NDalicPINVOKE.Animation_AnimateTo__SWIG_2(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), TimePeriod.getCPtr(period));
924             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
925         }
926
927         internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha, TimePeriod period)
928         {
929             NDalicPINVOKE.Animation_AnimateTo__SWIG_3(swigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
930             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
931         }
932
933         internal void AnimateBetween(Property target, KeyFrames keyFrames)
934         {
935             NDalicPINVOKE.Animation_AnimateBetween__SWIG_0(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames));
936             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
937         }
938
939         internal void AnimateBetween(Property target, KeyFrames keyFrames, Animation.Interpolation interpolation)
940         {
941             NDalicPINVOKE.Animation_AnimateBetween__SWIG_1(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), (int)interpolation);
942             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
943         }
944
945         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
946         {
947             NDalicPINVOKE.Animation_AnimateBetween__SWIG_2(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha));
948             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
949         }
950
951         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
952         {
953             NDalicPINVOKE.Animation_AnimateBetween__SWIG_3(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), (int)interpolation);
954             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
955         }
956
957         internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
958         {
959             NDalicPINVOKE.Animation_AnimateBetween__SWIG_4(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period));
960             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
961         }
962
963         internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period, Animation.Interpolation interpolation)
964         {
965             NDalicPINVOKE.Animation_AnimateBetween__SWIG_5(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period), (int)interpolation);
966             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967         }
968
969         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
970         {
971             NDalicPINVOKE.Animation_AnimateBetween__SWIG_6(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
972             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
973         }
974
975         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
976         {
977             NDalicPINVOKE.Animation_AnimateBetween__SWIG_7(swigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period), (int)interpolation);
978             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
979         }
980
981         internal void Animate(View view, Path path, Vector3 forward)
982         {
983             NDalicPINVOKE.Animation_Animate__SWIG_0(swigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward));
984             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
985         }
986
987         internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha)
988         {
989             NDalicPINVOKE.Animation_Animate__SWIG_1(swigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha));
990             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
991         }
992
993         internal void Animate(View view, Path path, Vector3 forward, TimePeriod period)
994         {
995             NDalicPINVOKE.Animation_Animate__SWIG_2(swigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), TimePeriod.getCPtr(period));
996             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
997         }
998
999         internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha, TimePeriod period)
1000         {
1001             NDalicPINVOKE.Animation_Animate__SWIG_3(swigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1002             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1003         }
1004
1005         internal void Show(View view, float delaySeconds)
1006         {
1007             NDalicPINVOKE.Animation_Show(swigCPtr, View.getCPtr(view), delaySeconds);
1008             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1009         }
1010
1011         internal void Hide(View view, float delaySeconds)
1012         {
1013             NDalicPINVOKE.Animation_Hide(swigCPtr, View.getCPtr(view), delaySeconds);
1014             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1015         }
1016
1017         /// <summary>
1018         /// Enumeration for what to do when the animation ends, is stopped, or is destroyed.
1019         /// </summary>
1020         public enum EndActions
1021         {
1022             /// <summary>
1023             /// When the animation ends, the animated property values are saved.
1024             /// </summary>
1025             Cancel,
1026             /// <summary>
1027             /// When the animation ends, the animated property values are forgotten.
1028             /// </summary>
1029             Discard,
1030             /// <summary>
1031             /// If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like Cancel.
1032             /// </summary>
1033             StopFinal
1034         }
1035
1036         /// <summary>
1037         /// Enumeration for what interpolation method to use on key-frame animations.
1038         /// </summary>
1039         public enum Interpolation
1040         {
1041             /// <summary>
1042             /// Values in between key frames are interpolated using a linear polynomial. (Default)
1043             /// </summary>
1044             Linear,
1045             /// <summary>
1046             /// Values in between key frames are interpolated using a cubic polynomial.
1047             /// </summary>
1048             Cubic
1049         }
1050
1051         /// <summary>
1052         /// Enumeration for what state the animation is in.
1053         /// </summary>
1054         /// <remarks>Calling Reset() on this class will NOT reset the animation. It will call BaseHandle.Reset() which drops the object handle.</remarks>
1055         public enum States
1056         {
1057             /// <summary>
1058             /// Animation has stopped
1059             /// </summary>
1060             Stopped,
1061             /// <summary>
1062             /// The animation is playing
1063             /// </summary>
1064             Playing,
1065             /// <summary>
1066             /// The animation is paused
1067             /// </summary>
1068             Paused
1069         }
1070
1071     }
1072
1073 }