Conversion to Apache 2.0 license
[platform/core/uifw/dali-core.git] / dali / public-api / animation / animation.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/animation/animation.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/animation/alpha-functions.h>
23 #include <dali/public-api/animation/time-period.h>
24 #include <dali/public-api/math/quaternion.h>
25 #include <dali/public-api/math/degree.h>
26 #include <dali/public-api/math/radian.h>
27 #include <dali/public-api/math/vector2.h>
28 #include <dali/internal/event/actors/actor-impl.h>
29 #include <dali/internal/event/animation/animation-impl.h>
30 #include <dali/internal/event/effects/shader-effect-impl.h>
31
32 namespace Dali
33 {
34
35 const char* const Animation::SIGNAL_FINISHED = "finished";
36 const char* const Animation::ACTION_PLAY = "play";
37 const char* const Animation::ACTION_STOP = "stop";
38 const char* const Animation::ACTION_PAUSE = "pause";
39
40 Animation::Animation()
41 {
42 }
43
44 Animation::Animation(Internal::Animation* animation)
45 : BaseHandle(animation)
46 {
47 }
48
49 Animation Animation::New(float durationSeconds)
50 {
51   Internal::AnimationPtr internal = Dali::Internal::Animation::New(durationSeconds);
52
53   return Animation(internal.Get());
54 }
55
56 Animation Animation::DownCast( BaseHandle handle )
57 {
58   return Animation( dynamic_cast<Dali::Internal::Animation*>(handle.GetObjectPtr()) );
59 }
60
61 Animation::~Animation()
62 {
63 }
64
65 void Animation::SetDuration(float durationSeconds)
66 {
67   GetImplementation(*this).SetDuration(durationSeconds);
68 }
69
70 float Animation::GetDuration() const
71 {
72   return GetImplementation(*this).GetDuration();
73 }
74
75 void Animation::SetLooping(bool looping)
76 {
77   GetImplementation(*this).SetLooping(looping);
78 }
79
80 bool Animation::IsLooping() const
81 {
82   return GetImplementation(*this).IsLooping();
83 }
84
85 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
86 {
87   GetImplementation(*this).SetEndAction(endAction);
88 }
89
90 Dali::Animation::EndAction Animation::GetEndAction() const
91 {
92   return GetImplementation(*this).GetEndAction();
93 }
94
95 void Animation::SetDestroyAction(Dali::Animation::EndAction destroyAction)
96 {
97   GetImplementation(*this).SetDestroyAction(destroyAction);
98 }
99
100 Dali::Animation::EndAction Animation::GetDestroyAction() const
101 {
102   return GetImplementation(*this).GetDestroyAction();
103 }
104
105 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
106 {
107   GetImplementation(*this).SetDefaultAlphaFunction(alpha);
108 }
109
110 AlphaFunction Animation::GetDefaultAlphaFunction() const
111 {
112   return GetImplementation(*this).GetDefaultAlphaFunction();
113 }
114
115 void Animation::Play()
116 {
117   GetImplementation(*this).Play();
118 }
119
120 void Animation::Pause()
121 {
122   GetImplementation(*this).Pause();
123 }
124
125 void Animation::Stop()
126 {
127   GetImplementation(*this).Stop();
128 }
129
130 void Animation::Clear()
131 {
132   GetImplementation(*this).Clear();
133 }
134
135 Animation::AnimationSignalV2& Animation::FinishedSignal()
136 {
137   return GetImplementation(*this).FinishedSignal();
138 }
139
140 void Animation::AnimateBy(Property target, Property::Value relativeValue)
141 {
142   GetImplementation(*this).AnimateBy(target, relativeValue);
143 }
144
145 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
146 {
147   GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
148 }
149
150 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
151 {
152   GetImplementation(*this).AnimateBy(target, relativeValue, period);
153 }
154
155 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
156 {
157   GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
158 }
159
160 void Animation::AnimateTo(Property target, Property::Value destinationValue)
161 {
162   GetImplementation(*this).AnimateTo(target, destinationValue);
163 }
164
165 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
166 {
167   GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
168 }
169
170 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
171 {
172   GetImplementation(*this).AnimateTo(target, destinationValue, period);
173 }
174
175 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
176 {
177   GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
178 }
179
180 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
181 {
182   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
183 }
184
185 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
186 {
187   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
188 }
189
190 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
191 {
192   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
193 }
194
195 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
196 {
197   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
198 }
199
200 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
201 {
202   GetImplementation(*this).Animate( target, targetType, func );
203 }
204
205 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
206 {
207   GetImplementation(*this).Animate( target, targetType, func, alpha );
208 }
209
210 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, TimePeriod period )
211 {
212   GetImplementation(*this).Animate( target, targetType, func, period );
213 }
214
215 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period )
216 {
217   GetImplementation(*this).Animate( target, targetType, func, alpha, period );
218 }
219
220 // Actor specific animations
221
222 void Animation::MoveBy(Actor actor, float x, float y, float z)
223 {
224   GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
225 }
226
227 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
228 {
229   GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
230 }
231
232 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
233 {
234   GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
235 }
236
237 void Animation::MoveTo(Actor actor, float x, float y, float z)
238 {
239   GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
240 }
241
242 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
243 {
244   GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
245 }
246
247 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
248 {
249   GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
250 }
251
252 void Animation::Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
253 {
254   GetImplementation(*this).Move(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
255 }
256
257 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
258 {
259   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
260 }
261
262 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
263 {
264   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
265 }
266
267 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
268 {
269   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
270 }
271
272 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
273 {
274   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
275 }
276
277 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
278 {
279   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
280 }
281
282 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
283 {
284   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
285 }
286
287 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
288 {
289   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
290 }
291
292 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
293 {
294   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
295 }
296
297 void Animation::RotateTo(Actor actor, Quaternion rotation)
298 {
299   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
300 }
301
302 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
303 {
304   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
305 }
306
307 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
308 {
309   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
310 }
311
312 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
313 {
314   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
315 }
316
317 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
318 {
319   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
320 }
321
322 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
323 {
324   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
325 }
326
327 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
328 {
329   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
330 }
331
332 void Animation::Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
333 {
334   GetImplementation(*this).Rotate(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
335 }
336
337 void Animation::ScaleBy(Actor actor, float x, float y, float z)
338 {
339   GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
340 }
341
342 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
343 {
344   GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
345 }
346
347 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
348 {
349   GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
350 }
351
352 void Animation::ScaleTo(Actor actor, float x, float y, float z)
353 {
354   GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
355 }
356
357 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
358 {
359   GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
360 }
361
362 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
363 {
364   GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
365 }
366
367 void Animation::Show(Actor actor, float delaySeconds)
368 {
369   GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
370 }
371
372 void Animation::Hide(Actor actor, float delaySeconds)
373 {
374   GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
375 }
376
377 void Animation::OpacityBy(Actor actor, float opacity)
378 {
379   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
380 }
381
382 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
383 {
384   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
385 }
386
387 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
388 {
389   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
390 }
391
392 void Animation::OpacityTo(Actor actor, float opacity)
393 {
394   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
395 }
396
397 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
398 {
399   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
400 }
401
402 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
403 {
404   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
405 }
406
407 void Animation::ColorBy(Actor actor, Vector4 color)
408 {
409   GetImplementation(*this).ColorBy(GetImplementation(actor), color);
410 }
411
412 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
413 {
414   GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
415 }
416
417 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
418 {
419   GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
420 }
421
422 void Animation::ColorTo(Actor actor, Vector4 color)
423 {
424   GetImplementation(*this).ColorTo(GetImplementation(actor), color);
425 }
426
427 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
428 {
429   GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
430 }
431
432 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
433 {
434   GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
435 }
436
437 void Animation::Resize(Actor actor, float width, float height)
438 {
439   GetImplementation(*this).Resize(GetImplementation(actor), width, height);
440 }
441
442 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
443 {
444   GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
445 }
446
447 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
448 {
449   GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
450 }
451
452 void Animation::Resize(Actor actor, Vector3 size)
453 {
454   GetImplementation(*this).Resize(GetImplementation(actor), size);
455 }
456
457 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
458 {
459   GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
460 }
461
462 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
463 {
464   GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);
465 }
466
467 } // namespace Dali