7e1773aa503d88cb968d2eefff00c8f978efa6b9
[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 Constraint Constraint::New( Property::Index target,
85                             Property::Type targetType,
86                             AnyFunction func,
87                             AnyFunction interpolator )
88 {
89   Internal::SourceContainer sources; // empty
90
91   return Constraint( new Internal::Constraint( target,
92                                                targetType,
93                                                sources,
94                                                func,
95                                                interpolator ) );
96 }
97
98 Constraint Constraint::New( Property::Index target,
99                             Property::Type targetType,
100                             ConstraintSource source1,
101                             AnyFunction func,
102                             AnyFunction interpolator )
103 {
104   Internal::SourceContainer sources;
105   sources.push_back( Internal::Source( source1 ) );
106
107   return Constraint( new Internal::Constraint( target,
108                                                targetType,
109                                                sources,
110                                                func,
111                                                interpolator ) );
112 }
113
114 Constraint Constraint::New( Property::Index target,
115                             Property::Type targetType,
116                             ConstraintSource source1,
117                             ConstraintSource source2,
118                             AnyFunction func,
119                             AnyFunction interpolator )
120 {
121   Internal::SourceContainer sources;
122   sources.push_back( Internal::Source( source1 ) );
123   sources.push_back( Internal::Source( source2 ) );
124
125   return Constraint( new Internal::Constraint( target,
126                                                targetType,
127                                                sources,
128                                                func,
129                                                interpolator ) );
130 }
131
132 Constraint Constraint::New( Property::Index target,
133                             Property::Type targetType,
134                             ConstraintSource source1,
135                             ConstraintSource source2,
136                             ConstraintSource source3,
137                             AnyFunction func,
138                             AnyFunction interpolator )
139 {
140   Internal::SourceContainer sources;
141   sources.push_back( Internal::Source( source1 ) );
142   sources.push_back( Internal::Source( source2 ) );
143   sources.push_back( Internal::Source( source3 ) );
144
145   return Constraint( new Internal::Constraint( target,
146                                                targetType,
147                                                sources,
148                                                func,
149                                                interpolator ) );
150 }
151
152 Constraint Constraint::New( Property::Index target,
153                             Property::Type targetType,
154                             ConstraintSource source1,
155                             ConstraintSource source2,
156                             ConstraintSource source3,
157                             ConstraintSource source4,
158                             AnyFunction func,
159                             AnyFunction interpolator )
160 {
161   Internal::SourceContainer sources;
162   sources.push_back( Internal::Source( source1 ) );
163   sources.push_back( Internal::Source( source2 ) );
164   sources.push_back( Internal::Source( source3 ) );
165   sources.push_back( Internal::Source( source4 ) );
166
167   return Constraint( new Internal::Constraint( target,
168                                                targetType,
169                                                sources,
170                                                func,
171                                                interpolator ) );
172 }
173
174 Constraint Constraint::New( Property::Index target,
175                             Property::Type targetType,
176                             ConstraintSource source1,
177                             ConstraintSource source2,
178                             ConstraintSource source3,
179                             ConstraintSource source4,
180                             ConstraintSource source5,
181                             AnyFunction func,
182                             AnyFunction interpolator )
183 {
184   Internal::SourceContainer sources;
185   sources.push_back( Internal::Source( source1 ) );
186   sources.push_back( Internal::Source( source2 ) );
187   sources.push_back( Internal::Source( source3 ) );
188   sources.push_back( Internal::Source( source4 ) );
189   sources.push_back( Internal::Source( source5 ) );
190
191   return Constraint( new Internal::Constraint( target,
192                                                targetType,
193                                                sources,
194                                                func,
195                                                interpolator ) );
196 }
197
198 Constraint Constraint::New( Property::Index target,
199                             Property::Type targetType,
200                             ConstraintSource source1,
201                             ConstraintSource source2,
202                             ConstraintSource source3,
203                             ConstraintSource source4,
204                             ConstraintSource source5,
205                             ConstraintSource source6,
206                             AnyFunction func,
207                             AnyFunction interpolator )
208 {
209   Internal::SourceContainer sources;
210   sources.push_back( Internal::Source( source1 ) );
211   sources.push_back( Internal::Source( source2 ) );
212   sources.push_back( Internal::Source( source3 ) );
213   sources.push_back( Internal::Source( source4 ) );
214   sources.push_back( Internal::Source( source5 ) );
215   sources.push_back( Internal::Source( source6 ) );
216
217   return Constraint( new Internal::Constraint( target,
218                                                targetType,
219                                                sources,
220                                                func,
221                                                interpolator ) );
222 }
223
224 Constraint Constraint::DownCast( BaseHandle handle )
225 {
226   return Constraint( dynamic_cast<Dali::Internal::Constraint*>(handle.GetObjectPtr()) );
227 }
228
229 } // namespace Dali