2 * Copyright (c) 2020 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/object/handle.h>
22 #include <dali/public-api/animation/constraint.h>
23 #include <dali/public-api/object/property-conditions.h>
24 #include <dali/public-api/object/property-notification.h>
25 #include <dali/internal/event/animation/constraint-impl.h>
26 #include <dali/internal/event/common/object-impl.h>
27 #include <dali/integration-api/debug.h>
32 Handle::Handle( Dali::Internal::Object* handle )
44 return Handle( Internal::Object::New().Get() );
51 Handle::Handle( const Handle& handle ) = default;
53 Handle& Handle::operator=( const Handle& rhs ) = default;
55 Handle::Handle( Handle&& rhs ) = default;
57 Handle& Handle::operator=( Handle&& rhs ) = default;
59 Handle Handle::DownCast( BaseHandle handle )
61 return Handle( dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()) );
64 bool Handle::Supports( Capability capability ) const
66 return GetImplementation(*this).Supports( capability );
69 uint32_t Handle::GetPropertyCount() const
71 return GetImplementation(*this).GetPropertyCount();
74 std::string Handle::GetPropertyName( Property::Index index ) const
76 return GetImplementation(*this).GetPropertyName( index );
79 Property::Index Handle::GetPropertyIndex( const std::string& name ) const
81 return GetImplementation(*this).GetPropertyIndex( name );
84 bool Handle::IsPropertyWritable( Property::Index index ) const
86 return GetImplementation(*this).IsPropertyWritable( index );
89 bool Handle::IsPropertyAnimatable( Property::Index index ) const
91 return GetImplementation(*this).IsPropertyAnimatable( index );
94 bool Handle::IsPropertyAConstraintInput( Property::Index index ) const
96 return GetImplementation(*this).IsPropertyAConstraintInput( index );
99 Property::Type Handle::GetPropertyType( Property::Index index ) const
101 return GetImplementation(*this).GetPropertyType( index );
104 void Handle::SetProperty( Property::Index index, const Property::Value& propertyValue )
106 GetImplementation(*this).SetProperty( index, propertyValue );
109 Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue )
111 return GetImplementation(*this).RegisterProperty( name, propertyValue );
114 Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode )
116 return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode );
119 Property::Value Handle::GetProperty( Property::Index index ) const
121 return GetImplementation(*this).GetProperty( index );
124 Property::Value Handle::GetCurrentProperty( Property::Index index ) const
126 return GetImplementation(*this).GetCurrentProperty( index );
129 void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const
131 GetImplementation(*this).GetPropertyIndices( indices );
134 Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
135 const PropertyCondition& condition )
137 return GetImplementation(*this).AddPropertyNotification( index, -1, condition );
140 Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
142 const PropertyCondition& condition )
144 return GetImplementation(*this).AddPropertyNotification( index, componentIndex, condition );
147 void Handle::RemovePropertyNotification( Dali::PropertyNotification propertyNotification )
149 GetImplementation(*this).RemovePropertyNotification( propertyNotification );
152 void Handle::RemovePropertyNotifications()
154 GetImplementation(*this).RemovePropertyNotifications();
157 void Handle::RemoveConstraints()
159 GetImplementation(*this).RemoveConstraints();
162 void Handle::RemoveConstraints( uint32_t tag )
164 GetImplementation(*this).RemoveConstraints( tag );
167 IndirectValue Handle::operator[]( Property::Index index )
169 // Will assert on access if handle is empty
170 return IndirectValue(*this, index);
173 IndirectValue Handle::operator[]( const std::string& name )
175 // Will assert immediately when GetPropertyIndex is called if handle is empty
176 return IndirectValue(*this, GetPropertyIndex(name));
179 namespace WeightObject
182 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
186 Handle handle = Handle::New();
188 handle.RegisterProperty( "weight", 0.0f );
193 } // namespace WeightObject