1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX 29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "animationactivity.hxx" 32*cdf0e10cSrcweir #include "activityparameters.hxx" 33*cdf0e10cSrcweir #include "animatableshape.hxx" 34*cdf0e10cSrcweir #include "shapeattributelayer.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir namespace slideshow { 37*cdf0e10cSrcweir namespace internal { 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir /** Base class for animation activities. 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir This whole class hierarchy is only for code sharing 42*cdf0e10cSrcweir between the various specializations (with or without 43*cdf0e10cSrcweir key times, fully discrete, etc.). 44*cdf0e10cSrcweir */ 45*cdf0e10cSrcweir class ActivityBase : public AnimationActivity 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir public: 48*cdf0e10cSrcweir ActivityBase( const ActivityParameters& rParms ); 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir /// From Disposable interface 51*cdf0e10cSrcweir virtual void dispose(); 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir protected: 54*cdf0e10cSrcweir /** From Activity interface 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir Derived classes should override, call this first 57*cdf0e10cSrcweir and then perform their work. 58*cdf0e10cSrcweir */ 59*cdf0e10cSrcweir virtual bool perform(); 60*cdf0e10cSrcweir virtual double calcTimeLag() const; 61*cdf0e10cSrcweir virtual bool isActive() const; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir private: 64*cdf0e10cSrcweir virtual void dequeued(); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir // From AnimationActivity interface 67*cdf0e10cSrcweir virtual void setTargets( 68*cdf0e10cSrcweir const AnimatableShapeSharedPtr& rShape, 69*cdf0e10cSrcweir const ShapeAttributeLayerSharedPtr& rAttrLayer ); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir private: 72*cdf0e10cSrcweir /** Hook for derived classes 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir This method will be called from the first 75*cdf0e10cSrcweir perform() invocation, to signal the start of the 76*cdf0e10cSrcweir activity. 77*cdf0e10cSrcweir */ 78*cdf0e10cSrcweir virtual void startAnimation() = 0; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir /** Hook for derived classes 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir This method will be called after the last perform() 83*cdf0e10cSrcweir invocation, and after the potential changes of that 84*cdf0e10cSrcweir perform() call are committed to screen. That is, in 85*cdf0e10cSrcweir endAnimation(), the animation objects (sprites, 86*cdf0e10cSrcweir animation) can safely be destroyed, without causing 87*cdf0e10cSrcweir visible artifacts on screen. 88*cdf0e10cSrcweir */ 89*cdf0e10cSrcweir virtual void endAnimation() = 0; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir protected: 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir /** End this activity, in a regular way. 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir This method is for derived classes needing to signal a 96*cdf0e10cSrcweir regular activity end (i.e. because the regular 97*cdf0e10cSrcweir duration is over) 98*cdf0e10cSrcweir */ 99*cdf0e10cSrcweir void endActivity(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir /** Modify fractional time. 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir This method modifies the fractional time (total 104*cdf0e10cSrcweir duration mapped to the [0,1] range) to the 105*cdf0e10cSrcweir effective simple time, but only according to 106*cdf0e10cSrcweir acceleration/deceleration. 107*cdf0e10cSrcweir */ 108*cdf0e10cSrcweir double calcAcceleratedTime( double nT ) const; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir bool isDisposed() const { 111*cdf0e10cSrcweir return (!mbIsActive && !mpEndEvent && !mpShape && 112*cdf0e10cSrcweir !mpAttributeLayer); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir EventQueue& getEventQueue() const { return mrEventQueue; } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir AnimatableShapeSharedPtr getShape() const { return mpShape; } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir ShapeAttributeLayerSharedPtr getShapeAttributeLayer() const 120*cdf0e10cSrcweir { return mpAttributeLayer; } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir bool isRepeatCountValid() const { return maRepeats; } 123*cdf0e10cSrcweir double getRepeatCount() const { return *maRepeats; } 124*cdf0e10cSrcweir bool isAutoReverse() const { return mbAutoReverse; } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir private: 127*cdf0e10cSrcweir /// Activity: 128*cdf0e10cSrcweir virtual void end(); 129*cdf0e10cSrcweir virtual void performEnd() = 0; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir private: 132*cdf0e10cSrcweir EventSharedPtr mpEndEvent; 133*cdf0e10cSrcweir EventQueue& mrEventQueue; 134*cdf0e10cSrcweir AnimatableShapeSharedPtr mpShape; // only to pass on to animation 135*cdf0e10cSrcweir ShapeAttributeLayerSharedPtr mpAttributeLayer; // only to pass on to anim 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir ::boost::optional<double> const maRepeats; 138*cdf0e10cSrcweir const double mnAccelerationFraction; 139*cdf0e10cSrcweir const double mnDecelerationFraction; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir const bool mbAutoReverse; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // true, if perform() has not yet been called: 144*cdf0e10cSrcweir mutable bool mbFirstPerformCall; 145*cdf0e10cSrcweir bool mbIsActive; 146*cdf0e10cSrcweir }; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir } // namespace internal 149*cdf0e10cSrcweir } // namespace presentation 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX */ 152*cdf0e10cSrcweir 153