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 <comphelper/diagnose_ex.hxx>
24 #include <animationactivity.hxx>
25 #include <animatableshape.hxx>
26 #include <shapeattributelayer.hxx>
27 #include <activitiesfactory.hxx>
30 namespace slideshow::internal
{
32 /** Templated setter for animation values
34 This template class implements the AnimationActivity
35 interface, but only the perform() and
36 setAttributeLayer() methods are functional. To be used for set animations.
38 @see AnimationSetNode.
40 template <class AnimationT
>
41 class SetActivity
: public AnimationActivity
44 typedef ::std::shared_ptr
< AnimationT
> AnimationSharedPtrT
;
45 typedef typename
AnimationT::ValueType ValueT
;
47 SetActivity( const ActivitiesFactory::CommonParameters
& rParms
,
48 AnimationSharedPtrT xAnimation
,
50 : mpAnimation(std::move( xAnimation
)),
53 mpEndEvent( rParms
.mpEndEvent
),
54 mrEventQueue( rParms
.mrEventQueue
),
55 maToValue(std::move( aToValue
)),
58 ENSURE_OR_THROW( mpAnimation
, "Invalid animation" );
61 virtual void dispose() override
66 mpAttributeLayer
.reset();
67 // discharge end event:
68 if (mpEndEvent
&& mpEndEvent
->isCharged())
69 mpEndEvent
->dispose();
73 virtual double calcTimeLag() const override
78 virtual bool perform() override
82 // we're going inactive immediately:
85 if (mpAnimation
&& mpAttributeLayer
&& mpShape
) {
86 mpAnimation
->start( mpShape
, mpAttributeLayer
);
87 (*mpAnimation
)(maToValue
);
90 // fire end event, if any
92 mrEventQueue
.addEvent( mpEndEvent
);
94 return false; // don't reinsert
97 virtual bool isActive() const override
102 virtual void dequeued() override
106 virtual void end() override
111 virtual void setTargets( const AnimatableShapeSharedPtr
& rShape
,
112 const ShapeAttributeLayerSharedPtr
& rAttrLayer
) override
114 ENSURE_OR_THROW( rShape
, "Invalid shape" );
115 ENSURE_OR_THROW( rAttrLayer
, "Invalid attribute layer" );
118 mpAttributeLayer
= rAttrLayer
;
122 AnimationSharedPtrT mpAnimation
;
123 AnimatableShapeSharedPtr mpShape
;
124 ShapeAttributeLayerSharedPtr mpAttributeLayer
;
125 EventSharedPtr mpEndEvent
;
126 EventQueue
& mrEventQueue
;
131 template <class AnimationT
> AnimationActivitySharedPtr
makeSetActivity(
132 const ActivitiesFactory::CommonParameters
& rParms
,
133 const ::std::shared_ptr
< AnimationT
>& rAnimation
,
134 const typename
AnimationT::ValueType
& rToValue
)
136 return std::make_shared
<SetActivity
<AnimationT
>>(rParms
,rAnimation
,rToValue
);
139 } // namespace presentation::internal
141 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */