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::SetDisconnectAction( Animation::EndAction disconnectAction )
115 GetImplementation(*this).SetDisconnectAction( disconnectAction );
118 Animation::EndAction Animation::GetDisconnectAction() const
120 return GetImplementation(*this).GetDisconnectAction();
123 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
125 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
128 AlphaFunction Animation::GetDefaultAlphaFunction() const
130 return GetImplementation(*this).GetDefaultAlphaFunction();
133 void Animation::Play()
135 GetImplementation(*this).Play();
138 void Animation::PlayFrom(float progress)
140 GetImplementation(*this).PlayFrom(progress);
144 void Animation::Pause()
146 GetImplementation(*this).Pause();
149 void Animation::Stop()
151 GetImplementation(*this).Stop();
154 void Animation::Clear()
156 GetImplementation(*this).Clear();
159 Animation::AnimationSignalV2& Animation::FinishedSignal()
161 return GetImplementation(*this).FinishedSignal();
164 void Animation::AnimateBy(Property target, Property::Value relativeValue)
166 GetImplementation(*this).AnimateBy(target, relativeValue);
169 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
171 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
174 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
176 GetImplementation(*this).AnimateBy(target, relativeValue, period);
179 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
181 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
184 void Animation::AnimateTo(Property target, Property::Value destinationValue)
186 GetImplementation(*this).AnimateTo(target, destinationValue);
189 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
191 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
194 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
196 GetImplementation(*this).AnimateTo(target, destinationValue, period);
199 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
201 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
204 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
206 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
209 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
211 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
214 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
216 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
219 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
221 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
224 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
226 GetImplementation(*this).Animate( target, targetType, func );
229 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
231 GetImplementation(*this).Animate( target, targetType, func, alpha );
234 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, TimePeriod period )
236 GetImplementation(*this).Animate( target, targetType, func, period );
239 void Animation::Animate( Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period )
241 GetImplementation(*this).Animate( target, targetType, func, alpha, period );
244 // Actor specific animations
246 void Animation::MoveBy(Actor actor, float x, float y, float z)
248 GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
251 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
253 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
256 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
258 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
261 void Animation::MoveTo(Actor actor, float x, float y, float z)
263 GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
266 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
268 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
271 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
273 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
276 void Animation::Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
278 GetImplementation(*this).Move(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
281 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
283 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
286 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
288 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
291 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
293 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
296 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
298 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
301 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
303 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
306 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
308 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
311 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
313 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
316 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
318 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
321 void Animation::RotateTo(Actor actor, Quaternion rotation)
323 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
326 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
328 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
331 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
333 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
336 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
338 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
341 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
343 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
346 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
348 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
351 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
353 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
356 void Animation::Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds)
358 GetImplementation(*this).Rotate(GetImplementation(actor), animatorFunc, alpha, delaySeconds, durationSeconds);
361 void Animation::ScaleBy(Actor actor, float x, float y, float z)
363 GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
366 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
368 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
371 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
373 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
376 void Animation::ScaleTo(Actor actor, float x, float y, float z)
378 GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
381 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
383 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
386 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
388 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
391 void Animation::Show(Actor actor, float delaySeconds)
393 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
396 void Animation::Hide(Actor actor, float delaySeconds)
398 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
401 void Animation::OpacityBy(Actor actor, float opacity)
403 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
406 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
408 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
411 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
413 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
416 void Animation::OpacityTo(Actor actor, float opacity)
418 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
421 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
423 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
426 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
428 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
431 void Animation::ColorBy(Actor actor, Vector4 color)
433 GetImplementation(*this).ColorBy(GetImplementation(actor), color);
436 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
438 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
441 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
443 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
446 void Animation::ColorTo(Actor actor, Vector4 color)
448 GetImplementation(*this).ColorTo(GetImplementation(actor), color);
451 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
453 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
456 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
458 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
461 void Animation::Resize(Actor actor, float width, float height)
463 GetImplementation(*this).Resize(GetImplementation(actor), width, height);
466 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
468 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
471 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
473 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
476 void Animation::Resize(Actor actor, Vector3 size)
478 GetImplementation(*this).Resize(GetImplementation(actor), size);
481 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
483 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
486 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
488 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);
491 void Animation::SetCurrentProgress( float progress )
493 return GetImplementation(*this).SetCurrentProgress( progress );
496 float Animation::GetCurrentProgress()
498 return GetImplementation(*this).GetCurrentProgress();
501 void Animation::SetSpeedFactor( float factor )
503 GetImplementation(*this).SetSpeedFactor( factor );
506 float Animation::GetSpeedFactor() const
508 return GetImplementation(*this).GetSpeedFactor();
511 void Animation::SetPlayRange( const Vector2& range )
513 GetImplementation(*this).SetPlayRange(range);
516 Vector2 Animation::GetPlayRange() const
518 return GetImplementation(*this).GetPlayRange();