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 void Animation::SetDuration(float durationSeconds)
78 GetImplementation(*this).SetDuration(durationSeconds);
81 float Animation::GetDuration() const
83 return GetImplementation(*this).GetDuration();
86 void Animation::SetLooping(bool looping)
88 GetImplementation(*this).SetLooping(looping);
91 bool Animation::IsLooping() const
93 return GetImplementation(*this).IsLooping();
96 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
98 GetImplementation(*this).SetEndAction(endAction);
101 Dali::Animation::EndAction Animation::GetEndAction() const
103 return GetImplementation(*this).GetEndAction();
106 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
108 GetImplementation(*this).SetDisconnectAction( disconnectAction );
111 Animation::EndAction Animation::GetDisconnectAction() const
113 return GetImplementation(*this).GetDisconnectAction();
116 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
118 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
121 AlphaFunction Animation::GetDefaultAlphaFunction() const
123 return GetImplementation(*this).GetDefaultAlphaFunction();
126 void Animation::Play()
128 GetImplementation(*this).Play();
131 void Animation::PlayFrom(float progress)
133 GetImplementation(*this).PlayFrom(progress);
137 void Animation::Pause()
139 GetImplementation(*this).Pause();
142 void Animation::Stop()
144 GetImplementation(*this).Stop();
147 void Animation::Clear()
149 GetImplementation(*this).Clear();
152 Animation::AnimationSignalType& Animation::FinishedSignal()
154 return GetImplementation(*this).FinishedSignal();
157 void Animation::AnimateBy(Property target, Property::Value relativeValue)
159 GetImplementation(*this).AnimateBy(target, relativeValue);
162 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
164 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
167 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
169 GetImplementation(*this).AnimateBy(target, relativeValue, period);
172 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
174 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
177 void Animation::AnimateTo(Property target, Property::Value destinationValue)
179 GetImplementation(*this).AnimateTo(target, destinationValue);
182 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
184 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
187 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
189 GetImplementation(*this).AnimateTo(target, destinationValue, period);
192 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
194 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
197 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames )
199 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) );
202 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
204 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation );
207 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
209 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
212 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
214 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation );
217 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
219 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
222 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
224 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
228 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
230 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
233 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
235 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
239 // Actor specific animations
241 void Animation::Animate( Actor actor, Path path, const Vector3& forward )
243 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward );
246 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
248 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha );
251 void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
253 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period);
256 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
258 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period );
261 void Animation::MoveBy(Actor actor, float x, float y, float z)
263 GetImplementation(*this).MoveBy(GetImplementation(actor), x, y, z);
266 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha)
268 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha);
271 void Animation::MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
273 GetImplementation(*this).MoveBy(GetImplementation(actor), displacement, alpha, delaySeconds, durationSeconds);
276 void Animation::MoveTo(Actor actor, float x, float y, float z)
278 GetImplementation(*this).MoveTo(GetImplementation(actor), x, y, z);
281 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha)
283 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha);
286 void Animation::MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
288 GetImplementation(*this).MoveTo(GetImplementation(actor), position, alpha, delaySeconds, durationSeconds);
291 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis)
293 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis);
296 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis)
298 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis);
301 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
303 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha);
306 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
308 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha);
311 void Animation::RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
313 GetImplementation(*this).RotateBy(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
316 void Animation::RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
318 GetImplementation(*this).RotateBy(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
321 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis)
323 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis);
326 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis)
328 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis);
331 void Animation::RotateTo(Actor actor, Quaternion rotation)
333 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation);
336 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha)
338 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha);
341 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha)
343 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha);
346 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha)
348 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha);
351 void Animation::RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
353 GetImplementation(*this).RotateTo(GetImplementation(actor), Radian(angle), axis, alpha, delaySeconds, durationSeconds);
356 void Animation::RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
358 GetImplementation(*this).RotateTo(GetImplementation(actor), angle, axis, alpha, delaySeconds, durationSeconds);
361 void Animation::RotateTo(Actor actor, Quaternion rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
363 GetImplementation(*this).RotateTo(GetImplementation(actor), rotation, alpha, delaySeconds, durationSeconds);
366 void Animation::ScaleBy(Actor actor, float x, float y, float z)
368 GetImplementation(*this).ScaleBy(GetImplementation(actor), x, y, z);
371 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha)
373 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha);
376 void Animation::ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
378 GetImplementation(*this).ScaleBy(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
381 void Animation::ScaleTo(Actor actor, float x, float y, float z)
383 GetImplementation(*this).ScaleTo(GetImplementation(actor), x, y, z);
386 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha)
388 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha);
391 void Animation::ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
393 GetImplementation(*this).ScaleTo(GetImplementation(actor), scale, alpha, delaySeconds, durationSeconds);
396 void Animation::Show(Actor actor, float delaySeconds)
398 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
401 void Animation::Hide(Actor actor, float delaySeconds)
403 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
406 void Animation::OpacityBy(Actor actor, float opacity)
408 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity);
411 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha)
413 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha);
416 void Animation::OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
418 GetImplementation(*this).OpacityBy(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
421 void Animation::OpacityTo(Actor actor, float opacity)
423 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity);
426 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha)
428 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha);
431 void Animation::OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
433 GetImplementation(*this).OpacityTo(GetImplementation(actor), opacity, alpha, delaySeconds, durationSeconds);
436 void Animation::ColorBy(Actor actor, Vector4 color)
438 GetImplementation(*this).ColorBy(GetImplementation(actor), color);
441 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha)
443 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha);
446 void Animation::ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
448 GetImplementation(*this).ColorBy(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
451 void Animation::ColorTo(Actor actor, Vector4 color)
453 GetImplementation(*this).ColorTo(GetImplementation(actor), color);
456 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha)
458 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha);
461 void Animation::ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
463 GetImplementation(*this).ColorTo(GetImplementation(actor), color, alpha, delaySeconds, durationSeconds);
466 void Animation::Resize(Actor actor, float width, float height)
468 GetImplementation(*this).Resize(GetImplementation(actor), width, height);
471 void Animation::Resize(Actor actor, float width, float height, AlphaFunction alpha)
473 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha);
476 void Animation::Resize(Actor actor,float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
478 GetImplementation(*this).Resize(GetImplementation(actor), width, height, alpha, delaySeconds, durationSeconds);
481 void Animation::Resize(Actor actor, Vector3 size)
483 GetImplementation(*this).Resize(GetImplementation(actor), size);
486 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha)
488 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha);
491 void Animation::Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
493 GetImplementation(*this).Resize(GetImplementation(actor), size, alpha, delaySeconds, durationSeconds);
496 void Animation::SetCurrentProgress( float progress )
498 return GetImplementation(*this).SetCurrentProgress( progress );
501 float Animation::GetCurrentProgress()
503 return GetImplementation(*this).GetCurrentProgress();
506 void Animation::SetSpeedFactor( float factor )
508 GetImplementation(*this).SetSpeedFactor( factor );
511 float Animation::GetSpeedFactor() const
513 return GetImplementation(*this).GetSpeedFactor();
516 void Animation::SetPlayRange( const Vector2& range )
518 GetImplementation(*this).SetPlayRange(range);
521 Vector2 Animation::GetPlayRange() const
523 return GetImplementation(*this).GetPlayRange();