2 * Copyright (c) 2018 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/animation/path-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(int32_t count)
84 GetImplementation(*this).SetLoopCount(count);
87 int32_t Animation::GetLoopCount()
89 return GetImplementation(*this).GetLoopCount();
92 int32_t 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);
142 void Animation::PlayAfter( float delaySeconds )
144 GetImplementation( *this ).PlayAfter( delaySeconds );
147 void Animation::Pause()
149 GetImplementation(*this).Pause();
152 Dali::Animation::State Animation::GetState() const
154 return GetImplementation(*this).GetState();
157 void Animation::Stop()
159 GetImplementation(*this).Stop();
162 void Animation::Clear()
164 GetImplementation(*this).Clear();
167 void Animation::SetLoopingMode( LoopingMode loopingMode )
169 GetImplementation( *this ).SetLoopingMode( loopingMode );
172 Animation::LoopingMode Animation::GetLoopingMode() const
174 return GetImplementation( *this ).GetLoopingMode();
177 Animation::AnimationSignalType& Animation::FinishedSignal()
179 return GetImplementation(*this).FinishedSignal();
182 void Animation::AnimateBy(Property target, Property::Value relativeValue)
184 GetImplementation(*this).AnimateBy(target, relativeValue);
187 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
189 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
192 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
194 GetImplementation(*this).AnimateBy(target, relativeValue, period);
197 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
199 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
202 void Animation::AnimateTo(Property target, Property::Value destinationValue)
204 GetImplementation(*this).AnimateTo(target, destinationValue);
207 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
209 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
212 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
214 GetImplementation(*this).AnimateTo(target, destinationValue, period);
217 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
219 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
222 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames )
224 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) );
227 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
229 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation );
232 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
234 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
237 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
239 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation );
242 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
244 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
247 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
249 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
253 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
255 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
258 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
260 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
264 // Actor specific animations
266 void Animation::Animate( Actor actor, Path path, const Vector3& forward )
268 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward );
271 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
273 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha );
276 void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
278 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period);
281 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
283 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period );
286 void Animation::Show(Actor actor, float delaySeconds)
288 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
291 void Animation::Hide(Actor actor, float delaySeconds)
293 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
296 void Animation::SetCurrentProgress( float progress )
298 return GetImplementation(*this).SetCurrentProgress( progress );
301 float Animation::GetCurrentProgress()
303 return GetImplementation(*this).GetCurrentProgress();
306 void Animation::SetSpeedFactor( float factor )
308 GetImplementation(*this).SetSpeedFactor( factor );
311 float Animation::GetSpeedFactor() const
313 return GetImplementation(*this).GetSpeedFactor();
316 void Animation::SetPlayRange( const Vector2& range )
318 GetImplementation(*this).SetPlayRange(range);
321 Vector2 Animation::GetPlayRange() const
323 return GetImplementation(*this).GetPlayRange();