2 * Copyright (c) 2020 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) = default;
58 Animation& Animation::operator=(const Animation& rhs) = default;
60 Animation::Animation( Animation&& rhs ) = default;
62 Animation& Animation::operator=( Animation&& rhs ) = default;
64 void Animation::SetDuration(float durationSeconds)
66 GetImplementation(*this).SetDuration(durationSeconds);
69 float Animation::GetDuration() const
71 return GetImplementation(*this).GetDuration();
74 void Animation::SetLooping(bool looping)
76 GetImplementation(*this).SetLooping(looping);
79 void Animation::SetLoopCount(int32_t count)
81 GetImplementation(*this).SetLoopCount(count);
84 int32_t Animation::GetLoopCount()
86 return GetImplementation(*this).GetLoopCount();
89 int32_t Animation::GetCurrentLoop()
91 return GetImplementation(*this).GetCurrentLoop();
94 bool Animation::IsLooping() const
96 return GetImplementation(*this).IsLooping();
99 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
101 GetImplementation(*this).SetEndAction(endAction);
104 Dali::Animation::EndAction Animation::GetEndAction() const
106 return GetImplementation(*this).GetEndAction();
109 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
111 GetImplementation(*this).SetDisconnectAction( disconnectAction );
114 Animation::EndAction Animation::GetDisconnectAction() const
116 return GetImplementation(*this).GetDisconnectAction();
119 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
121 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
124 AlphaFunction Animation::GetDefaultAlphaFunction() const
126 return GetImplementation(*this).GetDefaultAlphaFunction();
129 void Animation::Play()
131 GetImplementation(*this).Play();
134 void Animation::PlayFrom(float progress)
136 GetImplementation(*this).PlayFrom(progress);
139 void Animation::PlayAfter( float delaySeconds )
141 GetImplementation( *this ).PlayAfter( delaySeconds );
144 void Animation::Pause()
146 GetImplementation(*this).Pause();
149 Dali::Animation::State Animation::GetState() const
151 return GetImplementation(*this).GetState();
154 void Animation::Stop()
156 GetImplementation(*this).Stop();
159 void Animation::Clear()
161 GetImplementation(*this).Clear();
164 void Animation::SetLoopingMode( LoopingMode loopingMode )
166 GetImplementation( *this ).SetLoopingMode( loopingMode );
169 Animation::LoopingMode Animation::GetLoopingMode() const
171 return GetImplementation( *this ).GetLoopingMode();
174 Animation::AnimationSignalType& Animation::FinishedSignal()
176 return GetImplementation(*this).FinishedSignal();
179 void Animation::AnimateBy(Property target, Property::Value relativeValue)
181 GetImplementation(*this).AnimateBy(target, relativeValue);
184 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
186 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
189 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
191 GetImplementation(*this).AnimateBy(target, relativeValue, period);
194 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
196 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
199 void Animation::AnimateTo(Property target, Property::Value destinationValue)
201 GetImplementation(*this).AnimateTo(target, destinationValue);
204 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
206 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
209 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
211 GetImplementation(*this).AnimateTo(target, destinationValue, period);
214 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
216 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
219 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames )
221 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) );
224 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
226 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation );
229 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
231 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
234 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
236 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation );
239 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
241 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
244 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
246 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
250 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
252 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
255 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
257 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
261 // Actor specific animations
263 void Animation::Animate( Actor actor, Path path, const Vector3& forward )
265 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward );
268 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
270 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha );
273 void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
275 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period);
278 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
280 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period );
283 void Animation::Show(Actor actor, float delaySeconds)
285 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
288 void Animation::Hide(Actor actor, float delaySeconds)
290 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
293 void Animation::SetCurrentProgress( float progress )
295 return GetImplementation(*this).SetCurrentProgress( progress );
298 float Animation::GetCurrentProgress()
300 return GetImplementation(*this).GetCurrentProgress();
303 void Animation::SetSpeedFactor( float factor )
305 GetImplementation(*this).SetSpeedFactor( factor );
308 float Animation::GetSpeedFactor() const
310 return GetImplementation(*this).GetSpeedFactor();
313 void Animation::SetPlayRange( const Vector2& range )
315 GetImplementation(*this).SetPlayRange(range);
318 Vector2 Animation::GetPlayRange() const
320 return GetImplementation(*this).GetPlayRange();