2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/animation/animation.h>
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>
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";
40 Animation::Animation()
44 Animation::Animation(Internal::Animation* animation)
45 : BaseHandle(animation)
49 Animation Animation::New(float durationSeconds)
51 Internal::AnimationPtr internal = Dali::Internal::Animation::New(durationSeconds);
53 return Animation(internal.Get());
56 Animation Animation::DownCast( BaseHandle handle )
58 return Animation( dynamic_cast<Dali::Internal::Animation*>(handle.GetObjectPtr()) );
61 Animation::~Animation()
65 void Animation::SetDuration(float durationSeconds)
67 GetImplementation(*this).SetDuration(durationSeconds);
70 float Animation::GetDuration() const
72 return GetImplementation(*this).GetDuration();
75 void Animation::SetLooping(bool looping)
77 GetImplementation(*this).SetLooping(looping);
80 bool Animation::IsLooping() const
82 return GetImplementation(*this).IsLooping();
85 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
87 GetImplementation(*this).SetEndAction(endAction);
90 Dali::Animation::EndAction Animation::GetEndAction() const
92 return GetImplementation(*this).GetEndAction();
95 void Animation::SetDestroyAction(Dali::Animation::EndAction destroyAction)
97 GetImplementation(*this).SetDestroyAction(destroyAction);
100 Dali::Animation::EndAction Animation::GetDestroyAction() const
102 return GetImplementation(*this).GetDestroyAction();
105 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
107 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
110 AlphaFunction Animation::GetDefaultAlphaFunction() const
112 return GetImplementation(*this).GetDefaultAlphaFunction();
115 void Animation::Play()
117 GetImplementation(*this).Play();
120 void Animation::Pause()
122 GetImplementation(*this).Pause();
125 void Animation::Stop()
127 GetImplementation(*this).Stop();
130 void Animation::Clear()
132 GetImplementation(*this).Clear();
135 Animation::AnimationSignalV2& Animation::FinishedSignal()
137 return GetImplementation(*this).FinishedSignal();
140 void Animation::AnimateBy(Property target, Property::Value relativeValue)
142 GetImplementation(*this).AnimateBy(target, relativeValue);
145 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
147 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
150 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
152 GetImplementation(*this).AnimateBy(target, relativeValue, period);
155 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
157 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
160 void Animation::AnimateTo(Property target, Property::Value destinationValue)
162 GetImplementation(*this).AnimateTo(target, destinationValue);
165 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
167 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
170 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
172 GetImplementation(*this).AnimateTo(target, destinationValue, period);
175 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
177 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
180 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
182 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
185 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
187 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
190 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
192 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
195 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
197 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
200 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
202 GetImplementation(*this).Animate( target, targetType, func );
205 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
207 GetImplementation(*this).Animate( target, targetType, func, alpha );
210 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, TimePeriod period )
212 GetImplementation(*this).Animate( target, targetType, func, period );
215 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period )
217 GetImplementation(*this).Animate( target, targetType, func, alpha, period );
220 // Actor specific animations
222 void Animation::MoveBy(Actor actor, float x, float y, float z)
224 GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
227 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
229 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
232 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
234 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
237 void Animation::MoveTo(Actor actor, float x, float y, float z)
239 GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
242 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
244 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
247 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
249 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
252 void Animation::Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
254 GetImplementation(*this).Move(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
257 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
259 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
262 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
264 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
267 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
269 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
272 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
274 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
277 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
279 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
282 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
284 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
287 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
289 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
292 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
294 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
297 void Animation::RotateTo(Actor actor, Quaternion rotation)
299 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
302 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
304 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
307 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
309 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
312 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
314 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
317 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
319 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
322 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
324 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
327 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
329 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
332 void Animation::Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
334 GetImplementation(*this).Rotate(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
337 void Animation::ScaleBy(Actor actor, float x, float y, float z)
339 GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
342 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
344 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
347 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
349 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
352 void Animation::ScaleTo(Actor actor, float x, float y, float z)
354 GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
357 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
359 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
362 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
364 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
367 void Animation::Show(Actor actor, float delaySeconds)
369 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
372 void Animation::Hide(Actor actor, float delaySeconds)
374 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
377 void Animation::OpacityBy(Actor actor, float opacity)
379 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
382 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
384 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
387 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
389 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
392 void Animation::OpacityTo(Actor actor, float opacity)
394 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
397 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
399 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
402 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
404 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
407 void Animation::ColorBy(Actor actor, Vector4 color)
409 GetImplementation(*this).ColorBy(GetImplementation(actor), color);
412 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
414 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
417 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
419 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
422 void Animation::ColorTo(Actor actor, Vector4 color)
424 GetImplementation(*this).ColorTo(GetImplementation(actor), color);
427 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
429 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
432 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
434 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
437 void Animation::Resize(Actor actor, float width, float height)
439 GetImplementation(*this).Resize(GetImplementation(actor), width, height);
442 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
444 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
447 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
449 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
452 void Animation::Resize(Actor actor, Vector3 size)
454 GetImplementation(*this).Resize(GetImplementation(actor), size);
457 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
459 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
462 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
464 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);