diff options
Diffstat (limited to 'slideshow')
3 files changed, 42 insertions, 12 deletions
diff --git a/slideshow/source/engine/animationnodes/animationbasenode.cxx b/slideshow/source/engine/animationnodes/animationbasenode.cxx index ed6349522f22..719276dbca4b 100644 --- a/slideshow/source/engine/animationnodes/animationbasenode.cxx +++ b/slideshow/source/engine/animationnodes/animationbasenode.cxx @@ -422,16 +422,6 @@ AnimationBaseNode::fillCommonParameters() const else aRepeats.reset( nRepeats / nDuration ); } - // This is a temporary workaround: - // as the repeatCount attribute is defined on the <par> parent node - // and activities are created only for animation node leaves, that - // actual performs a shape effect, we get the repeatCount value - // from the parent node. - else if( ( getXAnimationNode()->getType() != animations::AnimationNodeType::SET ) - && (getParentNode()->getXAnimationNode()->getRepeatCount() >>= nRepeats) ) - { - aRepeats.reset( nRepeats ); - } else { // no double value for both values - Timing::INDEFINITE? diff --git a/slideshow/source/engine/animationnodes/basecontainernode.cxx b/slideshow/source/engine/animationnodes/basecontainernode.cxx index e9a53ac12bca..3ac076a19a18 100644 --- a/slideshow/source/engine/animationnodes/basecontainernode.cxx +++ b/slideshow/source/engine/animationnodes/basecontainernode.cxx @@ -32,10 +32,12 @@ #include <canvas/verbosetrace.hxx> #include "basecontainernode.hxx" +#include "eventqueue.hxx" #include "tools.hxx" #include "nodetools.hxx" #include "delayevent.hxx" +#include <boost/bind.hpp> #include <boost/mem_fn.hpp> #include <algorithm> @@ -65,7 +67,15 @@ void BaseContainerNode::dispose() bool BaseContainerNode::init_st() { + if( !(getXAnimationNode()->getRepeatCount() >>= mnLeftIterations) ) + mnLeftIterations = 1.0; + return init_children(); +} + +bool BaseContainerNode::init_children() +{ mnFinishedChildren = 0; + // initialize all children return (std::count_if( maChildren.begin(), maChildren.end(), @@ -75,6 +85,7 @@ bool BaseContainerNode::init_st() void BaseContainerNode::deactivate_st( NodeState eDestState ) { + mnLeftIterations = 0.0; if (eDestState == FROZEN) { // deactivate all children that are not FROZEN or ENDED: forEachChildNode( boost::mem_fn(&AnimationNode::deactivate), @@ -137,19 +148,44 @@ bool BaseContainerNode::notifyDeactivatedChild( std::size_t const nSize = maChildren.size(); OSL_ASSERT( mnFinishedChildren < nSize ); ++mnFinishedChildren; - bool const bFinished = (mnFinishedChildren >= nSize); + bool bFinished = (mnFinishedChildren >= nSize); // all children finished, and we've got indefinite duration? // think of ParallelTimeContainer::notifyDeactivating() // if duration given, we will be deactivated by some end event // @see fillCommonParameters() if (bFinished && isDurationIndefinite()) { - deactivate(); + if( mnLeftIterations >= 1.0 ) + { + mnLeftIterations -= 1.0; + } + if( mnLeftIterations >= 1.0 ) + { + bFinished = false; + EventSharedPtr aRepetitionEvent = + makeDelay( boost::bind( &BaseContainerNode::repeat, this ), + 0.0, + "BaseContainerNode::repeat"); + getContext().mrEventQueue.addEvent( aRepetitionEvent ); + } + else + { + deactivate(); + } } return bFinished; } +bool BaseContainerNode::repeat() +{ + deactivate_st( ENDED ); + sal_Bool bState = init_children(); + if( bState ) + activate_st(); + return bState; +} + #if OSL_DEBUG_LEVEL >= 2 && defined(DBG_UTIL) void BaseContainerNode::showState() const { diff --git a/slideshow/source/engine/animationnodes/basecontainernode.hxx b/slideshow/source/engine/animationnodes/basecontainernode.hxx index f4a0d78ac79a..4a9c6cd9057d 100644 --- a/slideshow/source/engine/animationnodes/basecontainernode.hxx +++ b/slideshow/source/engine/animationnodes/basecontainernode.hxx @@ -51,6 +51,7 @@ protected: private: virtual bool init_st(); + virtual bool init_children(); virtual void deactivate_st( NodeState eDestState ); virtual bool hasPendingAnimation() const; // force to be implemented by derived class: @@ -66,6 +67,8 @@ protected: /// @return true: if all children have been deactivated bool notifyDeactivatedChild( AnimationNodeSharedPtr const& pChildNode ); + bool repeat(); + template <typename FuncT> inline void forEachChildNode( FuncT const& func, int nodeStateMask = -1 ) const @@ -83,6 +86,7 @@ protected: typedef ::std::vector<AnimationNodeSharedPtr> VectorOfNodes; VectorOfNodes maChildren; ::std::size_t mnFinishedChildren; + double mnLeftIterations; private: const bool mbDurationIndefinite; |