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/integration-api/debug.h>
23 #include <dali/internal/event/animation/constraint-impl.h>
24 #include <dali/internal/event/common/object-impl.h>
25 #include <dali/public-api/animation/constraint.h>
26 #include <dali/public-api/object/property-conditions.h>
27 #include <dali/public-api/object/property-notification.h>
31 Handle::Handle(Dali::Internal::Object* handle)
42 return Handle(Internal::Object::New().Get());
49 Handle::Handle(const Handle& handle) = default;
51 Handle& Handle::operator=(const Handle& rhs) = default;
53 Handle::Handle(Handle&& rhs) = default;
55 Handle& Handle::operator=(Handle&& rhs) = default;
57 Handle Handle::DownCast(BaseHandle handle)
59 return Handle(dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()));
62 bool Handle::Supports(Capability capability) const
64 return GetImplementation(*this).Supports(capability);
67 uint32_t Handle::GetPropertyCount() const
69 return GetImplementation(*this).GetPropertyCount();
72 std::string Handle::GetPropertyName(Property::Index index) const
74 return GetImplementation(*this).GetPropertyName(index);
77 Property::Index Handle::GetPropertyIndex(Property::Key key) const
79 return GetImplementation(*this).GetPropertyIndex(key);
82 bool Handle::IsPropertyWritable(Property::Index index) const
84 return GetImplementation(*this).IsPropertyWritable(index);
87 bool Handle::IsPropertyAnimatable(Property::Index index) const
89 return GetImplementation(*this).IsPropertyAnimatable(index);
92 bool Handle::IsPropertyAConstraintInput(Property::Index index) const
94 return GetImplementation(*this).IsPropertyAConstraintInput(index);
97 Property::Type Handle::GetPropertyType(Property::Index index) const
99 return GetImplementation(*this).GetPropertyType(index);
102 void Handle::SetProperty(Property::Index index, Property::Value propertyValue)
104 GetImplementation(*this).SetProperty(index, std::move(propertyValue));
107 Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue)
109 return GetImplementation(*this).RegisterProperty(std::move(name), std::move(propertyValue));
112 Property::Index Handle::RegisterProperty(Property::Index key, std::string name, Property::Value propertyValue)
114 return GetImplementation(*this).RegisterProperty(std::move(name), key, std::move(propertyValue));
117 Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
119 return GetImplementation(*this).RegisterProperty(std::move(name), std::move(propertyValue), accessMode);
122 Property::Value Handle::GetProperty(Property::Index index) const
124 return GetImplementation(*this).GetProperty(index);
127 Property::Value Handle::GetCurrentProperty(Property::Index index) const
129 return GetImplementation(*this).GetCurrentProperty(index);
132 void Handle::SetProperties(const Property::Map& properties)
134 GetImplementation(*this).SetProperties(properties);
137 void Handle::GetProperties(Property::Map& properties)
139 GetImplementation(*this).GetProperties(properties);
142 void Handle::GetPropertyIndices(Property::IndexContainer& indices) const
144 GetImplementation(*this).GetPropertyIndices(indices);
147 bool Handle::DoesCustomPropertyExist(Property::Index index)
149 return GetImplementation(*this).DoesCustomPropertyExist(index);
152 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
153 const PropertyCondition& condition)
155 return GetImplementation(*this).AddPropertyNotification(index, -1, condition);
158 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
160 const PropertyCondition& condition)
162 return GetImplementation(*this).AddPropertyNotification(index, componentIndex, condition);
165 void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
167 GetImplementation(*this).RemovePropertyNotification(propertyNotification);
170 void Handle::RemovePropertyNotifications()
172 GetImplementation(*this).RemovePropertyNotifications();
175 void Handle::RemoveConstraints()
177 GetImplementation(*this).RemoveConstraints();
180 void Handle::RemoveConstraints(uint32_t tag)
182 GetImplementation(*this).RemoveConstraints(tag);
185 IndirectValue Handle::operator[](Property::Index index)
187 // Will assert on access if handle is empty
188 return IndirectValue(*this, index);
191 IndirectValue Handle::operator[](const std::string& name)
193 // Will assert immediately when GetPropertyIndex is called if handle is empty
194 return IndirectValue(*this, GetPropertyIndex(name));
197 Handle::PropertySetSignalType& Handle::PropertySetSignal()
199 return GetImplementation(*this).PropertySetSignal();
202 namespace WeightObject
204 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
208 Handle handle = Handle::New();
210 handle.RegisterProperty("weight", 0.0f);
215 } // namespace WeightObject