16382da201eaa72370e2a538d19954e7a3e6f784
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / KeyFrames.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
17 using System;
18
19 namespace Tizen.NUI
20 {
21
22     /// <summary>
23     /// A set of key frames for a property that can be animated using Dali Animation.<br>
24     /// This allows the generation of key frame objects from individual Property::Values.<br>
25     /// </summary>
26     public class KeyFrames : BaseHandle
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         internal KeyFrames(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.KeyFrames_SWIGUpcast(cPtr), cMemoryOwn)
31         {
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33         }
34
35         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(KeyFrames obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         protected override void Dispose(DisposeTypes type)
41         {
42             if(disposed)
43             {
44                 return;
45             }
46
47             if(type == DisposeTypes.Explicit)
48             {
49                 //Called by User
50                 //Release your own managed resources here.
51                 //You should release all of your own disposable objects here.
52             }
53
54             //Release your own unmanaged resources here.
55             //You should not access any managed member here except static instance.
56             //because the execution order of Finalizes is non-deterministic.
57
58             if (swigCPtr.Handle != global::System.IntPtr.Zero)
59             {
60                 if (swigCMemOwn)
61                 {
62                     swigCMemOwn = false;
63
64                     //Unreference this instance from Registry.
65                     Registry.Unregister(this);
66
67                     NDalicPINVOKE.delete_KeyFrames(swigCPtr);
68                 }
69                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
70             }
71
72             base.Dispose(type);
73         }
74
75
76
77         /// <summary>
78         /// Adds a key frame.
79         /// </summary>
80         /// <param name="progress">A progress value between 0.0 and 1.0</param>
81         /// <param name="value">A value</param>
82         public void Add(float progress, object value)
83         {
84             PropertyValue val = PropertyValue.CreateFromObject(value);
85             Add(progress, val);
86         }
87
88         /// <summary>
89         /// Adds a key frame.
90         /// </summary>
91         /// <param name="progress">A progress value between 0.0 and 1.0</param>
92         /// <param name="value">A value</param>
93         /// <param name="alpha">The alpha function used to blend to the next keyframe</param>
94         public void Add(float progress, object value, AlphaFunction alpha)
95         {
96             PropertyValue val = PropertyValue.CreateFromObject(value);
97             Add(progress, val, alpha);
98         }
99
100         /// <summary>
101         /// Creates an initialized KeyFrames handle.
102         /// </summary>
103         public KeyFrames() : this(NDalicPINVOKE.KeyFrames_New(), true)
104         {
105             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106
107         }
108
109         [Obsolete("Please do not use! this will be deprecated")]
110         public static KeyFrames DownCast(BaseHandle handle)
111         {
112             KeyFrames ret = new KeyFrames(NDalicPINVOKE.KeyFrames_DownCast(BaseHandle.getCPtr(handle)), true);
113             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114             return ret;
115         }
116
117         /// <summary>
118         /// Gets the type of the key frame.
119         /// </summary>
120         /// <returns>The key frame property type</returns>
121         public PropertyType GetType()
122         {
123             PropertyType ret = (PropertyType)NDalicPINVOKE.KeyFrames_GetType(swigCPtr);
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125             return ret;
126         }
127
128         /// <summary>
129         /// Adds a key frame.
130         /// </summary>
131         /// <param name="progress">A progress value between 0.0 and 1.0</param>
132         /// <param name="value">A value</param>
133         public void Add(float progress, PropertyValue value)
134         {
135             NDalicPINVOKE.KeyFrames_Add__SWIG_0(swigCPtr, progress, PropertyValue.getCPtr(value));
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137         }
138
139         /// <summary>
140         /// Adds a key frame.
141         /// </summary>
142         /// <param name="progress">A progress value between 0.0 and 1.0</param>
143         /// <param name="value">A value</param>
144         /// <param name="alpha">The alpha function used to blend to the next keyframe</param>
145         public void Add(float progress, PropertyValue value, AlphaFunction alpha)
146         {
147             NDalicPINVOKE.KeyFrames_Add__SWIG_1(swigCPtr, progress, PropertyValue.getCPtr(value), AlphaFunction.getCPtr(alpha));
148             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149         }
150
151     }
152
153 }