2 * Copyright(c) 2019 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.
18 using System.ComponentModel;
24 /// Alpha functions are used in animations to specify the rate of change of the animation parameter over time.<br />
25 /// Understanding an animation as a parametric function over time, the alpha function is applied to the parameter of
26 /// the animation before computing the final animation value.
28 /// <since_tizen> 3 </since_tizen>
29 public class AlphaFunction : Disposable
33 /// The constructor.<br />
34 /// Creates an alpha function object with the user-defined alpha function.<br />
36 /// <param name="func">User defined fuction. It must be a method formatted as float alphafunction(float progress)</param>
37 /// <since_tizen> 3 </since_tizen>
38 public AlphaFunction(global::System.Delegate func) : this(Interop.AlphaFunction.NewAlphaFunction(SWIGTYPE_p_f_float__float.getCPtr(new SWIGTYPE_p_f_float__float(System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func)))), true)
40 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
44 /// The default constructor.<br />
45 /// Creates an alpha function object with the default built-in alpha function.<br />
47 /// <since_tizen> 3 </since_tizen>
48 public AlphaFunction() : this(Interop.AlphaFunction.NewAlphaFunction(), true)
50 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 /// The constructor.<br />
55 /// Creates an alpha function object with the built-in alpha function passed as a parameter to the constructor.<br />
57 /// <param name="function">One of the built-in alpha functions.</param>
58 /// <since_tizen> 3 </since_tizen>
59 public AlphaFunction(AlphaFunction.BuiltinFunctions function) : this(Interop.AlphaFunction.NewAlphaFunction((int)function), true)
61 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65 /// The constructor.<br />
66 /// Creates a bezier alpha function. The bezier will have the first point at (0,0) and the end point at (1,1).<br />
68 /// <remarks>The x components of the control points will be clamped to the range [0, 1] to prevent non-monotonic curves.</remarks>
69 /// <param name="controlPoint0">A Vector2 which will be used as the first control point of the curve.</param>
70 /// <param name="controlPoint1">A Vector2 which will be used as the second control point of the curve.</param>
71 /// <since_tizen> 3 </since_tizen>
72 public AlphaFunction(Vector2 controlPoint0, Vector2 controlPoint1) : this(Interop.AlphaFunction.NewAlphaFunction(Vector2.getCPtr(controlPoint0), Vector2.getCPtr(controlPoint1)), true)
74 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77 internal AlphaFunction(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
81 internal AlphaFunction(SWIGTYPE_p_f_float__float function) : this(Interop.AlphaFunction.NewAlphaFunction(SWIGTYPE_p_f_float__float.getCPtr(function)), true)
83 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
87 /// This specifies the various types of BuiltinFunctions.
89 /// <since_tizen> 3 </since_tizen>
90 public enum BuiltinFunctions
95 [Description("DEFAULT")]
98 /// No transformation.
100 [Description("LINEAR")]
105 [Description("REVERSE")]
108 /// Speeds up and comes to a sudden stop (square).
110 [Description("EASE_IN_SQUARE")]
113 /// Sudden start and slows to a gradual stop (square).
115 [Description("EASE_OUT_SQUARE")]
118 /// Speeds up and comes to a sudden stop (cubic).
120 [Description("EASE_IN")]
123 /// Sudden start and slows to a gradual stop (cubic).
125 [Description("EASE_OUT")]
128 /// Speeds up and slows to a gradual stop (cubic).
130 [Description("EASE_IN_OUT")]
133 /// Speeds up and comes to a sudden stop (sinusoidal).
135 [Description("EASE_IN_SINE")]
138 /// Sudden start and slows to a gradual stop (sinusoidal).
140 [Description("EASE_OUT_SINE")]
143 /// Speeds up and slows to a gradual stop (sinusoidal).
145 [Description("EASE_IN_OUT_SINE")]
148 /// Sudden start, loses momentum and returns to start position.
150 [Description("BOUNCE")]
153 /// Single revolution.
158 /// Sudden start, exceed end position and return to a gradual stop.
160 [Description("EASE_OUT_BACK")]
163 /// The count of the BuiltinFunctions enum.
169 /// This specifies which mode is set for AlphaFunction.
171 /// <since_tizen> 3 </since_tizen>
175 /// The user has used a built-in function.
180 /// The user has provided a custom function.
184 /// The user has provided the control points of a bezier curve.
190 /// Retrives the control points of the alpha function.<br />
192 /// <param name="controlPoint0">A Vector2 which will be used as the first control point of the curve.</param>
193 /// <param name="controlPoint1">A Vector2 which will be used as the second control point of the curve.</param>
194 /// <since_tizen> 3 </since_tizen>
195 public void GetBezierControlPoints(out Vector2 controlPoint0, out Vector2 controlPoint1)
197 Vector4 ret = new Vector4(Interop.AlphaFunction.GetBezierControlPoints(SwigCPtr), true);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200 controlPoint0 = new Vector2(ret.X, ret.Y);
201 controlPoint1 = new Vector2(ret.Z, ret.W);
205 /// Returns the built-in function used by the alpha function.<br />
206 /// In case no built-in function has been specified, it will return AlphaFunction::DEFAULT.<br />
208 /// <returns>One of the built-in alpha functions.</returns>
209 /// <since_tizen> 3 </since_tizen>
210 public AlphaFunction.BuiltinFunctions GetBuiltinFunction()
212 AlphaFunction.BuiltinFunctions ret = (AlphaFunction.BuiltinFunctions)Interop.AlphaFunction.GetBuiltinFunction(SwigCPtr);
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 /// Returns the functioning mode of the alpha function.
220 /// <returns>The functioning mode of the alpha function.</returns>
221 /// <since_tizen> 3 </since_tizen>
222 public AlphaFunction.Modes GetMode()
224 AlphaFunction.Modes ret = (AlphaFunction.Modes)Interop.AlphaFunction.GetMode(SwigCPtr);
225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AlphaFunction obj)
231 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
234 internal static string BuiltinToPropertyKey(BuiltinFunctions? alphaFunction)
236 string propertyKey = null;
237 if (alphaFunction != null)
239 switch (alphaFunction)
241 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Linear:
243 propertyKey = "LINEAR";
246 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Reverse:
248 propertyKey = "REVERSE";
251 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSquare:
253 propertyKey = "EASE_IN_SQUARE";
256 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSquare:
258 propertyKey = "EASE_OUT_SQUARE";
261 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseIn:
263 propertyKey = "EASE_IN";
266 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOut:
268 propertyKey = "EASE_OUT";
271 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOut:
273 propertyKey = "EASE_IN_OUT";
276 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSine:
278 propertyKey = "EASE_IN_SINE";
281 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSine:
283 propertyKey = "EASE_OUT_SINE";
286 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOutSine:
288 propertyKey = "EASE_IN_OUT_SINE";
291 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Bounce:
293 propertyKey = "BOUNCE";
296 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Sin:
301 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutBack:
303 propertyKey = "EASE_OUT_BACK";
308 propertyKey = "DEFAULT";
316 internal SWIGTYPE_p_f_float__float GetCustomFunction()
318 global::System.IntPtr cPtr = Interop.AlphaFunction.GetCustomFunction(SwigCPtr);
319 SWIGTYPE_p_f_float__float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_float__float(cPtr);
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 /// This will not be public opened.
325 [EditorBrowsable(EditorBrowsableState.Never)]
326 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
328 Interop.AlphaFunction.DeleteAlphaFunction(swigCPtr);