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 function. 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 // Not used : This will be remained by 2021-05-30 to check side effect. After 2021-05-30 this will be removed cleanly
82 // internal AlphaFunction(SWIGTYPE_p_f_float__float function) : this(Interop.AlphaFunction.NewAlphaFunction(SWIGTYPE_p_f_float__float.getCPtr(function)), true)
84 // if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 /// This specifies the various types of BuiltinFunctions.
90 /// <since_tizen> 3 </since_tizen>
91 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
92 public enum BuiltinFunctions
97 [Description("DEFAULT")]
100 /// No transformation.
102 [Description("LINEAR")]
107 [Description("REVERSE")]
110 /// Speeds up and comes to a sudden stop (square).
112 [Description("EASE_IN_SQUARE")]
115 /// Sudden start and slows to a gradual stop (square).
117 [Description("EASE_OUT_SQUARE")]
120 /// Speeds up and comes to a sudden stop (cubic).
122 [Description("EASE_IN")]
125 /// Sudden start and slows to a gradual stop (cubic).
127 [Description("EASE_OUT")]
130 /// Speeds up and slows to a gradual stop (cubic).
132 [Description("EASE_IN_OUT")]
135 /// Speeds up and comes to a sudden stop (sinusoidal).
137 [Description("EASE_IN_SINE")]
140 /// Sudden start and slows to a gradual stop (sinusoidal).
142 [Description("EASE_OUT_SINE")]
145 /// Speeds up and slows to a gradual stop (sinusoidal).
147 [Description("EASE_IN_OUT_SINE")]
150 /// Sudden start, loses momentum and returns to start position.
152 [Description("BOUNCE")]
155 /// Single revolution.
160 /// Sudden start, exceed end position and return to a gradual stop.
162 [Description("EASE_OUT_BACK")]
165 /// The count of the BuiltinFunctions enum.
171 /// This specifies which mode is set for AlphaFunction.
173 /// <since_tizen> 3 </since_tizen>
174 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
178 /// The user has used a built-in function.
183 /// The user has provided a custom function.
187 /// The user has provided the control points of a bezier curve.
193 /// Retrieves the control points of the alpha function.<br />
195 /// <param name="controlPoint0">A Vector2 which will be used as the first control point of the curve.</param>
196 /// <param name="controlPoint1">A Vector2 which will be used as the second control point of the curve.</param>
197 /// <since_tizen> 3 </since_tizen>
198 public void GetBezierControlPoints(out Vector2 controlPoint0, out Vector2 controlPoint1)
200 Vector4 ret = new Vector4(Interop.AlphaFunction.GetBezierControlPoints(SwigCPtr), true);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 controlPoint0 = new Vector2(ret.X, ret.Y);
204 controlPoint1 = new Vector2(ret.Z, ret.W);
208 /// Returns the built-in function used by the alpha function.<br />
209 /// In case no built-in function has been specified, it will return AlphaFunction::DEFAULT.<br />
211 /// <returns>One of the built-in alpha functions.</returns>
212 /// <since_tizen> 3 </since_tizen>
213 public AlphaFunction.BuiltinFunctions GetBuiltinFunction()
215 AlphaFunction.BuiltinFunctions ret = (AlphaFunction.BuiltinFunctions)Interop.AlphaFunction.GetBuiltinFunction(SwigCPtr);
216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221 /// Returns the functioning mode of the alpha function.
223 /// <returns>The functioning mode of the alpha function.</returns>
224 /// <since_tizen> 3 </since_tizen>
225 public AlphaFunction.Modes GetMode()
227 AlphaFunction.Modes ret = (AlphaFunction.Modes)Interop.AlphaFunction.GetMode(SwigCPtr);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 internal static string BuiltinToPropertyKey(BuiltinFunctions? alphaFunction)
234 string propertyKey = null;
235 if (alphaFunction != null)
237 switch (alphaFunction)
239 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Linear:
241 propertyKey = "LINEAR";
244 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Reverse:
246 propertyKey = "REVERSE";
249 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSquare:
251 propertyKey = "EASE_IN_SQUARE";
254 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSquare:
256 propertyKey = "EASE_OUT_SQUARE";
259 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseIn:
261 propertyKey = "EASE_IN";
264 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOut:
266 propertyKey = "EASE_OUT";
269 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOut:
271 propertyKey = "EASE_IN_OUT";
274 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSine:
276 propertyKey = "EASE_IN_SINE";
279 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSine:
281 propertyKey = "EASE_OUT_SINE";
284 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOutSine:
286 propertyKey = "EASE_IN_OUT_SINE";
289 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Bounce:
291 propertyKey = "BOUNCE";
294 case Tizen.NUI.AlphaFunction.BuiltinFunctions.Sin:
299 case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutBack:
301 propertyKey = "EASE_OUT_BACK";
306 propertyKey = "DEFAULT";
314 // Not used : This will be remained by 2021-05-30 to check side effect. After 2021-05-30 this will be removed cleanly
315 // internal SWIGTYPE_p_f_float__float GetCustomFunction()
317 // global::System.IntPtr cPtr = Interop.AlphaFunction.GetCustomFunction(SwigCPtr);
318 // SWIGTYPE_p_f_float__float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_float__float(cPtr);
319 // if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 /// This will not be public opened.
324 [EditorBrowsable(EditorBrowsableState.Never)]
325 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
327 Interop.AlphaFunction.DeleteAlphaFunction(swigCPtr);