Merge remote-tracking branch 'origin/tizen' into new_text
[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 Constraint::Constraint(const Constraint& handle)
46 : BaseHandle(handle)
47 {
48 }
49
50 Constraint& Constraint::operator=(const Constraint& rhs)
51 {
52   BaseHandle::operator=(rhs);
53   return *this;
54 }
55
56 void Constraint::SetApplyTime( TimePeriod timePeriod )
57 {
58   GetImplementation(*this).SetApplyTime( timePeriod );
59 }
60
61 TimePeriod Constraint::GetApplyTime() const
62 {
63   return GetImplementation(*this).GetApplyTime();
64 }
65
66 void Constraint::SetAlphaFunction( AlphaFunction func )
67 {
68   GetImplementation(*this).SetAlphaFunction( func );
69 }
70
71 AlphaFunction Constraint::GetAlphaFunction()
72 {
73   return GetImplementation(*this).GetAlphaFunction();
74 }
75
76 void Constraint::SetRemoveAction(Constraint::RemoveAction action)
77 {
78   GetImplementation(*this).SetRemoveAction(action);
79 }
80
81 Constraint::RemoveAction Constraint::GetRemoveAction() const
82 {
83   return GetImplementation(*this).GetRemoveAction();
84 }
85
86 void Constraint::SetTag( const unsigned int tag )
87 {
88   GetImplementation(*this).SetTag( tag );
89 }
90
91 unsigned int Constraint::GetTag() const
92 {
93   return GetImplementation(*this).GetTag();
94 }
95
96
97
98
99
100 Constraint Constraint::New( Property::Index target,
101                             Property::Type targetType,
102                             AnyFunction func )
103 {
104   Internal::SourceContainer sources; // empty
105
106   return Constraint( new Internal::Constraint( target,
107                                                targetType,
108                                                sources,
109                                                func ) );
110 }
111
112 Constraint Constraint::New( Property::Index target,
113                             Property::Type targetType,
114                             ConstraintSource source1,
115                             AnyFunction func )
116 {
117   Internal::SourceContainer sources;
118   sources.push_back( Internal::Source( source1 ) );
119
120   return Constraint( new Internal::Constraint( target,
121                                                targetType,
122                                                sources,
123                                                func ) );
124 }
125
126 Constraint Constraint::New( Property::Index target,
127                             Property::Type targetType,
128                             ConstraintSource source1,
129                             ConstraintSource source2,
130                             AnyFunction func )
131 {
132   Internal::SourceContainer sources;
133   sources.push_back( Internal::Source( source1 ) );
134   sources.push_back( Internal::Source( source2 ) );
135
136   return Constraint( new Internal::Constraint( target,
137                                                targetType,
138                                                sources,
139                                                func ) );
140 }
141
142 Constraint Constraint::New( Property::Index target,
143                             Property::Type targetType,
144                             ConstraintSource source1,
145                             ConstraintSource source2,
146                             ConstraintSource source3,
147                             AnyFunction func )
148 {
149   Internal::SourceContainer sources;
150   sources.push_back( Internal::Source( source1 ) );
151   sources.push_back( Internal::Source( source2 ) );
152   sources.push_back( Internal::Source( source3 ) );
153
154   return Constraint( new Internal::Constraint( target,
155                                                targetType,
156                                                sources,
157                                                func ) );
158 }
159
160 Constraint Constraint::New( Property::Index target,
161                             Property::Type targetType,
162                             ConstraintSource source1,
163                             ConstraintSource source2,
164                             ConstraintSource source3,
165                             ConstraintSource source4,
166                             AnyFunction func )
167 {
168   Internal::SourceContainer sources;
169   sources.push_back( Internal::Source( source1 ) );
170   sources.push_back( Internal::Source( source2 ) );
171   sources.push_back( Internal::Source( source3 ) );
172   sources.push_back( Internal::Source( source4 ) );
173
174   return Constraint( new Internal::Constraint( target,
175                                                targetType,
176                                                sources,
177                                                func ) );
178 }
179
180 Constraint Constraint::New( Property::Index target,
181                             Property::Type targetType,
182                             ConstraintSource source1,
183                             ConstraintSource source2,
184                             ConstraintSource source3,
185                             ConstraintSource source4,
186                             ConstraintSource source5,
187                             AnyFunction func )
188 {
189   Internal::SourceContainer sources;
190   sources.push_back( Internal::Source( source1 ) );
191   sources.push_back( Internal::Source( source2 ) );
192   sources.push_back( Internal::Source( source3 ) );
193   sources.push_back( Internal::Source( source4 ) );
194   sources.push_back( Internal::Source( source5 ) );
195
196   return Constraint( new Internal::Constraint( target,
197                                                targetType,
198                                                sources,
199                                                func ) );
200 }
201
202 Constraint Constraint::New( Property::Index target,
203                             Property::Type targetType,
204                             ConstraintSource source1,
205                             ConstraintSource source2,
206                             ConstraintSource source3,
207                             ConstraintSource source4,
208                             ConstraintSource source5,
209                             ConstraintSource source6,
210                             AnyFunction func )
211 {
212   Internal::SourceContainer sources;
213   sources.push_back( Internal::Source( source1 ) );
214   sources.push_back( Internal::Source( source2 ) );
215   sources.push_back( Internal::Source( source3 ) );
216   sources.push_back( Internal::Source( source4 ) );
217   sources.push_back( Internal::Source( source5 ) );
218   sources.push_back( Internal::Source( source6 ) );
219
220   return Constraint( new Internal::Constraint( target,
221                                                targetType,
222                                                sources,
223                                                func ) );
224 }
225
226 Constraint Constraint::DownCast( BaseHandle handle )
227 {
228   return Constraint( dynamic_cast<Dali::Internal::Constraint*>(handle.GetObjectPtr()) );
229 }
230
231 } // namespace Dali