2 * Copyright (c) 2016 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>
30 Animation::Animation()
34 Animation::Animation(Internal::Animation* animation)
35 : BaseHandle(animation)
39 Animation Animation::New(float durationSeconds)
41 Internal::AnimationPtr internal = Dali::Internal::Animation::New(durationSeconds);
43 return Animation(internal.Get());
46 Animation Animation::DownCast( BaseHandle handle )
48 return Animation( dynamic_cast<Dali::Internal::Animation*>(handle.GetObjectPtr()) );
51 Animation::~Animation()
55 Animation::Animation(const Animation& handle)
60 Animation& Animation::operator=(const Animation& rhs)
62 BaseHandle::operator=(rhs);
66 void Animation::SetDuration(float durationSeconds)
68 GetImplementation(*this).SetDuration(durationSeconds);
71 float Animation::GetDuration() const
73 return GetImplementation(*this).GetDuration();
76 void Animation::SetLooping(bool looping)
78 GetImplementation(*this).SetLooping(looping);
81 void Animation::SetLoopCount(int count)
83 GetImplementation(*this).SetLoopCount(count);
86 int Animation::GetLoopCount()
88 return GetImplementation(*this).GetLoopCount();
91 int Animation::GetCurrentLoop()
93 return GetImplementation(*this).GetCurrentLoop();
96 bool Animation::IsLooping() const
98 return GetImplementation(*this).IsLooping();
101 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
103 GetImplementation(*this).SetEndAction(endAction);
106 Dali::Animation::EndAction Animation::GetEndAction() const
108 return GetImplementation(*this).GetEndAction();
111 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
113 GetImplementation(*this).SetDisconnectAction( disconnectAction );
116 Animation::EndAction Animation::GetDisconnectAction() const
118 return GetImplementation(*this).GetDisconnectAction();
121 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
123 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
126 AlphaFunction Animation::GetDefaultAlphaFunction() const
128 return GetImplementation(*this).GetDefaultAlphaFunction();
131 void Animation::Play()
133 GetImplementation(*this).Play();
136 void Animation::PlayFrom(float progress)
138 GetImplementation(*this).PlayFrom(progress);
142 void Animation::Pause()
144 GetImplementation(*this).Pause();
147 Dali::Animation::State Animation::GetState() const
149 return GetImplementation(*this).GetState();
152 void Animation::Stop()
154 GetImplementation(*this).Stop();
157 void Animation::Clear()
159 GetImplementation(*this).Clear();
162 Animation::AnimationSignalType& Animation::FinishedSignal()
164 return GetImplementation(*this).FinishedSignal();
167 void Animation::AnimateBy(Property target, Property::Value relativeValue)
169 GetImplementation(*this).AnimateBy(target, relativeValue);
172 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
174 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
177 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
179 GetImplementation(*this).AnimateBy(target, relativeValue, period);
182 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
184 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
187 void Animation::AnimateTo(Property target, Property::Value destinationValue)
189 GetImplementation(*this).AnimateTo(target, destinationValue);
192 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
194 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
197 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
199 GetImplementation(*this).AnimateTo(target, destinationValue, period);
202 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
204 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
207 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames )
209 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) );
212 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
214 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation );
217 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
219 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
222 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
224 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation );
227 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
229 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
232 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
234 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
238 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
240 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
243 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
245 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
249 // Actor specific animations
251 void Animation::Animate( Actor actor, Path path, const Vector3& forward )
253 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward );
256 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
258 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha );
261 void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
263 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period);
266 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
268 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period );
271 void Animation::Show(Actor actor, float delaySeconds)
273 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
276 void Animation::Hide(Actor actor, float delaySeconds)
278 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
281 void Animation::SetCurrentProgress( float progress )
283 return GetImplementation(*this).SetCurrentProgress( progress );
286 float Animation::GetCurrentProgress()
288 return GetImplementation(*this).GetCurrentProgress();
291 void Animation::SetSpeedFactor( float factor )
293 GetImplementation(*this).SetSpeedFactor( factor );
296 float Animation::GetSpeedFactor() const
298 return GetImplementation(*this).GetSpeedFactor();
301 void Animation::SetPlayRange( const Vector2& range )
303 GetImplementation(*this).SetPlayRange(range);
306 Vector2 Animation::GetPlayRange() const
308 return GetImplementation(*this).GetPlayRange();