const float withFlake(99.f);
Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
- Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
+ Property::Index index2 = actor.RegisterProperty( key1, "sideColor", testColor);
Property::Index index3 = actor.RegisterProperty( "MyPropertyTwo", Vector3::ONE );
- Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
+ Property::Index index4 = actor.RegisterProperty( key2, "iceCream", withFlake );
Property::Index index5 = actor.RegisterProperty( "MyPropertyThree", Vector3::ONE );
application.SendNotification();
application.Render();
// Test that we can get the property index from the integer key
- Property::Index testIndex1 = DevelHandle::GetPropertyIndex( actor, key1 );
- Property::Index testIndex2 = DevelHandle::GetPropertyIndex( actor, key2 );
+ Property::Index testIndex1 = actor.GetPropertyIndex( key1 );
+ Property::Index testIndex2 = actor.GetPropertyIndex( key2 );
DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION );
DALI_TEST_EQUALS( index4, testIndex2, TEST_LOCATION );
std::string myName("croydon");
Property::Index intKey = CORE_PROPERTY_MAX_INDEX+1;
Property::Value value( Color::GREEN );
- Property::Index myIndex = DevelHandle::RegisterProperty( actor, intKey, myName, value );
+ Property::Index myIndex = actor.RegisterProperty( intKey, myName, value );
- DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION );
+ DALI_TEST_EQUALS( myIndex, actor.GetPropertyIndex( intKey ), TEST_LOCATION );
Property::Key key1(myName);
Property::Key key2(intKey);
- DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION );
- DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION );
+ DALI_TEST_EQUALS( myIndex, actor.GetPropertyIndex( key1 ), TEST_LOCATION );
+ DALI_TEST_EQUALS( myIndex, actor.GetPropertyIndex( key2 ), TEST_LOCATION );
END_TEST;
}
const float withFlake(99.f);
Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
- Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
- Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
+ Property::Index index2 = actor.RegisterProperty( key1, "sideColor", testColor);
+ Property::Index index3 = actor.RegisterProperty( key2, "iceCream", withFlake );
application.SendNotification();
application.Render();
Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
- DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
+ actor.RegisterProperty( key1, "sideColor", testColor);
actor.RegisterProperty( "MyPropertyTwo", 1234 );
- Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
+ Property::Index index4 = actor.RegisterProperty( key2, "iceCream", withFlake );
actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) );
actor.GetPropertyIndices( indices );
Actor actor = Actor::New();
auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
- DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.DoesCustomPropertyExist( propertyIndex ), true, TEST_LOCATION );
END_TEST;
}
Actor actor = Actor::New();
auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
- DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex+1 ), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.DoesCustomPropertyExist( propertyIndex+1 ), false, TEST_LOCATION );
END_TEST;
}
tet_infoline( "Test that a default property does not show as a custom property on object" );
Actor actor = Actor::New();
- DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, Actor::Property::POSITION ), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.DoesCustomPropertyExist( Actor::Property::POSITION ), false, TEST_LOCATION );
END_TEST;
}
auto child = Actor::New();
container.Add( child ); // Resolve child properties (if any)
- DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.DoesCustomPropertyExist( CHILD_PROPERTY ), false, TEST_LOCATION );
END_TEST;
}
container.Add( child ); // Resolve child properties (if any)
child.SetProperty( CHILD_PROPERTY, 2 );
- DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.DoesCustomPropertyExist( CHILD_PROPERTY ), true, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 2, TEST_LOCATION );
END_TEST;
}
child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
container.Add( child ); // Resolve child properties (if any)
- DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.DoesCustomPropertyExist( CHILD_PROPERTY ), true, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
END_TEST;
}
tet_infoline( "Test that setting a default property triggers a signal" );
auto actor = Actor::New();
- DevelHandle::PropertySetSignal(actor).Connect(&application, propertySetCheck);
+ actor.PropertySetSignal().Connect(&application, propertySetCheck);
actor.SetProperty( Actor::Property::POSITION, Vector3::XAXIS );
propertySetCheck.CheckSignalReceived();
tet_infoline( "Test that setting a custom property triggers a signal" );
auto actor = Actor::New();
- DevelHandle::PropertySetSignal(actor).Connect(&application, propertySetCheck);
+ actor.PropertySetSignal().Connect(&application, propertySetCheck);
auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
actor.SetProperty( propertyIndex, 5.0f );
application.GetScene().Add( container );
auto child = Actor::New();
child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
- DevelHandle::PropertySetSignal(child).Connect(&application, propertySetCheck);
+ child.PropertySetSignal().Connect(&application, propertySetCheck);
container.Add( child ); // Resolve child properties (if any)
- DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.DoesCustomPropertyExist( CHILD_PROPERTY ), true, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
child.SetProperty( CHILD_PROPERTY, 29 );
END_TEST;
}
+
+
+int UtcDaliHandlePropertySetSignal04(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ bool signalReceived(false);
+ Property::Value value;
+ PropertySetSignalCheck propertySetCheck(signalReceived, value);
+
+ tet_infoline( "Test that setting a property on a vanilla Object triggers a signal" );
+
+ constexpr Property::Index TEST_PROPERTY_KEY_INDEX = 1;
+ const std::string TEST_PROPERTY_KEY_NAME = "testProperty";
+
+ Handle vanillaObject = Handle::New();
+ auto propertyIndex = vanillaObject.RegisterProperty(
+ TEST_PROPERTY_KEY_INDEX,
+ TEST_PROPERTY_KEY_NAME,
+ Color::WHITE );
+
+ vanillaObject.PropertySetSignal().Connect(&application, propertySetCheck);
+
+ DALI_TEST_EQUALS( vanillaObject.DoesCustomPropertyExist( propertyIndex ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( vanillaObject.GetProperty<Vector4>( propertyIndex ), Color::WHITE, 0.001f, TEST_LOCATION );
+
+ vanillaObject[TEST_PROPERTY_KEY_NAME] = Color::RED;
+
+ propertySetCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( Color::RED ), 0.001f, TEST_LOCATION );
+ DALI_TEST_VALUE_EQUALS( vanillaObject[propertyIndex], Property::Value( Color::RED), 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
int UtcDaliHandlePropertySetProperties(void)
{
TestApplication application;
const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
Handle handle = Actor::New();
- DevelHandle::SetProperties(
- handle,
+ handle.SetProperties(
Property::Map
{
{ Actor::Property::SIZE, actorSize },
END_TEST;
}
-int UtcDaliHandleTemplateNew(void)
+int UtcDaliHandleTemplateNew01(void)
{
TestApplication application;
const Vector3 actorSize( 10.0f, 20.0f, 30.0f );
const Vector3 anchorPoint( 1.0f, 0.5f, 0.0f );
const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
- Handle handle = DevelHandle::New< Actor >(
+ Handle handle = Handle::New< Actor >(
Property::Map
{
{ Actor::Property::SIZE, actorSize },
TestApplication application;
Handle handle = Actor::New();
- DevelHandle::SetProperties(
- handle,
+ handle.SetProperties(
Property::Map
{
{ Actor::Property::SIZE, Vector3( 400.0f, 200.0f, 100.0f ) },
);
Property::Map map;
- DevelHandle::GetProperties( handle, map );
+ handle.GetProperties( map );
// Get all the properties and ensure they match
// Add a custom property and ensure the count goes up by one.
const auto countBefore = map.Count();
handle.RegisterProperty( "tempProperty", Color::GREEN );
- DevelHandle::GetProperties( handle, map );
+ handle.GetProperties( map );
DALI_TEST_EQUALS( countBefore + 1, map.Count(), TEST_LOCATION );
END_TEST;
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
namespace DevelHandle
{
-Property::Index GetPropertyIndex( const Handle& handle, Property::Index key )
-{
- return GetImplementation( handle ).GetPropertyIndex( key );
-}
-
-Property::Index GetPropertyIndex( const Handle& handle, Property::Key key )
-{
- return GetImplementation( handle ).GetPropertyIndex( key );
-}
-
-Property::Index RegisterProperty( Handle handle, Property::Index key, const std::string& name, const Property::Value& propertyValue )
-{
- return GetImplementation( handle ).RegisterProperty( name, key, propertyValue );
-}
-
-void SetProperties( Handle handle, const Property::Map& properties )
-{
- GetImplementation( handle ).SetProperties( properties );
-}
-
-void GetProperties( Handle handle, Property::Map& properties )
-{
- GetImplementation( handle ).GetProperties( properties );
-}
-
void SetTypeInfo( Handle& handle, const TypeInfo& typeInfo )
{
GetImplementation( handle ).SetTypeInfo( &GetImplementation( typeInfo ) );
}
-bool DoesCustomPropertyExist( Handle& handle, Property::Index index )
-{
- return GetImplementation( handle ).DoesCustomPropertyExist( index );
-}
-
-PropertySetSignalType& PropertySetSignal( Handle handle )
-{
- return GetImplementation( handle ).PropertySetSignal();
-}
-
} // namespace DevelHandle
} // namespace Dali
#define DALI_HANDLE_DEVEL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
namespace DevelHandle
{
-/**
- * @brief Query the index of a custom property matching the given key.
- *
- * Returns the first custom property that matches the given integer key. This is
- * useful for other classes that know the key but not the name. Requires the property
- * to have been registered with the associated key.
- *
- * @note This key is not the same as the Property enum found in
- * objects such as Actor (which is a preset index).
- *
- * @param[in] handle The handle from where to retrieve the property index.
- * @param[in] key The integer key of the property
- *
- * @return The index of the property, or Property::INVALID_INDEX if no property exists with the given key.
- *
- * @note The key is not the same as the returned index, though it has the same type.
- */
-DALI_CORE_API Property::Index GetPropertyIndex( const Handle& handle, Property::Index key );
-
-/**
- * @brief Query the index of a property using the given key from a Property::Map
- *
- * @param[in] handle The handle from where to retrieve the property index.
- * @param[in] key The key of the property to search for.
- *
- * @return the matching property index of either the string key or the matching
- * custom property index of the index key, or Property::INVALID_INDEX if no
- * property matches the given key.
- *
- * @note See also, GetPropertyIndex(Property::Index) and GetPropertyIndex(const std::string&)
- */
-DALI_CORE_API Property::Index GetPropertyIndex( const Handle& handle, Property::Key key );
-
-/**
- * @brief Register a new animatable property with an integer key.
- *
- * @param[in] handle The handle where to register the property.
- * @param[in] key The integer key of the property.
- * @param[in] name The text key of the property.
- * @param[in] propertyValue The new value of the property.
- *
- * @return The index of the property or Property::INVALID_INDEX if registration failed
- *
- * @pre The object supports dynamic properties i.e. Supports(Handle::DYNAMIC_PROPERTIES) returns true.
- * Property names and keys are expected to be unique, but this is not enforced.
- * Property indices are unique to each registered custom property in a given object.
- *
- * @note Returns Property::INVALID_INDEX if registration failed. This can happen if you try to register
- * animatable property on an object that does not have scene graph object.
- *
- * @note The returned property index is not the same as the integer key (though it shares a type)
- *
- * This version of RegisterProperty associates both an integer key
- * and the text key with the property, allowing for lookup of the
- * property index by either key or name ( which is useful when other
- * classes know the key but not the name )
- *
- * @note Only the following types can be animated:
- * - Property::BOOLEAN
- * - Property::FLOAT
- * - Property::INTEGER
- * - Property::VECTOR2
- * - Property::VECTOR3
- * - Property::VECTOR4
- * - Property::MATRIX3
- * - Property::MATRIX
- * - Property::ROTATION
- * @note If a property with the desired name already exists, then the value given is just set.
- */
-DALI_CORE_API Property::Index RegisterProperty( Handle handle, Property::Index key, const std::string& name, const Property::Value& propertyValue );
-
-/**
- * @brief Sets all the properties in the given property map.
- *
- * @param[in] handle The handle to set the properties on
- * @param[in] properties The properties to set
- */
-DALI_CORE_API void SetProperties( Handle handle, const Property::Map& properties );
-
-/**
- * @brief Retrieves all the properties and the values for a handle.
- *
- * @param[in] handle The handle to retrieve properties from
- * @param[out] properties A map which is populated with the index-value pairs
- *
- * @note The properties map will be cleared by this method first.
- */
-DALI_CORE_API void GetProperties( Handle handle, Property::Map& properties );
-
/**
* @brief Set the type-info that the object is created by.
*
*/
DALI_CORE_API void SetTypeInfo( Handle& handle, const TypeInfo& typeInfo );
-
-/**
- * @brief Determine if the custom property index exists on this object without throwing a Dali::Exception.
- *
- * @note This does not check default properties.
- * @param[in] handle The handle to check
- * @param[in] index The index of the property to test for
- */
-DALI_CORE_API bool DoesCustomPropertyExist( Handle& handle, Property::Index index );
-
-/**
- * @brief PropertySetSignal function prototype for signal handler. Called when a property is set on this object.
- */
-using PropertySetSignalType = Signal< void( Handle& handle, Property::Index index, Property::Value value ) >;
-
-/**
- * @brief Get a signal when a property is set on this object through the API (i.e. not when animating)
- *
- * @param[in] handle The handle of the object to listen to.
- * @return The signal to attach a connection to.
- */
-DALI_CORE_API PropertySetSignalType& PropertySetSignal( Handle handle );
-
-/**
- * @brief Template to create a derived handle and set properties on it.
- *
- * @tparam T The derived class to create
- *
- * @param[in] properties The properties to set
- */
-template< typename T >
-DALI_INTERNAL T New( const Property::Map& properties )
-{
- T handle = T::New();
- SetProperties( handle, properties );
- return handle;
-}
-
} // namespace DevelHandle
} // namespace Dali
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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 std::string();
}
-Property::Index Object::GetPropertyIndex( const std::string& name ) const
+Property::Index Object::GetPropertyIndex( Property::Key key ) const
{
Property::Index index = Property::INVALID_INDEX;
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
- {
- index = typeInfo->GetPropertyIndex( name );
- }
- if( (index == Property::INVALID_INDEX)&&( mCustomProperties.Count() > 0 ) )
+ if( key.type == Property::Key::STRING )
{
- Property::Index count = PROPERTY_CUSTOM_START_INDEX;
- const auto end = mCustomProperties.End();
- for( auto iter = mCustomProperties.Begin(); iter != end; ++iter, ++count )
+ const TypeInfo* typeInfo( GetTypeInfo() );
+ if ( typeInfo )
{
- CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>(*iter);
- if ( custom->name == name )
- {
- if ( custom->childPropertyIndex != Property::INVALID_INDEX )
- {
- // If it is a child property, return the child property index
- index = custom->childPropertyIndex;
- }
- else
- {
- index = count;
- }
- break;
- }
+ index = typeInfo->GetPropertyIndex( key.stringKey );
}
}
- return index;
-}
-
-Property::Index Object::GetPropertyIndex( Property::Index key ) const
-{
- Property::Index index = Property::INVALID_INDEX;
-
- if( mCustomProperties.Count() > 0 )
+ if( (index == Property::INVALID_INDEX)&&( mCustomProperties.Count() > 0 ) )
{
Property::Index count = PROPERTY_CUSTOM_START_INDEX;
const auto end = mCustomProperties.End();
for( auto iter = mCustomProperties.Begin(); iter != end; ++iter, ++count )
{
CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>(*iter);
- if( custom->key == key )
+
+ if( ( key.type == Property::Key::STRING && custom->name == key.stringKey) ||
+ ( key.type == Property::Key::INDEX && custom->key == key.indexKey ) )
{
- if( custom->childPropertyIndex != Property::INVALID_INDEX )
+ if ( custom->childPropertyIndex != Property::INVALID_INDEX )
{
// If it is a child property, return the child property index
index = custom->childPropertyIndex;
return index;
}
-Property::Index Object::GetPropertyIndex( Property::Key key ) const
-{
- Property::Index index = Property::INVALID_INDEX;
- if( key.type == Property::Key::INDEX )
- {
- index = GetPropertyIndex( key.indexKey );
- }
- else
- {
- index = GetPropertyIndex( key.stringKey );
- }
- return index;
-}
-
bool Object::IsPropertyWritable( Property::Index index ) const
{
DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
{
// check whether the animatable property is registered already, if not then register one.
- // this is needed because property value may have been set as full property and get as a property component
+ // this is needed because property value may have been set as full property and get as a property component
AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr );
if( animatableProperty )
{
else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
{
// check whether the animatable property is registered already, if not then register one.
- // this is needed because property value may have been set as full property and get as a property component
+ // this is needed because property value may have been set as full property and get as a property component
AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr );
if( animatableProperty )
{
// Iterating twice to get the value we want should still be fairly quick in a Property::Map.
const auto& key = properties.GetKeyAt( position );
- const auto propertyIndex = ( key.type == Property::Key::INDEX ) ? key.indexKey : GetPropertyIndex( key.stringKey );
+ const auto propertyIndex = ( key.type == Property::Key::INDEX ) ? key.indexKey : GetPropertyIndex( key );
if( propertyIndex != Property::INVALID_INDEX )
{
return componentIndex;
}
-DevelHandle::PropertySetSignalType& Object::PropertySetSignal()
+Handle::PropertySetSignalType& Object::PropertySetSignal()
{
return mPropertySetSignal;
}
#define DALI_INTERNAL_OBJECT_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
*/
std::string GetPropertyName( Property::Index index ) const;
- /**
- * @copydoc Dali::Handle::GetPropertyIndex()
- */
- Property::Index GetPropertyIndex( const std::string& name ) const;
-
- /**
- * @copydoc Dali::Handle::GetPropertyIndex()
- */
- Property::Index GetPropertyIndex( Property::Index key ) const;
-
/**
* @copydoc Dali::Handle::GetPropertyIndex()
*/
/**
* @copydoc Dali::Handle::PropertySetSignal()
*/
- DevelHandle::PropertySetSignalType& PropertySetSignal();
+ Handle::PropertySetSignalType& PropertySetSignal();
protected:
using PropertyNotificationContainer = std::vector< Dali::PropertyNotification >;
PropertyNotificationContainer* mPropertyNotifications; ///< Container of owned property notifications.
- DevelHandle::PropertySetSignalType mPropertySetSignal;
+ Handle::PropertySetSignalType mPropertySetSignal;
};
} // namespace Internal
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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 name;
}
-std::string TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
- Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit )
+std::string TypeRegistry::Register( const std::type_info& theTypeInfo,
+ const std::type_info& baseTypeInfo,
+ Dali::TypeInfo::CreateFunction createInstance,
+ bool callCreateOnInit )
{
std::string uniqueTypeName = DemangleClassName( theTypeInfo.name() );
return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit );
}
-std::string TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
- Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit,
- const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount )
+std::string TypeRegistry::Register( const std::type_info& theTypeInfo,
+ const std::type_info& baseTypeInfo,
+ Dali::TypeInfo::CreateFunction createInstance,
+ bool callCreateOnInit,
+ const Dali::PropertyDetails* defaultProperties,
+ Property::Index defaultPropertyCount )
{
std::string uniqueTypeName = DemangleClassName( theTypeInfo.name() );
return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit, defaultProperties, defaultPropertyCount );
}
-std::string TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo,
- Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit,
- const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount )
+std::string TypeRegistry::Register( const std::string& uniqueTypeName,
+ const std::type_info& baseTypeInfo,
+ Dali::TypeInfo::CreateFunction createInstance,
+ bool callCreateOnInit,
+ const Dali::PropertyDetails* defaultProperties,
+ Property::Index defaultPropertyCount )
{
std::string baseTypeName = DemangleClassName( baseTypeInfo.name() );
}
}
- mRegistryLut.push_back( TypeRegistry::TypeInfoPointer( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance, defaultProperties, defaultPropertyCount ) ) );
+ mRegistryLut.push_back( TypeRegistry::TypeInfoPointer(
+ new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance, defaultProperties, defaultPropertyCount ) ) );
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() );
if( callCreateOnInit )
#if __GNUC__ >= 4
# ifndef HIDE_DALI_INTERNALS
# define DALI_EXPORT_API
+# define DALI_NO_EXPORT_API
# define DALI_IMPORT_API
# define DALI_CORE_API
# define DALI_INTERNAL
# else
# define DALI_EXPORT_API __attribute__ ((visibility ("default")))
+# define DALI_NO_EXPORT_API __attribute__ ((visibility ("hidden")))
# define DALI_IMPORT_API __attribute__ ((visibility ("default")))
# define DALI_CORE_API __attribute__ ((visibility ("default")))
# define DALI_INTERNAL __attribute__ ((visibility ("hidden")))
#endif
/** Visibility attribute to hide declarations */
# define DALI_INTERNAL
+# define DALI_NO_EXPORT_API
#endif
#ifdef DEPRECATION_WARNING
namespace Dali
{
+
Handle::Handle( Dali::Internal::Object* handle )
: BaseHandle(handle)
{
}
-
Handle::Handle()
{
}
return GetImplementation(*this).GetPropertyName( index );
}
-Property::Index Handle::GetPropertyIndex( const std::string& name ) const
+Property::Index Handle::GetPropertyIndex( Property::Key key ) const
{
- return GetImplementation(*this).GetPropertyIndex( name );
+ return GetImplementation( *this ).GetPropertyIndex( key );
}
bool Handle::IsPropertyWritable( Property::Index index ) const
return GetImplementation(*this).RegisterProperty( name, propertyValue );
}
+Property::Index Handle::RegisterProperty( Property::Index key, const std::string& name, const Property::Value& propertyValue )
+{
+ return GetImplementation( *this ).RegisterProperty( name, key, propertyValue );
+}
+
Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode )
{
return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode );
return GetImplementation(*this).GetCurrentProperty( index );
}
+void Handle::SetProperties( const Property::Map& properties )
+{
+ GetImplementation( *this ).SetProperties( properties );
+}
+
+void Handle::GetProperties( Property::Map& properties )
+{
+ GetImplementation( *this ).GetProperties( properties );
+}
+
void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const
{
GetImplementation(*this).GetPropertyIndices( indices );
}
+bool Handle::DoesCustomPropertyExist( Property::Index index )
+{
+ return GetImplementation( *this ).DoesCustomPropertyExist( index );
+}
+
Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
const PropertyCondition& condition )
{
return IndirectValue(*this, GetPropertyIndex(name));
}
+Handle::PropertySetSignalType& Handle::PropertySetSignal()
+{
+ return GetImplementation( *this ).PropertySetSignal();
+}
+
+
namespace WeightObject
{
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/object/indirect-value.h>
+#include <dali/public-api/object/property-key.h>
#include <dali/public-api/object/property-types.h>
#include <dali/public-api/object/property-value.h>
#include <dali/public-api/object/property-notification-declarations.h>
#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/signals/dali-signal.h>
namespace Dali
DYNAMIC_PROPERTIES = 0x01,
};
+ /**
+ * @brief PropertySetSignal function prototype for signal handler. Called when a property is set on this object.
+ */
+ using PropertySetSignalType = Signal< void( Handle& handle, Property::Index index, Property::Value value ) >;
+
public:
/**
*/
static Handle New();
+ /**
+ * @brief Template to create a derived handle and set properties on it.
+ *
+ * Marked as DALI_NO_EXPORT_API to prevent internal usage exporting symbols.
+ * @SINCE_1_9.27
+ * @tparam T The derived class to create
+ * @param[in] properties The properties to set
+ */
+ template< typename Type >
+ static DALI_NO_EXPORT_API Type New( const Property::Map& properties )
+ {
+ Type handle = Type::New();
+ handle.SetProperties( properties );
+ return handle;
+ }
+
/**
* @brief Dali::Handle is intended as a base class.
*
std::string GetPropertyName( Property::Index index ) const;
/**
- * @brief Queries the index of a property.
- *
- * Returns the first property index that matches the given name exactly.
+ * @brief Query the index of a property using the given key.
*
- * @SINCE_1_0.0
- * @param[in] name The name of the property
- * @return The index of the property, or Property::INVALID_INDEX if no property exists with the given name
+ * @SINCE_1_9.27
+ * @param[in] key The key of the property to search for. (The name or integer key provided to
+ * RegisterProperty()).
+ * @return the matching property index of the key, or Property::INVALID_INDEX if no
+ * property matches the given key.
*/
- Property::Index GetPropertyIndex( const std::string& name ) const;
+ Property::Index GetPropertyIndex( Property::Key key ) const;
/**
* @brief Queries whether a property can be set using SetProperty().
*/
Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue );
+ /**
+ * @brief Register a new animatable property with an integer key.
+ *
+ * @SINCE_1_9.27
+ * @param[in] key The integer key of the property.
+ * @param[in] name The text key of the property.
+ * @param[in] propertyValue The new value of the property.
+ *
+ * @return The index of the property or Property::INVALID_INDEX if registration failed
+ *
+ * @pre The object supports dynamic properties
+ * i.e. Supports(Handle::DYNAMIC_PROPERTIES) returns true. Property names and keys
+ * are expected to be unique, but this is not enforced. Property indices are unique
+ * to each registered custom property in a given object.
+ *
+ * @note Returns Property::INVALID_INDEX if registration failed. This can happen if
+ * you try to register animatable property on an object that does not have scene graph
+ * object.
+ *
+ * @note The returned property index is not the same as the integer key (though it
+ * shares a type)
+ *
+ * This version of RegisterProperty associates both an integer key and the text key
+ * with the property, allowing for lookup of the property index by either key or name
+ * ( which is useful when other classes know the key but not the name )
+ *
+ * @note Only the following types can be animated:
+ * - Property::BOOLEAN
+ * - Property::FLOAT
+ * - Property::INTEGER
+ * - Property::VECTOR2
+ * - Property::VECTOR3
+ * - Property::VECTOR4
+ * - Property::MATRIX3
+ * - Property::MATRIX
+ * - Property::ROTATION
+ * @note If a property with the desired name already exists, then the value given is just set.
+ */
+ Property::Index RegisterProperty( Property::Index key,
+ const std::string& name,
+ const Property::Value& propertyValue );
+
/**
* @brief Registers a new property.
*
return T( value.Get<T>() );
}
+ /**
+ * @brief Sets all the properties in the given property map.
+ *
+ * @SINCE_1_9.27
+ * @param[in] properties The properties to set
+ */
+ void SetProperties( const Property::Map& properties );
+
+ /**
+ * @brief Retrieves all the properties and the values for this object
+ *
+ * @SINCE_1_9.27
+ * @param[out] properties A map which is populated with the index-value pairs
+ *
+ * @note The properties map will be cleared by this method first.
+ */
+ void GetProperties( Property::Map& properties );
+
/**
* @brief Retrieves all the property indices for this object (including custom properties).
*
*/
void GetPropertyIndices( Property::IndexContainer& indices ) const;
+ /**
+ * @brief Determine if the custom property index exists on this object without throwing a Dali::Exception.
+ *
+ * @SINCE_1_9.27
+ * @note This does not check default properties.
+ * @param[in] index The index of the property to test for
+ */
+ bool DoesCustomPropertyExist( Property::Index index );
+
/**
* @brief Adds a property notification to this object.
*
* @return indirect value. Should have shorter scope than the handle
*/
IndirectValue operator[]( const std::string& name );
+
+public: // Signals
+ /**
+ * @brief Get a signal when a property is set on this object through the API (i.e. not when animating)
+ *
+ * @SINCE_1_9.27
+ * @return The signal to attach a connection to.
+ */
+ PropertySetSignalType& PropertySetSignal();
};
/**
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.