2 * Copyright (c) 2015 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-function.h>
23 #include <dali/public-api/animation/time-period.h>
24 #include <dali/internal/event/actors/actor-impl.h>
25 #include <dali/internal/event/animation/animation-impl.h>
26 #include <dali/internal/event/effects/shader-effect-impl.h>
31 Animation::Animation()
35 Animation::Animation(Internal::Animation* animation)
36 : BaseHandle(animation)
40 Animation Animation::New(float durationSeconds)
42 Internal::AnimationPtr internal = Dali::Internal::Animation::New(durationSeconds);
44 return Animation(internal.Get());
47 Animation Animation::DownCast( BaseHandle handle )
49 return Animation( dynamic_cast<Dali::Internal::Animation*>(handle.GetObjectPtr()) );
52 Animation::~Animation()
56 Animation::Animation(const Animation& handle)
61 Animation& Animation::operator=(const Animation& rhs)
63 BaseHandle::operator=(rhs);
67 void Animation::SetDuration(float durationSeconds)
69 GetImplementation(*this).SetDuration(durationSeconds);
72 float Animation::GetDuration() const
74 return GetImplementation(*this).GetDuration();
77 void Animation::SetLooping(bool looping)
79 GetImplementation(*this).SetLooping(looping);
82 void Animation::SetLoopCount(int count)
84 GetImplementation(*this).SetLoopCount(count);
87 int Animation::GetLoopCount()
89 return GetImplementation(*this).GetLoopCount();
92 int Animation::GetCurrentLoop()
94 return GetImplementation(*this).GetCurrentLoop();
97 bool Animation::IsLooping() const
99 return GetImplementation(*this).IsLooping();
102 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
104 GetImplementation(*this).SetEndAction(endAction);
107 Dali::Animation::EndAction Animation::GetEndAction() const
109 return GetImplementation(*this).GetEndAction();
112 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
114 GetImplementation(*this).SetDisconnectAction( disconnectAction );
117 Animation::EndAction Animation::GetDisconnectAction() const
119 return GetImplementation(*this).GetDisconnectAction();
122 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
124 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
127 AlphaFunction Animation::GetDefaultAlphaFunction() const
129 return GetImplementation(*this).GetDefaultAlphaFunction();
132 void Animation::Play()
134 GetImplementation(*this).Play();
137 void Animation::PlayFrom(float progress)
139 GetImplementation(*this).PlayFrom(progress);
143 void Animation::Pause()
145 GetImplementation(*this).Pause();
148 void Animation::Stop()
150 GetImplementation(*this).Stop();
153 void Animation::Clear()
155 GetImplementation(*this).Clear();
158 Animation::AnimationSignalType& Animation::FinishedSignal()
160 return GetImplementation(*this).FinishedSignal();
163 void Animation::AnimateBy(Property target, Property::Value relativeValue)
165 GetImplementation(*this).AnimateBy(target, relativeValue);
168 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
170 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
173 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
175 GetImplementation(*this).AnimateBy(target, relativeValue, period);
178 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
180 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
183 void Animation::AnimateTo(Property target, Property::Value destinationValue)
185 GetImplementation(*this).AnimateTo(target, destinationValue);
188 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
190 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
193 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
195 GetImplementation(*this).AnimateTo(target, destinationValue, period);
198 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
200 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
203 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames )
205 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) );
208 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
210 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation );
213 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
215 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
218 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
220 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation );
223 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
225 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
228 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
230 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
234 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
236 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
239 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
241 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
245 // Actor specific animations
247 void Animation::Animate( Actor actor, Path path, const Vector3& forward )
249 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward );
252 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
254 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha );
257 void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
259 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period);
262 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
264 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period );
267 void Animation::Show(Actor actor, float delaySeconds)
269 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
272 void Animation::Hide(Actor actor, float delaySeconds)
274 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
277 void Animation::SetCurrentProgress( float progress )
279 return GetImplementation(*this).SetCurrentProgress( progress );
282 float Animation::GetCurrentProgress()
284 return GetImplementation(*this).GetCurrentProgress();
287 void Animation::SetSpeedFactor( float factor )
289 GetImplementation(*this).SetSpeedFactor( factor );
292 float Animation::GetSpeedFactor() const
294 return GetImplementation(*this).GetSpeedFactor();
297 void Animation::SetPlayRange( const Vector2& range )
299 GetImplementation(*this).SetPlayRange(range);
302 Vector2 Animation::GetPlayRange() const
304 return GetImplementation(*this).GetPlayRange();