140475170724b548aaec8b0c814f85748bf2a994
[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/object-impl.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::Object*>(handle.GetObjectPtr()) );
49 }
50
51 Constrainable::~Constrainable()
52 {
53 }
54
55 Constrainable::Constrainable(const Constrainable& handle)
56 : Handle(handle)
57 {
58 }
59
60 Constrainable& Constrainable::operator=(const Constrainable& rhs)
61 {
62   BaseHandle::operator=(rhs);
63   return *this;
64 }
65
66 ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint )
67 {
68   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ) );
69 }
70
71 ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint, Constrainable weightObject )
72 {
73   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ), weightObject );
74 }
75
76 void Constrainable::RemoveConstraint(ActiveConstraint activeConstraint)
77 {
78   GetImplementation(*this).RemoveConstraint( activeConstraint );
79 }
80
81 void Constrainable::RemoveConstraints()
82 {
83   GetImplementation(*this).RemoveConstraints();
84 }
85
86 void Constrainable::RemoveConstraints( unsigned int tag )
87 {
88   GetImplementation(*this).RemoveConstraints( tag );
89 }
90
91 namespace WeightObject
92 {
93
94 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
95
96 Constrainable New()
97 {
98   Constrainable handle = Constrainable::New();
99
100   handle.RegisterProperty( "weight", 0.0f );
101
102   return handle;
103 }
104
105 } // namespace WeightObject
106
107 } // namespace Dali