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
23 #include <canvas/debug.hxx>
24 #include <tools/diagnose_ex.h>
25 #include <canvas/verbosetrace.hxx>
27 #include "animationactivity.hxx"
28 #include "animation.hxx"
29 #include "animatableshape.hxx"
30 #include "shapeattributelayer.hxx"
31 #include "activitiesfactory.hxx"
36 /** Templated setter for animation values
38 This template class implements the AnimationActivity
39 interface, but only the perform() and
40 setAttributeLayer() methods are functional. To be used for set animations.
42 @see AnimationSetNode.
44 template <class AnimationT
>
45 class SetActivity
: public AnimationActivity
48 typedef ::boost::shared_ptr
< AnimationT
> AnimationSharedPtrT
;
49 typedef typename
AnimationT::ValueType ValueT
;
51 SetActivity( const ActivitiesFactory::CommonParameters
& rParms
,
52 const AnimationSharedPtrT
& rAnimation
,
53 const ValueT
& rToValue
)
54 : mpAnimation( rAnimation
),
57 mpEndEvent( rParms
.mpEndEvent
),
58 mrEventQueue( rParms
.mrEventQueue
),
59 maToValue( rToValue
),
62 ENSURE_OR_THROW( mpAnimation
, "Invalid animation" );
65 virtual void dispose() SAL_OVERRIDE
70 mpAttributeLayer
.reset();
71 // discharge end event:
72 if (mpEndEvent
&& mpEndEvent
->isCharged())
73 mpEndEvent
->dispose();
77 virtual double calcTimeLag() const SAL_OVERRIDE
82 virtual bool perform() SAL_OVERRIDE
86 // we're going inactive immediately:
89 if (mpAnimation
&& mpAttributeLayer
&& mpShape
) {
90 mpAnimation
->start( mpShape
, mpAttributeLayer
);
91 (*mpAnimation
)(maToValue
);
94 // fire end event, if any
96 mrEventQueue
.addEvent( mpEndEvent
);
98 return false; // don't reinsert
101 virtual bool isActive() const SAL_OVERRIDE
106 virtual void dequeued() SAL_OVERRIDE
110 virtual void end() SAL_OVERRIDE
115 virtual void setTargets( const AnimatableShapeSharedPtr
& rShape
,
116 const ShapeAttributeLayerSharedPtr
& rAttrLayer
) SAL_OVERRIDE
118 ENSURE_OR_THROW( rShape
, "Invalid shape" );
119 ENSURE_OR_THROW( rAttrLayer
, "Invalid attribute layer" );
122 mpAttributeLayer
= rAttrLayer
;
126 AnimationSharedPtrT mpAnimation
;
127 AnimatableShapeSharedPtr mpShape
;
128 ShapeAttributeLayerSharedPtr mpAttributeLayer
;
129 EventSharedPtr mpEndEvent
;
130 EventQueue
& mrEventQueue
;
135 template <class AnimationT
> AnimationActivitySharedPtr
makeSetActivity(
136 const ActivitiesFactory::CommonParameters
& rParms
,
137 const ::boost::shared_ptr
< AnimationT
>& rAnimation
,
138 const typename
AnimationT::ValueType
& rToValue
)
140 return AnimationActivitySharedPtr(
141 new SetActivity
<AnimationT
>(rParms
,rAnimation
,rToValue
) );
144 } // namespace internal
145 } // namespace presentation
147 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ANIMATIONNODES_SETACTIVITY_HXX
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */