8782b69d6f50771832de9d3bc4043851fecb76fe
[platform/core/uifw/dali-core.git] / dali / public-api / object / constrainable.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/object/constrainable.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/object/property-index.h>
23 #include <dali/public-api/animation/constraint.h>
24 #include <dali/public-api/animation/active-constraint.h>
25 #include <dali/internal/event/common/proxy-object.h>
26 #include <dali/internal/event/animation/constraint-impl.h>
27 #include <dali/internal/event/object/custom-object-internal.h>
28
29 namespace Dali
30 {
31
32 Constrainable Constrainable::New()
33 {
34   return Constrainable( Internal::CustomObject::New() );
35 }
36
37 Constrainable::Constrainable(Dali::Internal::Object* handle)
38 : Handle(handle)
39 {
40 }
41
42 Constrainable::Constrainable()
43 {
44 }
45
46 Constrainable Constrainable::DownCast( BaseHandle handle )
47 {
48   return Constrainable( dynamic_cast<Dali::Internal::ProxyObject*>(handle.GetObjectPtr()) );
49 }
50
51 Constrainable::~Constrainable()
52 {
53 }
54
55 Constrainable::Constrainable(const Constrainable& handle)
56 : Handle(handle)
57 {
58 }
59
60 ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint )
61 {
62   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ) );
63 }
64
65 ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint, Constrainable weightObject )
66 {
67   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ), weightObject );
68 }
69
70 void Constrainable::RemoveConstraint(ActiveConstraint activeConstraint)
71 {
72   GetImplementation(*this).RemoveConstraint( activeConstraint );
73 }
74
75 void Constrainable::RemoveConstraints()
76 {
77   GetImplementation(*this).RemoveConstraints();
78 }
79
80 void Constrainable::RemoveConstraints( unsigned int tag )
81 {
82   GetImplementation(*this).RemoveConstraints( tag );
83 }
84
85 namespace WeightObject
86 {
87
88 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
89
90 Constrainable New()
91 {
92   Constrainable handle = Constrainable::New();
93
94   handle.RegisterProperty( "weight", 0.0f );
95
96   return handle;
97 }
98
99 } // namespace WeightObject
100
101 } // namespace Dali