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