0a1a088ba841b3206df489425b8fb79d0946a2fa
[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 Animation::Animation(const Animation& handle)
66 : BaseHandle(handle)
67 {
68 }
69
70 Animation& Animation::operator=(const Animation& rhs)
71 {
72   BaseHandle::operator=(rhs);
73   return *this;
74 }
75
76 Animation& Animation::operator=(BaseHandle::NullType* rhs)
77 {
78   DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
79   Reset();
80   return *this;
81 }
82
83 void Animation::SetDuration(float durationSeconds)
84 {
85   GetImplementation(*this).SetDuration(durationSeconds);
86 }
87
88 float Animation::GetDuration() const
89 {
90   return GetImplementation(*this).GetDuration();
91 }
92
93 void Animation::SetLooping(bool looping)
94 {
95   GetImplementation(*this).SetLooping(looping);
96 }
97
98 bool Animation::IsLooping() const
99 {
100   return GetImplementation(*this).IsLooping();
101 }
102
103 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
104 {
105   GetImplementation(*this).SetEndAction(endAction);
106 }
107
108 Dali::Animation::EndAction Animation::GetEndAction() const
109 {
110   return GetImplementation(*this).GetEndAction();
111 }
112
113 void Animation::SetDestroyAction(Dali::Animation::EndAction destroyAction)
114 {
115   // Deprecated
116   GetImplementation(*this).SetEndAction(destroyAction);
117 }
118
119 Dali::Animation::EndAction Animation::GetDestroyAction() const
120 {
121   // Deprecated
122   return GetImplementation(*this).GetEndAction();
123 }
124
125 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
126 {
127   GetImplementation(*this).SetDisconnectAction( disconnectAction );
128 }
129
130 Animation::EndAction Animation::GetDisconnectAction() const
131 {
132   return GetImplementation(*this).GetDisconnectAction();
133 }
134
135 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
136 {
137   GetImplementation(*this).SetDefaultAlphaFunction(alpha);
138 }
139
140 AlphaFunction Animation::GetDefaultAlphaFunction() const
141 {
142   return GetImplementation(*this).GetDefaultAlphaFunction();
143 }
144
145 void Animation::Play()
146 {
147   GetImplementation(*this).Play();
148 }
149
150 void Animation::PlayFrom(float progress)
151 {
152   GetImplementation(*this).PlayFrom(progress);
153 }
154
155
156 void Animation::Pause()
157 {
158   GetImplementation(*this).Pause();
159 }
160
161 void Animation::Stop()
162 {
163   GetImplementation(*this).Stop();
164 }
165
166 void Animation::Clear()
167 {
168   GetImplementation(*this).Clear();
169 }
170
171 Animation::AnimationSignalV2& Animation::FinishedSignal()
172 {
173   return GetImplementation(*this).FinishedSignal();
174 }
175
176 void Animation::AnimateBy(Property target, Property::Value relativeValue)
177 {
178   GetImplementation(*this).AnimateBy(target, relativeValue);
179 }
180
181 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
182 {
183   GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
184 }
185
186 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
187 {
188   GetImplementation(*this).AnimateBy(target, relativeValue, period);
189 }
190
191 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
192 {
193   GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
194 }
195
196 void Animation::AnimateTo(Property target, Property::Value destinationValue)
197 {
198   GetImplementation(*this).AnimateTo(target, destinationValue);
199 }
200
201 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
202 {
203   GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
204 }
205
206 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
207 {
208   GetImplementation(*this).AnimateTo(target, destinationValue, period);
209 }
210
211 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
212 {
213   GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
214 }
215
216 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
217 {
218   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
219 }
220
221 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
222 {
223   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
224 }
225
226 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
227 {
228   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
229 }
230
231 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
232 {
233   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
234 }
235
236 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
237 {
238   GetImplementation(*this).Animate( target, targetType, func );
239 }
240
241 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
242 {
243   GetImplementation(*this).Animate( target, targetType, func, alpha );
244 }
245
246 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, TimePeriod period )
247 {
248   GetImplementation(*this).Animate( target, targetType, func, period );
249 }
250
251 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period )
252 {
253   GetImplementation(*this).Animate( target, targetType, func, alpha, period );
254 }
255
256 // Actor specific animations
257
258 void Animation::MoveBy(Actor actor, float x, float y, float z)
259 {
260   GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
261 }
262
263 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
264 {
265   GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
266 }
267
268 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
269 {
270   GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
271 }
272
273 void Animation::MoveTo(Actor actor, float x, float y, float z)
274 {
275   GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
276 }
277
278 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
279 {
280   GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
281 }
282
283 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
284 {
285   GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
286 }
287
288 void Animation::Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
289 {
290   GetImplementation(*this).Move(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
291 }
292
293 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
294 {
295   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
296 }
297
298 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
299 {
300   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
301 }
302
303 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
304 {
305   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
306 }
307
308 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
309 {
310   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
311 }
312
313 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
314 {
315   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
316 }
317
318 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
319 {
320   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
321 }
322
323 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
324 {
325   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
326 }
327
328 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
329 {
330   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
331 }
332
333 void Animation::RotateTo(Actor actor, Quaternion rotation)
334 {
335   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
336 }
337
338 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
339 {
340   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
341 }
342
343 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
344 {
345   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
346 }
347
348 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
349 {
350   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
351 }
352
353 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
354 {
355   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
356 }
357
358 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
359 {
360   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
361 }
362
363 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
364 {
365   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
366 }
367
368 void Animation::Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
369 {
370   GetImplementation(*this).Rotate(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
371 }
372
373 void Animation::ScaleBy(Actor actor, float x, float y, float z)
374 {
375   GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
376 }
377
378 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
379 {
380   GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
381 }
382
383 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
384 {
385   GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
386 }
387
388 void Animation::ScaleTo(Actor actor, float x, float y, float z)
389 {
390   GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
391 }
392
393 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
394 {
395   GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
396 }
397
398 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
399 {
400   GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
401 }
402
403 void Animation::Show(Actor actor, float delaySeconds)
404 {
405   GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
406 }
407
408 void Animation::Hide(Actor actor, float delaySeconds)
409 {
410   GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
411 }
412
413 void Animation::OpacityBy(Actor actor, float opacity)
414 {
415   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
416 }
417
418 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
419 {
420   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
421 }
422
423 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
424 {
425   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
426 }
427
428 void Animation::OpacityTo(Actor actor, float opacity)
429 {
430   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
431 }
432
433 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
434 {
435   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
436 }
437
438 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
439 {
440   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
441 }
442
443 void Animation::ColorBy(Actor actor, Vector4 color)
444 {
445   GetImplementation(*this).ColorBy(GetImplementation(actor), color);
446 }
447
448 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
449 {
450   GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
451 }
452
453 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
454 {
455   GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
456 }
457
458 void Animation::ColorTo(Actor actor, Vector4 color)
459 {
460   GetImplementation(*this).ColorTo(GetImplementation(actor), color);
461 }
462
463 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
464 {
465   GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
466 }
467
468 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
469 {
470   GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
471 }
472
473 void Animation::Resize(Actor actor, float width, float height)
474 {
475   GetImplementation(*this).Resize(GetImplementation(actor), width, height);
476 }
477
478 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
479 {
480   GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
481 }
482
483 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
484 {
485   GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
486 }
487
488 void Animation::Resize(Actor actor, Vector3 size)
489 {
490   GetImplementation(*this).Resize(GetImplementation(actor), size);
491 }
492
493 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
494 {
495   GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
496 }
497
498 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
499 {
500   GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);
501 }
502
503 void Animation::SetCurrentProgress( float progress )
504 {
505   return GetImplementation(*this).SetCurrentProgress( progress );
506 }
507
508 float Animation::GetCurrentProgress()
509 {
510   return GetImplementation(*this).GetCurrentProgress();
511 }
512
513 void Animation::SetSpeedFactor( float factor )
514 {
515   GetImplementation(*this).SetSpeedFactor( factor );
516 }
517
518 float Animation::GetSpeedFactor() const
519 {
520   return GetImplementation(*this).GetSpeedFactor();
521 }
522
523 void Animation::SetPlayRange( const Vector2& range )
524 {
525   GetImplementation(*this).SetPlayRange(range);
526 }
527
528 Vector2 Animation::GetPlayRange() const
529 {
530   return GetImplementation(*this).GetPlayRange();
531 }
532
533 } // namespace Dali