#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;
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
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 );
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) );
-
- ExtendDuration( period );
-
- 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());
TimePeriod(delaySeconds, durationSeconds) ) );
}
-void Animation::Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds)
-{
- ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
-
- AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
- Dali::Actor::POSITION,
- Property::INVALID_COMPONENT_INDEX,
- func,
- alpha,
- TimePeriod(delaySeconds, durationSeconds) ) );
-}
-
void Animation::RotateBy(Actor& actor, Radian angle, const Vector3& axis)
{
RotateBy(actor, angle, axis, mDefaultAlpha, 0.0f, GetDuration());
TimePeriod(delaySeconds, durationSeconds) ) );
}
-void Animation::Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds)
-{
- ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
-
- AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
- Dali::Actor::ROTATION,
- Property::INVALID_COMPONENT_INDEX,
- func,
- alpha,
- TimePeriod(delaySeconds, durationSeconds) ) );
-}
-
void Animation::ScaleBy(Actor& actor, float x, float y, float z)
{
ScaleBy(actor, Vector3(x, y, z), mDefaultAlpha, 0.0f, GetDuration());
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) );