Merge "DALi Version 1.0.4" into tizen
[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 Constrainable& Constrainable::operator=(const Constrainable& rhs)
61 {
62   BaseHandle::operator=(rhs);
63   return *this;
64 }
65
66 Constrainable& Constrainable::operator=(BaseHandle::NullType* rhs)
67 {
68   DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
69   Reset();
70   return *this;
71 }
72
73 ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint )
74 {
75   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ) );
76 }
77
78 ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint, Constrainable weightObject )
79 {
80   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ), weightObject );
81 }
82
83 void Constrainable::RemoveConstraint(ActiveConstraint activeConstraint)
84 {
85   GetImplementation(*this).RemoveConstraint( activeConstraint );
86 }
87
88 void Constrainable::RemoveConstraints()
89 {
90   GetImplementation(*this).RemoveConstraints();
91 }
92
93 void Constrainable::RemoveConstraints( unsigned int tag )
94 {
95   GetImplementation(*this).RemoveConstraints( tag );
96 }
97
98 namespace WeightObject
99 {
100
101 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
102
103 Constrainable New()
104 {
105   Constrainable handle = Constrainable::New();
106
107   handle.RegisterProperty( "weight", 0.0f );
108
109   return handle;
110 }
111
112 } // namespace WeightObject
113
114 } // namespace Dali