tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / slideshow / source / engine / animationnodes / sequentialtimecontainer.cxx
blobeee8eaf3ed211792ab109b2737a1d9361d2e924f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <delayevent.hxx>
22 #include <eventqueue.hxx>
23 #include <usereventqueue.hxx>
24 #include "sequentialtimecontainer.hxx"
26 namespace slideshow::internal {
28 void SequentialTimeContainer::activate_st()
30 // resolve first possible child, ignore
31 for ( ; mnFinishedChildren < maChildren.size(); ++mnFinishedChildren ) {
32 if (resolveChild( maChildren[mnFinishedChildren] ))
33 break;
34 else {
35 // node still UNRESOLVED, no need to deactivate or end...
36 OSL_FAIL( "### resolving child failed!" );
40 if (isDurationIndefinite() &&
41 (maChildren.empty() || mnFinishedChildren >= maChildren.size()))
43 // deactivate ASAP:
44 auto self(getSelf());
45 scheduleDeactivationEvent(
46 makeEvent( [self=std::move(self)] () { self->deactivate(); },
47 u"SequentialTimeContainer::deactivate"_ustr) );
49 else // use default
50 scheduleDeactivationEvent();
53 void SequentialTimeContainer::dispose()
55 BaseContainerNode::dispose();
56 if (mpCurrentSkipEvent) {
57 mpCurrentSkipEvent->dispose();
58 mpCurrentSkipEvent.reset();
62 void SequentialTimeContainer::skipEffect(
63 AnimationNodeSharedPtr const& pChildNode )
65 if (isChildNode(pChildNode)) {
66 // empty all events ignoring timings => until next effect
67 getContext().mrEventQueue.forceEmpty();
68 getContext().mrEventQueue.addEvent(
69 makeEvent( [pChildNode] () { pChildNode->deactivate(); },
70 u"SequentialTimeContainer::deactivate, skipEffect with delay"_ustr) );
72 else
73 OSL_FAIL( "unknown notifier!" );
76 bool SequentialTimeContainer::resolveChild(
77 AnimationNodeSharedPtr const& pChildNode )
79 bool const bResolved = pChildNode->resolve();
80 if (bResolved && isMainSequenceRootNode()) {
81 // discharge events:
82 if (mpCurrentSkipEvent)
83 mpCurrentSkipEvent->dispose();
85 // event that will deactivate the resolved/running child:
86 mpCurrentSkipEvent = makeEvent(
87 std::bind( &SequentialTimeContainer::skipEffect,
88 std::dynamic_pointer_cast<SequentialTimeContainer>( getSelf() ),
89 pChildNode ),
90 u"SequentialTimeContainer::skipEffect, resolveChild"_ustr);
92 // deactivate child node when skip event occurs:
93 getContext().mrUserEventQueue.registerSkipEffectEvent(
94 mpCurrentSkipEvent,
95 mnFinishedChildren+1<maChildren.size());
97 return bResolved;
100 void SequentialTimeContainer::notifyDeactivating(
101 AnimationNodeSharedPtr const& rNotifier )
103 if (notifyDeactivatedChild( rNotifier ))
104 return;
106 OSL_ASSERT( mnFinishedChildren < maChildren.size() );
107 AnimationNodeSharedPtr const& pNextChild = maChildren[mnFinishedChildren];
108 OSL_ASSERT( pNextChild->getState() == UNRESOLVED );
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();
120 } // namespace slideshow::internal
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */