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)
61 Animation& Animation::operator=(const Animation& rhs)
63 BaseHandle::operator=(rhs);
67 Animation::Animation( Animation&& rhs ) = default;
69 Animation& Animation::operator=( Animation&& rhs ) = default;
71 void Animation::SetDuration(float durationSeconds)
73 GetImplementation(*this).SetDuration(durationSeconds);
76 float Animation::GetDuration() const
78 return GetImplementation(*this).GetDuration();
81 void Animation::SetLooping(bool looping)
83 GetImplementation(*this).SetLooping(looping);
86 void Animation::SetLoopCount(int32_t count)
88 GetImplementation(*this).SetLoopCount(count);
91 int32_t Animation::GetLoopCount()
93 return GetImplementation(*this).GetLoopCount();
96 int32_t Animation::GetCurrentLoop()
98 return GetImplementation(*this).GetCurrentLoop();
101 bool Animation::IsLooping() const
103 return GetImplementation(*this).IsLooping();
106 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
108 GetImplementation(*this).SetEndAction(endAction);
111 Dali::Animation::EndAction Animation::GetEndAction() const
113 return GetImplementation(*this).GetEndAction();
116 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
118 GetImplementation(*this).SetDisconnectAction( disconnectAction );
121 Animation::EndAction Animation::GetDisconnectAction() const
123 return GetImplementation(*this).GetDisconnectAction();
126 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
128 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
131 AlphaFunction Animation::GetDefaultAlphaFunction() const
133 return GetImplementation(*this).GetDefaultAlphaFunction();
136 void Animation::Play()
138 GetImplementation(*this).Play();
141 void Animation::PlayFrom(float progress)
143 GetImplementation(*this).PlayFrom(progress);
146 void Animation::PlayAfter( float delaySeconds )
148 GetImplementation( *this ).PlayAfter( delaySeconds );
151 void Animation::Pause()
153 GetImplementation(*this).Pause();
156 Dali::Animation::State Animation::GetState() const
158 return GetImplementation(*this).GetState();
161 void Animation::Stop()
163 GetImplementation(*this).Stop();
166 void Animation::Clear()
168 GetImplementation(*this).Clear();
171 void Animation::SetLoopingMode( LoopingMode loopingMode )
173 GetImplementation( *this ).SetLoopingMode( loopingMode );
176 Animation::LoopingMode Animation::GetLoopingMode() const
178 return GetImplementation( *this ).GetLoopingMode();
181 Animation::AnimationSignalType& Animation::FinishedSignal()
183 return GetImplementation(*this).FinishedSignal();
186 void Animation::AnimateBy(Property target, Property::Value relativeValue)
188 GetImplementation(*this).AnimateBy(target, relativeValue);
191 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
193 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
196 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
198 GetImplementation(*this).AnimateBy(target, relativeValue, period);
201 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
203 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
206 void Animation::AnimateTo(Property target, Property::Value destinationValue)
208 GetImplementation(*this).AnimateTo(target, destinationValue);
211 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
213 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
216 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
218 GetImplementation(*this).AnimateTo(target, destinationValue, period);
221 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
223 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
226 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames )
228 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) );
231 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
233 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation );
236 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
238 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
241 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
243 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation );
246 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
248 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
251 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
253 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
257 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
259 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
262 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
264 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
268 // Actor specific animations
270 void Animation::Animate( Actor actor, Path path, const Vector3& forward )
272 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward );
275 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
277 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha );
280 void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
282 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period);
285 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
287 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period );
290 void Animation::Show(Actor actor, float delaySeconds)
292 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
295 void Animation::Hide(Actor actor, float delaySeconds)
297 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
300 void Animation::SetCurrentProgress( float progress )
302 return GetImplementation(*this).SetCurrentProgress( progress );
305 float Animation::GetCurrentProgress()
307 return GetImplementation(*this).GetCurrentProgress();
310 void Animation::SetSpeedFactor( float factor )
312 GetImplementation(*this).SetSpeedFactor( factor );
315 float Animation::GetSpeedFactor() const
317 return GetImplementation(*this).GetSpeedFactor();
320 void Animation::SetPlayRange( const Vector2& range )
322 GetImplementation(*this).SetPlayRange(range);
325 Vector2 Animation::GetPlayRange() const
327 return GetImplementation(*this).GetPlayRange();