DALI_TEST_CHECK(actor.GetTargetSize() == vector);
+ application.GetScene().Add(actor);
+
// Start the animation
animation.Play();
END_TEST;
}
+int UtcDaliAnimationPlayOffSceneP(void)
+{
+ // Test that an animation cannot be played, when the actor is off-stage.
+ // And the property value and the current property value should not be changed in the case.
+
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 basePosition(Vector3::ZERO);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+ // Not added to the stage yet!
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+
+ // 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 * 1000.0f) + 1u /*just beyond the animation duration*/);
+
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+
+ // Add to the stage
+ application.GetScene().Add(actor);
+
+ // Start the animation again
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), targetPosition, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::POSITION), targetPosition, TEST_LOCATION);
+
+ // Reset the position
+ actor[Actor::Property::POSITION] = basePosition;
+
+ application.SendNotification();
+ application.Render();
+
+ // Create an animator again
+ animation.Clear();
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+
+ // Remove from the stage
+ application.GetScene().Remove(actor);
+
+ signalReceived = false;
+
+ // Start the animation again
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*just beyond the animation duration*/);
+
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliAnimationPlayOffSceneDiscardP(void)
{
- // Test that an animation can be played, when the actor is off-stage.
+ // Test that an animation cannot be played, when the actor is off-stage.
// When the actor is added to the stage, it should appear at the current position
// i.e. where it would have been anyway, if on-stage from the beginning.
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(20, 20, 20), TEST_LOCATION);
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
// Add to the stage
application.GetScene().Add(actor);
int UtcDaliAnimationPlayOffSceneBakeFinalP(void)
{
- // Test that an animation can be played, when the actor is off-stage.
+ // Test that an animation cannot be played, when the actor is off-stage.
// When the actor is added to the stage, it should appear at the current position
// i.e. where it would have been anyway, if on-stage from the beginning.
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(20, 20, 20), TEST_LOCATION);
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
// Add to the stage
application.GetScene().Add(actor);
int UtcDaliAnimationPlayOffSceneBakeP(void)
{
- // Test that an animation can be played, when the actor is off-stage.
+ // Test that an animation cannot be played, when the actor is off-stage.
// When the actor is added to the stage, it should appear at the current position
// i.e. where it would have been anyway, if on-stage from the beginning.
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(20, 20, 20), TEST_LOCATION);
+
+ // An animation can't be played. The position shouldn't be changed.
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), basePosition, TEST_LOCATION);
// Add to the stage
application.GetScene().Add(actor);
Test::TestCustomActor custom = Test::TestCustomActor::New();
DALI_TEST_EQUALS(0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
+ application.GetScene().Add(custom);
+
Animation anim = Animation::New(1.0f);
anim.AnimateTo(Property(custom, Actor::Property::SIZE), Vector3(8.0f, 9.0f, 10.0f));
anim.Play();
application.SendNotification();
application.Render(static_cast<unsigned int>(1000.0f));
- DALI_TEST_EQUALS(1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
- DALI_TEST_EQUALS("OnSizeAnimation", custom.GetMethodsCalled()[0], TEST_LOCATION);
+ DALI_TEST_EQUALS(2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
+ DALI_TEST_EQUALS("OnSizeAnimation", custom.GetMethodsCalled()[1], TEST_LOCATION);
DALI_TEST_EQUALS(8.0f, custom.GetTargetSize().width, TEST_LOCATION);
DALI_TEST_EQUALS(9.0f, custom.GetTargetSize().height, TEST_LOCATION);
DALI_TEST_EQUALS(10.0f, custom.GetTargetSize().depth, TEST_LOCATION);
float intialWidth(10.0f);
DALI_TEST_EQUALS(0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
+
custom.SetProperty(Actor::Property::SIZE, Vector2(intialWidth, 10.0f)); // First method
+ application.GetScene().Add(custom);
Animation anim = Animation::New(1.0f);
- DALI_TEST_EQUALS(2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
+ DALI_TEST_EQUALS(3, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
anim.AnimateTo(Property(custom, Actor::Property::SIZE_WIDTH), 20.0f);
- DALI_TEST_EQUALS(2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
+ DALI_TEST_EQUALS(3, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
anim.Play(); // Triggers second method ( OnSizeAnimation )
application.SendNotification();
application.Render(static_cast<unsigned int>(1000.0f));
- DALI_TEST_EQUALS(3, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
+ DALI_TEST_EQUALS(4, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION);
- DALI_TEST_EQUALS("OnSizeAnimation", custom.GetMethodsCalled()[2], TEST_LOCATION);
+ DALI_TEST_EQUALS("OnSizeAnimation", custom.GetMethodsCalled()[3], TEST_LOCATION);
END_TEST;
}
unsigned int customActorIndices = indices.Size();
DALI_TEST_EQUALS(actorIndices + 3u, customActorIndices, TEST_LOCATION); // Custom property + registered property
+ application.GetScene().Add(customActor);
+
// Attempt to animate component property, it should not crash
Animation animation = Animation::New(1.0f);
animation.AnimateTo(Property(customActor, animatablePropertyComponentIndex1), 200.0f);
BaseHandle handle = typeInfo.CreateInstance();
DALI_TEST_CHECK(handle);
Actor customActor = Actor::DownCast(handle);
+ application.GetScene().Add(customActor);
DALI_TEST_CHECK(customActor);
const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
BaseHandle handle = typeInfo.CreateInstance();
DALI_TEST_CHECK(handle);
Actor customActor = Actor::DownCast(handle);
+ application.GetScene().Add(customActor);
DALI_TEST_CHECK(customActor);
const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
BaseHandle handle = typeInfo.CreateInstance();
DALI_TEST_CHECK(handle);
Actor customActor = Actor::DownCast(handle);
+ application.GetScene().Add(customActor);
DALI_TEST_CHECK(customActor);
const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
return componentIndex;
}
+bool Actor::IsAnimationPossible() const
+{
+ return OnScene();
+}
+
void Actor::SetParent( Actor* parent )
{
if( parent )
int32_t GetPropertyComponentIndex( Property::Index index ) const override;
/**
+ * @copydoc Dali::Internal::Object::IsAnimationPossible()
+ */
+ bool IsAnimationPossible() const override;
+
+ /**
* Retrieve the actor's node.
* @return The node used by this actor
*/
AnimatorConnectorBase* connector = mConnectors[ iter->connectorIndex ];
Object* object = connector->GetObject();
- if( object )
+ if(object && object->IsAnimationPossible())
{
const auto propertyIndex = connector->GetPropertyIndex();
object->NotifyPropertyAnimation(
virtual int32_t GetPropertyComponentIndex( Property::Index index ) const;
/**
+ * Query whether playing an animation is possible or not.
+ * @return true if playing an animation is possible.
+ */
+ virtual bool IsAnimationPossible() const
+ {
+ return true;
+ }
+
+ /**
* @copydoc Dali::Handle::PropertySetSignal()
*/
Handle::PropertySetSignalType& PropertySetSignal();
{
mConnectedToSceneGraph = true;
mPropertyOwner->AddObserver(*this);
+
+ // Enable if the target object is valid and connected to the scene graph.
+ mEnabled = mPropertyOwner->IsAnimationPossible();
}
/**
void PropertyOwner::ConnectToSceneGraph()
{
+ mIsConnectedToSceneGraph = true;
+
// Notification for observers
const ConstObserverIter endIter = mObservers.End();
for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex )
{
+ mIsConnectedToSceneGraph = false;
+
// Notification for observers
const ConstObserverIter endIter = mObservers.End();
for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
}
PropertyOwner::PropertyOwner()
-: mUpdated( false )
+: mUpdated(false),
+ mIsConnectedToSceneGraph(false)
{
}
*/
void RemoveUniformMapObserver( UniformMap::Observer& observer );
+ /**
+ * Query whether playing an animation is possible or not.
+ * @return true if playing an animation is possible.
+ */
+ virtual bool IsAnimationPossible() const
+ {
+ return true;
+ }
protected:
OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
UniformMap mUniformMaps; ///< Container of owned uniform maps
bool mUpdated;
+ bool mIsConnectedToSceneGraph;
private:
using ObserverContainer = Dali::Vector<PropertyOwner::Observer*>;
mRegenerateUniformMap = 2;
}
+bool Node::IsAnimationPossible() const
+{
+ return mIsConnectedToSceneGraph;
+}
+
void Node::PrepareRender( BufferIndex bufferIndex )
{
if( mRegenerateUniformMap != 0 )
void RemoveUniformMapping( const std::string& uniformName ) override;
/**
+ * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
+ */
+ bool IsAnimationPossible() const override;
+
+ /**
* Prepare the node for rendering.
* This is called by the UpdateManager when an object is due to be rendered in the current frame.
* @param[in] updateBufferIndex The current update buffer index.