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 Animation::Animation(const Animation& handle)
70 Animation& Animation::operator=(const Animation& rhs)
72 BaseHandle::operator=(rhs);
76 Animation& Animation::operator=(BaseHandle::NullType* rhs)
78 DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
83 void Animation::SetDuration(float durationSeconds)
85 GetImplementation(*this).SetDuration(durationSeconds);
88 float Animation::GetDuration() const
90 return GetImplementation(*this).GetDuration();
93 void Animation::SetLooping(bool looping)
95 GetImplementation(*this).SetLooping(looping);
98 bool Animation::IsLooping() const
100 return GetImplementation(*this).IsLooping();
103 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
105 GetImplementation(*this).SetEndAction(endAction);
108 Dali::Animation::EndAction Animation::GetEndAction() const
110 return GetImplementation(*this).GetEndAction();
113 void Animation::SetDestroyAction(Dali::Animation::EndAction destroyAction)
116 GetImplementation(*this).SetEndAction(destroyAction);
119 Dali::Animation::EndAction Animation::GetDestroyAction() const
122 return GetImplementation(*this).GetEndAction();
125 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
127 GetImplementation(*this).SetDisconnectAction( disconnectAction );
130 Animation::EndAction Animation::GetDisconnectAction() const
132 return GetImplementation(*this).GetDisconnectAction();
135 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
137 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
140 AlphaFunction Animation::GetDefaultAlphaFunction() const
142 return GetImplementation(*this).GetDefaultAlphaFunction();
145 void Animation::Play()
147 GetImplementation(*this).Play();
150 void Animation::PlayFrom(float progress)
152 GetImplementation(*this).PlayFrom(progress);
156 void Animation::Pause()
158 GetImplementation(*this).Pause();
161 void Animation::Stop()
163 GetImplementation(*this).Stop();
166 void Animation::Clear()
168 GetImplementation(*this).Clear();
171 Animation::AnimationSignalV2& Animation::FinishedSignal()
173 return GetImplementation(*this).FinishedSignal();
176 void Animation::AnimateBy(Property target, Property::Value relativeValue)
178 GetImplementation(*this).AnimateBy(target, relativeValue);
181 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
183 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
186 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
188 GetImplementation(*this).AnimateBy(target, relativeValue, period);
191 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
193 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
196 void Animation::AnimateTo(Property target, Property::Value destinationValue)
198 GetImplementation(*this).AnimateTo(target, destinationValue);
201 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
203 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
206 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
208 GetImplementation(*this).AnimateTo(target, destinationValue, period);
211 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
213 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
216 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
218 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
221 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
223 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
226 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
228 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
231 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
233 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
236 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
238 GetImplementation(*this).Animate( target, targetType, func );
241 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
243 GetImplementation(*this).Animate( target, targetType, func, alpha );
246 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, TimePeriod period )
248 GetImplementation(*this).Animate( target, targetType, func, period );
251 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period )
253 GetImplementation(*this).Animate( target, targetType, func, alpha, period );
256 // Actor specific animations
258 void Animation::MoveBy(Actor actor, float x, float y, float z)
260 GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
263 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
265 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
268 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
270 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
273 void Animation::MoveTo(Actor actor, float x, float y, float z)
275 GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
278 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
280 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
283 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
285 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
288 void Animation::Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
290 GetImplementation(*this).Move(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
293 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
295 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
298 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
300 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
303 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
305 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
308 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
310 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
313 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
315 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
318 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
320 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
323 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
325 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
328 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
330 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
333 void Animation::RotateTo(Actor actor, Quaternion rotation)
335 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
338 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
340 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
343 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
345 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
348 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
350 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
353 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
355 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
358 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
360 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
363 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
365 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
368 void Animation::Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
370 GetImplementation(*this).Rotate(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
373 void Animation::ScaleBy(Actor actor, float x, float y, float z)
375 GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
378 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
380 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
383 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
385 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
388 void Animation::ScaleTo(Actor actor, float x, float y, float z)
390 GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
393 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
395 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
398 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
400 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
403 void Animation::Show(Actor actor, float delaySeconds)
405 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
408 void Animation::Hide(Actor actor, float delaySeconds)
410 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
413 void Animation::OpacityBy(Actor actor, float opacity)
415 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
418 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
420 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
423 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
425 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
428 void Animation::OpacityTo(Actor actor, float opacity)
430 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
433 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
435 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
438 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
440 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
443 void Animation::ColorBy(Actor actor, Vector4 color)
445 GetImplementation(*this).ColorBy(GetImplementation(actor), color);
448 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
450 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
453 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
455 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
458 void Animation::ColorTo(Actor actor, Vector4 color)
460 GetImplementation(*this).ColorTo(GetImplementation(actor), color);
463 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
465 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
468 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
470 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
473 void Animation::Resize(Actor actor, float width, float height)
475 GetImplementation(*this).Resize(GetImplementation(actor), width, height);
478 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
480 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
483 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
485 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
488 void Animation::Resize(Actor actor, Vector3 size)
490 GetImplementation(*this).Resize(GetImplementation(actor), size);
493 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
495 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
498 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
500 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);
503 void Animation::SetCurrentProgress( float progress )
505 return GetImplementation(*this).SetCurrentProgress( progress );
508 float Animation::GetCurrentProgress()
510 return GetImplementation(*this).GetCurrentProgress();
513 void Animation::SetSpeedFactor( float factor )
515 GetImplementation(*this).SetSpeedFactor( factor );
518 float Animation::GetSpeedFactor() const
520 return GetImplementation(*this).GetSpeedFactor();
523 void Animation::SetPlayRange( const Vector2& range )
525 GetImplementation(*this).SetPlayRange(range);
528 Vector2 Animation::GetPlayRange() const
530 return GetImplementation(*this).GetPlayRange();