2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 #include <dali/public-api/animation/animation.h>
21 #include <dali/public-api/animation/alpha-functions.h>
22 #include <dali/public-api/animation/time-period.h>
23 #include <dali/public-api/math/quaternion.h>
24 #include <dali/public-api/math/degree.h>
25 #include <dali/public-api/math/radian.h>
26 #include <dali/public-api/math/vector2.h>
27 #include <dali/internal/event/actors/actor-impl.h>
28 #include <dali/internal/event/animation/animation-impl.h>
29 #include <dali/internal/event/effects/shader-effect-impl.h>
34 const char* const Animation::SIGNAL_FINISHED = "finished";
35 const char* const Animation::ACTION_PLAY = "play";
36 const char* const Animation::ACTION_STOP = "stop";
37 const char* const Animation::ACTION_PAUSE = "pause";
39 Animation::Animation()
43 Animation::Animation(Internal::Animation* animation)
44 : BaseHandle(animation)
48 Animation Animation::New(float durationSeconds)
50 Internal::AnimationPtr internal = Dali::Internal::Animation::New(durationSeconds);
52 return Animation(internal.Get());
55 Animation Animation::DownCast( BaseHandle handle )
57 return Animation( dynamic_cast<Dali::Internal::Animation*>(handle.GetObjectPtr()) );
60 Animation::~Animation()
64 void Animation::SetDuration(float durationSeconds)
66 GetImplementation(*this).SetDuration(durationSeconds);
69 float Animation::GetDuration() const
71 return GetImplementation(*this).GetDuration();
74 void Animation::SetLooping(bool looping)
76 GetImplementation(*this).SetLooping(looping);
79 bool Animation::IsLooping() const
81 return GetImplementation(*this).IsLooping();
84 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
86 GetImplementation(*this).SetEndAction(endAction);
89 Dali::Animation::EndAction Animation::GetEndAction() const
91 return GetImplementation(*this).GetEndAction();
94 void Animation::SetDestroyAction(Dali::Animation::EndAction destroyAction)
96 GetImplementation(*this).SetDestroyAction(destroyAction);
99 Dali::Animation::EndAction Animation::GetDestroyAction() const
101 return GetImplementation(*this).GetDestroyAction();
104 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
106 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
109 AlphaFunction Animation::GetDefaultAlphaFunction() const
111 return GetImplementation(*this).GetDefaultAlphaFunction();
114 void Animation::Play()
116 GetImplementation(*this).Play();
119 void Animation::Pause()
121 GetImplementation(*this).Pause();
124 void Animation::Stop()
126 GetImplementation(*this).Stop();
129 void Animation::Clear()
131 GetImplementation(*this).Clear();
134 Animation::AnimationSignalV2& Animation::FinishedSignal()
136 return GetImplementation(*this).FinishedSignal();
139 void Animation::AnimateBy(Property target, Property::Value relativeValue)
141 GetImplementation(*this).AnimateBy(target, relativeValue);
144 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
146 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
149 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
151 GetImplementation(*this).AnimateBy(target, relativeValue, period);
154 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
156 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
159 void Animation::AnimateTo(Property target, Property::Value destinationValue)
161 GetImplementation(*this).AnimateTo(target, destinationValue);
164 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
166 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
169 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
171 GetImplementation(*this).AnimateTo(target, destinationValue, period);
174 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
176 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
179 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
181 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
184 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
186 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
189 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
191 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
194 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
196 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
199 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
201 GetImplementation(*this).Animate( target, targetType, func );
204 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
206 GetImplementation(*this).Animate( target, targetType, func, alpha );
209 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, TimePeriod period )
211 GetImplementation(*this).Animate( target, targetType, func, period );
214 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period )
216 GetImplementation(*this).Animate( target, targetType, func, alpha, period );
219 // Actor specific animations
221 void Animation::MoveBy(Actor actor, float x, float y, float z)
223 GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
226 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
228 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
231 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
233 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
236 void Animation::MoveTo(Actor actor, float x, float y, float z)
238 GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
241 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
243 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
246 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
248 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
251 void Animation::Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
253 GetImplementation(*this).Move(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
256 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
258 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
261 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
263 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
266 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
268 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
271 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
273 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
276 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
278 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
281 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
283 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
286 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
288 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
291 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
293 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
296 void Animation::RotateTo(Actor actor, Quaternion rotation)
298 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
301 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
303 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
306 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
308 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
311 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
313 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
316 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
318 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
321 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
323 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
326 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
328 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
331 void Animation::Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
333 GetImplementation(*this).Rotate(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
336 void Animation::ScaleBy(Actor actor, float x, float y, float z)
338 GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
341 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
343 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
346 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
348 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
351 void Animation::ScaleTo(Actor actor, float x, float y, float z)
353 GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
356 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
358 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
361 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
363 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
366 void Animation::Show(Actor actor, float delaySeconds)
368 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
371 void Animation::Hide(Actor actor, float delaySeconds)
373 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
376 void Animation::OpacityBy(Actor actor, float opacity)
378 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
381 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
383 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
386 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
388 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
391 void Animation::OpacityTo(Actor actor, float opacity)
393 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
396 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
398 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
401 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
403 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
406 void Animation::ColorBy(Actor actor, Vector4 color)
408 GetImplementation(*this).ColorBy(GetImplementation(actor), color);
411 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
413 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
416 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
418 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
421 void Animation::ColorTo(Actor actor, Vector4 color)
423 GetImplementation(*this).ColorTo(GetImplementation(actor), color);
426 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
428 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
431 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
433 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
436 void Animation::Resize(Actor actor, float width, float height)
438 GetImplementation(*this).Resize(GetImplementation(actor), width, height);
441 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
443 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
446 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
448 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
451 void Animation::Resize(Actor actor, Vector3 size)
453 GetImplementation(*this).Resize(GetImplementation(actor), size);
456 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
458 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
461 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
463 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);