LibreOffice Module slideshow (master) 1
setactivity.hxx
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#ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
20#define INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
21
23
24#include <animationactivity.hxx>
25#include <animatableshape.hxx>
27#include <activitiesfactory.hxx>
28#include <utility>
29
30namespace slideshow::internal {
31
40template <class AnimationT>
42{
43public:
44 typedef ::std::shared_ptr< AnimationT > AnimationSharedPtrT;
45 typedef typename AnimationT::ValueType ValueT;
46
48 AnimationSharedPtrT xAnimation,
49 ValueT aToValue )
50 : mpAnimation(std::move( xAnimation )),
51 mpShape(),
53 mpEndEvent( rParms.mpEndEvent ),
54 mrEventQueue( rParms.mrEventQueue ),
55 maToValue(std::move( aToValue )),
56 mbIsActive(true)
57 {
58 ENSURE_OR_THROW( mpAnimation, "Invalid animation" );
59 }
60
61 virtual void dispose() override
62 {
63 mbIsActive = false;
64 mpAnimation.reset();
65 mpShape.reset();
66 mpAttributeLayer.reset();
67 // discharge end event:
68 if (mpEndEvent && mpEndEvent->isCharged())
69 mpEndEvent->dispose();
70 mpEndEvent.reset();
71 }
72
73 virtual double calcTimeLag() const override
74 {
75 return 0.0;
76 }
77
78 virtual bool perform() override
79 {
80 if (! isActive())
81 return false;
82 // we're going inactive immediately:
83 mbIsActive = false;
84
87 (*mpAnimation)(maToValue);
88 mpAnimation->end();
89 }
90 // fire end event, if any
91 if (mpEndEvent)
93
94 return false; // don't reinsert
95 }
96
97 virtual bool isActive() const override
98 {
99 return mbIsActive;
100 }
101
102 virtual void dequeued() override
103 {
104 }
105
106 virtual void end() override
107 {
108 perform();
109 }
110
111 virtual void setTargets( const AnimatableShapeSharedPtr& rShape,
112 const ShapeAttributeLayerSharedPtr& rAttrLayer ) override
113 {
114 ENSURE_OR_THROW( rShape, "Invalid shape" );
115 ENSURE_OR_THROW( rAttrLayer, "Invalid attribute layer" );
116
117 mpShape = rShape;
118 mpAttributeLayer = rAttrLayer;
119 }
120
121private:
129};
130
131template <class AnimationT> AnimationActivitySharedPtr makeSetActivity(
133 const ::std::shared_ptr< AnimationT >& rAnimation,
134 const typename AnimationT::ValueType& rToValue )
135{
136 return std::make_shared<SetActivity<AnimationT>>(rParms,rAnimation,rToValue);
137}
138
139} // namespace presentation::internal
140
141#endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
142
143/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Extends the Activity interface with animation-specific functions.
This class handles events in a presentation.
Definition: eventqueue.hxx:41
bool addEvent(const EventSharedPtr &event)
Add the given event to the queue.
Definition: eventqueue.cxx:79
Templated setter for animation values.
Definition: setactivity.hxx:42
AnimatableShapeSharedPtr mpShape
virtual void setTargets(const AnimatableShapeSharedPtr &rShape, const ShapeAttributeLayerSharedPtr &rAttrLayer) override
Sets targets (shape and attributeLayer)
::std::shared_ptr< AnimationT > AnimationSharedPtrT
Definition: setactivity.hxx:44
virtual void end() override
Forces this activity deactivate and get to its end state (if possible), but does not dispose.
AnimationSharedPtrT mpAnimation
AnimationT::ValueType ValueT
Definition: setactivity.hxx:45
SetActivity(const ActivitiesFactory::CommonParameters &rParms, AnimationSharedPtrT xAnimation, ValueT aToValue)
Definition: setactivity.hxx:47
virtual void dequeued() override
Notifies the Activity that it has now left the ActivitiesQueue.
ShapeAttributeLayerSharedPtr mpAttributeLayer
virtual void dispose() override
Dispose all object references.
Definition: setactivity.hxx:61
virtual double calcTimeLag() const override
Calculates whether the activity lags time.
Definition: setactivity.hxx:73
virtual bool perform() override
Perform the activity associated with this interface's implementation.
Definition: setactivity.hxx:78
virtual bool isActive() const override
Query whether this activity is still continuing.
Definition: setactivity.hxx:97
#define ENSURE_OR_THROW(c, m)
::std::shared_ptr< AnimatableShape > AnimatableShapeSharedPtr
::std::shared_ptr< AnimationActivity > AnimationActivitySharedPtr
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
AnimationActivitySharedPtr makeSetActivity(const ActivitiesFactory::CommonParameters &rParms, const ::std::shared_ptr< AnimationT > &rAnimation, const typename AnimationT::ValueType &rToValue)
::std::shared_ptr< Event > EventSharedPtr
Definition: event.hxx:76