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 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_ACTIVITIES_ACTIVITYBASE_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_ACTIVITIES_ACTIVITYBASE_HXX
23 #include <animationactivity.hxx>
24 #include "activityparameters.hxx"
25 #include <animatableshape.hxx>
26 #include <shapeattributelayer.hxx>
28 namespace slideshow::internal
{
30 /** Base class for animation activities.
32 This whole class hierarchy is only for code sharing
33 between the various specializations (with or without
34 key times, fully discrete, etc.).
36 class ActivityBase
: public AnimationActivity
39 explicit ActivityBase( const ActivityParameters
& rParms
);
41 /// From Disposable interface
42 virtual void dispose() override
;
45 /** From Activity interface
47 Derived classes should override, call this first
48 and then perform their work.
50 virtual bool perform() override
;
51 virtual double calcTimeLag() const override
;
52 virtual bool isActive() const override
;
55 virtual void dequeued() override
;
57 // From AnimationActivity interface
58 virtual void setTargets(
59 const AnimatableShapeSharedPtr
& rShape
,
60 const ShapeAttributeLayerSharedPtr
& rAttrLayer
) override
;
63 /** Hook for derived classes
65 This method will be called from the first
66 perform() invocation, to signal the start of the
69 virtual void startAnimation() = 0;
71 /** Hook for derived classes
73 This method will be called after the last perform()
74 invocation, and after the potential changes of that
75 perform() call are committed to screen. That is, in
76 endAnimation(), the animation objects (sprites,
77 animation) can safely be destroyed, without causing
78 visible artifacts on screen.
80 virtual void endAnimation() = 0;
84 /** End this activity, in a regular way.
86 This method is for derived classes needing to signal a
87 regular activity end (i.e. because the regular
92 /** Modify fractional time.
94 This method modifies the fractional time (total
95 duration mapped to the [0,1] range) to the
96 effective simple time, but only according to
97 acceleration/deceleration.
99 double calcAcceleratedTime( double nT
) const;
101 bool isDisposed() const {
102 return (!mbIsActive
&& !mpEndEvent
&& !mpShape
&&
106 EventQueue
& getEventQueue() const { return mrEventQueue
; }
108 const AnimatableShapeSharedPtr
& getShape() const { return mpShape
; }
110 const ShapeAttributeLayerSharedPtr
& getShapeAttributeLayer() const
111 { return mpAttributeLayer
; }
113 bool isRepeatCountValid() const { return bool(maRepeats
); }
114 double getRepeatCount() const { return *maRepeats
; }
115 bool isAutoReverse() const { return mbAutoReverse
; }
119 virtual void end() override
;
120 virtual void performEnd() = 0;
123 EventSharedPtr mpEndEvent
;
124 EventQueue
& mrEventQueue
;
125 AnimatableShapeSharedPtr mpShape
; // only to pass on to animation
126 ShapeAttributeLayerSharedPtr mpAttributeLayer
; // only to pass on to anim
128 ::std::optional
<double> const maRepeats
;
129 const double mnAccelerationFraction
;
130 const double mnDecelerationFraction
;
132 const bool mbAutoReverse
;
134 // true, if perform() has not yet been called:
135 mutable bool mbFirstPerformCall
;
139 } // namespace presentation::internal
141 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ACTIVITIES_ACTIVITYBASE_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */