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