END_TEST;
}
+
+int UtcDaliAnimationIsPositionOrSizeCurrentlyAnimating(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
+
+ // Start the animation
+ Vector3 targetPosition(10.0f, 10.0f, 10.0f);
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+ animation.Play();
+
+ DALI_TEST_EQUALS( true, DevelActor::IsPositionOrSizeCurrentlyAnimating( actor ), TEST_LOCATION);
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+
+ DALI_TEST_EQUALS( true, DevelActor::IsPositionOrSizeCurrentlyAnimating( actor ), TEST_LOCATION);
+
+ application.Render(2u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ DALI_TEST_EQUALS( false, DevelActor::IsPositionOrSizeCurrentlyAnimating( actor ), TEST_LOCATION);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+
+ END_TEST;
+}
return GetImplementation( actor ).ChildOrderChangedSignal();
}
-
+bool IsPositionOrSizeCurrentlyAnimating( Actor actor )
+{
+ return GetImplementation( actor ).IsPositionOrSizeCurrentlyAnimating();
+}
} // namespace DevelActor
*/
DALI_CORE_API ChildOrderChangedSignalType& ChildOrderChangedSignal( Actor actor );
+/**
+ * @brief Returns weather the actor position or size are being animated
+ * @return The actor position or size are currently animating
+ */
+DALI_CORE_API bool IsPositionOrSizeCurrentlyAnimating( Actor actor );
} // namespace DevelActor
mName(),
mSortedDepth( 0u ),
mDepth( 0u ),
+ mPositionOrSizeAnimatingCount( 0 ),
mIsRoot( ROOT_LAYER == derivedType ),
mIsLayer( LAYER == derivedType || ROOT_LAYER == derivedType ),
mIsOnStage( false ),
return value;
}
-void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
{
+ switch ( index )
+ {
+ case Dali::Actor::Property::SIZE:
+ case Dali::Actor::Property::SIZE_WIDTH:
+ case Dali::Actor::Property::SIZE_HEIGHT:
+ case Dali::Actor::Property::SIZE_DEPTH:
+ case Dali::Actor::Property::POSITION:
+ case Dali::Actor::Property::POSITION_X:
+ case Dali::Actor::Property::POSITION_Y:
+ case Dali::Actor::Property::POSITION_Z:
+ {
+ mPositionOrSizeAnimatingCount += ( animationStarted ? 1 : -1 );
+ }
+ break;
+ }
+
+ if( !animationStarted )
+ {
+ return;
+ }
+
switch( animationType )
{
case Animation::TO:
}
}
+bool Actor::IsPositionOrSizeCurrentlyAnimating()
+{
+ return mPositionOrSizeAnimatingCount != 0;
+}
+
} // namespace Internal
} // namespace Dali
/**
* @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
*/
- virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+ virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
/**
* @copydoc Dali::Internal::Object::GetPropertyOwner()
*/
void LowerBelow( Internal::Actor& target );
+ /**
+ * @brief Checks if the size or position is currently animating.
+ * @return true if the actor position or size are currently animating.
+ */
+ bool IsPositionOrSizeCurrentlyAnimating();
+
private:
struct SendMessage
std::string mName; ///< Name of the actor
uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
int16_t mDepth; ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
+ int32_t mPositionOrSizeAnimatingCount; ///< The current count of ongoing animations
const bool mIsRoot : 1; ///< Flag to identify the root actor
const bool mIsLayer : 1; ///< Flag to identify that this is a layer
mState = Dali::Animation::PLAYING;
- NotifyObjects();
+ NotifyObjects( true );
SendFinalProgressNotificationMessage();
mState = Dali::Animation::PLAYING;
- NotifyObjects();
+ NotifyObjects( true );
SendFinalProgressNotificationMessage();
mState = Dali::Animation::PLAYING;
- NotifyObjects();
+ NotifyObjects( true );
SendFinalProgressNotificationMessage();
void Animation::EmitSignalFinish()
{
+ if ( !mConnectors.Empty() )
+ {
+ NotifyObjects( false );
+ }
+
if ( !mFinishedSignal.Empty() )
{
Dali::Animation handle( this );
return ( ( lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds ) < ( rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds ) );
}
-void Animation::NotifyObjects()
+void Animation::NotifyObjects( bool animationStarted )
{
if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
{
Object* object = connector->GetObject();
if( object )
{
- object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue, iter->animatorType );
+ object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue, iter->animatorType, animationStarted );
}
}
}
/**
* Notifies all the objects whose properties are being animated.
+ * @param[in] animationStarted The animation is started
*/
- void NotifyObjects();
+ void NotifyObjects( bool animationStarted );
/**
* Sends message to SceneGraph with final progress value
}
}
-void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
{
- if ( index < DEFAULT_PROPERTY_MAX_COUNT )
+ if( index < DEFAULT_PROPERTY_MAX_COUNT )
{
- OnNotifyDefaultPropertyAnimation( animation, index, value, animationType );
+ OnNotifyDefaultPropertyAnimation( animation, index, value, animationType, animationStarted );
}
else
{
- PropertyMetadata* propertyMetadata = NULL;
- if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
- {
- propertyMetadata = FindAnimatableProperty( index );
- }
- else
+ if( animationStarted )
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- if( custom && custom->IsAnimatable() )
+ PropertyMetadata* propertyMetadata = NULL;
+ if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
{
- propertyMetadata = custom;
+ propertyMetadata = FindAnimatableProperty( index );
}
- }
-
- if( propertyMetadata )
- {
- switch( animationType )
+ else
{
- case Animation::TO:
- case Animation::BETWEEN:
+ CustomPropertyMetadata* custom = FindCustomProperty( index );
+ if( custom && custom->IsAnimatable() )
{
- // Update the cached property value
- propertyMetadata->SetPropertyValue( value );
- break;
+ propertyMetadata = custom;
}
- case Animation::BY:
+ }
+
+ if( propertyMetadata )
+ {
+ switch( animationType )
{
- // Adjust the cached property value
- propertyMetadata->AdjustPropertyValueBy( value );
- break;
+ case Animation::TO:
+ case Animation::BETWEEN:
+ {
+ // Update the cached property value
+ propertyMetadata->SetPropertyValue( value );
+ break;
+ }
+ case Animation::BY:
+ {
+ // Adjust the cached property value
+ propertyMetadata->AdjustPropertyValueBy( value );
+ break;
+ }
}
}
}
* @param[in] index The index of the property.
* @param[in] value The value of the property after the animation.
* @param[in] animationType Whether the property value given is the target or a relative value.
+ * @param[in] animationStarted Whether the animation is started.
*/
- void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+ void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
/******************************** Uniform Mappings ********************************/
* @param[in] index The index of the property.
* @param[in] value The value of the property after the animation.
* @param[in] animationType Whether the property value given is the target or a relative value.
+ * @param[in] animationStarted Whether the animation is started.
*/
- virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType )
+ virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType, bool animationStarted )
{ }
/**
return value;
}
-void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
{
- switch( animationType )
+ if( animationStarted )
{
- case Animation::TO:
- case Animation::BETWEEN:
+ switch( animationType )
{
- switch ( index )
+ case Animation::TO:
+ case Animation::BETWEEN:
{
- case Dali::RenderTask::Property::VIEWPORT_POSITION:
+ switch ( index )
{
- value.Get( mViewportPosition );
- break;
- }
- case Dali::RenderTask::Property::VIEWPORT_SIZE:
- {
- value.Get( mViewportSize );
- break;
- }
- case Dali::RenderTask::Property::CLEAR_COLOR:
- {
- value.Get( mClearColor );
- break;
- }
- case Dali::RenderTask::Property::REQUIRES_SYNC:
- default:
- {
- // Nothing to do as not animatable
- break;
+ case Dali::RenderTask::Property::VIEWPORT_POSITION:
+ {
+ value.Get( mViewportPosition );
+ break;
+ }
+ case Dali::RenderTask::Property::VIEWPORT_SIZE:
+ {
+ value.Get( mViewportSize );
+ break;
+ }
+ case Dali::RenderTask::Property::CLEAR_COLOR:
+ {
+ value.Get( mClearColor );
+ break;
+ }
+ case Dali::RenderTask::Property::REQUIRES_SYNC:
+ default:
+ {
+ // Nothing to do as not animatable
+ break;
+ }
}
+ break;
}
- break;
- }
- case Animation::BY:
- {
- switch ( index )
+ case Animation::BY:
{
- case Dali::RenderTask::Property::VIEWPORT_POSITION:
- {
- AdjustValue< Vector2 >( mViewportPosition, value );
- break;
- }
- case Dali::RenderTask::Property::VIEWPORT_SIZE:
- {
- AdjustValue< Vector2 >( mViewportSize, value );
- break;
- }
- case Dali::RenderTask::Property::CLEAR_COLOR:
+ switch ( index )
{
- AdjustValue< Vector4 >( mClearColor, value );
- break;
- }
- case Dali::RenderTask::Property::REQUIRES_SYNC:
- default:
- {
- // Nothing to do as not animatable
- break;
+ case Dali::RenderTask::Property::VIEWPORT_POSITION:
+ {
+ AdjustValue< Vector2 >( mViewportPosition, value );
+ break;
+ }
+ case Dali::RenderTask::Property::VIEWPORT_SIZE:
+ {
+ AdjustValue< Vector2 >( mViewportSize, value );
+ break;
+ }
+ case Dali::RenderTask::Property::CLEAR_COLOR:
+ {
+ AdjustValue< Vector4 >( mClearColor, value );
+ break;
+ }
+ case Dali::RenderTask::Property::REQUIRES_SYNC:
+ default:
+ {
+ // Nothing to do as not animatable
+ break;
+ }
}
+ break;
}
- break;
}
}
}
/**
* @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
*/
- virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+ virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
/**
* @copydoc Dali::Internal::Object::GetSceneObject()
return value;
}
-void Renderer::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Renderer::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted )
{
- switch( animationType )
+ if( animationStarted )
{
- case Animation::TO:
- case Animation::BETWEEN:
+ switch( animationType )
{
- switch( index )
+ case Animation::TO:
+ case Animation::BETWEEN:
{
- case Dali::DevelRenderer::Property::OPACITY:
+ switch( index )
{
- value.Get( mOpacity );
- break;
+ case Dali::DevelRenderer::Property::OPACITY:
+ {
+ value.Get( mOpacity );
+ break;
+ }
}
+ break;
}
- break;
- }
- case Animation::BY:
- {
- switch( index )
+ case Animation::BY:
{
- case Dali::DevelRenderer::Property::OPACITY:
+ switch( index )
{
- AdjustValue< float >( mOpacity, value );
- break;
+ case Dali::DevelRenderer::Property::OPACITY:
+ {
+ AdjustValue< float >( mOpacity, value );
+ break;
+ }
}
+ break;
}
- break;
}
}
}
/**
* @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
*/
- virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+ virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType, bool animationStarted );
/**
* @copydoc Dali::Internal::Object::GetPropertyOwner()