Boost::any replacement in Dali Core functions
[platform/core/uifw/dali-core.git] / capi / dali / public-api / animation / interpolator-functions.h
1 #ifndef __DALI_INTERPOLATOR_FUNCTIONS_H__
2 #define __DALI_INTERPOLATOR_FUNCTIONS_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 /**
21  * @addtogroup CAPI_DALI_ANIMATION_MODULE
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/object/any.h>
27 #include <dali/public-api/math/vector2.h>
28 #include <dali/public-api/math/vector3.h>
29 #include <dali/public-api/math/vector4.h>
30 #include <dali/public-api/math/quaternion.h>
31 #include <dali/public-api/math/matrix.h>
32 #include <dali/public-api/math/matrix3.h>
33 #include <dali/public-api/object/property.h>
34
35 namespace Dali DALI_IMPORT_API
36 {
37
38 // Interpolation functions used by Constraints
39
40 /**
41  * @brief Interpolate linearly between two boolean values.
42  * @param [in] current The current value.
43  * @param [in] target The target value.
44  * @param [in] progress The current progress (between 0 & 1).
45  * @return The interpolated value.
46  */
47 bool LerpBoolean( const bool& current, const bool& target, float progress );
48
49 /**
50  * @brief Interpolate linearly between two float values.
51  *
52  * @param [in] current The current value.
53  * @param [in] target The target value.
54  * @param [in] progress The current progress (between 0 & 1).
55  * @return The interpolated value.
56  */
57 float LerpFloat( const float& current, const float& target, float progress );
58
59 /**
60  * @brief Interpolate linearly between two Vector2 values.
61  *
62  * @param [in] current The current value.
63  * @param [in] target The target value.
64  * @param [in] progress The current progress (between 0 & 1).
65  * @return The interpolated value.
66  */
67 Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress );
68
69 /**
70  * @brief Interpolate linearly between two Vector3 values.
71  *
72  * @param [in] current The current value.
73  * @param [in] target The target value.
74  * @param [in] progress The current progress (between 0 & 1).
75  * @return The interpolated value.
76  */
77 Vector3 LerpVector3( const Vector3& current, const Vector3& target, float progress );
78
79 /**
80  * @brief Interpolate linearly between two Vector4 values.
81  *
82  * @param [in] current The current value.
83  * @param [in] target The target value.
84  * @param [in] progress The current progress (between 0 & 1).
85  * @return The interpolated value.
86  */
87 Vector4 LerpVector4( const Vector4& current, const Vector4& target, float progress );
88
89 /**
90  * @brief Spherical linear interpolation between two Quaternion values.
91  *
92  * @param [in] current The current value.
93  * @param [in] target The target value.
94  * @param [in] progress The current progress (between 0 & 1).
95  * @return The interpolated value.
96  */
97 Quaternion SlerpQuaternion( const Quaternion& current, const Quaternion& target, float progress );
98
99 /**
100  * @brief A function which interpolates between a start and target value.
101  *
102  * @param[in] start The start value.
103  * @param[in] target The target value.
104  * @param[in] progress The current progress (between 0 and 1).
105  * @return The interpolated value.
106  */
107 typedef boost::function<bool (const bool& start, const bool& target, float progress)> BoolInterpolator;
108
109 /**
110  * @brief A function which interpolates between a start and target value.
111  *
112  * @param[in] start The start value.
113  * @param[in] target The target value.
114  * @param[in] progress The current progress (between 0 and 1).
115  * @return The interpolated value.
116  */
117 typedef boost::function<float (const float& start, const float& target, float progress)> FloatInterpolator;
118
119 /**
120  * @brief A function which interpolates between a start and target value.
121  *
122  * @param[in] start The start value.
123  * @param[in] target The target value.
124  * @param[in] progress The current progress (between 0 and 1).
125  * @return The interpolated value.
126  */
127 typedef boost::function<Vector2 (const Vector2& current, const Vector2& target, float progress)> Vector2Interpolator;
128
129 /**
130  * @brief A function which interpolates between a start and target value.
131  *
132  * @param[in] start The start value.
133  * @param[in] target The target value.
134  * @param[in] progress The current progress (between 0 and 1).
135  * @return The interpolated value.
136  */
137 typedef boost::function<Vector3 (const Vector3& current, const Vector3& target, float progress)> Vector3Interpolator;
138
139 /**
140  * @brief A function which interpolates between a start and target value.
141  *
142  * @param[in] start The start value.
143  * @param[in] target The target value.
144  * @param[in] progress The current progress (between 0 and 1).
145  * @return The interpolated value.
146  */
147 typedef boost::function<Vector4 (const Vector4& current, const Vector4& target, float progress)> Vector4Interpolator;
148
149 /**
150  * @brief A function which interpolates between a start and target value.
151  *
152  * @param[in] start The start value.
153  * @param[in] target The target value.
154  * @param[in] progress The current progress (between 0 and 1).
155  * @return The interpolated value.
156  */
157 typedef boost::function<Quaternion (const Quaternion& current, const Quaternion& target, float progress)> QuaternionInterpolator;
158
159 /**
160  * @brief A function which interpolates between a start and target value.
161  *
162  * @param[in] start The start value.
163  * @param[in] target The target value.
164  * @param[in] progress The current progress (between 0 and 1).
165  * @return The interpolated value.
166  */
167 typedef boost::function<Matrix3 (const Matrix3& current, const Matrix3& target, float progress)> Matrix3Interpolator;
168
169 /**
170  * @brief A function which interpolates between a start and target value.
171  *
172  * @param[in] start The start value.
173  * @param[in] target The target value.
174  * @param[in] progress The current progress (between 0 and 1).
175  * @return The interpolated value.
176  */
177 typedef boost::function<Matrix (const Matrix& current, const Matrix& target, float progress)> MatrixInterpolator;
178
179 /**
180  * @brief Any interpolator function.
181  */
182 typedef Any AnyInterpolator;
183
184 /**
185  * @brief Retrieve an interpolator function for a property.
186  *
187  * This can be cast to boost::function<P (const P&, const P&, float)> where P corresponds to the property type.
188  * @param[in] type The property type for which to get an interpolator
189  * @return The interpolator function.
190  */
191 AnyInterpolator GetDefaultInterpolator(Property::Type type);
192
193 } // namespace Dali
194
195 /**
196  * @}
197  */
198 #endif // __DALI_INTERPOLATOR_FUNCTIONS_H__