#include <dali/internal/event/effects/shader-effect-impl.h>
#include <dali/internal/event/common/thread-local-storage.h>
-using namespace std;
-
using Dali::Internal::SceneGraph::UpdateManager;
using Dali::Internal::SceneGraph::AnimatorBase;
using Dali::Internal::SceneGraph::Shader;
TypeAction action2( mType, Dali::Animation::ACTION_STOP, &Animation::DoAction );
TypeAction action3( mType, Dali::Animation::ACTION_PAUSE, &Animation::DoAction );
+const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::Bake );
+const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BakeFinal );
+const Dali::Animation::Interpolation DEFAULT_INTERPOLATION( Dali::Animation::Linear );
+
} // anon namespace
AnimationPtr Animation::New(float durationSeconds)
{
- return New(durationSeconds, Dali::Animation::Bake, Dali::Animation::Bake, Dali::AlphaFunctions::Linear);
-}
-
-AnimationPtr Animation::New(float durationSeconds, EndAction endAction, EndAction destroyAction)
-{
- return New(durationSeconds, endAction, destroyAction, Dali::AlphaFunctions::Linear);
-}
-
-AnimationPtr Animation::New(float durationSeconds, EndAction endAction, EndAction destroyAction, AlphaFunction alpha)
-{
ThreadLocalStorage& tls = ThreadLocalStorage::Get();
UpdateManager& updateManager = tls.GetUpdateManager();
AnimationPlaylist& playlist = Stage::GetCurrent()->GetAnimationPlaylist();
- AnimationPtr progress = new Animation( updateManager, playlist, durationSeconds, endAction, destroyAction, alpha );
+ AnimationPtr animation = new Animation( updateManager, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, Dali::AlphaFunctions::Linear );
// Second-phase construction
- progress->Initialize();
+ animation->Initialize();
- return progress;
+ return animation;
}
-Animation::Animation( UpdateManager& updateManager, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction destroyAction, AlphaFunction defaultAlpha )
+Animation::Animation( UpdateManager& updateManager, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
: mUpdateManager( updateManager ),
mPlaylist( playlist ),
mAnimation( NULL ),
mFinishedCallback( NULL ),
mFinishedCallbackObject( NULL ),
mDurationSeconds( durationSeconds ),
+ mSpeedFactor(1.0f),
mIsLooping( false ),
+ mPlayRange( Vector2(0.0f,1.0f)),
mEndAction( endAction ),
- mDestroyAction( destroyAction ),
+ mDisconnectAction( disconnectAction ),
mDefaultAlpha( defaultAlpha )
{
}
DALI_ASSERT_DEBUG( mAnimation == NULL );
// Create a new animation, temporarily owned
- SceneGraph::Animation* animation = SceneGraph::Animation::New( mDurationSeconds, mIsLooping, mEndAction, mDestroyAction );
+ SceneGraph::Animation* animation = SceneGraph::Animation::New( mDurationSeconds, mSpeedFactor, mPlayRange, mIsLooping, mEndAction, mDisconnectAction );
// Keep a const pointer to the animation.
mAnimation = animation;
return mEndAction;
}
-void Animation::SetDestroyAction(EndAction action)
+void Animation::SetDisconnectAction(EndAction action)
{
// Cache for public getters
- mDestroyAction = action;
+ mDisconnectAction = action;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetDestroyActionMessage( mUpdateManager.GetEventToUpdate(), *mAnimation, action );
+ SetDisconnectActionMessage( mUpdateManager.GetEventToUpdate(), *mAnimation, action );
}
-Dali::Animation::EndAction Animation::GetDestroyAction() const
+Dali::Animation::EndAction Animation::GetDisconnectAction() const
{
// This is not animatable; the cached value is up-to-date.
- return mDestroyAction;
+ return mDisconnectAction;
}
void Animation::Play()
void Animation::PlayFrom( float progress )
{
- if( progress >= 0.0f && progress <= 1.0f )
+ if( progress >= mPlayRange.x && progress <= mPlayRange.y )
{
// Update the current playlist
mPlaylist.OnPlay( *this );
{
ProxyObject& proxy = dynamic_cast<ProxyObject&>( GetImplementation(target.object) );
+ ExtendDuration( period );
+
switch ( relativeValue.GetType() )
{
case Property::BOOLEAN:
}
DALI_ASSERT_ALWAYS( type == destinationValue.GetType() && "DestinationValue does not match Target Property type" );
+ ExtendDuration( period );
+
switch (destinationValue.GetType())
{
case Property::BOOLEAN:
if ( maybeActor )
{
// Notify the actor that its size is being animated
- maybeActor->OnSizeAnimation( *this, destinationValue.Get<Vector3>() );
+ maybeActor->NotifySizeAnimation( *this, destinationValue.Get<Vector3>() );
}
}
void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames)
{
- AnimateBetween(target, keyFrames, mDefaultAlpha, mDurationSeconds);
+ AnimateBetween(target, keyFrames, mDefaultAlpha, mDurationSeconds, DEFAULT_INTERPOLATION );
+}
+
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation )
+{
+ AnimateBetween(target, keyFrames, mDefaultAlpha, mDurationSeconds, interpolation );
}
void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period)
{
- AnimateBetween(target, keyFrames, mDefaultAlpha, period);
+ AnimateBetween(target, keyFrames, mDefaultAlpha, period, DEFAULT_INTERPOLATION);
+}
+
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
+{
+ AnimateBetween(target, keyFrames, mDefaultAlpha, period, interpolation);
}
void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha)
{
- AnimateBetween(target, keyFrames, alpha, mDurationSeconds);
+ AnimateBetween(target, keyFrames, alpha, mDurationSeconds, DEFAULT_INTERPOLATION);
+}
+
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
+{
+ AnimateBetween(target, keyFrames, alpha, mDurationSeconds, interpolation);
}
void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
{
+ AnimateBetween(target, keyFrames, alpha, period, DEFAULT_INTERPOLATION);
+}
+
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
+{
ProxyObject& proxy = dynamic_cast<ProxyObject&>( GetImplementation(target.object) );
+ ExtendDuration( period );
+
switch(keyFrames.GetType())
{
case Dali::Property::BOOLEAN:
AddAnimatorConnector( AnimatorConnector<float>::New( proxy,
target.propertyIndex,
target.componentIndex,
- KeyFrameNumberFunctor(kfCopy),
+ KeyFrameNumberFunctor(kfCopy,interpolation),
alpha,
period ) );
break;
AddAnimatorConnector( AnimatorConnector<int>::New( proxy,
target.propertyIndex,
target.componentIndex,
- KeyFrameIntegerFunctor(kfCopy),
+ KeyFrameIntegerFunctor(kfCopy,interpolation),
alpha,
period ) );
break;
AddAnimatorConnector( AnimatorConnector<Vector2>::New( proxy,
target.propertyIndex,
target.componentIndex,
- KeyFrameVector2Functor(kfCopy),
+ KeyFrameVector2Functor(kfCopy,interpolation),
alpha,
period ) );
break;
AddAnimatorConnector( AnimatorConnector<Vector3>::New( proxy,
target.propertyIndex,
target.componentIndex,
- KeyFrameVector3Functor(kfCopy),
+ KeyFrameVector3Functor(kfCopy,interpolation),
alpha,
period ) );
break;
AddAnimatorConnector( AnimatorConnector<Vector4>::New( proxy,
target.propertyIndex,
target.componentIndex,
- KeyFrameVector4Functor(kfCopy),
+ KeyFrameVector4Functor(kfCopy,interpolation),
alpha,
period ) );
break;
}
}
-void Animation::Animate( Property& target, Property::Type targetType, AnyFunction& func )
-{
- Animate( target, targetType, func, mDefaultAlpha, mDurationSeconds );
-}
-
-void Animation::Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha )
-{
- Animate( target, targetType, func, alpha, mDurationSeconds );
-}
-
-void Animation::Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period )
-{
- Animate( target, targetType, func, mDefaultAlpha, period );
-}
-
-void Animation::Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period )
-{
- Property::Type type = target.object.GetPropertyType(target.propertyIndex);
- if(target.componentIndex != Property::INVALID_COMPONENT_INDEX)
- {
- if( type == Property::VECTOR2
- || type == Property::VECTOR3
- || type == Property::VECTOR4 )
- {
- type = Property::FLOAT;
- }
- }
- DALI_ASSERT_ALWAYS( type == targetType && "Animation function must match target property type" );
-
- ProxyObject& proxy = dynamic_cast<ProxyObject&>( GetImplementation(target.object) );
-
- switch ( targetType )
- {
- case Property::BOOLEAN:
- {
- AddAnimatorConnector( AnimatorConnector<bool>::New(proxy,
- target.propertyIndex,
- target.componentIndex,
- AnyCast< AnimatorFunctionBool >( func ),
- alpha,
- period) );
- break;
- }
-
- case Property::FLOAT:
- {
- AddAnimatorConnector( AnimatorConnector<float>::New(proxy,
- target.propertyIndex,
- target.componentIndex,
- AnyCast< AnimatorFunctionFloat >( func ),
- alpha,
- period) );
- 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,
- target.propertyIndex,
- target.componentIndex,
- AnyCast< AnimatorFunctionVector2 >( func ),
- alpha,
- period) );
- break;
- }
-
- case Property::VECTOR3:
- {
- AddAnimatorConnector( AnimatorConnector<Vector3>::New(proxy,
- target.propertyIndex,
- target.componentIndex,
- AnyCast< AnimatorFunctionVector3 >( func ),
- alpha,
- period) );
- break;
- }
-
- case Property::VECTOR4:
- {
- AddAnimatorConnector( AnimatorConnector<Vector4>::New(proxy,
- target.propertyIndex,
- target.componentIndex,
- AnyCast< AnimatorFunctionVector4 >( func ),
- alpha,
- period) );
- break;
- }
-
- case Property::ROTATION:
- {
- AddAnimatorConnector( AnimatorConnector<Quaternion>::New(proxy,
- target.propertyIndex,
- target.componentIndex,
- AnyCast< AnimatorFunctionQuaternion >( func ),
- alpha,
- period) );
- break;
- }
-
- default:
- DALI_ASSERT_ALWAYS(false && "Property type enumeration out of bounds" ); // should never come here
- break;
- }
-}
-
bool Animation::HasFinished()
{
bool hasFinished(false);
mConnectors.PushBack( connector );
}
+void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward )
+{
+ Animate( actor, path, forward, mDefaultAlpha, TimePeriod(0.0f,GetDuration()) );
+}
+
+void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha )
+{
+ Animate( actor, path, forward, alpha, TimePeriod(0.0f,GetDuration()) );
+}
+
+void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, TimePeriod period )
+{
+ Animate( actor, path, forward, mDefaultAlpha, period );
+}
+
+void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
+{
+ ExtendDuration( period );
+
+ PathPtr pathCopy = Path::Clone(path);
+
+ //Position animation
+ AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
+ Dali::Actor::POSITION,
+ Property::INVALID_COMPONENT_INDEX,
+ PathPositionFunctor( pathCopy ),
+ alpha,
+ period ) );
+
+ //If forward is zero, PathRotationFunctor will always return the unit quaternion
+ if( forward != Vector3::ZERO )
+ {
+ //Rotation animation
+ AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
+ Dali::Actor::ROTATION,
+ Property::INVALID_COMPONENT_INDEX,
+ PathRotationFunctor( pathCopy, forward ),
+ alpha,
+ period ) );
+ }
+}
+
void Animation::MoveBy(Actor& actor, float x, float y, float z)
{
MoveBy(actor, Vector3(x, y, z), mDefaultAlpha, 0.0f, GetDuration());
void Animation::MoveBy(Actor& actor, const Vector3& displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::POSITION,
Property::INVALID_COMPONENT_INDEX,
void Animation::MoveTo(Actor& actor, const Vector3& position, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
- AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
- Dali::Actor::POSITION,
- Property::INVALID_COMPONENT_INDEX,
- AnimateToVector3(position),
- alpha,
- TimePeriod(delaySeconds, durationSeconds) ) );
-}
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
-void Animation::Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds)
-{
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::POSITION,
Property::INVALID_COMPONENT_INDEX,
- func,
+ AnimateToVector3(position),
alpha,
TimePeriod(delaySeconds, durationSeconds) ) );
}
void Animation::RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
Dali::Actor::ROTATION,
Property::INVALID_COMPONENT_INDEX,
void Animation::RotateTo(Actor& actor, const Quaternion& rotation, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
- AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
- Dali::Actor::ROTATION,
- Property::INVALID_COMPONENT_INDEX,
- RotateToQuaternion(rotation),
- alpha,
- TimePeriod(delaySeconds, durationSeconds) ) );
-}
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
-void Animation::Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds)
-{
AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
Dali::Actor::ROTATION,
Property::INVALID_COMPONENT_INDEX,
- func,
+ RotateToQuaternion(rotation),
alpha,
TimePeriod(delaySeconds, durationSeconds) ) );
}
void Animation::ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::SCALE,
Property::INVALID_COMPONENT_INDEX,
void Animation::ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::SCALE,
Property::INVALID_COMPONENT_INDEX,
void Animation::Show(Actor& actor, float delaySeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, 0) );
+
AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
Dali::Actor::VISIBLE,
Property::INVALID_COMPONENT_INDEX,
void Animation::Hide(Actor& actor, float delaySeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, 0) );
+
AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
Dali::Actor::VISIBLE,
Property::INVALID_COMPONENT_INDEX,
void Animation::OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Vector4>::New( actor,
Dali::Actor::COLOR,
Property::INVALID_COMPONENT_INDEX,
void Animation::OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Vector4>::New( actor,
Dali::Actor::COLOR,
Property::INVALID_COMPONENT_INDEX,
void Animation::ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Vector4>::New( actor,
Dali::Actor::COLOR,
Property::INVALID_COMPONENT_INDEX,
void Animation::ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
AddAnimatorConnector( AnimatorConnector<Vector4>::New( actor,
Dali::Actor::COLOR,
Property::INVALID_COMPONENT_INDEX,
void Animation::Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
- Vector3 targetSize( width, height, min(width, height) );
+ Vector3 targetSize( width, height, std::min(width, height) );
+
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
- // notify the actor impl that its size is being animated
- actor.OnSizeAnimation( *this, targetSize );
+ // Notify the actor impl that its size is being animated
+ actor.NotifySizeAnimation( *this, targetSize );
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::SIZE,
void Animation::Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds)
{
- // notify the actor impl that its size is being animated
- actor.OnSizeAnimation( *this, size );
+ ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
+
+ // Notify the actor impl that its size is being animated
+ actor.NotifySizeAnimation( *this, size );
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::SIZE,
TimePeriod(delaySeconds, durationSeconds) ) );
}
-void Animation::ParentOriginTo(Actor& actor, const Vector3& parentOrigin)
-{
- ParentOriginTo(actor, parentOrigin, mDefaultAlpha, 0.0f, GetDuration());
-}
-
-void Animation::ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha)
-{
- ParentOriginTo(actor, parentOrigin, alpha, 0.0f, GetDuration());
-}
-
-void Animation::ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha, float delaySeconds, float durationSeconds)
-{
- AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
- Dali::Actor::PARENT_ORIGIN,
- Property::INVALID_COMPONENT_INDEX,
- AnimateToVector3(parentOrigin),
- alpha,
- TimePeriod(delaySeconds, durationSeconds) ) );
-}
-
-void Animation::AnchorPointTo(Actor& actor, const Vector3& anchorPoint)
-{
- AnchorPointTo(actor, anchorPoint, mDefaultAlpha, 0.0f, GetDuration());
-}
-
-void Animation::AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha)
-{
- AnchorPointTo(actor, anchorPoint, alpha, 0.0f, GetDuration());
-}
-
-void Animation::AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha, float delaySeconds, float durationSeconds)
-{
- AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
- Dali::Actor::ANCHOR_POINT,
- Property::INVALID_COMPONENT_INDEX,
- AnimateToVector3(anchorPoint),
- alpha,
- TimePeriod(delaySeconds, durationSeconds) ) );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value )
-{
- AnimateProperty( shaderEffect, name, value, GetDefaultAlphaFunction(), 0, GetDuration() );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha )
-{
- AnimateProperty( shaderEffect, name, value, alpha, 0, GetDuration() );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
-{
- Property::Value propertyValue( value );
-
- // Register the property if it does not exist
- Property::Index index = shaderEffect.GetPropertyIndex( name );
- if ( Property::INVALID_INDEX == index )
- {
- index = shaderEffect.RegisterProperty( name, propertyValue );
- }
-
- AnimateTo( shaderEffect, index, Property::INVALID_COMPONENT_INDEX, propertyValue, alpha, TimePeriod(delaySeconds, durationSeconds) );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector2 value )
-{
- AnimateProperty( shaderEffect, name, value, GetDefaultAlphaFunction(), 0, GetDuration());
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha )
-{
- AnimateProperty( shaderEffect, name, value, alpha, 0, GetDuration() );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
-{
- Property::Value propertyValue( value );
-
- // Register the property if it does not exist
- Property::Index index = shaderEffect.GetPropertyIndex( name );
- if ( Property::INVALID_INDEX == index )
- {
- index = shaderEffect.RegisterProperty( name, propertyValue );
- }
-
- AnimateTo( shaderEffect, index, Property::INVALID_COMPONENT_INDEX, propertyValue, alpha, TimePeriod(delaySeconds, durationSeconds) );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector3 value )
-{
- AnimateProperty( shaderEffect, name, value, GetDefaultAlphaFunction(), 0, GetDuration() );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha )
-{
- AnimateProperty( shaderEffect, name, value, alpha, 0, GetDuration() );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
-{
- Property::Value propertyValue( value );
-
- // Register the property if it does not exist
- Property::Index index = shaderEffect.GetPropertyIndex( name );
- if ( Property::INVALID_INDEX == index )
- {
- index = shaderEffect.RegisterProperty( name, propertyValue );
- }
-
- AnimateTo( shaderEffect, index, Property::INVALID_COMPONENT_INDEX, propertyValue, alpha, TimePeriod(delaySeconds, durationSeconds) );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector4 value )
-{
- AnimateProperty( shaderEffect, name, value, GetDefaultAlphaFunction(), 0, GetDuration() );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha )
-{
- AnimateProperty( shaderEffect, name, value, alpha, 0, GetDuration() );
-}
-
-void Animation::AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
-{
- Property::Value propertyValue( value );
-
- // Register the property if it does not exist
- Property::Index index = shaderEffect.GetPropertyIndex( name );
- if ( Property::INVALID_INDEX == index )
- {
- index = shaderEffect.RegisterProperty( name, propertyValue );
- }
-
- AnimateTo( shaderEffect, index, Property::INVALID_COMPONENT_INDEX, propertyValue, alpha, TimePeriod(delaySeconds, durationSeconds) );
-}
-
bool Animation::DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes)
{
bool done = false;
return done;
}
+void Animation::SetCurrentProgress(float progress)
+{
+ if( mAnimation && progress >= mPlayRange.x && progress <= mPlayRange.y )
+ {
+ // mAnimation is being used in a separate thread; queue a message to set the current progress
+ SetCurrentProgressMessage( mUpdateManager.GetEventToUpdate(), *mAnimation, progress );
+ }
+}
+
float Animation::GetCurrentProgress()
{
if( mAnimation )
return 0.0f;
}
-void Animation::SetCurrentProgress(float progress)
+void Animation::ExtendDuration( const TimePeriod& timePeriod )
{
- if( mAnimation && progress >= 0.0f && progress <= 1.0f )
+ float duration = timePeriod.delaySeconds + timePeriod.durationSeconds;
+
+ if( duration > mDurationSeconds )
{
- // mAnimation is being used in a separate thread; queue a message to set the current progress
- SetCurrentProgressMessage( mUpdateManager.GetEventToUpdate(), *mAnimation, progress );
+ SetDuration( duration );
+ }
+}
+
+void Animation::SetSpeedFactor( float factor )
+{
+ if( mAnimation )
+ {
+ mSpeedFactor = factor;
+ SetSpeedFactorMessage( mUpdateManager.GetEventToUpdate(), *mAnimation, factor );
}
}
+float Animation::GetSpeedFactor() const
+{
+ return mSpeedFactor;
+}
+
+void Animation::SetPlayRange( const Vector2& range)
+{
+ //Make sure the range specified is between 0.0 and 1.0
+ if( range.x >= 0.0f && range.x <= 1.0f && range.y >= 0.0f && range.y <= 1.0f )
+ {
+ Vector2 orderedRange( range );
+ //If the range is not in order swap values
+ if( range.x > range.y )
+ {
+ orderedRange = Vector2(range.y, range.x);
+ }
+
+ // Cache for public getters
+ mPlayRange = orderedRange;
+
+ // mAnimation is being used in a separate thread; queue a message to set play range
+ SetPlayRangeMessage( mUpdateManager.GetEventToUpdate(), *mAnimation, orderedRange );
+ }
+}
+
+Vector2 Animation::GetPlayRange() const
+{
+ return mPlayRange;
+}
+
+
} // namespace Internal
} // namespace Dali