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::SetRemoveTime( TimePeriod timePeriod )
75 GetImplementation(*this).SetRemoveTime( timePeriod );
78 TimePeriod Constraint::GetRemoveTime() const
80 return GetImplementation(*this).GetRemoveTime();
83 void Constraint::SetAlphaFunction( AlphaFunction func )
85 GetImplementation(*this).SetAlphaFunction( func );
88 AlphaFunction Constraint::GetAlphaFunction()
90 return GetImplementation(*this).GetAlphaFunction();
93 void Constraint::SetRemoveAction(Constraint::RemoveAction action)
95 GetImplementation(*this).SetRemoveAction(action);
98 Constraint::RemoveAction Constraint::GetRemoveAction() const
100 return GetImplementation(*this).GetRemoveAction();
103 void Constraint::SetTag( const unsigned int tag )
105 GetImplementation(*this).SetTag( tag );
108 unsigned int Constraint::GetTag() const
110 return GetImplementation(*this).GetTag();
117 Constraint Constraint::New( Property::Index target,
118 Property::Type targetType,
120 AnyFunction interpolator )
122 Internal::SourceContainer sources; // empty
124 return Constraint( new Internal::Constraint( target,
131 Constraint Constraint::New( Property::Index target,
132 Property::Type targetType,
133 ConstraintSource source1,
135 AnyFunction interpolator )
137 Internal::SourceContainer sources;
138 sources.push_back( Internal::Source( source1 ) );
140 return Constraint( new Internal::Constraint( target,
147 Constraint Constraint::New( Property::Index target,
148 Property::Type targetType,
149 ConstraintSource source1,
150 ConstraintSource source2,
152 AnyFunction interpolator )
154 Internal::SourceContainer sources;
155 sources.push_back( Internal::Source( source1 ) );
156 sources.push_back( Internal::Source( source2 ) );
158 return Constraint( new Internal::Constraint( target,
165 Constraint Constraint::New( Property::Index target,
166 Property::Type targetType,
167 ConstraintSource source1,
168 ConstraintSource source2,
169 ConstraintSource source3,
171 AnyFunction interpolator )
173 Internal::SourceContainer sources;
174 sources.push_back( Internal::Source( source1 ) );
175 sources.push_back( Internal::Source( source2 ) );
176 sources.push_back( Internal::Source( source3 ) );
178 return Constraint( new Internal::Constraint( target,
185 Constraint Constraint::New( Property::Index target,
186 Property::Type targetType,
187 ConstraintSource source1,
188 ConstraintSource source2,
189 ConstraintSource source3,
190 ConstraintSource source4,
192 AnyFunction interpolator )
194 Internal::SourceContainer sources;
195 sources.push_back( Internal::Source( source1 ) );
196 sources.push_back( Internal::Source( source2 ) );
197 sources.push_back( Internal::Source( source3 ) );
198 sources.push_back( Internal::Source( source4 ) );
200 return Constraint( new Internal::Constraint( target,
207 Constraint Constraint::New( Property::Index target,
208 Property::Type targetType,
209 ConstraintSource source1,
210 ConstraintSource source2,
211 ConstraintSource source3,
212 ConstraintSource source4,
213 ConstraintSource source5,
215 AnyFunction interpolator )
217 Internal::SourceContainer sources;
218 sources.push_back( Internal::Source( source1 ) );
219 sources.push_back( Internal::Source( source2 ) );
220 sources.push_back( Internal::Source( source3 ) );
221 sources.push_back( Internal::Source( source4 ) );
222 sources.push_back( Internal::Source( source5 ) );
224 return Constraint( new Internal::Constraint( target,
231 Constraint Constraint::New( Property::Index target,
232 Property::Type targetType,
233 ConstraintSource source1,
234 ConstraintSource source2,
235 ConstraintSource source3,
236 ConstraintSource source4,
237 ConstraintSource source5,
238 ConstraintSource source6,
240 AnyFunction interpolator )
242 Internal::SourceContainer sources;
243 sources.push_back( Internal::Source( source1 ) );
244 sources.push_back( Internal::Source( source2 ) );
245 sources.push_back( Internal::Source( source3 ) );
246 sources.push_back( Internal::Source( source4 ) );
247 sources.push_back( Internal::Source( source5 ) );
248 sources.push_back( Internal::Source( source6 ) );
250 return Constraint( new Internal::Constraint( target,
257 Constraint Constraint::DownCast( BaseHandle handle )
259 return Constraint( dynamic_cast<Dali::Internal::Constraint*>(handle.GetObjectPtr()) );