[dali_1.0.17] Merge branch 'tizen'
[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, TimePeriod period)
203 {
204   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
205 }
206
207 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
208 {
209   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
210 }
211
212 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
213 {
214   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
215 }
216
217 // Actor specific animations
218
219 void Animation::MoveBy(Actor actor, float x, float y, float z)
220 {
221   GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
222 }
223
224 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
225 {
226   GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
227 }
228
229 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
230 {
231   GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
232 }
233
234 void Animation::MoveTo(Actor actor, float x, float y, float z)
235 {
236   GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
237 }
238
239 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
240 {
241   GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
242 }
243
244 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
245 {
246   GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
247 }
248
249 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
250 {
251   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
252 }
253
254 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
255 {
256   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
257 }
258
259 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
260 {
261   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
262 }
263
264 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
265 {
266   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
267 }
268
269 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
270 {
271   GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
272 }
273
274 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
275 {
276   GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
277 }
278
279 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
280 {
281   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
282 }
283
284 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
285 {
286   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
287 }
288
289 void Animation::RotateTo(Actor actor, Quaternion rotation)
290 {
291   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
292 }
293
294 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
295 {
296   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
297 }
298
299 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
300 {
301   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
302 }
303
304 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
305 {
306   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
307 }
308
309 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
310 {
311   GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
312 }
313
314 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
315 {
316   GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
317 }
318
319 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
320 {
321   GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
322 }
323
324 void Animation::ScaleBy(Actor actor, float x, float y, float z)
325 {
326   GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
327 }
328
329 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
330 {
331   GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
332 }
333
334 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
335 {
336   GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
337 }
338
339 void Animation::ScaleTo(Actor actor, float x, float y, float z)
340 {
341   GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
342 }
343
344 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
345 {
346   GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
347 }
348
349 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
350 {
351   GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
352 }
353
354 void Animation::Show(Actor actor, float delaySeconds)
355 {
356   GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
357 }
358
359 void Animation::Hide(Actor actor, float delaySeconds)
360 {
361   GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
362 }
363
364 void Animation::OpacityBy(Actor actor, float opacity)
365 {
366   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
367 }
368
369 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
370 {
371   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
372 }
373
374 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
375 {
376   GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
377 }
378
379 void Animation::OpacityTo(Actor actor, float opacity)
380 {
381   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
382 }
383
384 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
385 {
386   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
387 }
388
389 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
390 {
391   GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
392 }
393
394 void Animation::ColorBy(Actor actor, Vector4 color)
395 {
396   GetImplementation(*this).ColorBy(GetImplementation(actor), color);
397 }
398
399 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
400 {
401   GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
402 }
403
404 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
405 {
406   GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
407 }
408
409 void Animation::ColorTo(Actor actor, Vector4 color)
410 {
411   GetImplementation(*this).ColorTo(GetImplementation(actor), color);
412 }
413
414 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
415 {
416   GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
417 }
418
419 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
420 {
421   GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
422 }
423
424 void Animation::Resize(Actor actor, float width, float height)
425 {
426   GetImplementation(*this).Resize(GetImplementation(actor), width, height);
427 }
428
429 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
430 {
431   GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
432 }
433
434 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
435 {
436   GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
437 }
438
439 void Animation::Resize(Actor actor, Vector3 size)
440 {
441   GetImplementation(*this).Resize(GetImplementation(actor), size);
442 }
443
444 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
445 {
446   GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
447 }
448
449 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
450 {
451   GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);
452 }
453
454 void Animation::SetCurrentProgress( float progress )
455 {
456   return GetImplementation(*this).SetCurrentProgress( progress );
457 }
458
459 float Animation::GetCurrentProgress()
460 {
461   return GetImplementation(*this).GetCurrentProgress();
462 }
463
464 void Animation::SetSpeedFactor( float factor )
465 {
466   GetImplementation(*this).SetSpeedFactor( factor );
467 }
468
469 float Animation::GetSpeedFactor() const
470 {
471   return GetImplementation(*this).GetSpeedFactor();
472 }
473
474 void Animation::SetPlayRange( const Vector2& range )
475 {
476   GetImplementation(*this).SetPlayRange(range);
477 }
478
479 Vector2 Animation::GetPlayRange() const
480 {
481   return GetImplementation(*this).GetPlayRange();
482 }
483
484 } // namespace Dali