2 * Copyright (c) 2022 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)
36 Handle::Handle() = default;
40 return Handle(Internal::Object::New().Get());
43 Handle::~Handle() = default;
45 Handle::Handle(const Handle& handle) = default;
47 Handle& Handle::operator=(const Handle& rhs) = default;
49 Handle::Handle(Handle&& rhs) noexcept = default;
51 Handle& Handle::operator=(Handle&& rhs) noexcept = default;
53 Handle Handle::DownCast(BaseHandle handle)
55 return Handle(dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()));
58 bool Handle::Supports(Capability capability) const
60 return GetImplementation(*this).Supports(capability);
63 uint32_t Handle::GetPropertyCount() const
65 return GetImplementation(*this).GetPropertyCount();
68 std::string Handle::GetPropertyName(Property::Index index) const
70 return std::string(GetImplementation(*this).GetPropertyName(index));
73 Property::Index Handle::GetPropertyIndex(Property::Key key) const
75 return GetImplementation(*this).GetPropertyIndex(key);
78 bool Handle::IsPropertyWritable(Property::Index index) const
80 return GetImplementation(*this).IsPropertyWritable(index);
83 bool Handle::IsPropertyAnimatable(Property::Index index) const
85 return GetImplementation(*this).IsPropertyAnimatable(index);
88 bool Handle::IsPropertyAConstraintInput(Property::Index index) const
90 return GetImplementation(*this).IsPropertyAConstraintInput(index);
93 Property::Type Handle::GetPropertyType(Property::Index index) const
95 return GetImplementation(*this).GetPropertyType(index);
98 void Handle::SetProperty(Property::Index index, Property::Value propertyValue)
100 GetImplementation(*this).SetProperty(index, std::move(propertyValue));
103 void Handle::ReserveCustomProperties(int propertyCount)
105 GetImplementation(*this).ReserveCustomProperties(propertyCount);
108 Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue)
110 return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue));
113 Property::Index Handle::RegisterProperty(Property::Index key, std::string_view name, Property::Value propertyValue)
115 return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), true);
118 Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue, Property::AccessMode accessMode)
120 return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue), accessMode);
123 Property::Index Handle::RegisterUniqueProperty(std::string_view name, Property::Value propertyValue)
125 return GetImplementation(*this).RegisterProperty(name, Property::INVALID_KEY, std::move(propertyValue), false);
128 Property::Index Handle::RegisterUniqueProperty(Property::Index key, std::string_view name, Property::Value propertyValue)
130 return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), false);
133 Property::Value Handle::GetProperty(Property::Index index) const
135 return GetImplementation(*this).GetProperty(index);
138 Property::Value Handle::GetCurrentProperty(Property::Index index) const
140 return GetImplementation(*this).GetCurrentProperty(index);
143 void Handle::SetProperties(const Property::Map& properties)
145 GetImplementation(*this).SetProperties(properties);
148 void Handle::GetProperties(Property::Map& properties)
150 GetImplementation(*this).GetProperties(properties);
153 void Handle::GetPropertyIndices(Property::IndexContainer& indices) const
155 GetImplementation(*this).GetPropertyIndices(indices);
158 bool Handle::DoesCustomPropertyExist(Property::Index index)
160 return GetImplementation(*this).DoesCustomPropertyExist(index);
163 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
164 const PropertyCondition& condition)
166 return GetImplementation(*this).AddPropertyNotification(index, -1, condition);
169 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
171 const PropertyCondition& condition)
173 return GetImplementation(*this).AddPropertyNotification(index, componentIndex, condition);
176 void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
178 GetImplementation(*this).RemovePropertyNotification(propertyNotification);
181 void Handle::RemovePropertyNotifications()
183 GetImplementation(*this).RemovePropertyNotifications();
186 void Handle::RemoveConstraints()
188 GetImplementation(*this).RemoveConstraints();
191 void Handle::RemoveConstraints(uint32_t tag)
193 GetImplementation(*this).RemoveConstraints(tag);
196 IndirectValue Handle::operator[](Property::Index index)
198 // Will assert on access if handle is empty
199 return IndirectValue(*this, index);
202 IndirectValue Handle::operator[](const std::string& name)
204 // Will assert immediately when GetPropertyIndex is called if handle is empty
205 return IndirectValue(*this, GetPropertyIndex(name));
208 Handle::PropertySetSignalType& Handle::PropertySetSignal()
210 return GetImplementation(*this).PropertySetSignal();
213 namespace WeightObject
215 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
219 Handle handle = Handle::New();
221 handle.RegisterProperty("weight", 0.0f);
226 } // namespace WeightObject