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) = default;
51 Handle& Handle::operator=(Handle&& rhs) = 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 Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue)
105 return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue));
108 Property::Index Handle::RegisterProperty(Property::Index key, std::string_view name, Property::Value propertyValue)
110 return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), true);
113 Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue, Property::AccessMode accessMode)
115 return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue), accessMode);
118 Property::Index Handle::RegisterUniqueProperty(std::string_view name, Property::Value propertyValue)
120 return GetImplementation(*this).RegisterProperty(name, Property::INVALID_KEY, std::move(propertyValue), false);
123 Property::Index Handle::RegisterUniqueProperty(Property::Index key, std::string_view name, Property::Value propertyValue)
125 return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), false);
128 Property::Value Handle::GetProperty(Property::Index index) const
130 return GetImplementation(*this).GetProperty(index);
133 Property::Value Handle::GetCurrentProperty(Property::Index index) const
135 return GetImplementation(*this).GetCurrentProperty(index);
138 void Handle::SetProperties(const Property::Map& properties)
140 GetImplementation(*this).SetProperties(properties);
143 void Handle::GetProperties(Property::Map& properties)
145 GetImplementation(*this).GetProperties(properties);
148 void Handle::GetPropertyIndices(Property::IndexContainer& indices) const
150 GetImplementation(*this).GetPropertyIndices(indices);
153 bool Handle::DoesCustomPropertyExist(Property::Index index)
155 return GetImplementation(*this).DoesCustomPropertyExist(index);
158 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
159 const PropertyCondition& condition)
161 return GetImplementation(*this).AddPropertyNotification(index, -1, condition);
164 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
166 const PropertyCondition& condition)
168 return GetImplementation(*this).AddPropertyNotification(index, componentIndex, condition);
171 void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
173 GetImplementation(*this).RemovePropertyNotification(propertyNotification);
176 void Handle::RemovePropertyNotifications()
178 GetImplementation(*this).RemovePropertyNotifications();
181 void Handle::RemoveConstraints()
183 GetImplementation(*this).RemoveConstraints();
186 void Handle::RemoveConstraints(uint32_t tag)
188 GetImplementation(*this).RemoveConstraints(tag);
191 IndirectValue Handle::operator[](Property::Index index)
193 // Will assert on access if handle is empty
194 return IndirectValue(*this, index);
197 IndirectValue Handle::operator[](const std::string& name)
199 // Will assert immediately when GetPropertyIndex is called if handle is empty
200 return IndirectValue(*this, GetPropertyIndex(name));
203 Handle::PropertySetSignalType& Handle::PropertySetSignal()
205 return GetImplementation(*this).PropertySetSignal();
208 namespace WeightObject
210 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
214 Handle handle = Handle::New();
216 handle.RegisterProperty("weight", 0.0f);
221 } // namespace WeightObject