From 394f74e6f168f034f7ed73e3027e4ff07f6b94b9 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Fri, 14 Aug 2020 01:18:14 +0300 Subject: add bounciness velocity and density options to physics animations Adding new xml options to specify the starting velocity, bounciness, and density of the rigid body that physics animation control. Change-Id: Ifaba785e82c8ee17be00711a3e7a75257e7704ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101141 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- animations/source/animcore/animcore.cxx | 87 +++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 3 deletions(-) (limited to 'animations/source') diff --git a/animations/source/animcore/animcore.cxx b/animations/source/animcore/animcore.cxx index 88e42772936a..107353cf327a 100644 --- a/animations/source/animcore/animcore.cxx +++ b/animations/source/animcore/animcore.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,7 @@ namespace animcore namespace { class AnimationNodeBase : public XAnimateMotion, + public XAnimatePhysics, public XAnimateColor, public XTransitionFilter, public XAnimateSet, @@ -224,6 +226,16 @@ public: virtual Any SAL_CALL getOrigin() override; virtual void SAL_CALL setOrigin( const Any& _origin ) override; + // XAnimatePhysics + virtual Any SAL_CALL getStartVelocityX() override; + virtual void SAL_CALL setStartVelocityX( const Any& _startvelocityx ) override; + virtual Any SAL_CALL getStartVelocityY() override; + virtual void SAL_CALL setStartVelocityY( const Any& _startvelocityy ) override; + virtual Any SAL_CALL getDensity() override; + virtual void SAL_CALL setDensity( const Any& _density ) override; + virtual Any SAL_CALL getBounciness() override; + virtual void SAL_CALL setBounciness( const Any& _bounciness ) override; + // XAnimateTransform virtual sal_Int16 SAL_CALL getTransformType() override; virtual void SAL_CALL setTransformType( sal_Int16 _transformtype ) override; @@ -322,6 +334,9 @@ private: // attributes for XAnimateMotion Any maPath, maOrigin; + // attributes for XAnimatePhysics + Any maStartVelocityX, maStartVelocityY, maDensity, maBounciness; + // attributes for XAnimateTransform sal_Int16 mnTransformType; @@ -671,8 +686,8 @@ Any SAL_CALL AnimationNode::queryInterface( const Type& aType ) case AnimationNodeType::ANIMATEPHYSICS: aRet = ::cppu::queryInterface( aType, - static_cast< XAnimate * >( static_cast< XAnimateMotion * >(this) ), - static_cast< XAnimateMotion * >( this ) ); + static_cast< XAnimate * >( static_cast< XAnimatePhysics * >(this) ), + static_cast< XAnimatePhysics * >( this ) ); break; case AnimationNodeType::ANIMATECOLOR: aRet = ::cppu::queryInterface( @@ -767,7 +782,7 @@ void AnimationNode::initTypeProvider( sal_Int16 nNodeType ) throw() pTypeAr[nPos++] = cppu::UnoType::get(); break; case AnimationNodeType::ANIMATEPHYSICS: - pTypeAr[nPos++] = cppu::UnoType::get(); + pTypeAr[nPos++] = cppu::UnoType::get(); break; case AnimationNodeType::ANIMATECOLOR: pTypeAr[nPos++] = cppu::UnoType::get(); @@ -1584,6 +1599,72 @@ void SAL_CALL AnimationNode::setOrigin( const Any& _origin ) fireChangeListener(); } +// XAnimatePhysics +Any SAL_CALL AnimationNode::getStartVelocityX() +{ + Guard< Mutex > aGuard( maMutex ); + return maStartVelocityX; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setStartVelocityX( const Any& _startvelocityx ) +{ + Guard< Mutex > aGuard( maMutex ); + maStartVelocityX = _startvelocityx; + fireChangeListener(); +} + +// XAnimatePhysics +Any SAL_CALL AnimationNode::getStartVelocityY() +{ + Guard< Mutex > aGuard( maMutex ); + return maStartVelocityY; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setStartVelocityY( const Any& _startvelocityy ) +{ + Guard< Mutex > aGuard( maMutex ); + maStartVelocityY = _startvelocityy; + fireChangeListener(); +} + + +// XAnimatePhysics +Any SAL_CALL AnimationNode::getDensity() +{ + Guard< Mutex > aGuard( maMutex ); + return maDensity; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setDensity( const Any& _density ) +{ + Guard< Mutex > aGuard( maMutex ); + maDensity = _density; + fireChangeListener(); +} + + +// XAnimatePhysics +Any SAL_CALL AnimationNode::getBounciness() +{ + Guard< Mutex > aGuard( maMutex ); + return maBounciness; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setBounciness( const Any& _bounciness ) +{ + Guard< Mutex > aGuard( maMutex ); + maBounciness = _bounciness; + fireChangeListener(); +} + // XAnimateTransform sal_Int16 SAL_CALL AnimationNode::getTransformType() -- cgit