diff options
author | Marco Cecchetti <mrcekets@gmail.com> | 2012-06-19 18:53:14 +0200 |
---|---|---|
committer | Marco Cecchetti <mrcekets@gmail.com> | 2012-06-28 12:28:06 +0200 |
commit | 1ef95a7206979756a885b7bea4c788684f5e7b61 (patch) | |
tree | 1e821e8d5856ba62200bb84f3c767c4d3f01bfea /slideshow/source/engine/animationnodes/basecontainernode.cxx | |
parent | 17ac2bb3b37d738488c12b26387822d62c4e8ded (diff) |
Added support for the repeatCount attribute for time containers.
The support is limited to the case when the value of the repeatCount attribute is an integral
number and the duration time is defined implicitly by the active duration of the time container
children. The accumulate attribute is not handled.
The support for such a feature has been implemented for both the C++ and the JavaScript
presentation engine.
Diffstat (limited to 'slideshow/source/engine/animationnodes/basecontainernode.cxx')
-rw-r--r-- | slideshow/source/engine/animationnodes/basecontainernode.cxx | 40 |
1 files changed, 38 insertions, 2 deletions
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 { |