float mEnd;
};
+struct AnimateIntegerTestFunctor
+{
+ AnimateIntegerTestFunctor( int start, int end )
+ : mStart( start ),
+ mEnd( end )
+ {
+ }
+
+ int operator()( float alpha, const int& current )
+ {
+ return static_cast<int>( mStart + ((mEnd - mStart) * alpha ) + 0.5f );
+ }
+
+ int mStart;
+ int mEnd;
+};
+
struct AnimateVector2TestFunctor
{
AnimateVector2TestFunctor( Vector2 start, Vector2 end )
END_TEST;
}
+int UtcDaliAnimationAnimateByInteger(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(1);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(50);
+ int relativeValue(targetValue - startValue);
+ animation.AnimateBy(Property(actor, index), relativeValue);
+
+ int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByIntegerAlphaFunction(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(1);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(90);
+ int relativeValue(targetValue - startValue);
+ animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut);
+
+ int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+
+ // The position should have moved more, than with a linear alpha function
+ int current(actor.GetProperty<int>(index));
+ DALI_TEST_CHECK( current > ninetyFivePercentProgress );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByIntegerTimePeriod(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(30);
+ int relativeValue(targetValue - startValue);
+ float delay = 0.5f;
+ animation.AnimateBy(Property(actor, index),
+ relativeValue,
+ TimePeriod(delay, durationSeconds - delay));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriod(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(30);
+ int relativeValue(targetValue - startValue);
+ float delay = 0.5f;
+ animation.AnimateBy(Property(actor, index),
+ relativeValue,
+ AlphaFunctions::Linear,
+ TimePeriod(delay, durationSeconds - delay));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliAnimationAnimateByVector2(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliAnimationAnimateToInteger(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(2.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(50);
+ int relativeValue(targetValue - startValue);
+ animation.AnimateTo(Property(actor, "test-property"), targetValue);
+
+ int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), ninetyFivePercentProgress, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateToIntegerAlphaFunction(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(90);
+ int relativeValue(targetValue - startValue);
+ animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut);
+
+ int ninetyFivePercentProgress(static_cast<int>(startValue + relativeValue*0.95f + 0.5f));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*950.0f)/* 95% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+
+ // The position should have moved more, than with a linear alpha function
+ int current(actor.GetProperty<int>(index));
+ DALI_TEST_CHECK( current > ninetyFivePercentProgress );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateToIntegerTimePeriod(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(30);
+ int relativeValue(targetValue - startValue);
+ float delay = 0.5f;
+ animation.AnimateTo(Property(actor, index),
+ targetValue,
+ TimePeriod(delay, durationSeconds - delay));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriod(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetValue(30);
+ int relativeValue(targetValue - startValue);
+ float delay = 0.5f;
+ animation.AnimateTo(Property(actor, index),
+ targetValue,
+ AlphaFunctions::Linear,
+ TimePeriod(delay, durationSeconds - delay));
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), static_cast<int>(startValue+(relativeValue*0.5f)+0.5f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetValue, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliAnimationAnimateToVector2(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliAnimationAnimateInteger(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Register an integer property
+ int startValue(10);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ // Build the animation
+ float durationSeconds(10.0f);
+ Animation animation = Animation::New(durationSeconds);
+ int targetPosition(0);
+ AnimateIntegerTestFunctor func( 100, targetPosition );
+ animation.Animate<int>( Property(actor, index), func );
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 75, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 50, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 25, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), targetPosition, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliAnimationAnimateVector2(void)
{
TestApplication application;
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 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 ) {}
const float& GetFloat() const { return mFloatData; }
+ const int& GetInteger() const { return mIntData; }
+
const Vector2& GetVector2() const { return mVector2Data; }
const Vector3& GetVector3() const { return mVector3Data; }
const Vector4& GetVector4() const { return mVector4Data; }
Dali::Property::Type mType;
bool mBoolData;
float mFloatData;
+ int mIntData;
Vector2 mVector2Data;
Vector3 mVector3Data;
Vector4 mVector4Data;
}
};
-struct TestAlwaysEqualOrGreaterThanConstraint
+struct TestAlwaysEqualOrGreaterThanConstraintFloat
{
- TestAlwaysEqualOrGreaterThanConstraint( float value )
+ TestAlwaysEqualOrGreaterThanConstraintFloat( float value )
: mValue( value )
{
}
float mValue;
};
+struct TestAlwaysEqualOrGreaterThanConstraintInteger
+{
+ TestAlwaysEqualOrGreaterThanConstraintInteger( int value )
+ : mValue( value )
+ {
+ }
+
+ int operator()( const int& current )
+ {
+ return ( current < mValue ) ? mValue : current;
+ }
+
+ int mValue;
+};
+
struct TestAlwaysEqualOrGreaterThanConstraintVector2
{
TestAlwaysEqualOrGreaterThanConstraintVector2( Vector2 value )
float mValue;
};
+struct TestConstraintInteger
+{
+ TestConstraintInteger( int value )
+ : mValue( value )
+ {
+ }
+
+ int operator()( const int& current )
+ {
+ return mValue;
+ }
+
+ int mValue;
+};
+
struct TestConstraintVector2
{
TestConstraintVector2( Vector2 value )
// Apply constraint
float minValue( 2.0f );
- Constraint constraint = Constraint::New<float>( index, TestAlwaysEqualOrGreaterThanConstraint( minValue ) );
+ Constraint constraint = Constraint::New<float>( index, TestAlwaysEqualOrGreaterThanConstraintFloat( minValue ) );
actor.ApplyConstraint( constraint );
DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
END_TEST;
}
+int UtcDaliConstraintNewInteger(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue( 1 );
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
+
+ /**
+ * Test that the Constraint is correctly applied on a clean Node
+ */
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
+
+ // Apply constraint
+
+ int minValue( 2 );
+ Constraint constraint = Constraint::New<int>( index, TestAlwaysEqualOrGreaterThanConstraintInteger( minValue ) );
+
+ actor.ApplyConstraint( constraint );
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Constraint should be fully applied
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
+
+ // Set to greater than 2f, the constraint will allow this
+ actor.SetProperty( index, 3 );
+
+ application.SendNotification();
+ application.Render(0);
+
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 3, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 3, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 3, TEST_LOCATION );
+
+ // Set to less than 2, the constraint will NOT allow this
+ actor.SetProperty( index, 1 );
+
+ application.SendNotification();
+ application.Render(0);
+
+ DALI_TEST_EQUALS( actor.GetProperty<int>(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<int>(index), minValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), minValue, TEST_LOCATION );
+
+ // Remove the constraint, then set new value
+ actor.RemoveConstraints();
+ actor.SetProperty( index, 1 );
+
+ // Constraint should have been removed
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 1, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), 1, TEST_LOCATION );
+ END_TEST;
+
+}
+
int UtcDaliConstraintNewVector2(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliConstraintNewOffStageInteger(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(1);
+ Property::Index index = actor.RegisterProperty( "test-property", startValue );
+ DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
+
+ // Apply constraint to off-stage Actor
+ int constrainedValue( 2 );
+ Constraint constraint = Constraint::New<int>( index, TestConstraintInteger( constrainedValue ) );
+ actor.ApplyConstraint( constraint );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(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<int>(index), constrainedValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
+
+ // Take the actor off-stage
+ Stage::GetCurrent().Remove(actor);
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(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<int>(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<int>(index), constrainedValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), constrainedValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(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<int>(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<int>(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<int>(index), startValue, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliConstraintNewOffStageVector2(void)
{
TestApplication application;
// Register some dynamic properties
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 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) );
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::VECTOR2 == actor.GetPropertyType( vector2Index ) );
DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) );
DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) );
Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
+ Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE);
Property::Index nonAnimUnsignedIntIndex = actor.RegisterProperty( "unsinged-int", unsingedIntTest, Property::READ_WRITE);
DALI_TEST_CHECK( nonAnimStringIndex != Property::INVALID_INDEX );
DALI_TEST_CHECK( nonAnimV4Index != Property::INVALID_INDEX );
DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
DALI_TEST_CHECK( nonAnimFloatIndex != Property::INVALID_INDEX );
+ DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX );
DALI_TEST_CHECK( nonAnimUnsignedIntIndex != Property::INVALID_INDEX );
DALI_TEST_CHECK( Property::STRING == actor.GetPropertyType( nonAnimStringIndex ) );
DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( nonAnimV4Index ) );
DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( nonAnimBooleanIndex ) );
DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( nonAnimFloatIndex ) );
+ DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( nonAnimIntegerIndex ) );
DALI_TEST_CHECK( Property::UNSIGNED_INTEGER == actor.GetPropertyType( nonAnimUnsignedIntIndex ) );
DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
+ DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) );
DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimUnsignedIntIndex ) );
DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get<int>(), TEST_LOCATION );
DALI_TEST_EQUALS( unsingedIntTest, actor.GetProperty( nonAnimUnsignedIntIndex ).Get<unsigned int>(), TEST_LOCATION );
END_TEST;
break;
}
+ case Property::INTEGER:
+ {
+ AnimatableProperty<int>* property = dynamic_cast< 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<int>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<int>::Bake, value.Get<int>() );
+
+ break;
+ }
+
case Property::VECTOR2:
{
AnimatableProperty<Vector2>* property = dynamic_cast< AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
break;
}
+ case Property::INTEGER:
+ {
+ AddAnimatorConnector( AnimatorConnector<int>::New( proxy,
+ target.propertyIndex,
+ target.componentIndex,
+ AnimateByInteger(relativeValue.Get<int>()),
+ alpha,
+ period ) );
+ break;
+ }
+
case Property::VECTOR2:
{
AddAnimatorConnector( AnimatorConnector<Vector2>::New( proxy,
break;
}
+ case Property::INTEGER:
+ {
+ AddAnimatorConnector( AnimatorConnector<int>::New(targetObject,
+ targetPropertyIndex,
+ componentIndex,
+ AnimateToInteger(destinationValue.Get<int>()),
+ alpha,
+ period) );
+ break;
+ }
+
case Property::VECTOR2:
{
AddAnimatorConnector( AnimatorConnector<Vector2>::New(targetObject,
period ) );
break;
}
+
case Dali::Property::FLOAT:
{
const KeyFrameNumber* kf;
break;
}
+ case Dali::Property::INTEGER:
+ {
+ const KeyFrameInteger* kf;
+ GetSpecialization(keyFrames, kf);
+ KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf);
+ AddAnimatorConnector( AnimatorConnector<int>::New( proxy,
+ target.propertyIndex,
+ target.componentIndex,
+ KeyFrameIntegerFunctor(kfCopy),
+ alpha,
+ period ) );
+ break;
+ }
+
case Dali::Property::VECTOR2:
{
const KeyFrameVector2* kf;
break;
}
+ case Property::INTEGER:
+ {
+ AddAnimatorConnector( AnimatorConnector<int>::New(proxy,
+ target.propertyIndex,
+ target.componentIndex,
+ AnyCast< AnimatorFunctionInteger >( func ),
+ alpha,
+ period) );
+ break;
+ }
+
case Property::VECTOR2:
{
AddAnimatorConnector( AnimatorConnector<Vector2>::New(proxy,
break;
}
+ case Property::INTEGER:
+ {
+ PropertyConstraintPtr<int>::Type funcPtr( CreatePropertyConstraint<int>( func, sources.size() ) );
+
+ mActiveConstraintTemplate = ActiveConstraint<int>::New( targetIndex,
+ sources,
+ funcPtr,
+ AnyCast< IntegerInterpolator >( interpolator ) );
+ break;
+ }
+
case Property::VECTOR2:
{
PropertyConstraintPtr<Vector2>::Type funcPtr( CreatePropertyConstraint<Vector2>( func, sources.size() ) );
case Property::FLOAT:
mKeyFrames = Internal::KeyFrameNumber::New();
break;
+ case Property::INTEGER:
+ mKeyFrames = Internal::KeyFrameInteger::New();
+ break;
case Property::VECTOR2:
mKeyFrames = Internal::KeyFrameVector2::New();
break;
kf->AddKeyFrame(time, value.Get<float>(), alpha);
break;
}
+ case Property::INTEGER:
+ {
+ Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(mKeyFrames.Get());
+ kf->AddKeyFrame(time, value.Get<int>(), alpha);
+ break;
+ }
case Property::VECTOR2:
{
Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
typedef KeyFrameBaseSpec<float> KeyFrameNumber;
typedef KeyFrameBaseSpec<bool> KeyFrameBoolean;
+typedef KeyFrameBaseSpec<int> KeyFrameInteger;
typedef KeyFrameBaseSpec<Vector2> KeyFrameVector2;
typedef KeyFrameBaseSpec<Vector3> KeyFrameVector3;
typedef KeyFrameBaseSpec<Vector4> KeyFrameVector4;
typedef IntrusivePtr<KeyFrameBoolean> KeyFrameBooleanPtr;
typedef IntrusivePtr<KeyFrameNumber> KeyFrameNumberPtr;
+typedef IntrusivePtr<KeyFrameInteger> KeyFrameIntegerPtr;
typedef IntrusivePtr<KeyFrameVector2> KeyFrameVector2Ptr;
typedef IntrusivePtr<KeyFrameVector3> KeyFrameVector3Ptr;
typedef IntrusivePtr<KeyFrameVector4> KeyFrameVector4Ptr;
keyFrameSpec = static_cast<const Internal::KeyFrameBoolean*>(keyFrames.GetKeyFramesBase());
}
-
inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameNumber*& keyFrameSpec)
{
keyFrameSpec = static_cast<Internal::KeyFrameNumber*>(keyFrames.GetKeyFramesBase());
keyFrameSpec = static_cast<const Internal::KeyFrameNumber*>(keyFrames.GetKeyFramesBase());
}
+inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameInteger*& keyFrameSpec)
+{
+ keyFrameSpec = static_cast<Internal::KeyFrameInteger*>(keyFrames.GetKeyFramesBase());
+}
+
+inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameInteger*& keyFrameSpec)
+{
+ keyFrameSpec = static_cast<const Internal::KeyFrameInteger*>(keyFrames.GetKeyFramesBase());
+}
+
inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector2*& keyFrameSpec)
{
keyFrameSpec = static_cast<Internal::KeyFrameVector2*>(keyFrames.GetKeyFramesBase());
typedef std::vector<ProgressQuaternion> ProgressQuaternionContainer;
typedef ProgressValue<AngleAxis> ProgressAngleAxis;
-typedef std::vector<ProgressQuaternion> ProgressQuaternionContainer;
+typedef std::vector<AngleAxis> ProgressAngleAxisContainer;
typedef ProgressValue<bool> ProgressBoolean;
typedef std::vector<ProgressBoolean> ProgressBooleanContainer;
typedef ProgressValue<float> ProgressNumber;
typedef std::vector<ProgressNumber> ProgressNumberContainer;
+typedef ProgressValue<int> ProgressInteger;
+typedef std::vector<ProgressInteger> ProgressIntegerContainer;
+
typedef ProgressValue<Vector2> ProgressVector2;
typedef std::vector<ProgressVector2> ProgressVector2Container;
return (a.GetValue() + (b.GetValue() - a.GetValue()) * progress);
}
+inline int Interpolate (ProgressInteger& a, ProgressInteger& b, float progress)
+{
+ return static_cast<int>(a.GetValue() + (b.GetValue() - a.GetValue()) * progress + 0.5f);
+}
+
inline Vector2 Interpolate (ProgressVector2& a, ProgressVector2& b, float progress)
{
return (a.GetValue() + (b.GetValue() - a.GetValue()) * progress);
}
/**
+ * @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
}
/**
+ * @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::GetConstraintInputVector2()
*/
const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
}
/**
+ * @copydoc Dali::Internal::PropertyInput::GetInteger()
+ */
+ virtual const int& GetInteger() const
+ {
+ return mInput->GetConstraintInputInteger( mBufferIndex );
+ }
+
+ /**
* @copydoc Dali::Internal::PropertyInput::GetVector2()
*/
virtual const Vector2& GetVector2() const
*/
static const bool DUMMY_BOOLEAN_VALUE( false );
static const float DUMMY_FLOAT_VALUE( 0.0f );
+static const int DUMMY_INTEGER_VALUE( 0 );
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 );
}
/**
+ * Retrieve an integer value.
+ * @pre GetType() returns Property::INTEGER.
+ * @param[in] bufferIndex The buffer to read from.
+ * @return The integer value.
+ */
+ virtual const int& GetInteger( BufferIndex bufferIndex ) const
+ {
+ DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
+ return DUMMY_INTEGER_VALUE;
+ }
+
+ /**
* Retrieve a Vector2 value.
* @pre GetType() returns Property::VECTOR2.
* @param[in] bufferIndex The buffer to read from.
}
/**
+ * 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::INTEGER.
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @return The integer value.
+ */
+ virtual const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
+ {
+ return GetInteger( updateBufferIndex );
+ }
+
+ /**
* Retrieve a Vector2 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.
break;
}
+ case Property::INTEGER:
+ {
+ debugStream << GetInteger( bufferIndex );
+ break;
+ }
+
case Property::VECTOR2:
{
debugStream << GetVector2( bufferIndex );
break;
}
+ case Property::INTEGER:
+ {
+ AnimatableProperty<int>* property = dynamic_cast< AnimatableProperty<int>* >( entry->second.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
+
+ value = (*property)[ bufferIndex ];
+ break;
+ }
+
case Property::VECTOR2:
{
AnimatableProperty<Vector2>* property = dynamic_cast< AnimatableProperty<Vector2>* >( entry->second.GetSceneGraphProperty() );
break;
}
+ case Property::INTEGER:
+ {
+ newProperty.reset(new AnimatableProperty<int>( propertyValue.Get<int>()));
+ break;
+ }
+
case Property::VECTOR2:
{
newProperty.reset(new AnimatableProperty<Vector2>( propertyValue.Get<Vector2>()));
break;
}
+ case Property::INTEGER:
+ {
+ AnimatableProperty<int>* property = dynamic_cast< AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
+
+ // property is being used in a separate thread; queue a message to set the property
+ BakeMessage<int>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<int>() );
+ break;
+ }
+
case Property::VECTOR2:
{
AnimatableProperty<Vector2>* property = dynamic_cast< AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
program.SetUniform1f( loc, property.GetFloat( bufferIndex ) );
break;
}
+ case Property::INTEGER :
+ {
+ program.SetUniform1i( loc, property.GetInteger( bufferIndex ) );
+ break;
+ }
case Property::VECTOR2 :
{
Vector2 value( property.GetVector2( bufferIndex ) );
float mTarget;
};
+struct AnimateByInteger
+{
+ AnimateByInteger(const int& relativeValue)
+ : mRelative(relativeValue)
+ {
+ }
+
+ float operator()(float alpha, const int& property)
+ {
+ return int(property + mRelative * alpha + 0.5f );
+ }
+
+ int mRelative;
+};
+
+struct AnimateToInteger
+{
+ AnimateToInteger(const int& targetValue)
+ : mTarget(targetValue)
+ {
+ }
+
+ float operator()(float alpha, const int& property)
+ {
+ return int(property + ((mTarget - property) * alpha) + 0.5f);
+ }
+
+ int mTarget;
+};
+
struct AnimateByVector2
{
AnimateByVector2(const Vector2& relativeValue)
KeyFrameNumberPtr mKeyFrames;
};
+struct KeyFrameIntegerFunctor
+{
+ KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames)
+ : mKeyFrames(keyFrames)
+ {
+ }
+
+ float operator()(float progress, const int& property)
+ {
+ if(mKeyFrames->IsActive(progress))
+ {
+ return mKeyFrames->GetValue(progress);
+ }
+ return property;
+ }
+
+ KeyFrameIntegerPtr mKeyFrames;
+};
+
struct KeyFrameVector2Functor
{
KeyFrameVector2Functor(KeyFrameVector2Ptr keyFrames)
};
/**
+ * An integer animatable property of a scene-graph object.
+ */
+template <>
+class AnimatableProperty<int> : public AnimatablePropertyBase
+{
+public:
+
+ /**
+ * Create an animatable property.
+ * @param [in] initialValue The initial value of the property.
+ */
+ AnimatableProperty( int 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<int>();
+ }
+
+ /**
+ * @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::GetInteger()
+ */
+ virtual const int& GetInteger( 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, int 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, int delta)
+ {
+ mValue[bufferIndex] = mValue[bufferIndex] + delta;
+
+ OnSet();
+ }
+
+ /**
+ * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
+ */
+ int& Get(size_t bufferIndex)
+ {
+ return mValue[bufferIndex];
+ }
+
+ /**
+ * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
+ */
+ const int& Get(size_t bufferIndex) const
+ {
+ return mValue[bufferIndex];
+ }
+
+ /**
+ * Retrieve the property value.
+ * @param[in] bufferIndex The buffer to read.
+ * @return The property value.
+ */
+ int& operator[](size_t bufferIndex)
+ {
+ return mValue[bufferIndex];
+ }
+
+ /**
+ * Retrieve the property value.
+ * @param[in] bufferIndex The buffer to read.
+ * @return The property value.
+ */
+ const int& 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, int 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, int 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 int& 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 int& 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<int> mValue; ///< The double-buffered property value
+ int mBaseValue; ///< Reset to this base value at the beginning of each frame
+
+};
+
+/**
* An Vector2 animatable property of a scene-graph object.
*/
template <>
function = LessThan::EvalFloat;
break;
}
+ case Property::INTEGER:
+ {
+ function = LessThan::EvalInteger;
+ break;
+ }
case Property::VECTOR2:
{
function = LessThan::EvalVector2;
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::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
function = GreaterThan::EvalFloat;
break;
}
+ case Property::INTEGER:
+ {
+ function = GreaterThan::EvalInteger;
+ break;
+ }
case Property::VECTOR2:
{
function = GreaterThan::EvalVector2;
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::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
function = Inside::EvalFloat;
break;
}
+ case Property::INTEGER:
+ {
+ function = Inside::EvalInteger;
+ break;
+ }
case Property::VECTOR2:
{
function = Inside::EvalVector2;
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::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector2().LengthSquared();
function = Outside::EvalFloat;
break;
}
+ case Property::INTEGER:
+ {
+ function = Outside::EvalInteger;
+ break;
+ }
case Property::VECTOR2:
{
function = Outside::EvalVector2;
return ( (valueFloat < arg[0]) || (valueFloat > arg[1]) );
}
+bool Outside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const int valueInterger = value.GetInteger();
+ return ( (valueInterger < arg[0]) || (valueInterger > arg[1]) );
+}
+
bool Outside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector2().LengthSquared();
static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
+ * 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
* Checks if Vector2.Length() is LessThan
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
+ * 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
* Checks if Vector2.Length() is GreaterThan
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
+ * 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
* Checks if Vector2.Length() is Inside
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
+ * 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
* Checks if Vector2.Length() is Outside
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
function = EvalFloat;
break;
}
+ case Property::INTEGER:
+ {
+ function = EvalInteger;
+ break;
+ }
case Property::VECTOR2:
{
function = EvalVector2;
return Evaluate( propertyValue, arg );
}
+bool Step::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = static_cast<float>( value.GetInteger() );
+ return Evaluate( propertyValue, arg );
+}
+
bool Step::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float propertyValue = value.GetVector2().LengthSquared();
static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
+ * 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
* Checks if Vector2.Length() is Outside
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
function = EvalFloat;
break;
}
+ case Property::INTEGER:
+ {
+ function = EvalInteger;
+ break;
+ }
case Property::VECTOR2:
{
function = EvalVector2;
return Evaluate( propertyValue, arg );
}
+bool VariableStep::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = static_cast<float>( value.GetInteger() );
+ return Evaluate( propertyValue, arg );
+}
+
bool VariableStep::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float propertyValue = value.GetVector2().LengthSquared();
static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
+ * 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
* Checks if Vector2.Length() is Outside
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
typedef boost::function<bool (float alpha, const bool& current)> AnimatorFunctionBool; ///< Animator function signature for boolean properties.
typedef boost::function<float (float alpha, const float& current)> AnimatorFunctionFloat; ///< Animator function signature for float properties.
+typedef boost::function<int (float alpha, const int& current)> AnimatorFunctionInteger; ///< Animator function signature for integer properties.
typedef boost::function<Vector2 (float alpha, const Vector2& current)> AnimatorFunctionVector2; ///< Animator function signature for Vector2 properties.
typedef boost::function<Vector3 (float alpha, const Vector3& current)> AnimatorFunctionVector3; ///< Animator function signature for Vector3 properties.
typedef boost::function<Vector4 (float alpha, const Vector4& current)> AnimatorFunctionVector4; ///< Animator function signature for Vector4 properties.
return current + ((target - current) * progress);
}
+int LerpInteger( const int& current, const int& target, float progress )
+{
+ return static_cast<int>( current + ( (target - current) * progress ) + 0.5f );
+}
+
Vector2 LerpVector2( const Vector2& current, const Vector2& target, float progress )
{
return current + ((target - current) * progress);
break;
}
+ case Property::INTEGER:
+ {
+ function = boost::function<int (const int&, const int&, float)>( &LerpInteger );
+ break;
+ }
+
case Property::VECTOR2:
{
function = boost::function<Vector2 (const Vector2&, const Vector2&, float)>( &LerpVector2 );
float LerpFloat( const float& current, const float& target, float progress );
/**
+ * @brief Interpolate linearly between two integer values.
+ *
+ * @param [in] current The current value.
+ * @param [in] target The target value.
+ * @param [in] progress The current progress (between 0 & 1).
+ * @return The interpolated value.
+ */
+int LerpInteger( const int& current, const int& target, float progress );
+
+/**
* @brief Interpolate linearly between two Vector2 values.
*
* @param [in] current The current value.
* @param[in] progress The current progress (between 0 and 1).
* @return The interpolated value.
*/
+typedef boost::function<int (const int& start, const int& target, float progress)> IntegerInterpolator;
+
+/**
+ * @brief A function which interpolates between a start and target value.
+ *
+ * @param[in] start The start value.
+ * @param[in] target The target value.
+ * @param[in] progress The current progress (between 0 and 1).
+ * @return The interpolated value.
+ */
typedef boost::function<Vector2 (const Vector2& current, const Vector2& target, float progress)> Vector2Interpolator;
/**
virtual const float& GetFloat() const = 0;
/**
+ * @brief Retrieve an integer value.
+ *
+ * @pre GetType() returns Property::INTEGER.
+ * @return The integer value.
+ */
+ virtual const int& GetInteger() const = 0;
+
+ /**
* @brief Retrieve a Vector2 value.
*
* @pre GetType() returns Property::VECTOR2.