2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 09:51:50 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-09-17 07:36:50 +00:00
|
|
|
|
2017-10-23 22:32:17 +02:00
|
|
|
#include <delayevent.hxx>
|
|
|
|
#include <eventqueue.hxx>
|
|
|
|
#include <usereventqueue.hxx>
|
2005-10-11 07:44:25 +00:00
|
|
|
#include "sequentialtimecontainer.hxx"
|
2017-10-23 22:32:17 +02:00
|
|
|
#include <tools.hxx>
|
2007-07-17 13:50:28 +00:00
|
|
|
|
2005-01-21 16:07:44 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2006-12-13 14:35:05 +00:00
|
|
|
namespace slideshow {
|
2006-07-26 06:36:50 +00:00
|
|
|
namespace internal {
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::activate_st()
|
2005-01-21 16:07:44 +00:00
|
|
|
{
|
2006-07-26 06:36:50 +00:00
|
|
|
// resolve first possible child, ignore
|
|
|
|
for ( ; mnFinishedChildren < maChildren.size(); ++mnFinishedChildren ) {
|
|
|
|
if (resolveChild( maChildren[mnFinishedChildren] ))
|
|
|
|
break;
|
|
|
|
else {
|
|
|
|
// node still UNRESOLVED, no need to deactivate or end...
|
2011-03-12 11:41:23 +01:00
|
|
|
OSL_FAIL( "### resolving child failed!" );
|
2005-01-21 16:07:44 +00:00
|
|
|
}
|
2006-07-26 06:36:50 +00:00
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
if (isDurationIndefinite() &&
|
|
|
|
(maChildren.empty() || mnFinishedChildren >= maChildren.size()))
|
|
|
|
{
|
|
|
|
// deactivate ASAP:
|
2015-08-03 17:20:26 +02:00
|
|
|
auto self(getSelf());
|
2006-07-26 06:36:50 +00:00
|
|
|
scheduleDeactivationEvent(
|
2015-08-03 17:20:26 +02:00
|
|
|
makeEvent( [self] () { self->deactivate(); },
|
2009-11-30 15:37:50 +00:00
|
|
|
"SequentialTimeContainer::deactivate") );
|
2006-07-26 06:36:50 +00:00
|
|
|
}
|
|
|
|
else // use default
|
|
|
|
scheduleDeactivationEvent();
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::dispose()
|
|
|
|
{
|
|
|
|
BaseContainerNode::dispose();
|
|
|
|
if (mpCurrentSkipEvent) {
|
|
|
|
mpCurrentSkipEvent->dispose();
|
|
|
|
mpCurrentSkipEvent.reset();
|
|
|
|
}
|
|
|
|
if (mpCurrentRewindEvent) {
|
|
|
|
mpCurrentRewindEvent->dispose();
|
|
|
|
mpCurrentRewindEvent.reset();
|
|
|
|
}
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::skipEffect(
|
|
|
|
AnimationNodeSharedPtr const& pChildNode )
|
|
|
|
{
|
|
|
|
if (isChildNode(pChildNode)) {
|
|
|
|
// empty all events ignoring timings => until next effect
|
|
|
|
getContext().mrEventQueue.forceEmpty();
|
2009-03-04 13:41:44 +00:00
|
|
|
getContext().mrEventQueue.addEvent(
|
2015-08-03 17:20:26 +02:00
|
|
|
makeEvent( [pChildNode] () { pChildNode->deactivate(); },
|
2009-11-30 15:37:50 +00:00
|
|
|
"SequentialTimeContainer::deactivate, skipEffect with delay") );
|
2006-07-26 06:36:50 +00:00
|
|
|
}
|
|
|
|
else
|
2011-03-12 11:41:23 +01:00
|
|
|
OSL_FAIL( "unknown notifier!" );
|
2006-07-26 06:36:50 +00:00
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
bool SequentialTimeContainer::resolveChild(
|
|
|
|
AnimationNodeSharedPtr const& pChildNode )
|
|
|
|
{
|
|
|
|
bool const bResolved = pChildNode->resolve();
|
|
|
|
if (bResolved && isMainSequenceRootNode()) {
|
|
|
|
// discharge events:
|
|
|
|
if (mpCurrentSkipEvent)
|
|
|
|
mpCurrentSkipEvent->dispose();
|
|
|
|
if (mpCurrentRewindEvent)
|
|
|
|
mpCurrentRewindEvent->dispose();
|
|
|
|
|
|
|
|
// event that will deactivate the resolved/running child:
|
|
|
|
mpCurrentSkipEvent = makeEvent(
|
2015-08-03 17:20:26 +02:00
|
|
|
std::bind( &SequentialTimeContainer::skipEffect,
|
2016-02-01 18:53:50 +02:00
|
|
|
std::dynamic_pointer_cast<SequentialTimeContainer>( getSelf() ),
|
2009-04-27 11:42:05 +00:00
|
|
|
pChildNode ),
|
|
|
|
"SequentialTimeContainer::skipEffect, resolveChild");
|
2006-07-26 06:36:50 +00:00
|
|
|
|
|
|
|
// deactivate child node when skip event occurs:
|
|
|
|
getContext().mrUserEventQueue.registerSkipEffectEvent(
|
2009-03-04 13:41:44 +00:00
|
|
|
mpCurrentSkipEvent,
|
|
|
|
mnFinishedChildren+1<maChildren.size());
|
2006-07-26 06:36:50 +00:00
|
|
|
}
|
|
|
|
return bResolved;
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::notifyDeactivating(
|
|
|
|
AnimationNodeSharedPtr const& rNotifier )
|
|
|
|
{
|
|
|
|
if (notifyDeactivatedChild( rNotifier ))
|
|
|
|
return;
|
|
|
|
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT( mnFinishedChildren < maChildren.size() );
|
2006-07-26 06:36:50 +00:00
|
|
|
AnimationNodeSharedPtr const& pNextChild = maChildren[mnFinishedChildren];
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT( pNextChild->getState() == UNRESOLVED );
|
2006-07-26 06:36:50 +00:00
|
|
|
|
|
|
|
if (! resolveChild( pNextChild )) {
|
|
|
|
// could not resolve child - since we risk to
|
|
|
|
// stall the chain of events here, play it safe
|
|
|
|
// and deactivate this node (only if we have
|
|
|
|
// indefinite duration - otherwise, we'll get a
|
|
|
|
// deactivation event, anyways).
|
|
|
|
deactivate();
|
2005-01-21 16:07:44 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-26 06:36:50 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
2006-12-13 14:35:05 +00:00
|
|
|
} // namespace slideshow
|
2006-07-26 06:36:50 +00:00
|
|
|
|
2010-10-12 15:51:52 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|