1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sequentialtimecontainer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
34 #include <canvas/debug.hxx>
35 #include <canvas/verbosetrace.hxx>
37 #include "delayevent.hxx"
38 #include "eventqueue.hxx"
39 #include "usereventqueue.hxx"
40 #include "sequentialtimecontainer.hxx"
43 #include <boost/bind.hpp>
49 void SequentialTimeContainer::activate_st()
51 // resolve first possible child, ignore
52 for ( ; mnFinishedChildren
< maChildren
.size(); ++mnFinishedChildren
) {
53 if (resolveChild( maChildren
[mnFinishedChildren
] ))
56 // node still UNRESOLVED, no need to deactivate or end...
57 OSL_ENSURE( false, "### resolving child failed!" );
61 if (isDurationIndefinite() &&
62 (maChildren
.empty() || mnFinishedChildren
>= maChildren
.size()))
65 scheduleDeactivationEvent(
66 makeEvent( boost::bind
< void >( boost::mem_fn( &AnimationNode::deactivate
), getSelf() ) ) );
69 scheduleDeactivationEvent();
72 void SequentialTimeContainer::dispose()
74 BaseContainerNode::dispose();
75 if (mpCurrentSkipEvent
) {
76 mpCurrentSkipEvent
->dispose();
77 mpCurrentSkipEvent
.reset();
79 if (mpCurrentRewindEvent
) {
80 mpCurrentRewindEvent
->dispose();
81 mpCurrentRewindEvent
.reset();
85 void SequentialTimeContainer::skipEffect(
86 AnimationNodeSharedPtr
const& pChildNode
)
88 if (isChildNode(pChildNode
)) {
89 // empty all events ignoring timings => until next effect
90 getContext().mrEventQueue
.forceEmpty();
91 getContext().mrEventQueue
.addEvent(
92 makeEvent( boost::bind
<void>( boost::mem_fn( &AnimationNode::deactivate
), pChildNode
) ) );
95 OSL_ENSURE( false, "unknown notifier!" );
98 void SequentialTimeContainer::rewindEffect(
99 AnimationNodeSharedPtr
const& /*pChildNode*/ )
104 bool SequentialTimeContainer::resolveChild(
105 AnimationNodeSharedPtr
const& pChildNode
)
107 bool const bResolved
= pChildNode
->resolve();
108 if (bResolved
&& isMainSequenceRootNode()) {
110 if (mpCurrentSkipEvent
)
111 mpCurrentSkipEvent
->dispose();
112 if (mpCurrentRewindEvent
)
113 mpCurrentRewindEvent
->dispose();
115 // event that will deactivate the resolved/running child:
116 mpCurrentSkipEvent
= makeEvent(
117 boost::bind( &SequentialTimeContainer::skipEffect
,
118 boost::dynamic_pointer_cast
<SequentialTimeContainer
>( getSelf() ),
120 // event that will reresolve the resolved/activated child:
121 mpCurrentRewindEvent
= makeEvent(
122 boost::bind( &SequentialTimeContainer::rewindEffect
,
123 boost::dynamic_pointer_cast
<SequentialTimeContainer
>( getSelf() ),
126 // deactivate child node when skip event occurs:
127 getContext().mrUserEventQueue
.registerSkipEffectEvent(
129 mnFinishedChildren
+1<maChildren
.size());
130 // rewind to previous child:
131 getContext().mrUserEventQueue
.registerRewindEffectEvent(
132 mpCurrentRewindEvent
);
137 void SequentialTimeContainer::notifyDeactivating(
138 AnimationNodeSharedPtr
const& rNotifier
)
140 OSL_TRACE(" SequentialTimeContainer::notifyDeactivating\r");
141 if (notifyDeactivatedChild( rNotifier
))
144 OSL_ASSERT( mnFinishedChildren
< maChildren
.size() );
145 AnimationNodeSharedPtr
const& pNextChild
= maChildren
[mnFinishedChildren
];
146 OSL_ASSERT( pNextChild
->getState() == UNRESOLVED
);
148 if (! resolveChild( pNextChild
)) {
149 // could not resolve child - since we risk to
150 // stall the chain of events here, play it safe
151 // and deactivate this node (only if we have
152 // indefinite duration - otherwise, we'll get a
153 // deactivation event, anyways).
158 } // namespace internal
159 } // namespace slideshow