1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
22 #include <tools/diagnose_ex.h>
24 #include <animationactivity.hxx>
25 #include <animatableshape.hxx>
26 #include <shapeattributelayer.hxx>
27 #include <activitiesfactory.hxx>
29 namespace slideshow::internal
{
31 /** Templated setter for animation values
33 This template class implements the AnimationActivity
34 interface, but only the perform() and
35 setAttributeLayer() methods are functional. To be used for set animations.
37 @see AnimationSetNode.
39 template <class AnimationT
>
40 class SetActivity
: public AnimationActivity
43 typedef ::std::shared_ptr
< AnimationT
> AnimationSharedPtrT
;
44 typedef typename
AnimationT::ValueType ValueT
;
46 SetActivity( const ActivitiesFactory::CommonParameters
& rParms
,
47 const AnimationSharedPtrT
& rAnimation
,
48 const ValueT
& rToValue
)
49 : mpAnimation( rAnimation
),
52 mpEndEvent( rParms
.mpEndEvent
),
53 mrEventQueue( rParms
.mrEventQueue
),
54 maToValue( rToValue
),
57 ENSURE_OR_THROW( mpAnimation
, "Invalid animation" );
60 virtual void dispose() override
65 mpAttributeLayer
.reset();
66 // discharge end event:
67 if (mpEndEvent
&& mpEndEvent
->isCharged())
68 mpEndEvent
->dispose();
72 virtual double calcTimeLag() const override
77 virtual bool perform() override
81 // we're going inactive immediately:
84 if (mpAnimation
&& mpAttributeLayer
&& mpShape
) {
85 mpAnimation
->start( mpShape
, mpAttributeLayer
);
86 (*mpAnimation
)(maToValue
);
89 // fire end event, if any
91 mrEventQueue
.addEvent( mpEndEvent
);
93 return false; // don't reinsert
96 virtual bool isActive() const override
101 virtual void dequeued() override
105 virtual void end() override
110 virtual void setTargets( const AnimatableShapeSharedPtr
& rShape
,
111 const ShapeAttributeLayerSharedPtr
& rAttrLayer
) override
113 ENSURE_OR_THROW( rShape
, "Invalid shape" );
114 ENSURE_OR_THROW( rAttrLayer
, "Invalid attribute layer" );
117 mpAttributeLayer
= rAttrLayer
;
121 AnimationSharedPtrT mpAnimation
;
122 AnimatableShapeSharedPtr mpShape
;
123 ShapeAttributeLayerSharedPtr mpAttributeLayer
;
124 EventSharedPtr mpEndEvent
;
125 EventQueue
& mrEventQueue
;
130 template <class AnimationT
> AnimationActivitySharedPtr
makeSetActivity(
131 const ActivitiesFactory::CommonParameters
& rParms
,
132 const ::std::shared_ptr
< AnimationT
>& rAnimation
,
133 const typename
AnimationT::ValueType
& rToValue
)
135 return std::make_shared
<SetActivity
<AnimationT
>>(rParms
,rAnimation
,rToValue
);
138 } // namespace presentation::internal
140 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */