Added Animation loop count
[platform/core/uifw/dali-core.git] / dali / public-api / animation / animation.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/animation/animation.h>
20
21 // INTERNAL INCLUDES
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/effects/shader-effect-impl.h>
27
28 namespace Dali
29 {
30
31 Animation::Animation()
32 {
33 }
34
35 Animation::Animation(Internal::Animation* animation)
36 : BaseHandle(animation)
37 {
38 }
39
40 Animation Animation::New(float durationSeconds)
41 {
42   Internal::AnimationPtr internal = Dali::Internal::Animation::New(durationSeconds);
43
44   return Animation(internal.Get());
45 }
46
47 Animation Animation::DownCast( BaseHandle handle )
48 {
49   return Animation( dynamic_cast<Dali::Internal::Animation*>(handle.GetObjectPtr()) );
50 }
51
52 Animation::~Animation()
53 {
54 }
55
56 Animation::Animation(const Animation& handle)
57 : BaseHandle(handle)
58 {
59 }
60
61 Animation& Animation::operator=(const Animation& rhs)
62 {
63   BaseHandle::operator=(rhs);
64   return *this;
65 }
66
67 void Animation::SetDuration(float durationSeconds)
68 {
69   GetImplementation(*this).SetDuration(durationSeconds);
70 }
71
72 float Animation::GetDuration() const
73 {
74   return GetImplementation(*this).GetDuration();
75 }
76
77 void Animation::SetLooping(bool looping)
78 {
79   GetImplementation(*this).SetLooping(looping);
80 }
81
82 void Animation::SetLoopCount(int count)
83 {
84   GetImplementation(*this).SetLoopCount(count);
85 }
86
87 int Animation::GetLoopCount()
88 {
89   return GetImplementation(*this).GetLoopCount();
90 }
91
92 int Animation::GetCurrentLoop()
93 {
94   return GetImplementation(*this).GetCurrentLoop();
95 }
96
97 bool Animation::IsLooping() const
98 {
99   return GetImplementation(*this).IsLooping();
100 }
101
102 void Animation::SetEndAction(Dali::Animation::EndAction endAction)
103 {
104   GetImplementation(*this).SetEndAction(endAction);
105 }
106
107 Dali::Animation::EndAction Animation::GetEndAction() const
108 {
109   return GetImplementation(*this).GetEndAction();
110 }
111
112 void Animation::SetDisconnectAction( Animation::EndAction disconnectAction )
113 {
114   GetImplementation(*this).SetDisconnectAction( disconnectAction );
115 }
116
117 Animation::EndAction Animation::GetDisconnectAction() const
118 {
119   return GetImplementation(*this).GetDisconnectAction();
120 }
121
122 void Animation::SetDefaultAlphaFunction(AlphaFunction alpha)
123 {
124   GetImplementation(*this).SetDefaultAlphaFunction(alpha);
125 }
126
127 AlphaFunction Animation::GetDefaultAlphaFunction() const
128 {
129   return GetImplementation(*this).GetDefaultAlphaFunction();
130 }
131
132 void Animation::Play()
133 {
134   GetImplementation(*this).Play();
135 }
136
137 void Animation::PlayFrom(float progress)
138 {
139   GetImplementation(*this).PlayFrom(progress);
140 }
141
142
143 void Animation::Pause()
144 {
145   GetImplementation(*this).Pause();
146 }
147
148 void Animation::Stop()
149 {
150   GetImplementation(*this).Stop();
151 }
152
153 void Animation::Clear()
154 {
155   GetImplementation(*this).Clear();
156 }
157
158 Animation::AnimationSignalType& Animation::FinishedSignal()
159 {
160   return GetImplementation(*this).FinishedSignal();
161 }
162
163 void Animation::AnimateBy(Property target, Property::Value relativeValue)
164 {
165   GetImplementation(*this).AnimateBy(target, relativeValue);
166 }
167
168 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
169 {
170   GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
171 }
172
173 void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
174 {
175   GetImplementation(*this).AnimateBy(target, relativeValue, period);
176 }
177
178 void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
179 {
180   GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
181 }
182
183 void Animation::AnimateTo(Property target, Property::Value destinationValue)
184 {
185   GetImplementation(*this).AnimateTo(target, destinationValue);
186 }
187
188 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
189 {
190   GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
191 }
192
193 void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
194 {
195   GetImplementation(*this).AnimateTo(target, destinationValue, period);
196 }
197
198 void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
199 {
200   GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
201 }
202
203 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames )
204 {
205   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) );
206 }
207
208 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
209 {
210   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation );
211 }
212
213 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
214 {
215   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period);
216 }
217
218 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
219 {
220   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation );
221 }
222
223 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha)
224 {
225   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha);
226 }
227
228 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
229 {
230   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation);
231 }
232
233
234 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
235 {
236   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period);
237 }
238
239 void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
240 {
241   GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation);
242 }
243
244
245 // Actor specific animations
246
247 void Animation::Animate( Actor actor, Path path, const Vector3& forward )
248 {
249   GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward );
250 }
251
252 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
253 {
254   GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha );
255 }
256
257 void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
258 {
259   GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period);
260 }
261
262 void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
263 {
264   GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period );
265 }
266
267 void Animation::Show(Actor actor, float delaySeconds)
268 {
269   GetImplementation(*this).Show(GetImplementation(actor), delaySeconds);
270 }
271
272 void Animation::Hide(Actor actor, float delaySeconds)
273 {
274   GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds);
275 }
276
277 void Animation::SetCurrentProgress( float progress )
278 {
279   return GetImplementation(*this).SetCurrentProgress( progress );
280 }
281
282 float Animation::GetCurrentProgress()
283 {
284   return GetImplementation(*this).GetCurrentProgress();
285 }
286
287 void Animation::SetSpeedFactor( float factor )
288 {
289   GetImplementation(*this).SetSpeedFactor( factor );
290 }
291
292 float Animation::GetSpeedFactor() const
293 {
294   return GetImplementation(*this).GetSpeedFactor();
295 }
296
297 void Animation::SetPlayRange( const Vector2& range )
298 {
299   GetImplementation(*this).SetPlayRange(range);
300 }
301
302 Vector2 Animation::GetPlayRange() const
303 {
304   return GetImplementation(*this).GetPlayRange();
305 }
306
307 } // namespace Dali