From b8ddb116397d3cfe1874dd13ad803332f2e40ddf Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 2 Apr 2015 16:30:42 +0100 Subject: [PATCH 1/1] Added animation and constraint support for UNSIGNED_INTEGER property type Change-Id: Idbb1a954584d2528a5de7912082054c0f4313d27 --- automated-tests/src/dali/utc-Dali-Animation.cpp | 42 ++++ automated-tests/src/dali/utc-Dali-Constraint.cpp | 215 +++++++++++++++++- automated-tests/src/dali/utc-Dali-Handle.cpp | 5 +- dali/internal/event/actors/actor-impl.cpp | 23 +- dali/internal/event/animation/animation-impl.cpp | 104 ++++++--- dali/internal/event/animation/key-frames-impl.cpp | 29 ++- dali/internal/event/animation/key-frames-impl.h | 42 ++-- dali/internal/event/animation/progress-value.h | 31 ++- .../event/animation/property-input-accessor.h | 28 ++- .../event/animation/property-input-indexer.h | 20 +- dali/internal/event/common/object-impl.cpp | 54 +++-- dali/internal/event/common/property-input-impl.h | 74 ++++-- dali/internal/render/shaders/shader.cpp | 24 +- .../update/animation/scene-graph-animator.h | 115 +++++++--- dali/internal/update/common/animatable-property.h | 251 ++++++++++++++++++--- .../update/common/property-condition-functions.cpp | 124 ++++++---- .../update/common/property-condition-functions.h | 64 ++++-- .../common/property-condition-step-functions.cpp | 27 ++- .../common/property-condition-step-functions.h | 16 +- .../property-condition-variable-step-functions.cpp | 27 ++- .../property-condition-variable-step-functions.h | 16 +- dali/public-api/object/handle.h | 2 + dali/public-api/object/property-input.h | 8 + dali/public-api/object/property-value.h | 16 +- 24 files changed, 1071 insertions(+), 286 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index 698e12c..9652797 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -8854,3 +8854,45 @@ int UtcDaliAnimationExtendDuratioN(void) DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); END_TEST; } + +int UtcDaliAnimationCustomUnsignedIntProperty(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + unsigned int startValue(0u); + + Property::Index index = actor.RegisterProperty("an-index", startValue); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, index), 20u ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), 10u, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), 20u, TEST_LOCATION ); + END_TEST; +} + diff --git a/automated-tests/src/dali/utc-Dali-Constraint.cpp b/automated-tests/src/dali/utc-Dali-Constraint.cpp index 2f7ae2a..61016d1 100644 --- a/automated-tests/src/dali/utc-Dali-Constraint.cpp +++ b/automated-tests/src/dali/utc-Dali-Constraint.cpp @@ -65,8 +65,9 @@ class PropertyInputAbstraction : public Dali::PropertyInput { public: PropertyInputAbstraction(const bool& val) : mType(Dali::Property::BOOLEAN), mBoolData( val ) {} - PropertyInputAbstraction(const float& val) : mType(Dali::Property::FLOAT), mFloatData( val ) {} PropertyInputAbstraction(const int& val) : mType(Dali::Property::INTEGER), mIntData( val ) {} + PropertyInputAbstraction(const unsigned int& val) : mType(Dali::Property::UNSIGNED_INTEGER), mUIntData( val ) {} + PropertyInputAbstraction(const float& val) : mType(Dali::Property::FLOAT), mFloatData( val ) {} PropertyInputAbstraction(const Vector2& val) : mType(Dali::Property::VECTOR2), mVector2Data( val ) {} PropertyInputAbstraction(const Vector3& val) : mType(Dali::Property::VECTOR3), mVector3Data( val ) {} PropertyInputAbstraction(const Vector4& val) : mType(Dali::Property::VECTOR4), mVector4Data( val ) {} @@ -80,10 +81,10 @@ public: const bool& GetBoolean() const { return mBoolData; } - const float& GetFloat() const { return mFloatData; } - const int& GetInteger() const { return mIntData; } + const unsigned int& GetUnsignedInteger() const { return mUIntData; } + const float& GetFloat() const { return mFloatData; } const Vector2& GetVector2() const { return mVector2Data; } const Vector3& GetVector3() const { return mVector3Data; } const Vector4& GetVector4() const { return mVector4Data; } @@ -96,8 +97,9 @@ public: private: Dali::Property::Type mType; bool mBoolData; - float mFloatData; int mIntData; + unsigned int mUIntData; + float mFloatData; Vector2 mVector2Data; Vector3 mVector3Data; Vector4 mVector4Data; @@ -201,6 +203,21 @@ struct TestAlwaysEqualOrGreaterThanConstraintInteger int mValue; }; +struct TestAlwaysEqualOrGreaterThanConstraintUnsignedInteger +{ + TestAlwaysEqualOrGreaterThanConstraintUnsignedInteger( unsigned int value ) + : mValue( value ) + { + } + + unsigned int operator()( unsigned const int& current ) + { + return ( current < mValue ) ? mValue : current; + } + + unsigned int mValue; +}; + struct TestAlwaysEqualOrGreaterThanConstraintVector2 { TestAlwaysEqualOrGreaterThanConstraintVector2( Vector2 value ) @@ -285,6 +302,21 @@ struct TestConstraintInteger int mValue; }; +struct TestConstraintUnsignedInteger +{ + TestConstraintUnsignedInteger( int value ) + : mValue( value ) + { + } + + unsigned int operator()( const unsigned int& current ) + { + return mValue; + } + + unsigned int mValue; +}; + struct TestConstraintVector2 { TestConstraintVector2( Vector2 value ) @@ -769,6 +801,91 @@ int UtcDaliConstraintNewInteger(void) } +int UtcDaliConstraintNewUnsignedInteger(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + unsigned int startValue( 1u ); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + + unsigned int minValue( 2 ); + Constraint constraint = Constraint::New( index, TestAlwaysEqualOrGreaterThanConstraintUnsignedInteger( minValue ) ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Set to greater than 2f, the constraint will allow this + actor.SetProperty( index, 3u ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), 3, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 3, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 3, TEST_LOCATION ); + + // Set to less than 2, the constraint will NOT allow this + actor.SetProperty( index, 1u ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), minValue/*not 1*/, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetProperty( index, 1u ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 1, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 1, TEST_LOCATION ); + END_TEST; +} + + int UtcDaliConstraintNewVector2(void) { TestApplication application; @@ -1439,6 +1556,96 @@ int UtcDaliConstraintNewOffStageInteger(void) END_TEST; } +int UtcDaliConstraintNewOffStageUnsignedInteger(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register an integer property + unsigned int startValue(1); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint to off-stage Actor + unsigned int constrainedValue( 2 ); + Constraint constraint = Constraint::New( index, TestConstraintUnsignedInteger( constrainedValue ) ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Set back to startValue; the constraint will not prevent this + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (2nd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied (2nd time) + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage (2nd-time) + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Remove the constraint, and set back to startValue + actor.RemoveConstraints(); + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (3rd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be gone + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + END_TEST; +} + + int UtcDaliConstraintNewOffStageVector2(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp index 72df1a7..69d4990 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -357,6 +357,7 @@ int UtcDaliHandleGetPropertyType(void) Property::Index boolIndex = actor.RegisterProperty( "bool-property", bool(true) ); Property::Index floatIndex = actor.RegisterProperty( "float-property", float(123.0f) ); Property::Index intIndex = actor.RegisterProperty( "int-property", 123 ); + Property::Index unsignedIntIndex = actor.RegisterProperty( "unsigned-int-property", 456u ); Property::Index vector2Index = actor.RegisterProperty( "vector2-property", Vector2(1.0f, 2.0f) ); Property::Index vector3Index = actor.RegisterProperty( "vector3-property", Vector3(1.0f, 2.0f, 3.0f) ); Property::Index vector4Index = actor.RegisterProperty( "vector4-property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) ); @@ -365,6 +366,7 @@ int UtcDaliHandleGetPropertyType(void) DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( boolIndex ) ); DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( floatIndex ) ); DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( intIndex ) ); + DALI_TEST_CHECK( Property::UNSIGNED_INTEGER == actor.GetPropertyType( unsignedIntIndex ) ); DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) ); DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) ); DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) ); @@ -740,7 +742,7 @@ int UtcDaliHandleRegisterPropertyTypes(void) { "Property::BOOLEAN", true, true }, { "Property::FLOAT", 1.0f, true }, { "Property::INTEGER", 1, true }, - { "Property::UNSIGNED_INTEGER", 1u, false }, + { "Property::UNSIGNED_INTEGER", 1u, true }, { "Property::VECTOR2", Vector2::ONE, true }, { "Property::VECTOR3", Vector3::ONE, true }, { "Property::VECTOR4", Vector4::ONE, true }, @@ -752,6 +754,7 @@ int UtcDaliHandleRegisterPropertyTypes(void) { "Property::ARRAY", array, false }, { "Property::MAP", map, false }, }; + unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) ); for ( unsigned int i = 0; i < numOfProperties; ++i ) diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index e1bdc83..5d99b15 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -2945,24 +2945,35 @@ void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata break; } - case Property::FLOAT: + case Property::INTEGER: { - const AnimatableProperty< float >* property = dynamic_cast< const AnimatableProperty< float >* >( entry.GetSceneGraphProperty() ); + const AnimatableProperty< int >* property = dynamic_cast< const AnimatableProperty< int >* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty::Bake, value.Get() ); break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - const AnimatableProperty< int >* property = dynamic_cast< const AnimatableProperty< int >* >( entry.GetSceneGraphProperty() ); + const AnimatableProperty< unsigned int >* property = dynamic_cast< const AnimatableProperty< unsigned int >* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + + break; + } + + case Property::FLOAT: + { + const AnimatableProperty< float >* property = dynamic_cast< const AnimatableProperty< float >* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); + + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), mNode, property, &AnimatableProperty::Bake, value.Get() ); break; } diff --git a/dali/internal/event/animation/animation-impl.cpp b/dali/internal/event/animation/animation-impl.cpp index 5ee0bdf..bf8075a 100644 --- a/dali/internal/event/animation/animation-impl.cpp +++ b/dali/internal/event/animation/animation-impl.cpp @@ -321,28 +321,39 @@ void Animation::AnimateBy(Property& target, Property::Value& relativeValue, Alph break; } - case Property::FLOAT: + case Property::INTEGER: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByFloat(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector( AnimatorConnector::New( object, + target.propertyIndex, + target.componentIndex, + new AnimateByInteger(relativeValue.Get()), + alpha, + period ) ); break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - AddAnimatorConnector( AnimatorConnector::New( object, + AddAnimatorConnector( AnimatorConnector::New( object, target.propertyIndex, target.componentIndex, - new AnimateByInteger(relativeValue.Get()), + new AnimateByUnsignedInteger(relativeValue.Get()), alpha, period ) ); break; } + case Property::FLOAT: + { + AddAnimatorConnector( AnimatorConnector::New( object, + target.propertyIndex, + target.componentIndex, + new AnimateByFloat(relativeValue.Get()), + alpha, + period ) ); + break; + } + case Property::VECTOR2: { AddAnimatorConnector( AnimatorConnector::New( object, @@ -446,17 +457,6 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn break; } - case Property::FLOAT: - { - AddAnimatorConnector( AnimatorConnector::New( targetObject, - targetPropertyIndex, - componentIndex, - new AnimateToFloat( destinationValue.Get() ), - alpha, - period ) ); - break; - } - case Property::INTEGER: { AddAnimatorConnector( AnimatorConnector::New( targetObject, @@ -468,6 +468,28 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn break; } + case Property::UNSIGNED_INTEGER: + { + AddAnimatorConnector( AnimatorConnector::New( targetObject, + targetPropertyIndex, + componentIndex, + new AnimateToUnsignedInteger( destinationValue.Get() ), + alpha, + period ) ); + break; + } + + case Property::FLOAT: + { + AddAnimatorConnector( AnimatorConnector::New( targetObject, + targetPropertyIndex, + componentIndex, + new AnimateToFloat( destinationValue.Get() ), + alpha, + period ) ); + break; + } + case Property::VECTOR2: { AddAnimatorConnector( AnimatorConnector::New( targetObject, @@ -586,34 +608,48 @@ void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Alph break; } - case Dali::Property::FLOAT: + case Dali::Property::INTEGER: { - const KeyFrameNumber* kf; + const KeyFrameInteger* kf; GetSpecialization(keyFrames, kf); - KeyFrameNumberPtr kfCopy = KeyFrameNumber::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameNumberFunctor(kfCopy,interpolation), - alpha, - period ) ); + KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf); + AddAnimatorConnector( AnimatorConnector::New( object, + target.propertyIndex, + target.componentIndex, + new KeyFrameIntegerFunctor(kfCopy,interpolation), + alpha, + period ) ); break; } - case Dali::Property::INTEGER: + case Dali::Property::UNSIGNED_INTEGER: { - const KeyFrameInteger* kf; + const KeyFrameUnsignedInteger* kf; GetSpecialization(keyFrames, kf); - KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf); + KeyFrameUnsignedIntegerPtr kfCopy = KeyFrameUnsignedInteger::Clone(*kf); AddAnimatorConnector( AnimatorConnector::New( object, target.propertyIndex, target.componentIndex, - new KeyFrameIntegerFunctor(kfCopy,interpolation), + new KeyFrameUnsignedIntegerFunctor(kfCopy,interpolation), alpha, period ) ); break; } + case Dali::Property::FLOAT: + { + const KeyFrameNumber* kf; + GetSpecialization(keyFrames, kf); + KeyFrameNumberPtr kfCopy = KeyFrameNumber::Clone(*kf); + AddAnimatorConnector( AnimatorConnector::New( object, + target.propertyIndex, + target.componentIndex, + new KeyFrameNumberFunctor(kfCopy,interpolation), + alpha, + period ) ); + break; + } + case Dali::Property::VECTOR2: { const KeyFrameVector2* kf; diff --git a/dali/internal/event/animation/key-frames-impl.cpp b/dali/internal/event/animation/key-frames-impl.cpp index 3237e4d..48bdaef 100644 --- a/dali/internal/event/animation/key-frames-impl.cpp +++ b/dali/internal/event/animation/key-frames-impl.cpp @@ -48,12 +48,15 @@ void KeyFrames::CreateKeyFramesSpec(Property::Type type) case Property::BOOLEAN: mKeyFrames = Internal::KeyFrameBoolean::New(); break; - case Property::FLOAT: - mKeyFrames = Internal::KeyFrameNumber::New(); - break; case Property::INTEGER: mKeyFrames = Internal::KeyFrameInteger::New(); break; + case Property::UNSIGNED_INTEGER: + mKeyFrames = Internal::KeyFrameUnsignedInteger::New(); + break; + case Property::FLOAT: + mKeyFrames = Internal::KeyFrameNumber::New(); + break; case Property::VECTOR2: mKeyFrames = Internal::KeyFrameVector2::New(); break; @@ -97,18 +100,24 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) kf->AddKeyFrame(time, value.Get(), alpha); break; } - case Property::FLOAT: - { - Internal::KeyFrameNumber* kf = static_cast(mKeyFrames.Get()); - kf->AddKeyFrame(time, value.Get(), alpha); - break; - } case Property::INTEGER: { Internal::KeyFrameInteger* kf = static_cast(mKeyFrames.Get()); kf->AddKeyFrame(time, value.Get(), alpha); break; } + case Property::UNSIGNED_INTEGER: + { + Internal::KeyFrameUnsignedInteger* kf = static_cast(mKeyFrames.Get()); + kf->AddKeyFrame(time, value.Get(), alpha); + break; + } + case Property::FLOAT: + { + Internal::KeyFrameNumber* kf = static_cast(mKeyFrames.Get()); + kf->AddKeyFrame(time, value.Get(), alpha); + break; + } case Property::VECTOR2: { Internal::KeyFrameVector2* kf = static_cast(mKeyFrames.Get()); @@ -146,5 +155,3 @@ KeyFrameSpec* KeyFrames::GetKeyFramesBase() const } // Internal } // Dali - - diff --git a/dali/internal/event/animation/key-frames-impl.h b/dali/internal/event/animation/key-frames-impl.h index 4f55c9f..4e42829 100644 --- a/dali/internal/event/animation/key-frames-impl.h +++ b/dali/internal/event/animation/key-frames-impl.h @@ -238,21 +238,23 @@ public: } }; -typedef KeyFrameBaseSpec KeyFrameNumber; -typedef KeyFrameBaseSpec KeyFrameBoolean; -typedef KeyFrameBaseSpec KeyFrameInteger; -typedef KeyFrameBaseSpec KeyFrameVector2; -typedef KeyFrameBaseSpec KeyFrameVector3; -typedef KeyFrameBaseSpec KeyFrameVector4; -typedef KeyFrameBaseSpec KeyFrameQuaternion; - -typedef IntrusivePtr KeyFrameBooleanPtr; -typedef IntrusivePtr KeyFrameNumberPtr; -typedef IntrusivePtr KeyFrameIntegerPtr; -typedef IntrusivePtr KeyFrameVector2Ptr; -typedef IntrusivePtr KeyFrameVector3Ptr; -typedef IntrusivePtr KeyFrameVector4Ptr; -typedef IntrusivePtr KeyFrameQuaternionPtr; +typedef KeyFrameBaseSpec KeyFrameNumber; +typedef KeyFrameBaseSpec KeyFrameBoolean; +typedef KeyFrameBaseSpec KeyFrameInteger; +typedef KeyFrameBaseSpec KeyFrameUnsignedInteger; +typedef KeyFrameBaseSpec KeyFrameVector2; +typedef KeyFrameBaseSpec KeyFrameVector3; +typedef KeyFrameBaseSpec KeyFrameVector4; +typedef KeyFrameBaseSpec KeyFrameQuaternion; + +typedef IntrusivePtr KeyFrameBooleanPtr; +typedef IntrusivePtr KeyFrameNumberPtr; +typedef IntrusivePtr KeyFrameIntegerPtr; +typedef IntrusivePtr KeyFrameUnsignedIntegerPtr; +typedef IntrusivePtr KeyFrameVector2Ptr; +typedef IntrusivePtr KeyFrameVector3Ptr; +typedef IntrusivePtr KeyFrameVector4Ptr; +typedef IntrusivePtr KeyFrameQuaternionPtr; inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameBoolean*& keyFrameSpec) @@ -285,6 +287,16 @@ inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Intern keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); } +inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameUnsignedInteger*& keyFrameSpec) +{ + keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); +} + +inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameUnsignedInteger*& keyFrameSpec) +{ + keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); +} + inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector2*& keyFrameSpec) { keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); diff --git a/dali/internal/event/animation/progress-value.h b/dali/internal/event/animation/progress-value.h index 1022e61..d993d6e 100644 --- a/dali/internal/event/animation/progress-value.h +++ b/dali/internal/event/animation/progress-value.h @@ -71,12 +71,15 @@ typedef std::vector ProgressAngleAxisContain typedef ProgressValue ProgressBoolean; typedef std::vector ProgressBooleanContainer; -typedef ProgressValue ProgressNumber; -typedef std::vector ProgressNumberContainer; - typedef ProgressValue ProgressInteger; typedef std::vector ProgressIntegerContainer; +typedef ProgressValue ProgressUnsignedInteger; +typedef std::vector ProgressUnsignedIntegerContainer; + +typedef ProgressValue ProgressNumber; +typedef std::vector ProgressNumberContainer; + typedef ProgressValue ProgressVector2; typedef std::vector ProgressVector2Container; @@ -106,14 +109,19 @@ inline void Interpolate (bool& result, bool a, bool b, float progress) result = progress < 0.5f ? a : b; } -inline void Interpolate (float& result, float a, float b, float progress) +inline void Interpolate (int& result, int a, int b, float progress) { - result = a + (b-a) * progress; + result = static_cast(a + (b - a) * progress + 0.5f); } -inline void Interpolate (int& result, int a, int b, float progress) +inline void Interpolate (unsigned int& result, unsigned int a, unsigned int b, float progress) { - result = static_cast(a + (b - a) * progress + 0.5f); + result = static_cast(a + (b - a) * progress + 0.5f); +} + +inline void Interpolate (float& result, float a, float b, float progress) +{ + result = a + (b-a) * progress; } inline void Interpolate (Vector2& result, const Vector2& a, const Vector2& b, float progress) @@ -147,6 +155,15 @@ inline void CubicInterpolate( int& result, int p0, int p1, int p2, int p3, float result = static_cast( a3*progress*progress*progress + a2*progress*progress + a1*progress + p1 + 0.5f ); } +inline void CubicInterpolate( unsigned int& result, unsigned int p0, unsigned int p1, unsigned int p2, unsigned int p3, float progress ) +{ + float a3 = p3*0.5f - p2*1.5f + p1*1.5f - p0*0.5f; + float a2 = p0 - p1*2.5f + p2*2.0f - p3*0.5f; + float a1 = (p2-p0)*0.5f; + + result = static_cast( a3*progress*progress*progress + a2*progress*progress + a1*progress + p1 + 0.5f ); +} + inline void CubicInterpolate( float& result, float p0, float p1, float p2, float p3, float progress ) { float a3 = p3*0.5f - p2*1.5f + p1*1.5f - p0*0.5f; diff --git a/dali/internal/event/animation/property-input-accessor.h b/dali/internal/event/animation/property-input-accessor.h index 8c37e0a..01cf766 100644 --- a/dali/internal/event/animation/property-input-accessor.h +++ b/dali/internal/event/animation/property-input-accessor.h @@ -103,6 +103,26 @@ public: } /** + * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const + */ + const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const + { + DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" ); + + return mInput->GetConstraintInputInteger( updateBufferIndex ); + } + + /** + * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputUnsignedInteger() const + */ + const unsigned int& GetConstraintInputUnsignedInteger( BufferIndex updateBufferIndex ) const + { + DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" ); + + return mInput->GetConstraintInputUnsignedInteger( updateBufferIndex ); + } + + /** * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat() */ const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const @@ -147,14 +167,6 @@ public: } /** - * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const - */ - const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const - { - return mInput->GetConstraintInputInteger( updateBufferIndex ); - } - - /** * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2() */ const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const diff --git a/dali/internal/event/animation/property-input-indexer.h b/dali/internal/event/animation/property-input-indexer.h index 3d95edf..295adf1 100644 --- a/dali/internal/event/animation/property-input-indexer.h +++ b/dali/internal/event/animation/property-input-indexer.h @@ -91,19 +91,27 @@ public: } /** - * @copydoc Dali::Internal::PropertyInput::GetFloat() + * @copydoc Dali::Internal::PropertyInput::GetInteger() */ - virtual const float& GetFloat() const + virtual const int& GetInteger() const { - return mInput->GetConstraintInputFloat( mBufferIndex ); + return mInput->GetConstraintInputInteger( mBufferIndex ); } /** - * @copydoc Dali::Internal::PropertyInput::GetInteger() + * @copydoc Dali::Internal::PropertyInput::GetUnsignedInteger() */ - virtual const int& GetInteger() const + virtual const unsigned int& GetUnsignedInteger() const { - return mInput->GetConstraintInputInteger( mBufferIndex ); + return mInput->GetConstraintInputUnsignedInteger( mBufferIndex ); + } + + /** + * @copydoc Dali::Internal::PropertyInput::GetFloat() + */ + virtual const float& GetFloat() const + { + return mInput->GetConstraintInputFloat( mBufferIndex ); } /** diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index fb8a26a..34bd166 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -527,15 +527,21 @@ Property::Index Object::RegisterSceneGraphProperty(const std::string& name, Prop break; } - case Property::FLOAT: + case Property::INTEGER: { - newProperty = new AnimatableProperty( propertyValue.Get() ); + newProperty = new AnimatableProperty( propertyValue.Get() ); break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - newProperty = new AnimatableProperty( propertyValue.Get() ); + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::FLOAT: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); break; } @@ -575,7 +581,6 @@ Property::Index Object::RegisterSceneGraphProperty(const std::string& name, Prop break; } - case Property::UNSIGNED_INTEGER: case Property::RECTANGLE: case Property::STRING: case Property::ARRAY: @@ -789,18 +794,27 @@ Property::Value Object::GetPropertyValue( const PropertyMetadata* entry ) const break; } - case Property::FLOAT: + case Property::INTEGER: { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); + + value = (*property)[ bufferIndex ]; + break; + } + + case Property::FLOAT: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; @@ -886,23 +900,33 @@ void Object::SetSceneGraphProperty( Property::Index index, const PropertyMetadat break; } - case Property::FLOAT: + case Property::INTEGER: { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); // property is being used in a separate thread; queue a message to set the property - BakeMessage( GetEventThreadServices(), *property, value.Get() ); + BakeMessage( GetEventThreadServices(), *property, value.Get() ); break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); // property is being used in a separate thread; queue a message to set the property - BakeMessage( GetEventThreadServices(), *property, value.Get() ); + BakeMessage( GetEventThreadServices(), *property, value.Get() ); + break; + } + + case Property::FLOAT: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); + + // property is being used in a separate thread; queue a message to set the property + BakeMessage( GetEventThreadServices(), *property, value.Get() ); break; } diff --git a/dali/internal/event/common/property-input-impl.h b/dali/internal/event/common/property-input-impl.h index cd9f2a4..c8fa3ad 100644 --- a/dali/internal/event/common/property-input-impl.h +++ b/dali/internal/event/common/property-input-impl.h @@ -43,6 +43,7 @@ namespace Internal static const bool DUMMY_BOOLEAN_VALUE( false ); static const float DUMMY_FLOAT_VALUE( 0.0f ); static const int DUMMY_INTEGER_VALUE( 0 ); +static const unsigned int DUMMY_UNSIGNED_INTEGER_VALUE( 0u ); static const Vector2 DUMMY_VECTOR2_VALUE( 0.0f, 0.0f ); static const Vector3 DUMMY_VECTOR3_VALUE( 0.0f, 0.0f, 0.0f ); static const Vector4 DUMMY_VECTOR4_VALUE( 0.0f, 0.0f, 0.0f, 0.0f ); @@ -96,27 +97,39 @@ public: } /** - * Retrieve a float value. - * @pre GetType() returns Property::FLOAT. + * Retrieve an integer value. + * @pre GetType() returns Property::INTEGER. * @param[in] bufferIndex The buffer to read from. - * @return The float value. + * @return The integer value. */ - virtual const float& GetFloat( BufferIndex bufferIndex ) const + virtual const int& GetInteger( BufferIndex bufferIndex ) const { DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_FLOAT_VALUE; + return DUMMY_INTEGER_VALUE; } /** * Retrieve an integer value. - * @pre GetType() returns Property::INTEGER. + * @pre GetType() returns Property::UNSIGNED_INTEGER. * @param[in] bufferIndex The buffer to read from. * @return The integer value. */ - virtual const int& GetInteger( BufferIndex bufferIndex ) const + virtual const unsigned int& GetUnsignedInteger( BufferIndex bufferIndex ) const { DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); - return DUMMY_INTEGER_VALUE; + return DUMMY_UNSIGNED_INTEGER_VALUE; + } + + /** + * Retrieve a float value. + * @pre GetType() returns Property::FLOAT. + * @param[in] bufferIndex The buffer to read from. + * @return The float value. + */ + virtual const float& GetFloat( BufferIndex bufferIndex ) const + { + DALI_ASSERT_ALWAYS( false && "Property type mismatch" ); + return DUMMY_FLOAT_VALUE; } /** @@ -207,29 +220,42 @@ public: } /** - * Retrieve a float input for a constraint function. + * Retrieve an integer input for a constraint function. * @note For inherited properties, this method should be overriden to return the value * from the previous frame i.e. not from the current update buffer. - * @pre GetType() returns Property::FLOAT. + * @pre GetType() returns Property::INTEGER. * @param[in] updateBufferIndex The current update buffer index. - * @return The float value. + * @return The integer value. */ - virtual const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const + virtual const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const { - return GetFloat( updateBufferIndex ); + return GetInteger( updateBufferIndex ); } /** - * Retrieve an integer input for a constraint function. + * Retrieve an unsigned integer input for a constraint function. * @note For inherited properties, this method should be overriden to return the value * from the previous frame i.e. not from the current update buffer. - * @pre GetType() returns Property::INTEGER. + * @pre GetType() returns Property::UNSIGNED_INTEGER. * @param[in] updateBufferIndex The current update buffer index. * @return The integer value. */ - virtual const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const + virtual const unsigned int& GetConstraintInputUnsignedInteger( BufferIndex updateBufferIndex ) const { - return GetInteger( updateBufferIndex ); + return GetUnsignedInteger( updateBufferIndex ); + } + + /** + * Retrieve a float input for a constraint function. + * @note For inherited properties, this method should be overriden to return the value + * from the previous frame i.e. not from the current update buffer. + * @pre GetType() returns Property::FLOAT. + * @param[in] updateBufferIndex The current update buffer index. + * @return The float value. + */ + virtual const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const + { + return GetFloat( updateBufferIndex ); } /** @@ -326,15 +352,21 @@ public: break; } - case Property::FLOAT: + case Property::INTEGER: { - debugStream << GetFloat( bufferIndex ); + debugStream << GetInteger( bufferIndex ); break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - debugStream << GetInteger( bufferIndex ); + debugStream << GetUnsignedInteger( bufferIndex ); + break; + } + + case Property::FLOAT: + { + debugStream << GetFloat( bufferIndex ); break; } diff --git a/dali/internal/render/shaders/shader.cpp b/dali/internal/render/shaders/shader.cpp index 718a6f5..2ca57e3 100644 --- a/dali/internal/render/shaders/shader.cpp +++ b/dali/internal/render/shaders/shader.cpp @@ -351,9 +351,9 @@ void Shader::SetUniforms( Context& context, // switch based on property type to use correct GL uniform setter switch ( property.GetType() ) { - case Property::FLOAT : + case Property::BOOLEAN : { - program.SetUniform1f( loc, property.GetFloat( bufferIndex ) ); + program.SetUniform1i( loc, property.GetBoolean( bufferIndex ) ); break; } case Property::INTEGER : @@ -361,6 +361,16 @@ void Shader::SetUniforms( Context& context, program.SetUniform1i( loc, property.GetInteger( bufferIndex ) ); break; } + case Property::UNSIGNED_INTEGER : + { + program.SetUniform1i( loc, property.GetUnsignedInteger( bufferIndex ) ); + break; + } + case Property::FLOAT : + { + program.SetUniform1f( loc, property.GetFloat( bufferIndex ) ); + break; + } case Property::VECTOR2 : { Vector2 value( property.GetVector2( bufferIndex ) ); @@ -450,9 +460,15 @@ void Shader::SetUniforms( Context& context, break; } - default : + case Property::NONE: + case Property::ROTATION: + case Property::STRING: + case Property::RECTANGLE: + case Property::MAP: + case Property::ARRAY: + case Property::TYPE_COUNT: { - // Only float and Vector properties are passed as uniforms; other types are ignored. + DALI_ASSERT_ALWAYS( 0 && "Invalid property type for a uniform" ); break; } } diff --git a/dali/internal/update/animation/scene-graph-animator.h b/dali/internal/update/animation/scene-graph-animator.h index 68326c5..9997d9d 100644 --- a/dali/internal/update/animation/scene-graph-animator.h +++ b/dali/internal/update/animation/scene-graph-animator.h @@ -379,17 +379,22 @@ struct AnimatorFunctionBase virtual ~AnimatorFunctionBase(){} ///Stub "()" operators. + virtual bool operator()(float progress, const bool& property) + { + return property; + } + virtual float operator()(float progress, const int& property) { return property; } - virtual float operator()(float progress, const float& property) + virtual float operator()(float progress, const unsigned int& property) { return property; } - virtual bool operator()(float progress, const bool& property) + virtual float operator()(float progress, const float& property) { return property; } @@ -417,64 +422,94 @@ struct AnimatorFunctionBase // Update functions -struct AnimateByFloat : public AnimatorFunctionBase +struct AnimateByInteger : public AnimatorFunctionBase { - AnimateByFloat(const float& relativeValue) + AnimateByInteger(const int& relativeValue) : mRelative(relativeValue) { } - float operator()(float alpha, const float& property) + float operator()(float alpha, const int& property) { - return float(property + mRelative * alpha); + return int(property + mRelative * alpha + 0.5f ); } - float mRelative; + int mRelative; }; -struct AnimateToFloat : public AnimatorFunctionBase +struct AnimateToInteger : public AnimatorFunctionBase { - AnimateToFloat(const float& targetValue) + AnimateToInteger(const int& targetValue) : mTarget(targetValue) { } - float operator()(float alpha, const float& property) + float operator()(float alpha, const int& property) { - return float(property + ((mTarget - property) * alpha)); + return int(property + ((mTarget - property) * alpha) + 0.5f); } - float mTarget; + int mTarget; }; -struct AnimateByInteger : public AnimatorFunctionBase +struct AnimateByUnsignedInteger : public AnimatorFunctionBase { - AnimateByInteger(const int& relativeValue) + AnimateByUnsignedInteger(const unsigned int& relativeValue) : mRelative(relativeValue) { } - float operator()(float alpha, const int& property) + float operator()(float alpha, const unsigned int& property) { - return int(property + mRelative * alpha + 0.5f ); + return static_cast(property + mRelative * alpha + 0.5f ); } - int mRelative; + unsigned int mRelative; }; -struct AnimateToInteger : public AnimatorFunctionBase +struct AnimateToUnsignedInteger : public AnimatorFunctionBase { - AnimateToInteger(const int& targetValue) + AnimateToUnsignedInteger(const unsigned int& targetValue) : mTarget(targetValue) { } - float operator()(float alpha, const int& property) + float operator()(float alpha, const unsigned int& property) { - return int(property + ((mTarget - property) * alpha) + 0.5f); + return static_cast(property + ((mTarget - property) * alpha) + 0.5f); } - int mTarget; + unsigned int mTarget; +}; + +struct AnimateByFloat : public AnimatorFunctionBase +{ + AnimateByFloat(const float& relativeValue) + : mRelative(relativeValue) + { + } + + float operator()(float alpha, const float& property) + { + return float(property + mRelative * alpha); + } + + float mRelative; +}; + +struct AnimateToFloat : public AnimatorFunctionBase +{ + AnimateToFloat(const float& targetValue) + : mTarget(targetValue) + { + } + + float operator()(float alpha, const float& property) + { + return float(property + ((mTarget - property) * alpha)); + } + + float mTarget; }; struct AnimateByVector2 : public AnimatorFunctionBase @@ -692,14 +727,14 @@ struct KeyFrameBooleanFunctor : public AnimatorFunctionBase KeyFrameBooleanPtr mKeyFrames; }; -struct KeyFrameNumberFunctor : public AnimatorFunctionBase +struct KeyFrameIntegerFunctor : public AnimatorFunctionBase { - KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation) + KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation) : mKeyFrames(keyFrames),mInterpolation(interpolation) { } - float operator()(float progress, const float& property) + float operator()(float progress, const int& property) { if(mKeyFrames->IsActive(progress)) { @@ -708,18 +743,18 @@ struct KeyFrameNumberFunctor : public AnimatorFunctionBase return property; } - KeyFrameNumberPtr mKeyFrames; + KeyFrameIntegerPtr mKeyFrames; Interpolation mInterpolation; }; -struct KeyFrameIntegerFunctor : public AnimatorFunctionBase +struct KeyFrameUnsignedIntegerFunctor : public AnimatorFunctionBase { - KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation) + KeyFrameUnsignedIntegerFunctor(KeyFrameUnsignedIntegerPtr keyFrames, Interpolation interpolation) : mKeyFrames(keyFrames),mInterpolation(interpolation) { } - float operator()(float progress, const int& property) + float operator()(float progress, const unsigned int& property) { if(mKeyFrames->IsActive(progress)) { @@ -728,7 +763,27 @@ struct KeyFrameIntegerFunctor : public AnimatorFunctionBase return property; } - KeyFrameIntegerPtr mKeyFrames; + KeyFrameUnsignedIntegerPtr mKeyFrames; + Interpolation mInterpolation; +}; + +struct KeyFrameNumberFunctor : public AnimatorFunctionBase +{ + KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation) + : mKeyFrames(keyFrames),mInterpolation(interpolation) + { + } + + float operator()(float progress, const float& property) + { + if(mKeyFrames->IsActive(progress)) + { + return mKeyFrames->GetValue(progress, mInterpolation); + } + return property; + } + + KeyFrameNumberPtr mKeyFrames; Interpolation mInterpolation; }; diff --git a/dali/internal/update/common/animatable-property.h b/dali/internal/update/common/animatable-property.h index 8429b93..7e8fbf0 100644 --- a/dali/internal/update/common/animatable-property.h +++ b/dali/internal/update/common/animatable-property.h @@ -292,11 +292,12 @@ private: }; + /** - * An float animatable property of a scene-graph object. + * An integer animatable property of a scene-graph object. */ template <> -class AnimatableProperty : public AnimatablePropertyBase +class AnimatableProperty : public AnimatablePropertyBase { public: @@ -304,7 +305,7 @@ public: * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( float initialValue ) + AnimatableProperty( int initialValue ) : mValue( initialValue ), mBaseValue( initialValue ) { @@ -322,7 +323,7 @@ public: */ virtual Dali::Property::Type GetType() const { - return Dali::PropertyTypes::Get(); + return Dali::PropertyTypes::Get(); } /** @@ -339,9 +340,9 @@ public: } /** - * @copydoc Dali::Internal::PropertyInputImpl::GetFloat() + * @copydoc Dali::Internal::PropertyInputImpl::GetInteger() */ - virtual const float& GetFloat( BufferIndex bufferIndex ) const + virtual const int& GetInteger( BufferIndex bufferIndex ) const { return mValue[ bufferIndex ]; } @@ -352,7 +353,7 @@ public: * @param[in] bufferIndex The buffer to write. * @param[in] value The new property value. */ - void Set(BufferIndex bufferIndex, float value) + void Set(BufferIndex bufferIndex, int value) { mValue[bufferIndex] = value; @@ -364,7 +365,7 @@ public: * @param[in] bufferIndex The buffer to write. * @param[in] delta The property will change by this amount. */ - void SetRelative(BufferIndex bufferIndex, float delta) + void SetRelative(BufferIndex bufferIndex, int delta) { mValue[bufferIndex] = mValue[bufferIndex] + delta; @@ -374,7 +375,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - float& Get(size_t bufferIndex) + int& Get(size_t bufferIndex) { return mValue[bufferIndex]; } @@ -382,7 +383,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const float& Get(size_t bufferIndex) const + const int& Get(size_t bufferIndex) const { return mValue[bufferIndex]; } @@ -392,7 +393,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - float& operator[](size_t bufferIndex) + int& operator[](size_t bufferIndex) { return mValue[bufferIndex]; } @@ -402,7 +403,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const float& operator[](size_t bufferIndex) const + const int& operator[](size_t bufferIndex) const { return mValue[bufferIndex]; } @@ -412,7 +413,7 @@ public: * @param[in] bufferIndex The buffer to write for the property value. * @param[in] value The new property value. */ - void Bake(BufferIndex bufferIndex, float value) + void Bake(BufferIndex bufferIndex, int value) { mValue[bufferIndex] = value; mBaseValue = mValue[bufferIndex]; @@ -425,7 +426,7 @@ public: * @param[in] bufferIndex The buffer to write for the local property value. * @param[in] delta The property will change by this amount. */ - void BakeRelative(BufferIndex bufferIndex, float delta) + void BakeRelative(BufferIndex bufferIndex, int delta) { mValue[bufferIndex] = mValue[bufferIndex] + delta; mBaseValue = mValue[bufferIndex]; @@ -438,7 +439,7 @@ public: * This should only be used when the owning object has not been connected to the scene-graph. * @param[in] value The new property value. */ - void SetInitial(const float& value) + void SetInitial(const int& value) { mValue[0] = value; mValue[1] = mValue[0]; @@ -450,7 +451,7 @@ public: * This should only be used when the owning object has not been connected to the scene-graph. * @param[in] delta The property will change by this amount. */ - void SetInitialRelative(const float& delta) + void SetInitialRelative(const int& delta) { mValue[0] = mValue[0] + delta; mValue[1] = mValue[0]; @@ -467,16 +468,16 @@ private: private: - DoubleBuffered mValue; ///< The double-buffered property value - float mBaseValue; ///< Reset to this base value at the beginning of each frame + DoubleBuffered mValue; ///< The double-buffered property value + int mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** - * An integer animatable property of a scene-graph object. + * An unsigned integer animatable property of a scene-graph object. */ template <> -class AnimatableProperty : public AnimatablePropertyBase +class AnimatableProperty : public AnimatablePropertyBase { public: @@ -484,7 +485,7 @@ public: * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( int initialValue ) + AnimatableProperty( unsigned int initialValue ) : mValue( initialValue ), mBaseValue( initialValue ) { @@ -502,7 +503,7 @@ public: */ virtual Dali::Property::Type GetType() const { - return Dali::PropertyTypes::Get(); + return Dali::PropertyTypes::Get(); } /** @@ -519,9 +520,9 @@ public: } /** - * @copydoc Dali::Internal::PropertyInputImpl::GetInteger() + * @copydoc Dali::Internal::PropertyInputImpl::GetUnsignedInteger() */ - virtual const int& GetInteger( BufferIndex bufferIndex ) const + virtual const unsigned int& GetUnsignedInteger( BufferIndex bufferIndex ) const { return mValue[ bufferIndex ]; } @@ -532,7 +533,7 @@ public: * @param[in] bufferIndex The buffer to write. * @param[in] value The new property value. */ - void Set(BufferIndex bufferIndex, int value) + void Set(BufferIndex bufferIndex, unsigned int value) { mValue[bufferIndex] = value; @@ -544,7 +545,7 @@ public: * @param[in] bufferIndex The buffer to write. * @param[in] delta The property will change by this amount. */ - void SetRelative(BufferIndex bufferIndex, int delta) + void SetRelative(BufferIndex bufferIndex, unsigned int delta) { mValue[bufferIndex] = mValue[bufferIndex] + delta; @@ -554,7 +555,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - int& Get(size_t bufferIndex) + unsigned int& Get(size_t bufferIndex) { return mValue[bufferIndex]; } @@ -562,7 +563,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const int& Get(size_t bufferIndex) const + const unsigned int& Get(size_t bufferIndex) const { return mValue[bufferIndex]; } @@ -572,7 +573,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - int& operator[](size_t bufferIndex) + unsigned int& operator[](size_t bufferIndex) { return mValue[bufferIndex]; } @@ -582,7 +583,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const int& operator[](size_t bufferIndex) const + const unsigned int& operator[](size_t bufferIndex) const { return mValue[bufferIndex]; } @@ -592,7 +593,7 @@ public: * @param[in] bufferIndex The buffer to write for the property value. * @param[in] value The new property value. */ - void Bake(BufferIndex bufferIndex, int value) + void Bake(BufferIndex bufferIndex, unsigned int value) { mValue[bufferIndex] = value; mBaseValue = mValue[bufferIndex]; @@ -605,7 +606,7 @@ public: * @param[in] bufferIndex The buffer to write for the local property value. * @param[in] delta The property will change by this amount. */ - void BakeRelative(BufferIndex bufferIndex, int delta) + void BakeRelative(BufferIndex bufferIndex, unsigned int delta) { mValue[bufferIndex] = mValue[bufferIndex] + delta; mBaseValue = mValue[bufferIndex]; @@ -618,7 +619,7 @@ public: * This should only be used when the owning object has not been connected to the scene-graph. * @param[in] value The new property value. */ - void SetInitial(const int& value) + void SetInitial(const unsigned int& value) { mValue[0] = value; mValue[1] = mValue[0]; @@ -630,7 +631,7 @@ public: * This should only be used when the owning object has not been connected to the scene-graph. * @param[in] delta The property will change by this amount. */ - void SetInitialRelative(const int& delta) + void SetInitialRelative(const unsigned int& delta) { mValue[0] = mValue[0] + delta; mValue[1] = mValue[0]; @@ -646,10 +647,188 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: + DoubleBuffered mValue; ///< The double-buffered property value + unsigned int mBaseValue; ///< Reset to this base value at the beginning of each frame +}; - DoubleBuffered mValue; ///< The double-buffered property value - int mBaseValue; ///< Reset to this base value at the beginning of each frame +/** + * An float animatable property of a scene-graph object. + */ +template <> +class AnimatableProperty : public AnimatablePropertyBase +{ +public: + + /** + * Create an animatable property. + * @param [in] initialValue The initial value of the property. + */ + AnimatableProperty( float initialValue ) + : mValue( initialValue ), + mBaseValue( initialValue ) + { + } + + /** + * Virtual destructor. + */ + virtual ~AnimatableProperty() + { + } + + /** + * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() + */ + virtual Dali::Property::Type GetType() const + { + return Dali::PropertyTypes::Get(); + } + + /** + * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue() + */ + virtual void ResetToBaseValue(BufferIndex updateBufferIndex) + { + if (CLEAN_FLAG != mDirtyFlags) + { + mValue[updateBufferIndex] = mBaseValue; + + mDirtyFlags = ( mDirtyFlags >> 1 ); + } + } + + /** + * @copydoc Dali::Internal::PropertyInputImpl::GetFloat() + */ + virtual const float& GetFloat( BufferIndex bufferIndex ) const + { + return mValue[ bufferIndex ]; + } + + /** + * Set the property value. This will only persist for the current frame; the property + * will be reset with the base value, at the beginning of the next frame. + * @param[in] bufferIndex The buffer to write. + * @param[in] value The new property value. + */ + void Set(BufferIndex bufferIndex, float value) + { + mValue[bufferIndex] = value; + + OnSet(); + } + + /** + * Change the property value by a relative amount. + * @param[in] bufferIndex The buffer to write. + * @param[in] delta The property will change by this amount. + */ + void SetRelative(BufferIndex bufferIndex, float delta) + { + mValue[bufferIndex] = mValue[bufferIndex] + delta; + + OnSet(); + } + + /** + * @copydoc Dali::SceneGraph::AnimatableProperty::Get() + */ + float& Get(size_t bufferIndex) + { + return mValue[bufferIndex]; + } + + /** + * @copydoc Dali::SceneGraph::AnimatableProperty::Get() + */ + const float& Get(size_t bufferIndex) const + { + return mValue[bufferIndex]; + } + + /** + * Retrieve the property value. + * @param[in] bufferIndex The buffer to read. + * @return The property value. + */ + float& operator[](size_t bufferIndex) + { + return mValue[bufferIndex]; + } + + /** + * Retrieve the property value. + * @param[in] bufferIndex The buffer to read. + * @return The property value. + */ + const float& operator[](size_t bufferIndex) const + { + return mValue[bufferIndex]; + } + + /** + * Set both the property value & base value. + * @param[in] bufferIndex The buffer to write for the property value. + * @param[in] value The new property value. + */ + void Bake(BufferIndex bufferIndex, float value) + { + mValue[bufferIndex] = value; + mBaseValue = mValue[bufferIndex]; + + OnBake(); + } + + /** + * Change the property value & base value by a relative amount. + * @param[in] bufferIndex The buffer to write for the local property value. + * @param[in] delta The property will change by this amount. + */ + void BakeRelative(BufferIndex bufferIndex, float delta) + { + mValue[bufferIndex] = mValue[bufferIndex] + delta; + mBaseValue = mValue[bufferIndex]; + + OnBake(); + } + + /** + * Sets both double-buffered values & the base value. + * This should only be used when the owning object has not been connected to the scene-graph. + * @param[in] value The new property value. + */ + void SetInitial(const float& value) + { + mValue[0] = value; + mValue[1] = mValue[0]; + mBaseValue = mValue[0]; + } + + /** + * Change both double-buffered values & the base value by a relative amount. + * This should only be used when the owning object has not been connected to the scene-graph. + * @param[in] delta The property will change by this amount. + */ + void SetInitialRelative(const float& delta) + { + mValue[0] = mValue[0] + delta; + mValue[1] = mValue[0]; + mBaseValue = mValue[0]; + } + +private: + + // Undefined + AnimatableProperty(const AnimatableProperty& property); + + // Undefined + AnimatableProperty& operator=(const AnimatableProperty& rhs); + +private: + + DoubleBuffered mValue; ///< The double-buffered property value + float mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** diff --git a/dali/internal/update/common/property-condition-functions.cpp b/dali/internal/update/common/property-condition-functions.cpp index 67167cf..bca0dec 100644 --- a/dali/internal/update/common/property-condition-functions.cpp +++ b/dali/internal/update/common/property-condition-functions.cpp @@ -44,14 +44,19 @@ ConditionFunction LessThan::GetFunction(Property::Type valueType) function = LessThan::EvalBoolean; break; } - case Property::FLOAT: + case Property::INTEGER: { - function = LessThan::EvalFloat; + function = LessThan::EvalInteger; break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - function = LessThan::EvalInteger; + function = LessThan::EvalUnsignedInteger; + break; + } + case Property::FLOAT: + { + function = LessThan::EvalFloat; break; } case Property::VECTOR2: @@ -85,18 +90,24 @@ bool LessThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotificati return (value.GetBoolean() < arg0); } -bool LessThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) -{ - const float arg0 = arg[0]; - return (value.GetFloat() < arg0); -} - bool LessThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { const int arg0 = arg[0]; return (value.GetInteger() < arg0); } +bool LessThan::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const unsigned int arg0 = arg[0]; + return (value.GetUnsignedInteger() < arg0); +} + +bool LessThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const float arg0 = arg[0]; + return (value.GetFloat() < arg0); +} + bool LessThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { const float arg0 = arg[0]; @@ -133,14 +144,19 @@ ConditionFunction GreaterThan::GetFunction(Property::Type valueType) function = GreaterThan::EvalBoolean; break; } - case Property::FLOAT: + case Property::INTEGER: { - function = GreaterThan::EvalFloat; + function = GreaterThan::EvalInteger; break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - function = GreaterThan::EvalInteger; + function = GreaterThan::EvalUnsignedInteger; + break; + } + case Property::FLOAT: + { + function = GreaterThan::EvalFloat; break; } case Property::VECTOR2: @@ -174,18 +190,24 @@ bool GreaterThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotific return (value.GetBoolean() > arg0); } -bool GreaterThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) -{ - const float arg0 = arg[0]; - return (value.GetFloat() > arg0); -} - bool GreaterThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { const int arg0 = arg[0]; return (value.GetInteger() > arg0); } +bool GreaterThan::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const unsigned int arg0 = arg[0]; + return (value.GetUnsignedInteger() > arg0); +} + +bool GreaterThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const float arg0 = arg[0]; + return (value.GetFloat() > arg0); +} + bool GreaterThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { const float arg0 = arg[0]; @@ -222,14 +244,19 @@ ConditionFunction Inside::GetFunction(Property::Type valueType) function = Inside::EvalBoolean; break; } - case Property::FLOAT: + case Property::INTEGER: { - function = Inside::EvalFloat; + function = Inside::EvalInteger; break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - function = Inside::EvalInteger; + function = Inside::EvalUnsignedInteger; + break; + } + case Property::FLOAT: + { + function = Inside::EvalFloat; break; } case Property::VECTOR2: @@ -263,18 +290,24 @@ bool Inside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification return ( (valueBoolean > arg[0]) && (valueBoolean < arg[1]) ); } -bool Inside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) -{ - const float valueFloat = value.GetFloat(); - return ( (valueFloat > arg[0]) && (valueFloat < arg[1]) ); -} - bool Inside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { const int valueInteger = value.GetInteger(); return ( (valueInteger > arg[0]) && (valueInteger < arg[1]) ); } +bool Inside::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const unsigned int valueUInt = value.GetUnsignedInteger(); + return ( (valueUInt > arg[0]) && (valueUInt < arg[1]) ); +} + +bool Inside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const float valueFloat = value.GetFloat(); + return ( (valueFloat > arg[0]) && (valueFloat < arg[1]) ); +} + bool Inside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { const float length2 = value.GetVector2().LengthSquared(); @@ -311,14 +344,19 @@ ConditionFunction Outside::GetFunction(Property::Type valueType) function = Outside::EvalBoolean; break; } - case Property::FLOAT: + case Property::INTEGER: { - function = Outside::EvalFloat; + function = Outside::EvalInteger; break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - function = Outside::EvalInteger; + function = Outside::EvalUnsignedInteger; + break; + } + case Property::FLOAT: + { + function = Outside::EvalFloat; break; } case Property::VECTOR2: @@ -352,16 +390,22 @@ bool Outside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotificatio return ( (valueBoolean < arg[0]) || (valueBoolean > arg[1]) ); } -bool Outside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool Outside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { - const float valueFloat = value.GetFloat(); - return ( (valueFloat < arg[0]) || (valueFloat > arg[1]) ); + const int valueInteger = value.GetInteger(); + return ( (valueInteger < arg[0]) || (valueInteger > arg[1]) ); } -bool Outside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool Outside::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { - const int valueInterger = value.GetInteger(); - return ( (valueInterger < arg[0]) || (valueInterger > arg[1]) ); + const unsigned int valueUInt = value.GetUnsignedInteger(); + return ( (valueUInt < arg[0]) || (valueUInt > arg[1]) ); +} + +bool Outside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const float valueFloat = value.GetFloat(); + return ( (valueFloat < arg[0]) || (valueFloat > arg[1]) ); } bool Outside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) diff --git a/dali/internal/update/common/property-condition-functions.h b/dali/internal/update/common/property-condition-functions.h index 08825c9..7d1faa0 100644 --- a/dali/internal/update/common/property-condition-functions.h +++ b/dali/internal/update/common/property-condition-functions.h @@ -73,20 +73,28 @@ private: static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if float is LessThan + * Checks if integer is LessThan * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if integer is LessThan + * Checks if unsigned integer is LessThan * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + + /** + * Checks if float is LessThan + * @param[in] value The value being examined. + * @param[in] arg The supplied arguments for the condition. + * @return Condition result (true if condition met, false if not) + */ + static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** * Checks if Vector2.Length() is LessThan @@ -157,20 +165,28 @@ private: static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if float is GreaterThan + * Checks if integer is GreaterThan * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if integer is GreaterThan + * Checks if unsigned integer is GreaterThan * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + + /** + * Checks if float is GreaterThan + * @param[in] value The value being examined. + * @param[in] arg The supplied arguments for the condition. + * @return Condition result (true if condition met, false if not) + */ + static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** * Checks if Vector2.Length() is GreaterThan @@ -241,20 +257,28 @@ private: static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if float is Inside + * Checks if integer is Inside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if integer is Inside + * Checks if unsigned integer is Inside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + + /** + * Checks if float is Inside + * @param[in] value The value being examined. + * @param[in] arg The supplied arguments for the condition. + * @return Condition result (true if condition met, false if not) + */ + static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** * Checks if Vector2.Length() is Inside @@ -325,20 +349,28 @@ private: static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if float is Outside + * Checks if integer is Outside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if integer is Outside + * Checks if unsigned integer is Outside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + + /** + * Checks if float is Outside + * @param[in] value The value being examined. + * @param[in] arg The supplied arguments for the condition. + * @return Condition result (true if condition met, false if not) + */ + static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** * Checks if Vector2.Length() is Outside diff --git a/dali/internal/update/common/property-condition-step-functions.cpp b/dali/internal/update/common/property-condition-step-functions.cpp index 92110fd..25547da 100644 --- a/dali/internal/update/common/property-condition-step-functions.cpp +++ b/dali/internal/update/common/property-condition-step-functions.cpp @@ -46,14 +46,19 @@ ConditionFunction Step::GetFunction(Property::Type valueType) switch(valueType) { - case Property::FLOAT: + case Property::INTEGER: { - function = EvalFloat; + function = EvalInteger; break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - function = EvalInteger; + function = EvalUnsignedInteger; + break; + } + case Property::FLOAT: + { + function = EvalFloat; break; } case Property::VECTOR2: @@ -99,18 +104,24 @@ bool Step::Evaluate( const float propertyValue, PropertyNotification::RawArgumen return false; } -bool Step::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) + +bool Step::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { - const float propertyValue = value.GetFloat(); + const float propertyValue = static_cast( value.GetInteger() ); return Evaluate( propertyValue, arg ); } -bool Step::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool Step::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { - const float propertyValue = static_cast( value.GetInteger() ); + const float propertyValue = static_cast( value.GetUnsignedInteger() ); return Evaluate( propertyValue, arg ); } +bool Step::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const float propertyValue = value.GetFloat(); + return Evaluate( propertyValue, arg ); +} bool Step::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { const float propertyValue = value.GetVector2().LengthSquared(); diff --git a/dali/internal/update/common/property-condition-step-functions.h b/dali/internal/update/common/property-condition-step-functions.h index 44537bc..4a7104c 100644 --- a/dali/internal/update/common/property-condition-step-functions.h +++ b/dali/internal/update/common/property-condition-step-functions.h @@ -60,20 +60,28 @@ private: static bool Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if float is Outside + * Checks if integer is Outside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if integer is Outside + * Checks if unsigned integer is Outside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + + /** + * Checks if float is Outside + * @param[in] value The value being examined. + * @param[in] arg The supplied arguments for the condition. + * @return Condition result (true if condition met, false if not) + */ + static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** * Checks if Vector2.Length() is Outside diff --git a/dali/internal/update/common/property-condition-variable-step-functions.cpp b/dali/internal/update/common/property-condition-variable-step-functions.cpp index 1be75e8..3b259dc 100644 --- a/dali/internal/update/common/property-condition-variable-step-functions.cpp +++ b/dali/internal/update/common/property-condition-variable-step-functions.cpp @@ -46,14 +46,19 @@ ConditionFunction VariableStep::GetFunction( Property::Type valueType ) switch( valueType ) { - case Property::FLOAT: + case Property::INTEGER: { - function = EvalFloat; + function = EvalInteger; break; } - case Property::INTEGER: + case Property::UNSIGNED_INTEGER: { - function = EvalInteger; + function = EvalUnsignedInteger; + break; + } + case Property::FLOAT: + { + function = EvalFloat; break; } case Property::VECTOR2: @@ -148,15 +153,21 @@ bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::Ra return false; } -bool VariableStep::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { - const float propertyValue = value.GetFloat(); + const float propertyValue = static_cast( value.GetInteger() ); return Evaluate( propertyValue, arg ); } -bool VariableStep::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) { - const float propertyValue = static_cast( value.GetInteger() ); + const float propertyValue = static_cast( value.GetUnsignedInteger() ); + return Evaluate( propertyValue, arg ); +} + +bool VariableStep::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +{ + const float propertyValue = value.GetFloat(); return Evaluate( propertyValue, arg ); } diff --git a/dali/internal/update/common/property-condition-variable-step-functions.h b/dali/internal/update/common/property-condition-variable-step-functions.h index b5b1133..672df6b 100644 --- a/dali/internal/update/common/property-condition-variable-step-functions.h +++ b/dali/internal/update/common/property-condition-variable-step-functions.h @@ -65,20 +65,28 @@ private: static bool Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if float is Outside + * Checks if integer is Outside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** - * Checks if integer is Outside + * Checks if unsigned integer is Outside * @param[in] value The value being examined. * @param[in] arg The supplied arguments for the condition. * @return Condition result (true if condition met, false if not) */ - static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); + + /** + * Checks if float is Outside + * @param[in] value The value being examined. + * @param[in] arg The supplied arguments for the condition. + * @return Condition result (true if condition met, false if not) + */ + static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ); /** * Checks if Vector2.Length() is Outside diff --git a/dali/public-api/object/handle.h b/dali/public-api/object/handle.h index f376984..d46d7f1 100644 --- a/dali/public-api/object/handle.h +++ b/dali/public-api/object/handle.h @@ -213,6 +213,7 @@ public: * - Property::BOOLEAN * - Property::FLOAT * - Property::INTEGER + * - Property::UNSIGNED_INTEGER * - Property::VECTOR2 * - Property::VECTOR3 * - Property::VECTOR4 @@ -235,6 +236,7 @@ public: * - Property::BOOLEAN * - Property::FLOAT * - Property::INTEGER + * - Property::UNSIGNED_INTEGER * - Property::VECTOR2 * - Property::VECTOR3 * - Property::VECTOR4 diff --git a/dali/public-api/object/property-input.h b/dali/public-api/object/property-input.h index 097b013..6b21972 100644 --- a/dali/public-api/object/property-input.h +++ b/dali/public-api/object/property-input.h @@ -75,6 +75,14 @@ public: virtual const int& GetInteger() const = 0; /** + * @brief Retrieve an integer value. + * + * @pre GetType() returns Property::UNSIGNED_INTEGER. + * @return The integer value. + */ + virtual const unsigned int& GetUnsignedInteger() const = 0; + + /** * @brief Retrieve a Vector2 value. * * @pre GetType() returns Property::VECTOR2. diff --git a/dali/public-api/object/property-value.h b/dali/public-api/object/property-value.h index 62e79fd..378fba2 100644 --- a/dali/public-api/object/property-value.h +++ b/dali/public-api/object/property-value.h @@ -60,13 +60,6 @@ public: Value(bool boolValue); /** - * @brief Create a float property value. - * - * @param [in] floatValue A floating-point value. - */ - Value(float floatValue); - - /** * @brief Create an integer property value. * * @param [in] integerValue An integer value. @@ -76,11 +69,18 @@ public: /** * @brief Create an unsigned integer property value. * - * @param [in] unsignedIntegerValue An unsinged integer value. + * @param [in] unsignedIntegerValue An unsigned integer value. */ Value(unsigned int unsignedIntegerValue); /** + * @brief Create a float property value. + * + * @param [in] floatValue A floating-point value. + */ + Value(float floatValue); + + /** * @brief Create a Vector2 property value. * * @param [in] vectorValue A vector of 2 floating-point values. -- 2.7.4