summaryrefslogtreecommitdiff
path: root/slideshow/source/inc
diff options
context:
space:
mode:
authorSarper Akdemir <q.sarperakdemir@gmail.com>2020-06-11 19:29:38 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-08-09 23:44:00 +0200
commit28022cee396715bc4b474ed1571074dc721bbe13 (patch)
tree98918b687f2ebddc979083771c4614f9e7f44f7f /slideshow/source/inc
parent6ce2eddfdc35100b8079a4584dd3945e923d66a9 (diff)
make physics based animation effects part of the animation engine
Wiring up and creating required classes for physics based animation effects to be part of the animation engine. Creating a new animation node AnimationPhysicsNode for physics based animation effects and PhysicsAnimation class that inherits the NumberAnimation in the animation factory. Change-Id: I1f125df5324673e9937b8164c0fc267c9683afa0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100151 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'slideshow/source/inc')
-rw-r--r--slideshow/source/inc/animationfactory.hxx16
-rw-r--r--slideshow/source/inc/box2dtools.hxx48
-rw-r--r--slideshow/source/inc/slideshowcontext.hxx7
3 files changed, 50 insertions, 21 deletions
diff --git a/slideshow/source/inc/animationfactory.hxx b/slideshow/source/inc/animationfactory.hxx
index db24dbb55094..af3b9b9a4e49 100644
--- a/slideshow/source/inc/animationfactory.hxx
+++ b/slideshow/source/inc/animationfactory.hxx
@@ -30,6 +30,8 @@
#include "shapemanager.hxx"
+namespace box2d::utils { typedef ::std::shared_ptr< class box2DWorld > Box2DWorldSharedPtr; }
+
/* Definition of AnimationFactory class */
namespace slideshow::internal
@@ -79,18 +81,21 @@ namespace slideshow::internal
const AnimatableShapeSharedPtr& rShape,
const ShapeManagerSharedPtr& rShapeManager,
const ::basegfx::B2DVector& rSlideSize,
+ const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld,
int nFlags=0 );
EnumAnimationSharedPtr createEnumPropertyAnimation( const OUString& rAttrName,
const AnimatableShapeSharedPtr& rShape,
const ShapeManagerSharedPtr& rShapeManager,
const ::basegfx::B2DVector& rSlideSize,
+ const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld,
int nFlags );
ColorAnimationSharedPtr createColorPropertyAnimation( const OUString& rAttrName,
const AnimatableShapeSharedPtr& rShape,
const ShapeManagerSharedPtr& rShapeManager,
const ::basegfx::B2DVector& rSlideSize,
+ const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld,
int nFlags=0 );
/** Create scale or move animation
@@ -110,12 +115,14 @@ namespace slideshow::internal
const AnimatableShapeSharedPtr& rShape,
const ShapeManagerSharedPtr& rShapeManager,
const ::basegfx::B2DVector& rSlideSize,
+ const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld,
int nFlags );
BoolAnimationSharedPtr createBoolPropertyAnimation( const OUString& rAttrName,
const AnimatableShapeSharedPtr& rShape,
const ShapeManagerSharedPtr& rShapeManager,
const ::basegfx::B2DVector& rSlideSize,
+ const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld,
int nFlags );
NumberAnimationSharedPtr createPathMotionAnimation( const OUString& rSVGDPath,
@@ -123,7 +130,14 @@ namespace slideshow::internal
const AnimatableShapeSharedPtr& rShape,
const ShapeManagerSharedPtr& rShapeManager,
const ::basegfx::B2DVector& rSlideSize,
- int nFlags);
+ const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld,
+ int nFlags );
+
+ NumberAnimationSharedPtr createPhysicsAnimation( const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld,
+ const double fDuration,
+ const ShapeManagerSharedPtr& rShapeManager,
+ const ::basegfx::B2DVector& rSlideSize,
+ int nFlags );
}
}
diff --git a/slideshow/source/inc/box2dtools.hxx b/slideshow/source/inc/box2dtools.hxx
index 0824a3c260c5..dacf24845b45 100644
--- a/slideshow/source/inc/box2dtools.hxx
+++ b/slideshow/source/inc/box2dtools.hxx
@@ -11,6 +11,7 @@
#include "shape.hxx"
#include "shapeattributelayer.hxx"
+#include "attributemap.hxx"
#include <unordered_map>
#include <queue>
@@ -155,6 +156,21 @@ private:
void step(const float fTimeStep = 1.0f / 100.0f, const int nVelocityIterations = 6,
const int nPositionIterations = 2);
+ /// Queue a rotation update on the next step of the box2DWorld for the corresponding body
+ void queueRotationUpdate(const css::uno::Reference<com::sun::star::drawing::XShape>& xShape,
+ const double fAngle);
+
+ /// Queue an angular velocity update for the corresponding body
+ /// to take place after the next step of the box2DWorld
+ void
+ queueAngularVelocityUpdate(const css::uno::Reference<com::sun::star::drawing::XShape>& xShape,
+ const double fAngularVelocity);
+
+ /// Queue an update that changes collision of the corresponding body
+ /// on the next step of the box2DWorld, used for animations that change visibility
+ void queueShapeVisibilityUpdate(const css::uno::Reference<css::drawing::XShape>& xShape,
+ const bool bVisibility);
+
public:
box2DWorld(const ::basegfx::B2DVector& rSlideSize);
~box2DWorld();
@@ -184,7 +200,7 @@ public:
@param pShape
Pointer to the shape to alter the corresponding Box2D body of
*/
- Box2DBodySharedPtr makeShapeDynamic(const slideshow::internal::ShapeSharedPtr pShape);
+ Box2DBodySharedPtr makeShapeDynamic(const slideshow::internal::ShapeSharedPtr& pShape);
/** Make the Box2D body a dynamic one
@@ -193,7 +209,7 @@ public:
@param pBox2DBody
Pointer to the Box2D body
*/
- Box2DBodySharedPtr makeBodyDynamic(const Box2DBodySharedPtr pBox2DBody);
+ Box2DBodySharedPtr makeBodyDynamic(const Box2DBodySharedPtr& pBox2DBody);
/** Make the Box2D body corresponding to the given shape a static one
@@ -202,7 +218,7 @@ public:
@param pShape
Pointer to the shape to alter the corresponding Box2D body of
*/
- Box2DBodySharedPtr makeShapeStatic(const slideshow::internal::ShapeSharedPtr pShape);
+ Box2DBodySharedPtr makeShapeStatic(const slideshow::internal::ShapeSharedPtr& pShape);
/** Make the Box2D body a dynamic one
@@ -211,7 +227,7 @@ public:
@param pBox2DBody
Pointer to the Box2D body
*/
- Box2DBodySharedPtr makeBodyStatic(const Box2DBodySharedPtr pBox2DBody);
+ Box2DBodySharedPtr makeBodyStatic(const Box2DBodySharedPtr& pBox2DBody);
/// Create a static body from the given shape's bounding box
Box2DBodySharedPtr
@@ -220,7 +236,7 @@ public:
/// Initiate all the shapes in the current slide in the box2DWorld as static ones
void
- initateAllShapesAsStaticBodies(const slideshow::internal::ShapeManagerSharedPtr pShapeManager);
+ initateAllShapesAsStaticBodies(const slideshow::internal::ShapeManagerSharedPtr& pShapeManager);
/// @return whether the box2DWorld has a stepper or not
bool hasWorldStepper();
@@ -229,27 +245,21 @@ public:
void setHasWorldStepper(const bool bHasWorldStepper);
/// Queue a position update the next step of the box2DWorld for the corresponding body
- void queuePositionUpdate(css::uno::Reference<css::drawing::XShape> xShape,
+ void queuePositionUpdate(const css::uno::Reference<css::drawing::XShape>& xShape,
const ::basegfx::B2DPoint& rOutPos);
/// Queue a linear velocity update for the corresponding body
/// to take place after the next step of the box2DWorld
- void queueLinearVelocityUpdate(css::uno::Reference<css::drawing::XShape> xShape,
+ void queueLinearVelocityUpdate(const css::uno::Reference<css::drawing::XShape>& xShape,
const ::basegfx::B2DVector& rVelocity);
- /// Queue a rotation update on the next step of the box2DWorld for the corresponding body
- void queueRotationUpdate(css::uno::Reference<com::sun::star::drawing::XShape> xShape,
- const double fAngle);
-
- /// Queue an angular velocity update for the corresponding body
- /// to take place after the next step of the box2DWorld
- void queueAngularVelocityUpdate(css::uno::Reference<com::sun::star::drawing::XShape> xShape,
- const double fAngularVelocity);
+ void
+ queueShapeAnimationUpdate(const css::uno::Reference<css::drawing::XShape>& xShape,
+ const slideshow::internal::ShapeAttributeLayerSharedPtr& pAttrLayer,
+ const slideshow::internal::AttributeType eAttrType);
- /// Queue an update that changes collision of the corresponding body
- /// on the next step of the box2DWorld, used for animations that change visibility
- void queueShapeVisibilityUpdate(css::uno::Reference<css::drawing::XShape> xShape,
- const bool bVisibility);
+ void queueShapeAnimationEndUpdate(const css::uno::Reference<css::drawing::XShape>& xShape,
+ const slideshow::internal::AttributeType eAttrType);
};
/// Class that manages a single box2D Body
diff --git a/slideshow/source/inc/slideshowcontext.hxx b/slideshow/source/inc/slideshowcontext.hxx
index 558ee6f037c0..565f0ff411aa 100644
--- a/slideshow/source/inc/slideshowcontext.hxx
+++ b/slideshow/source/inc/slideshowcontext.hxx
@@ -24,6 +24,9 @@
#include <memory>
namespace com::sun::star::uno { class XComponentContext; }
+namespace box2d::utils { class box2DWorld;
+ typedef ::std::shared_ptr< box2DWorld > Box2DWorldSharedPtr; }
+
namespace slideshow::internal
@@ -90,7 +93,8 @@ namespace slideshow::internal
CursorManager& rCursorManager,
MediaFileManager& rMediaFileManager,
const UnoViewContainer& rViewContainer,
- const css::uno::Reference< css::uno::XComponentContext>& rComponentContext );
+ const css::uno::Reference< css::uno::XComponentContext>& rComponentContext,
+ box2d::utils::Box2DWorldSharedPtr& rBox2DWorldPtr );
void dispose();
std::shared_ptr<SubsettableShapeManager>& mpSubsettableShapeManager;
@@ -103,6 +107,7 @@ namespace slideshow::internal
MediaFileManager& mrMediaFileManager;
const UnoViewContainer& mrViewContainer;
css::uno::Reference< css::uno::XComponentContext> mxComponentContext;
+ box2d::utils::Box2DWorldSharedPtr& mpBox2DWorld;
};
}