2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/animation/constraint.h>
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>
29 const AlphaFunction Constraint::DEFAULT_ALPHA_FUNCTION = AlphaFunctions::Linear;
30 const Constraint::RemoveAction Constraint::DEFAULT_REMOVE_ACTION = Constraint::Bake;
32 Constraint::Constraint()
36 Constraint::Constraint(Internal::Constraint* constraint)
37 : BaseHandle(constraint)
41 Constraint::~Constraint()
45 Constraint::Constraint(const Constraint& handle)
50 Constraint& Constraint::operator=(const Constraint& rhs)
52 BaseHandle::operator=(rhs);
56 Constraint& Constraint::operator=(BaseHandle::NullType* rhs)
58 DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
63 void Constraint::SetApplyTime( TimePeriod timePeriod )
65 GetImplementation(*this).SetApplyTime( timePeriod );
68 TimePeriod Constraint::GetApplyTime() const
70 return GetImplementation(*this).GetApplyTime();
73 void Constraint::SetAlphaFunction( AlphaFunction func )
75 GetImplementation(*this).SetAlphaFunction( func );
78 AlphaFunction Constraint::GetAlphaFunction()
80 return GetImplementation(*this).GetAlphaFunction();
83 void Constraint::SetRemoveAction(Constraint::RemoveAction action)
85 GetImplementation(*this).SetRemoveAction(action);
88 Constraint::RemoveAction Constraint::GetRemoveAction() const
90 return GetImplementation(*this).GetRemoveAction();
93 void Constraint::SetTag( const unsigned int tag )
95 GetImplementation(*this).SetTag( tag );
98 unsigned int Constraint::GetTag() const
100 return GetImplementation(*this).GetTag();
107 Constraint Constraint::New( Property::Index target,
108 Property::Type targetType,
110 AnyFunction interpolator )
112 Internal::SourceContainer sources; // empty
114 return Constraint( new Internal::Constraint( target,
121 Constraint Constraint::New( Property::Index target,
122 Property::Type targetType,
123 ConstraintSource source1,
125 AnyFunction interpolator )
127 Internal::SourceContainer sources;
128 sources.push_back( Internal::Source( source1 ) );
130 return Constraint( new Internal::Constraint( target,
137 Constraint Constraint::New( Property::Index target,
138 Property::Type targetType,
139 ConstraintSource source1,
140 ConstraintSource source2,
142 AnyFunction interpolator )
144 Internal::SourceContainer sources;
145 sources.push_back( Internal::Source( source1 ) );
146 sources.push_back( Internal::Source( source2 ) );
148 return Constraint( new Internal::Constraint( target,
155 Constraint Constraint::New( Property::Index target,
156 Property::Type targetType,
157 ConstraintSource source1,
158 ConstraintSource source2,
159 ConstraintSource source3,
161 AnyFunction interpolator )
163 Internal::SourceContainer sources;
164 sources.push_back( Internal::Source( source1 ) );
165 sources.push_back( Internal::Source( source2 ) );
166 sources.push_back( Internal::Source( source3 ) );
168 return Constraint( new Internal::Constraint( target,
175 Constraint Constraint::New( Property::Index target,
176 Property::Type targetType,
177 ConstraintSource source1,
178 ConstraintSource source2,
179 ConstraintSource source3,
180 ConstraintSource source4,
182 AnyFunction interpolator )
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 ) );
190 return Constraint( new Internal::Constraint( target,
197 Constraint Constraint::New( Property::Index target,
198 Property::Type targetType,
199 ConstraintSource source1,
200 ConstraintSource source2,
201 ConstraintSource source3,
202 ConstraintSource source4,
203 ConstraintSource source5,
205 AnyFunction interpolator )
207 Internal::SourceContainer sources;
208 sources.push_back( Internal::Source( source1 ) );
209 sources.push_back( Internal::Source( source2 ) );
210 sources.push_back( Internal::Source( source3 ) );
211 sources.push_back( Internal::Source( source4 ) );
212 sources.push_back( Internal::Source( source5 ) );
214 return Constraint( new Internal::Constraint( target,
221 Constraint Constraint::New( Property::Index target,
222 Property::Type targetType,
223 ConstraintSource source1,
224 ConstraintSource source2,
225 ConstraintSource source3,
226 ConstraintSource source4,
227 ConstraintSource source5,
228 ConstraintSource source6,
230 AnyFunction interpolator )
232 Internal::SourceContainer sources;
233 sources.push_back( Internal::Source( source1 ) );
234 sources.push_back( Internal::Source( source2 ) );
235 sources.push_back( Internal::Source( source3 ) );
236 sources.push_back( Internal::Source( source4 ) );
237 sources.push_back( Internal::Source( source5 ) );
238 sources.push_back( Internal::Source( source6 ) );
240 return Constraint( new Internal::Constraint( target,
247 Constraint Constraint::DownCast( BaseHandle handle )
249 return Constraint( dynamic_cast<Dali::Internal::Constraint*>(handle.GetObjectPtr()) );