2 * Copyright (c) 2024 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/internal/event/actors/actor-impl.h>
23 #include <dali/internal/event/animation/animation-impl.h>
24 #include <dali/internal/event/animation/path-impl.h>
25 #include <dali/public-api/animation/alpha-function.h>
26 #include <dali/public-api/animation/time-period.h>
30 Animation::Animation() = default;
32 Animation::Animation(Internal::Animation* animation)
33 : BaseHandle(animation)
37 Animation Animation::New(float durationSeconds)
39 Internal::AnimationPtr internal = Dali::Internal::Animation::New(durationSeconds);
41 return Animation(internal.Get());
44 Animation Animation::DownCast(BaseHandle handle)
46 return Animation(dynamic_cast<Dali::Internal::Animation*>(handle.GetObjectPtr()));
49 Animation::~Animation() = default;
51 Animation::Animation(const Animation& handle) = default;
53 Animation& Animation::operator=(const Animation& rhs) = default;
55 Animation::Animation(Animation&& rhs) noexcept = default;
57 Animation& Animation::operator=(Animation&& rhs) noexcept = default;
59 void Animation::SetDuration(float durationSeconds)
61 GetImplementation(*this).SetDuration(durationSeconds);
64 float Animation::GetDuration() const
66 return GetImplementation(*this).GetDuration();
69 void Animation::SetLooping(bool looping)
71 GetImplementation(*this).SetLooping(looping);
74 void Animation::SetLoopCount(int32_t count)
76 GetImplementation(*this).SetLoopCount(count);
79 int32_t Animation::GetLoopCount()
81 return GetImplementation(*this).GetLoopCount();
84 int32_t Animation::GetCurrentLoop()
86 return GetImplementation(*this).GetCurrentLoop();
89 bool Animation::IsLooping() const
91 return GetImplementation(*this).IsLooping();
94 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
96 GetImplementation(*this).SetEndAction(endAction);
99 Dali::Animation::EndAction Animation::GetEndAction() const
101 return GetImplementation(*this).GetEndAction();
104 void Animation::SetDisconnectAction(Animation::EndAction disconnectAction)
106 GetImplementation(*this).SetDisconnectAction(disconnectAction);
109 Animation::EndAction Animation::GetDisconnectAction() const
111 return GetImplementation(*this).GetDisconnectAction();
114 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
116 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
119 AlphaFunction Animation::GetDefaultAlphaFunction() const
121 return GetImplementation(*this).GetDefaultAlphaFunction();
124 void Animation::Play()
126 GetImplementation(*this).Play();
129 void Animation::PlayFrom(float progress)
131 GetImplementation(*this).PlayFrom(progress);
134 void Animation::PlayAfter(float delaySeconds)
136 GetImplementation(*this).PlayAfter(delaySeconds);
139 void Animation::Pause()
141 GetImplementation(*this).Pause();
144 Dali::Animation::State Animation::GetState() const
146 return GetImplementation(*this).GetState();
149 void Animation::Stop()
151 GetImplementation(*this).Stop();
154 void Animation::Clear()
156 GetImplementation(*this).Clear();
159 void Animation::SetLoopingMode(LoopingMode loopingMode)
161 GetImplementation(*this).SetLoopingMode(loopingMode);
164 Animation::LoopingMode Animation::GetLoopingMode() const
166 return GetImplementation(*this).GetLoopingMode();
169 uint32_t Animation::GetAnimationId() const
171 return GetImplementation(*this).GetAnimationId();
174 Animation::AnimationSignalType& Animation::FinishedSignal()
176 return GetImplementation(*this).FinishedSignal();
179 void Animation::AnimateBy(Property target, Property::Value relativeValue)
181 GetImplementation(*this).AnimateBy(target, std::move(relativeValue));
184 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
186 GetImplementation(*this).AnimateBy(target, std::move(relativeValue), alpha);
189 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
191 GetImplementation(*this).AnimateBy(target, std::move(relativeValue), period);
194 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
196 GetImplementation(*this).AnimateBy(target, std::move(relativeValue), alpha, period);
199 void Animation::AnimateTo(Property target, Property::Value destinationValue)
201 GetImplementation(*this).AnimateTo(target, std::move(destinationValue));
204 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
206 GetImplementation(*this).AnimateTo(target, std::move(destinationValue), alpha);
209 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
211 GetImplementation(*this).AnimateTo(target, std::move(destinationValue), period);
214 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
216 GetImplementation(*this).AnimateTo(target, std::move(destinationValue), alpha, period);
219 void Animation::AnimateBetween(Property target, KeyFrames keyFrames)
221 GetImplementation(*this).AnimateBetween(target, keyFrames);
224 void Animation::AnimateBetween(Property target, KeyFrames keyFrames, Interpolation interpolation)
226 GetImplementation(*this).AnimateBetween(target, keyFrames, interpolation);
229 void Animation::AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
231 GetImplementation(*this).AnimateBetween(target, keyFrames, period);
234 void Animation::AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period, Interpolation interpolation)
236 GetImplementation(*this).AnimateBetween(target, keyFrames, period, interpolation);
239 void Animation::AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
241 GetImplementation(*this).AnimateBetween(target, keyFrames, alpha);
244 void Animation::AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Interpolation interpolation)
246 GetImplementation(*this).AnimateBetween(target, keyFrames, alpha, interpolation);
249 void Animation::AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
251 GetImplementation(*this).AnimateBetween(target, keyFrames, alpha, period);
254 void Animation::AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
256 GetImplementation(*this).AnimateBetween(target, keyFrames, alpha, period, interpolation);
259 // Actor specific animations
261 void Animation::Animate(Actor actor, Path path, const Vector3& forward)
263 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward);
266 void Animation::Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha)
268 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, alpha);
271 void Animation::Animate(Actor actor, Path path, const Vector3& forward, TimePeriod period)
273 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, period);
276 void Animation::Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
278 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, alpha, period);
281 void Animation::Show(Actor actor, float delaySeconds)
283 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
286 void Animation::Hide(Actor actor, float delaySeconds)
288 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
291 void Animation::SetCurrentProgress(float progress)
293 return GetImplementation(*this).SetCurrentProgress(progress);
296 float Animation::GetCurrentProgress()
298 return GetImplementation(*this).GetCurrentProgress();
301 void Animation::SetSpeedFactor(float factor)
303 GetImplementation(*this).SetSpeedFactor(factor);
306 float Animation::GetSpeedFactor() const
308 return GetImplementation(*this).GetSpeedFactor();
311 void Animation::SetPlayRange(const Vector2& range)
313 GetImplementation(*this).SetPlayRange(range);
316 Vector2 Animation::GetPlayRange() const
318 return GetImplementation(*this).GetPlayRange();
321 void Animation::SetBlendPoint(float blendPoint)
323 GetImplementation(*this).SetBlendPoint(blendPoint);
326 float Animation::GetBlendPoint() const
328 return GetImplementation(*this).GetBlendPoint();