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