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/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()
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) = default;
57 Animation& Animation::operator=(const Animation& rhs) = default;
59 Animation::Animation(Animation&& rhs) = default;
61 Animation& Animation::operator=(Animation&& rhs) = default;
63 void Animation::SetDuration(float durationSeconds)
65 GetImplementation(*this).SetDuration(durationSeconds);
68 float Animation::GetDuration() const
70 return GetImplementation(*this).GetDuration();
73 void Animation::SetLooping(bool looping)
75 GetImplementation(*this).SetLooping(looping);
78 void Animation::SetLoopCount(int32_t count)
80 GetImplementation(*this).SetLoopCount(count);
83 int32_t Animation::GetLoopCount()
85 return GetImplementation(*this).GetLoopCount();
88 int32_t Animation::GetCurrentLoop()
90 return GetImplementation(*this).GetCurrentLoop();
93 bool Animation::IsLooping() const
95 return GetImplementation(*this).IsLooping();
98 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
100 GetImplementation(*this).SetEndAction(endAction);
103 Dali::Animation::EndAction Animation::GetEndAction() const
105 return GetImplementation(*this).GetEndAction();
108 void Animation::SetDisconnectAction(Animation::EndAction disconnectAction)
110 GetImplementation(*this).SetDisconnectAction(disconnectAction);
113 Animation::EndAction Animation::GetDisconnectAction() const
115 return GetImplementation(*this).GetDisconnectAction();
118 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
120 GetImplementation(*this).SetDefaultAlphaFunction(alpha);
123 AlphaFunction Animation::GetDefaultAlphaFunction() const
125 return GetImplementation(*this).GetDefaultAlphaFunction();
128 void Animation::Play()
130 GetImplementation(*this).Play();
133 void Animation::PlayFrom(float progress)
135 GetImplementation(*this).PlayFrom(progress);
138 void Animation::PlayAfter(float delaySeconds)
140 GetImplementation(*this).PlayAfter(delaySeconds);
143 void Animation::Pause()
145 GetImplementation(*this).Pause();
148 Dali::Animation::State Animation::GetState() const
150 return GetImplementation(*this).GetState();
153 void Animation::Stop()
155 GetImplementation(*this).Stop();
158 void Animation::Clear()
160 GetImplementation(*this).Clear();
163 void Animation::SetLoopingMode(LoopingMode loopingMode)
165 GetImplementation(*this).SetLoopingMode(loopingMode);
168 Animation::LoopingMode Animation::GetLoopingMode() const
170 return GetImplementation(*this).GetLoopingMode();
173 Animation::AnimationSignalType& Animation::FinishedSignal()
175 return GetImplementation(*this).FinishedSignal();
178 void Animation::AnimateBy(Property target, Property::Value relativeValue)
180 GetImplementation(*this).AnimateBy(target, relativeValue);
183 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
185 GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
188 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
190 GetImplementation(*this).AnimateBy(target, relativeValue, period);
193 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
195 GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
198 void Animation::AnimateTo(Property target, Property::Value destinationValue)
200 GetImplementation(*this).AnimateTo(target, destinationValue);
203 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
205 GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
208 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
210 GetImplementation(*this).AnimateTo(target, destinationValue, period);
213 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
215 GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
218 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
220 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames));
223 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
225 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation);
228 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
230 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
233 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
235 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation);
238 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
240 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
243 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
245 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
248 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
250 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
253 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
255 GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
258 // Actor specific animations
260 void Animation::Animate(Actor actor, Path path, const Vector3& forward)
262 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward);
265 void Animation::Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha)
267 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, alpha);
270 void Animation::Animate(Actor actor, Path path, const Vector3& forward, TimePeriod period)
272 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, period);
275 void Animation::Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
277 GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, alpha, period);
280 void Animation::Show(Actor actor, float delaySeconds)
282 GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
285 void Animation::Hide(Actor actor, float delaySeconds)
287 GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
290 void Animation::SetCurrentProgress(float progress)
292 return GetImplementation(*this).SetCurrentProgress(progress);
295 float Animation::GetCurrentProgress()
297 return GetImplementation(*this).GetCurrentProgress();
300 void Animation::SetSpeedFactor(float factor)
302 GetImplementation(*this).SetSpeedFactor(factor);
305 float Animation::GetSpeedFactor() const
307 return GetImplementation(*this).GetSpeedFactor();
310 void Animation::SetPlayRange(const Vector2& range)
312 GetImplementation(*this).SetPlayRange(range);
315 Vector2 Animation::GetPlayRange() const
317 return GetImplementation(*this).GetPlayRange();