License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / public-api / animation / constraint.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/constraint.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/animation/time-period.h>
23 #include <dali/internal/event/animation/constraint-impl.h>
24 #include <dali/internal/event/animation/constraint-source-impl.h>
25
26 namespace Dali
27 {
28
29 const AlphaFunction            Constraint::DEFAULT_ALPHA_FUNCTION = AlphaFunctions::Linear;
30 const Constraint::RemoveAction Constraint::DEFAULT_REMOVE_ACTION  = Constraint::Bake;
31
32 Constraint::Constraint()
33 {
34 }
35
36 Constraint::Constraint(Internal::Constraint* constraint)
37 : BaseHandle(constraint)
38 {
39 }
40
41 Constraint::~Constraint()
42 {
43 }
44
45 void Constraint::SetApplyTime( TimePeriod timePeriod )
46 {
47   GetImplementation(*this).SetApplyTime( timePeriod );
48 }
49
50 TimePeriod Constraint::GetApplyTime() const
51 {
52   return GetImplementation(*this).GetApplyTime();
53 }
54
55 void Constraint::SetRemoveTime( TimePeriod timePeriod )
56 {
57   GetImplementation(*this).SetRemoveTime( timePeriod );
58 }
59
60 TimePeriod Constraint::GetRemoveTime() const
61 {
62   return GetImplementation(*this).GetRemoveTime();
63 }
64
65 void Constraint::SetAlphaFunction( AlphaFunction func )
66 {
67   GetImplementation(*this).SetAlphaFunction( func );
68 }
69
70 AlphaFunction Constraint::GetAlphaFunction()
71 {
72   return GetImplementation(*this).GetAlphaFunction();
73 }
74
75 void Constraint::SetRemoveAction(Constraint::RemoveAction action)
76 {
77   GetImplementation(*this).SetRemoveAction(action);
78 }
79
80 Constraint::RemoveAction Constraint::GetRemoveAction() const
81 {
82   return GetImplementation(*this).GetRemoveAction();
83 }
84
85 void Constraint::SetTag( const unsigned int tag )
86 {
87   GetImplementation(*this).SetTag( tag );
88 }
89
90 unsigned int Constraint::GetTag() const
91 {
92   return GetImplementation(*this).GetTag();
93 }
94
95
96
97
98
99 Constraint Constraint::New( Property::Index target,
100                             Property::Type targetType,
101                             AnyFunction func,
102                             AnyFunction interpolator )
103 {
104   Internal::SourceContainer sources; // empty
105
106   return Constraint( new Internal::Constraint( target,
107                                                targetType,
108                                                sources,
109                                                func,
110                                                interpolator ) );
111 }
112
113 Constraint Constraint::New( Property::Index target,
114                             Property::Type targetType,
115                             ConstraintSource source1,
116                             AnyFunction func,
117                             AnyFunction interpolator )
118 {
119   Internal::SourceContainer sources;
120   sources.push_back( Internal::Source( source1 ) );
121
122   return Constraint( new Internal::Constraint( target,
123                                                targetType,
124                                                sources,
125                                                func,
126                                                interpolator ) );
127 }
128
129 Constraint Constraint::New( Property::Index target,
130                             Property::Type targetType,
131                             ConstraintSource source1,
132                             ConstraintSource source2,
133                             AnyFunction func,
134                             AnyFunction interpolator )
135 {
136   Internal::SourceContainer sources;
137   sources.push_back( Internal::Source( source1 ) );
138   sources.push_back( Internal::Source( source2 ) );
139
140   return Constraint( new Internal::Constraint( target,
141                                                targetType,
142                                                sources,
143                                                func,
144                                                interpolator ) );
145 }
146
147 Constraint Constraint::New( Property::Index target,
148                             Property::Type targetType,
149                             ConstraintSource source1,
150                             ConstraintSource source2,
151                             ConstraintSource source3,
152                             AnyFunction func,
153                             AnyFunction interpolator )
154 {
155   Internal::SourceContainer sources;
156   sources.push_back( Internal::Source( source1 ) );
157   sources.push_back( Internal::Source( source2 ) );
158   sources.push_back( Internal::Source( source3 ) );
159
160   return Constraint( new Internal::Constraint( target,
161                                                targetType,
162                                                sources,
163                                                func,
164                                                interpolator ) );
165 }
166
167 Constraint Constraint::New( Property::Index target,
168                             Property::Type targetType,
169                             ConstraintSource source1,
170                             ConstraintSource source2,
171                             ConstraintSource source3,
172                             ConstraintSource source4,
173                             AnyFunction func,
174                             AnyFunction interpolator )
175 {
176   Internal::SourceContainer sources;
177   sources.push_back( Internal::Source( source1 ) );
178   sources.push_back( Internal::Source( source2 ) );
179   sources.push_back( Internal::Source( source3 ) );
180   sources.push_back( Internal::Source( source4 ) );
181
182   return Constraint( new Internal::Constraint( target,
183                                                targetType,
184                                                sources,
185                                                func,
186                                                interpolator ) );
187 }
188
189 Constraint Constraint::New( Property::Index target,
190                             Property::Type targetType,
191                             ConstraintSource source1,
192                             ConstraintSource source2,
193                             ConstraintSource source3,
194                             ConstraintSource source4,
195                             ConstraintSource source5,
196                             AnyFunction func,
197                             AnyFunction interpolator )
198 {
199   Internal::SourceContainer sources;
200   sources.push_back( Internal::Source( source1 ) );
201   sources.push_back( Internal::Source( source2 ) );
202   sources.push_back( Internal::Source( source3 ) );
203   sources.push_back( Internal::Source( source4 ) );
204   sources.push_back( Internal::Source( source5 ) );
205
206   return Constraint( new Internal::Constraint( target,
207                                                targetType,
208                                                sources,
209                                                func,
210                                                interpolator ) );
211 }
212
213 Constraint Constraint::New( Property::Index target,
214                             Property::Type targetType,
215                             ConstraintSource source1,
216                             ConstraintSource source2,
217                             ConstraintSource source3,
218                             ConstraintSource source4,
219                             ConstraintSource source5,
220                             ConstraintSource source6,
221                             AnyFunction func,
222                             AnyFunction interpolator )
223 {
224   Internal::SourceContainer sources;
225   sources.push_back( Internal::Source( source1 ) );
226   sources.push_back( Internal::Source( source2 ) );
227   sources.push_back( Internal::Source( source3 ) );
228   sources.push_back( Internal::Source( source4 ) );
229   sources.push_back( Internal::Source( source5 ) );
230   sources.push_back( Internal::Source( source6 ) );
231
232   return Constraint( new Internal::Constraint( target,
233                                                targetType,
234                                                sources,
235                                                func,
236                                                interpolator ) );
237 }
238
239 Constraint Constraint::DownCast( BaseHandle handle )
240 {
241   return Constraint( dynamic_cast<Dali::Internal::Constraint*>(handle.GetObjectPtr()) );
242 }
243
244 } // namespace Dali