LibreOffice Module slideshow (master) 1
sequentialtimecontainer.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
20
21#include <delayevent.hxx>
22#include <eventqueue.hxx>
23#include <usereventqueue.hxx>
25
26namespace slideshow::internal {
27
29{
30 // resolve first possible child, ignore
33 break;
34 else {
35 // node still UNRESOLVED, no need to deactivate or end...
36 OSL_FAIL( "### resolving child failed!" );
37 }
38 }
39
41 (maChildren.empty() || mnFinishedChildren >= maChildren.size()))
42 {
43 // deactivate ASAP:
44 auto self(getSelf());
46 makeEvent( [self] () { self->deactivate(); },
47 "SequentialTimeContainer::deactivate") );
48 }
49 else // use default
51}
52
54{
57 mpCurrentSkipEvent->dispose();
58 mpCurrentSkipEvent.reset();
59 }
60}
61
63 AnimationNodeSharedPtr const& pChildNode )
64{
65 if (isChildNode(pChildNode)) {
66 // empty all events ignoring timings => until next effect
69 makeEvent( [pChildNode] () { pChildNode->deactivate(); },
70 "SequentialTimeContainer::deactivate, skipEffect with delay") );
71 }
72 else
73 OSL_FAIL( "unknown notifier!" );
74}
75
77 AnimationNodeSharedPtr const& pChildNode )
78{
79 bool const bResolved = pChildNode->resolve();
80 if (bResolved && isMainSequenceRootNode()) {
81 // discharge events:
83 mpCurrentSkipEvent->dispose();
84
85 // event that will deactivate the resolved/running child:
88 std::dynamic_pointer_cast<SequentialTimeContainer>( getSelf() ),
89 pChildNode ),
90 "SequentialTimeContainer::skipEffect, resolveChild");
91
92 // deactivate child node when skip event occurs:
96 }
97 return bResolved;
98}
99
101 AnimationNodeSharedPtr const& rNotifier )
102{
103 if (notifyDeactivatedChild( rNotifier ))
104 return;
105
106 OSL_ASSERT( mnFinishedChildren < maChildren.size() );
108 OSL_ASSERT( pNextChild->getState() == UNRESOLVED );
109
110 if (! resolveChild( pNextChild )) {
111 // could not resolve child - since we risk to
112 // stall the chain of events here, play it safe
113 // and deactivate this node (only if we have
114 // indefinite duration - otherwise, we'll get a
115 // deactivation event, anyways).
116 deactivate();
117 }
118}
119
120} // namespace slideshow::internal
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ UNRESOLVED
Unresolved start time.
bool notifyDeactivatedChild(AnimationNodeSharedPtr const &pChildNode)
bool isChildNode(AnimationNodeSharedPtr const &pNode) const
virtual void dispose() override
Dispose all object references.
bool isMainSequenceRootNode() const
Definition: basenode.hxx:125
SlideShowContext const & getContext() const
Definition: basenode.hxx:135
::std::shared_ptr< BaseNode > const & getSelf() const
Definition: basenode.hxx:136
virtual void deactivate() override
Immediately stop this node.
Definition: basenode.cxx:564
void scheduleDeactivationEvent(EventSharedPtr const &pEvent=EventSharedPtr())
Definition: basenode.cxx:519
void forceEmpty()
Forces an empty queue, firing all events immediately without minding any times.
Definition: eventqueue.cxx:142
bool addEvent(const EventSharedPtr &event)
Add the given event to the queue.
Definition: eventqueue.cxx:79
virtual void dispose() override
Dispose all object references.
bool resolveChild(AnimationNodeSharedPtr const &pChildNode)
void skipEffect(AnimationNodeSharedPtr const &pChildNode)
virtual void notifyDeactivating(AnimationNodeSharedPtr const &rNotifier) override
Called to notify another AnimationNode's deactivation.
void registerSkipEffectEvent(EventSharedPtr const &pEvent, const bool bSkipTriggersNextEffect)
Registers an event that is fired when the current effects(s) are skipped, .e.g.
#define makeEvent(f, d)
Definition: delayevent.hxx:131
::std::shared_ptr< AnimationNode > AnimationNodeSharedPtr