41c608894db2ba019db02ea6a6fa11ac79b0adc2
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / AlphaFunction.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     /// <summary>
23     /// Alpha functions are used in animations to specify the rate of change of the animation parameter over time.<br>
24     /// Understanding an animation as a parametric function over time, the alpha function is applied to the parameter of
25     /// the animation before computing the final animation value.
26     /// </summary>
27     public class AlphaFunction : global::System.IDisposable
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30         protected bool swigCMemOwn;
31
32         internal AlphaFunction(global::System.IntPtr cPtr, bool cMemoryOwn)
33         {
34             swigCMemOwn = cMemoryOwn;
35             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36         }
37
38         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AlphaFunction obj)
39         {
40             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
41         }
42
43         //A Flag to check who called Dispose(). (By User or DisposeQueue)
44         private bool isDisposeQueued = false;
45         //A Flat to check if it is already disposed.
46         protected bool disposed = false;
47
48         ~AlphaFunction()
49         {
50             if(!isDisposeQueued)
51             {
52                 isDisposeQueued = true;
53                 DisposeQueue.Instance.Add(this);
54             }
55         }
56         /// <summary>
57         /// To make the AlphaFunction instance be disposed.
58         /// </summary>
59         public void Dispose()
60         {
61             //Throw excpetion if Dispose() is called in separate thread.
62             if (!Window.IsInstalled())
63             {
64                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
65             }
66
67             if (isDisposeQueued)
68             {
69                 Dispose(DisposeTypes.Implicit);
70             }
71             else
72             {
73                 Dispose(DisposeTypes.Explicit);
74                 System.GC.SuppressFinalize(this);
75             }
76         }
77
78         protected virtual void Dispose(DisposeTypes type)
79         {
80             if (disposed)
81             {
82                 return;
83             }
84
85             if(type == DisposeTypes.Explicit)
86             {
87                 //Called by User
88                 //Release your own managed resources here.
89                 //You should release all of your own disposable objects here.
90             }
91
92             //Release your own unmanaged resources here.
93             //You should not access any managed member here except static instance.
94             //because the execution order of Finalizes is non-deterministic.
95
96             if (swigCPtr.Handle != global::System.IntPtr.Zero)
97             {
98                 if (swigCMemOwn)
99                 {
100                     swigCMemOwn = false;
101                     NDalicPINVOKE.delete_AlphaFunction(swigCPtr);
102                 }
103                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
104             }
105             disposed = true;
106         }
107
108         /// <summary>
109         /// The constructor.<br>
110         /// Creates an alpha function object with the user-defined alpha function.<br>
111         /// </summary>
112         /// <param name="func">User defined fuction. It must be a method formatted as float alphafunction(float progress)</param>
113         public AlphaFunction(System.Delegate func) : this(NDalicPINVOKE.new_AlphaFunction__SWIG_2(SWIGTYPE_p_f_float__float.getCPtr(new SWIGTYPE_p_f_float__float(System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func), true))), true)
114         {
115             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116         }
117
118         /// <summary>
119         /// The default constructor.<br>
120         /// Creates an alpha function object with the default built-in alpha function.<br>
121         /// </summary>
122         public AlphaFunction() : this(NDalicPINVOKE.new_AlphaFunction__SWIG_0(), true)
123         {
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125         }
126
127         /// <summary>
128         /// The constructor.<br>
129         /// Creates an alpha function object with the built-in alpha function passed as a parameter to the constructor.<br>
130         /// </summary>
131         /// <param name="function">One of the built-in alpha functions.</param>
132         public AlphaFunction(AlphaFunction.BuiltinFunctions function) : this(NDalicPINVOKE.new_AlphaFunction__SWIG_1((int)function), true)
133         {
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135         }
136
137         internal AlphaFunction(SWIGTYPE_p_f_float__float function) : this(NDalicPINVOKE.new_AlphaFunction__SWIG_2(SWIGTYPE_p_f_float__float.getCPtr(function)), true)
138         {
139             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140         }
141
142         /// <summary>
143         /// The constructor.<br>
144         /// Creates a bezier alpha function. The bezier will have the first point at (0,0) and the end point at (1,1).<br>
145         /// </summary>
146         /// <remarks>The x components of the control points will be clamped to the range [0, 1] to prevent non-monotonic curves.</remarks>
147         /// <param name="controlPoint0">A Vector2 which will be used as the first control point of the curve.</param>
148         /// <param name="controlPoint1">A Vector2 which will be used as the second control point of the curve.</param>
149         public AlphaFunction(Vector2 controlPoint0, Vector2 controlPoint1) : this(NDalicPINVOKE.new_AlphaFunction__SWIG_3(Vector2.getCPtr(controlPoint0), Vector2.getCPtr(controlPoint1)), true)
150         {
151             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152         }
153
154         /// <summary>
155         /// Retrives the control points of the alpha function.<br>
156         /// </summary>
157         /// <param name="controlPoint0">A Vector2 which will be used as the first control point of the curve.</param>
158         /// <param name="controlPoint1">A Vector2 which will be used as the second control point of the curve.</param>
159         public void GetBezierControlPoints(out Vector2 controlPoint0, out Vector2 controlPoint1)
160         {
161             Vector4 ret = new Vector4(NDalicPINVOKE.AlphaFunction_GetBezierControlPoints(swigCPtr), true);
162             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163
164             controlPoint0 = new Vector2(ret.X, ret.Y);
165             controlPoint1 = new Vector2(ret.Z, ret.W);
166         }
167
168         internal SWIGTYPE_p_f_float__float GetCustomFunction()
169         {
170             global::System.IntPtr cPtr = NDalicPINVOKE.AlphaFunction_GetCustomFunction(swigCPtr);
171             SWIGTYPE_p_f_float__float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_float__float(cPtr, false);
172             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173             return ret;
174         }
175
176         /// <summary>
177         /// Returns the built-in function used by the alpha function.<br>
178         /// In case no built-in function has been specified, it will return AlphaFunction::DEFAULT.<br>
179         /// </summary>
180         /// <returns>One of the built-in alpha functions.</returns>
181         public AlphaFunction.BuiltinFunctions GetBuiltinFunction()
182         {
183             AlphaFunction.BuiltinFunctions ret = (AlphaFunction.BuiltinFunctions)NDalicPINVOKE.AlphaFunction_GetBuiltinFunction(swigCPtr);
184             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185             return ret;
186         }
187
188         /// <summary>
189         ///  Returns the functioning mode of the alpha function.
190         /// </summary>
191         /// <returns>The functioning mode of the alpha function.</returns>
192         public AlphaFunction.Modes GetMode()
193         {
194             AlphaFunction.Modes ret = (AlphaFunction.Modes)NDalicPINVOKE.AlphaFunction_GetMode(swigCPtr);
195             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196             return ret;
197         }
198
199         /// <summary>
200         /// This specifies the various types of BuiltinFunctions.
201         /// </summary>
202         public enum BuiltinFunctions
203         {
204             /// <summary>
205             /// Linear.
206             /// </summary>
207             Default,
208             /// <summary>
209             /// No transformation.
210             /// </summary>
211             Linear,
212             /// <summary>
213             /// Reverse linear.
214             /// </summary>
215             Reverse,
216             /// <summary>
217             /// Speeds up and comes to a sudden stop (square).
218             /// </summary>
219             EaseInSquare,
220             /// <summary>
221             /// Sudden start and slows to a gradual stop (square).
222             /// </summary>
223             EaseOutSquare,
224             /// <summary>
225             /// Speeds up and comes to a sudden stop (cubic).
226             /// </summary>
227             EaseIn,
228             /// <summary>
229             /// Sudden start and slows to a gradual stop (cubic).
230             /// </summary>
231             EaseOut,
232             /// <summary>
233             /// Speeds up and slows to a gradual stop (cubic).
234             /// </summary>
235             EaseInOut,
236             /// <summary>
237             /// Speeds up and comes to a sudden stop (sinusoidal).
238             /// </summary>
239             EaseInSine,
240             /// <summary>
241             /// Sudden start and slows to a gradual stop (sinusoidal).
242             /// </summary>
243             EaseOutSine,
244             /// <summary>
245             /// Speeds up and slows to a gradual stop (sinusoidal).
246             /// </summary>
247             EaseInOutSine,
248             /// <summary>
249             /// Sudden start, loses momentum and returns to start position.
250             /// </summary>
251             Bounce,
252             /// <summary>
253             /// Single revolution.
254             /// </summary>
255             Sin,
256             /// <summary>
257             /// Sudden start, exceed end position and return to a gradual stop.
258             /// </summary>
259             EaseOutBack,
260             Count
261         }
262
263         /// <summary>
264         /// This specifies which mode is set for AlphaFunction.
265         /// </summary>
266         public enum Modes
267         {
268             /// <summary>
269             /// The user has used a built-in function.
270             /// </summary>
271             BuiltinFunction,
272
273             /// <summary>
274             /// The user has provided a custom function.
275             /// </summary>
276             CustomFunction,
277             /// <summary>
278             /// The user has provided the control points of a bezier curve.
279             /// </summary>
280             Bezier
281         }
282
283         internal static string BuiltinToPropertyKey(BuiltinFunctions? alphaFunction)
284         {
285             string propertyKey = null;
286             if (alphaFunction != null)
287             {
288                 switch (alphaFunction)
289                 {
290                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.Linear:
291                     {
292                         propertyKey = "LINEAR";
293                         break;
294                     }
295                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.Reverse:
296                     {
297                         propertyKey = "REVERSE";
298                         break;
299                     }
300                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSquare:
301                     {
302                         propertyKey = "EASE_IN_SQUARE";
303                         break;
304                     }
305                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSquare:
306                     {
307                         propertyKey = "EASE_OUT_SQUARE";
308                         break;
309                     }
310                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseIn:
311                     {
312                         propertyKey = "EASE_IN";
313                         break;
314                     }
315                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOut:
316                     {
317                         propertyKey = "EASE_OUT";
318                         break;
319                     }
320                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOut:
321                     {
322                         propertyKey = "EASE_IN_OUT";
323                         break;
324                     }
325                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSine:
326                     {
327                         propertyKey = "EASE_IN_SINE";
328                         break;
329                     }
330                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSine:
331                     {
332                         propertyKey = "EASE_OUT_SINE";
333                         break;
334                     }
335                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOutSine:
336                     {
337                         propertyKey = "EASE_IN_OUT_SINE";
338                         break;
339                     }
340                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.Bounce:
341                     {
342                         propertyKey = "BOUNCE";
343                         break;
344                     }
345                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.Sin:
346                     {
347                         propertyKey = "SIN";
348                         break;
349                     }
350                     case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutBack:
351                     {
352                         propertyKey = "EASE_OUT_BACK";
353                         break;
354                     }
355                     default:
356                     {
357                         propertyKey = "DEFAULT";
358                         break;
359                     }
360                 }
361             }
362             return propertyKey;
363         }
364     }
365 }