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::PlayFrom(float progress)
122 GetImplementation(*this).PlayFrom(progress);
126 void Animation::Pause()
128 GetImplementation(*this).Pause();
131 void Animation::Stop()
133 GetImplementation(*this).Stop();
136 void Animation::Clear()
138 GetImplementation(*this).Clear();
141 Animation::AnimationSignalV2& Animation::FinishedSignal()
143 return GetImplementation(*this).FinishedSignal();
146 void Animation::AnimateBy(Property target, Property::Value relativeValue)
148 GetImplementation(*this).AnimateBy(target, relativeValue);
151 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
153 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
156 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
158 GetImplementation(*this).AnimateBy(target, relativeValue, period);
161 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
163 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
166 void Animation::AnimateTo(Property target, Property::Value destinationValue)
168 GetImplementation(*this).AnimateTo(target, destinationValue);
171 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
173 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
176 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
178 GetImplementation(*this).AnimateTo(target, destinationValue, period);
181 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
183 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
186 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
188 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
191 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
193 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
196 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
198 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
201 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
203 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
206 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
208 GetImplementation(*this).Animate( target, targetType, func );
211 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
213 GetImplementation(*this).Animate( target, targetType, func, alpha );
216 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, TimePeriod period )
218 GetImplementation(*this).Animate( target, targetType, func, period );
221 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period )
223 GetImplementation(*this).Animate( target, targetType, func, alpha, period );
226 // Actor specific animations
228 void Animation::MoveBy(Actor actor, float x, float y, float z)
230 GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
233 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
235 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
238 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
240 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
243 void Animation::MoveTo(Actor actor, float x, float y, float z)
245 GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
248 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
250 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
253 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
255 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
258 void Animation::Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
260 GetImplementation(*this).Move(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
263 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
265 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
268 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
270 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
273 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
275 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
278 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
280 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
283 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
285 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
288 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
290 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
293 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
295 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
298 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
300 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
303 void Animation::RotateTo(Actor actor, Quaternion rotation)
305 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
308 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
310 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
313 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
315 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
318 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
320 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
323 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
325 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
328 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
330 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
333 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
335 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
338 void Animation::Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
340 GetImplementation(*this).Rotate(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
343 void Animation::ScaleBy(Actor actor, float x, float y, float z)
345 GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
348 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
350 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
353 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
355 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
358 void Animation::ScaleTo(Actor actor, float x, float y, float z)
360 GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
363 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
365 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
368 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
370 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
373 void Animation::Show(Actor actor, float delaySeconds)
375 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
378 void Animation::Hide(Actor actor, float delaySeconds)
380 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
383 void Animation::OpacityBy(Actor actor, float opacity)
385 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
388 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
390 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
393 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
395 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
398 void Animation::OpacityTo(Actor actor, float opacity)
400 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
403 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
405 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
408 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
410 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
413 void Animation::ColorBy(Actor actor, Vector4 color)
415 GetImplementation(*this).ColorBy(GetImplementation(actor), color);
418 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
420 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
423 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
425 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
428 void Animation::ColorTo(Actor actor, Vector4 color)
430 GetImplementation(*this).ColorTo(GetImplementation(actor), color);
433 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
435 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
438 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
440 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
443 void Animation::Resize(Actor actor, float width, float height)
445 GetImplementation(*this).Resize(GetImplementation(actor), width, height);
448 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
450 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
453 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
455 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
458 void Animation::Resize(Actor actor, Vector3 size)
460 GetImplementation(*this).Resize(GetImplementation(actor), size);
463 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
465 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
468 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
470 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);
473 float Animation::GetCurrentProgress()
475 return GetImplementation(*this).GetCurrentProgress();
478 void Animation::SetCurrentProgress( float progress )
480 return GetImplementation(*this).SetCurrentProgress( progress );