Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / engine / activities / activitybase.hxx
blob990e65c0ed261bf2f4026fb7791487becb572a18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 {
29 namespace internal {
31 /** Base class for animation activities.
33 This whole class hierarchy is only for code sharing
34 between the various specializations (with or without
35 key times, fully discrete, etc.).
37 class ActivityBase : public AnimationActivity
39 public:
40 explicit ActivityBase( const ActivityParameters& rParms );
42 /// From Disposable interface
43 virtual void dispose() override;
45 protected:
46 /** From Activity interface
48 Derived classes should override, call this first
49 and then perform their work.
51 virtual bool perform() override;
52 virtual double calcTimeLag() const override;
53 virtual bool isActive() const override;
55 private:
56 virtual void dequeued() override;
58 // From AnimationActivity interface
59 virtual void setTargets(
60 const AnimatableShapeSharedPtr& rShape,
61 const ShapeAttributeLayerSharedPtr& rAttrLayer ) override;
63 private:
64 /** Hook for derived classes
66 This method will be called from the first
67 perform() invocation, to signal the start of the
68 activity.
70 virtual void startAnimation() = 0;
72 /** Hook for derived classes
74 This method will be called after the last perform()
75 invocation, and after the potential changes of that
76 perform() call are committed to screen. That is, in
77 endAnimation(), the animation objects (sprites,
78 animation) can safely be destroyed, without causing
79 visible artifacts on screen.
81 virtual void endAnimation() = 0;
83 protected:
85 /** End this activity, in a regular way.
87 This method is for derived classes needing to signal a
88 regular activity end (i.e. because the regular
89 duration is over)
91 void endActivity();
93 /** Modify fractional time.
95 This method modifies the fractional time (total
96 duration mapped to the [0,1] range) to the
97 effective simple time, but only according to
98 acceleration/deceleration.
100 double calcAcceleratedTime( double nT ) const;
102 bool isDisposed() const {
103 return (!mbIsActive && !mpEndEvent && !mpShape &&
104 !mpAttributeLayer);
107 EventQueue& getEventQueue() const { return mrEventQueue; }
109 const AnimatableShapeSharedPtr& getShape() const { return mpShape; }
111 const ShapeAttributeLayerSharedPtr& getShapeAttributeLayer() const
112 { return mpAttributeLayer; }
114 bool isRepeatCountValid() const { return bool(maRepeats); }
115 double getRepeatCount() const { return *maRepeats; }
116 bool isAutoReverse() const { return mbAutoReverse; }
118 private:
119 /// Activity:
120 virtual void end() override;
121 virtual void performEnd() = 0;
123 private:
124 EventSharedPtr mpEndEvent;
125 EventQueue& mrEventQueue;
126 AnimatableShapeSharedPtr mpShape; // only to pass on to animation
127 ShapeAttributeLayerSharedPtr mpAttributeLayer; // only to pass on to anim
129 ::boost::optional<double> const maRepeats;
130 const double mnAccelerationFraction;
131 const double mnDecelerationFraction;
133 const bool mbAutoReverse;
135 // true, if perform() has not yet been called:
136 mutable bool mbFirstPerformCall;
137 bool mbIsActive;
140 } // namespace internal
141 } // namespace presentation
143 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_ACTIVITIES_ACTIVITYBASE_HXX
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */