Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX
21 : #define INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX
22 :
23 : #include "animationactivity.hxx"
24 : #include "activityparameters.hxx"
25 : #include "animatableshape.hxx"
26 : #include "shapeattributelayer.hxx"
27 :
28 : namespace slideshow {
29 : namespace internal {
30 :
31 : /** Base class for animation activities.
32 :
33 : This whole class hierarchy is only for code sharing
34 : between the various specializations (with or without
35 : key times, fully discrete, etc.).
36 : */
37 0 : class ActivityBase : public AnimationActivity
38 : {
39 : public:
40 : ActivityBase( const ActivityParameters& rParms );
41 :
42 : /// From Disposable interface
43 : virtual void dispose() SAL_OVERRIDE;
44 :
45 : protected:
46 : /** From Activity interface
47 :
48 : Derived classes should override, call this first
49 : and then perform their work.
50 : */
51 : virtual bool perform() SAL_OVERRIDE;
52 : virtual double calcTimeLag() const SAL_OVERRIDE;
53 : virtual bool isActive() const SAL_OVERRIDE;
54 :
55 : private:
56 : virtual void dequeued() SAL_OVERRIDE;
57 :
58 : // From AnimationActivity interface
59 : virtual void setTargets(
60 : const AnimatableShapeSharedPtr& rShape,
61 : const ShapeAttributeLayerSharedPtr& rAttrLayer ) SAL_OVERRIDE;
62 :
63 : private:
64 : /** Hook for derived classes
65 :
66 : This method will be called from the first
67 : perform() invocation, to signal the start of the
68 : activity.
69 : */
70 : virtual void startAnimation() = 0;
71 :
72 : /** Hook for derived classes
73 :
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.
80 : */
81 : virtual void endAnimation() = 0;
82 :
83 : protected:
84 :
85 : /** End this activity, in a regular way.
86 :
87 : This method is for derived classes needing to signal a
88 : regular activity end (i.e. because the regular
89 : duration is over)
90 : */
91 : void endActivity();
92 :
93 : /** Modify fractional time.
94 :
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.
99 : */
100 : double calcAcceleratedTime( double nT ) const;
101 :
102 0 : bool isDisposed() const {
103 0 : return (!mbIsActive && !mpEndEvent && !mpShape &&
104 0 : !mpAttributeLayer);
105 : }
106 :
107 0 : EventQueue& getEventQueue() const { return mrEventQueue; }
108 :
109 0 : AnimatableShapeSharedPtr getShape() const { return mpShape; }
110 :
111 0 : ShapeAttributeLayerSharedPtr getShapeAttributeLayer() const
112 0 : { return mpAttributeLayer; }
113 :
114 0 : bool isRepeatCountValid() const { return maRepeats; }
115 0 : double getRepeatCount() const { return *maRepeats; }
116 0 : bool isAutoReverse() const { return mbAutoReverse; }
117 :
118 : private:
119 : /// Activity:
120 : virtual void end() SAL_OVERRIDE;
121 : virtual void performEnd() = 0;
122 :
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
128 :
129 : ::boost::optional<double> const maRepeats;
130 : const double mnAccelerationFraction;
131 : const double mnDecelerationFraction;
132 :
133 : const bool mbAutoReverse;
134 :
135 : // true, if perform() has not yet been called:
136 : mutable bool mbFirstPerformCall;
137 : bool mbIsActive;
138 : };
139 :
140 : } // namespace internal
141 : } // namespace presentation
142 :
143 : #endif /* INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX */
144 :
145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|