LibreOffice Module slideshow (master) 1
animationphysicsnode.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <animationfactory.hxx>
22
23constexpr double fDefaultStartVelocityX(0.0);
24constexpr double fDefaultStartVelocityY(0.0);
25constexpr double fDefaultDensity(1.0);
26constexpr double fDefaultBounciness(0.1);
27
28namespace slideshow::internal
29{
31{
32 mxPhysicsMotionNode.clear();
34}
35
37{
38 double fDuration(0.0);
39 ENSURE_OR_THROW((mxPhysicsMotionNode->getDuration() >>= fDuration),
40 "Couldn't get the animation duration.");
41
42 ::css::uno::Any aTemp;
43 double fStartVelocityX = fDefaultStartVelocityX;
44 aTemp = mxPhysicsMotionNode->getStartVelocityX();
45 if (aTemp.hasValue())
46 aTemp >>= fStartVelocityX;
47
48 double fStartVelocityY = fDefaultStartVelocityY;
49 aTemp = mxPhysicsMotionNode->getStartVelocityY();
50 if (aTemp.hasValue())
51 aTemp >>= fStartVelocityY;
52
53 double fDensity = fDefaultDensity;
54 aTemp = mxPhysicsMotionNode->getDensity();
55 if (aTemp.hasValue())
56 {
57 aTemp >>= fDensity;
58 fDensity = (fDensity < 0.0) ? 0.0 : fDensity;
59 }
60
61 double fBounciness = fDefaultBounciness;
62 aTemp = mxPhysicsMotionNode->getBounciness();
63 if (aTemp.hasValue())
64 {
65 aTemp >>= fBounciness;
66 fBounciness = std::clamp(fBounciness, 0.0, 1.0);
67 }
68
71 aParms,
74 getSlideSize(), { fStartVelocityX, fStartVelocityY }, fDensity, fBounciness, 0),
75 true);
76}
77
79{
81}
82
83} // namespace slideshow::internal
84
85/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static T clamp(const T &rIn)
box2d::utils::Box2DWorldSharedPtr mpBox2DWorld
constexpr double fDefaultStartVelocityY(0.0)
constexpr double fDefaultDensity(1.0)
constexpr double fDefaultBounciness(0.1)
constexpr double fDefaultStartVelocityX(0.0)
bool addTailActivity(const ActivitySharedPtr &pActivity)
Add the given activity prioritized last in the queue.
::basegfx::B2DVector const & getSlideSize() const
virtual void dispose() override
Dispose all object references.
ActivitiesFactory::CommonParameters fillCommonParameters() const
Create parameter struct for ActivitiesFactory.
virtual void dispose() override
Dispose all object references.
virtual AnimationActivitySharedPtr createActivity() const override
css::uno::Reference< css::animations::XAnimatePhysics > mxPhysicsMotionNode
virtual bool enqueueActivity() const override
SlideShowContext const & getContext() const
Definition: basenode.hxx:135
#define ENSURE_OR_THROW(c, m)
AnimationActivitySharedPtr createSimpleActivity(const CommonParameters &rParms, const NumberAnimationSharedPtr &rAnimator, bool bDirectionForward)
Create a simple activity for the given animator.
NumberAnimationSharedPtr createPhysicsAnimation(const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, const double fDuration, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const ::basegfx::B2DVector &rStartVelocity, const double fDensity, const double fBounciness, int nFlags)
::std::shared_ptr< AnimationActivity > AnimationActivitySharedPtr
std::shared_ptr< SubsettableShapeManager > mpSubsettableShapeManager
Definition: slideimpl.cxx:199