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