/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// update the cached property value
animatableProperty->SetPropertyValue(propertyValue);
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
+ {
+ // will do nothing if additional setter is nullptr
+ typeInfo->SetAnimatableProperty(this, index, propertyValue);
+ }
+
// set the scene graph property value
SetSceneGraphProperty(index, *animatableProperty, propertyValue);
}
AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty(index, nullptr);
if(animatableProperty)
{
- // get the cached animatable property value
- value = animatableProperty->GetPropertyValue();
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
+ {
+ // call additional getter if set
+ value = typeInfo->GetAnimatableProperty(this, index);
+ }
+
+ if(value.GetType() == Property::Type::NONE)
+ {
+ // get the cached animatable property value
+ value = animatableProperty->GetPropertyValue();
+ }
}
else
{
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
-void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Type type)
+void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc)
{
- if(DALI_UNLIKELY(!mRegisteredProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))))
+ if(DALI_UNLIKELY(!mRegisteredProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))))
{
DALI_LOG_ERROR("Property index already added to Type! name:%s, index:%d, type:%d\n", name.c_str(), index, static_cast<int32_t>(type));
DALI_ASSERT_ALWAYS(!"Property index already added to Type");
return Property::Value(); // return none
}
+void TypeInfo::SetAnimatableProperty(BaseObject* object, Property::Index index, Property::Value value) const
+{
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+ if(iter != mRegisteredProperties.end() && iter->second.setFunc)
+ {
+ iter->second.setFunc(object, index, value);
+ }
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
+ {
+ // call base type recursively
+ mBaseType->SetAnimatableProperty(object, index, std::move(value));
+ }
+ else
+ {
+ DALI_LOG_ERROR("Property index %d not found\n", index);
+ }
+}
+
void TypeInfo::SetProperty(BaseObject* object, Property::Index index, Property::Value value) const
{
const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
}
}
+Property::Value TypeInfo::GetAnimatableProperty(const BaseObject* object, Property::Index index) const
+{
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+ if(iter != mRegisteredProperties.end() && iter->second.getFunc)
+ {
+ return iter->second.getFunc(const_cast<BaseObject*>(object), index);
+ }
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
+ {
+ // call base type recursively
+ return mBaseType->GetAnimatableProperty(object, index);
+ }
+
+ // not an error, because scene graph might have the value
+ return Property::Value();
+}
+
Property::Value TypeInfo::GetProperty(const BaseObject* object, Property::Index index) const
{
const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
#define DALI_INTERNAL_TYPE_INFO_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param[in] name The name of the property.
* @param[in] index The index of the property
* @param[in] type The Property::Type.
+ * @param[in] setFunc An additional function to call to set the property (Can be nullptr).
+ * @param[in] getFunc An additional function to call to retrieve the value of the property (Can be nullptr).
*/
- void AddAnimatableProperty(std::string name, Property::Index index, Property::Type type);
+ void AddAnimatableProperty(std::string name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc);
/**
* Adds an animatable property with the given default value.
*/
Property::Value GetPropertyDefaultValue(Property::Index index) const;
+ /**
+ * Sets the value of an animatable property at the index specified for the given object.
+ * @param[in] object The object whose property is to be set.
+ * @param[in] index The property index.
+ * @param[in] value The value to set.
+ */
+ void SetAnimatableProperty(BaseObject* object, Property::Index index, Property::Value value) const;
+
/**
* Sets the value of a property at the index specified for the given object.
* @param[in] object The object whose property is to be set.
*/
void SetProperty(BaseObject* object, const std::string& name, Property::Value value) const;
+ /**
+ * Retrieves the value of an animatable property at the index specified for the given object.
+ * @param[in] object The object whose property is to be queried.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ Property::Value GetAnimatableProperty(const BaseObject* object, Property::Index index) const;
+
/**
* Retrieves the value of a property at the index specified for the given object.
* @param[in] object The object whose property is to be queried.
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return false;
}
-bool TypeRegistry::RegisterAnimatableProperty(TypeRegistration& typeRegistration, std::string name, Property::Index index, Property::Type type)
+bool TypeRegistry::RegisterAnimatableProperty(TypeRegistration& typeRegistration, std::string name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc)
{
auto iter = mRegistryLut.Get(ConstString(typeRegistration.RegisteredName()));
if(iter != mRegistryLut.end())
{
- iter->second->AddAnimatableProperty(std::move(name), index, type);
+ iter->second->AddAnimatableProperty(std::move(name), index, type, setFunc, getFunc);
return true;
}
#define DALI_INTERNAL_TYPE_REGISTRY_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param [in] name Property name
* @param [in] index Property index
* @param [in] type Property type
+ * @param [in] setFunc An additional function to set the property (Can be nullptr).
+ * @param [in] getFunc An additional function to get the value of a property (Can be nullptr).
* @return true if registered
*/
- bool RegisterAnimatableProperty(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type);
+ bool RegisterAnimatableProperty(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc);
/**
* Register a scene graph only property with a default value
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Internal::TypeRegistry::Get()->RegisterProperty(registered, std::move(name), index, type, setFunc, getFunc);
}
-AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
+AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc)
{
DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
- Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, type);
+ Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, type, setFunc, getFunc);
}
AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, const Property::Value& value)
#define DALI_TYPE_REGISTRY_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param[in] name The name of the property
* @param[in] index The property index. Must be a value between ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX and ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX inclusive
* @param[in] type The property value type
+ * @param[in] setFunc An additional function to call when setting the property (Can be nullptr).
+ * @param[in] getFunc An additional function to call to retrieve the current value of the property (Can be nullptr).
* @pre "registered" must be registered with the TypeRegistry.
*/
- AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type);
+ explicit AnimatablePropertyRegistration(TypeRegistration& registered,
+ std::string name,
+ Property::Index index,
+ Property::Type type,
+ TypeInfo::SetPropertyFunction setFunc = nullptr,
+ TypeInfo::GetPropertyFunction getFunc = nullptr);
/**
* @brief This constructor registers the animatable property with the registered default value.
* @param[in] value The property default value
* @pre "registered" must be registered with the TypeRegistry.
*/
- AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, const Property::Value& value);
+ explicit AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, const Property::Value& value);
};
/**