1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef SDEXT_PRESENTER_ANIMATION_HXX 25*b1cdbd2cSJim Jagielski #define SDEXT_PRESENTER_ANIMATION_HXX 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <sal/types.h> 28*b1cdbd2cSJim Jagielski #include <boost/function.hpp> 29*b1cdbd2cSJim Jagielski #include <boost/noncopyable.hpp> 30*b1cdbd2cSJim Jagielski #include <boost/scoped_ptr.hpp> 31*b1cdbd2cSJim Jagielski #include <boost/shared_ptr.hpp> 32*b1cdbd2cSJim Jagielski #include <vector> 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski namespace sdext { namespace presenter { 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski /** Base class for animations handled by a PresenterAnimator object. 37*b1cdbd2cSJim Jagielski A PresenterAnimation objects basically states when it wants to be 38*b1cdbd2cSJim Jagielski started, how long it runs, and in what steps it wants to be called back 39*b1cdbd2cSJim Jagielski while running. 40*b1cdbd2cSJim Jagielski When a PresenterAnimation object is active/running its Run() method is 41*b1cdbd2cSJim Jagielski called back with increasing values between 0 and 1. 42*b1cdbd2cSJim Jagielski */ 43*b1cdbd2cSJim Jagielski class PresenterAnimation 44*b1cdbd2cSJim Jagielski : private ::boost::noncopyable 45*b1cdbd2cSJim Jagielski { 46*b1cdbd2cSJim Jagielski public: 47*b1cdbd2cSJim Jagielski /** Create a new PresenterAnimation object. 48*b1cdbd2cSJim Jagielski @param nStartDelay 49*b1cdbd2cSJim Jagielski The delay in ms (milliseconds) from this call until the new 50*b1cdbd2cSJim Jagielski object is to be activated. 51*b1cdbd2cSJim Jagielski @param nTotalDuration 52*b1cdbd2cSJim Jagielski The duration in ms the Run() method is to be called with 53*b1cdbd2cSJim Jagielski increasing values between 0 and 1. 54*b1cdbd2cSJim Jagielski @param nStepDuration 55*b1cdbd2cSJim Jagielski The duration between calls to Run(). This leads to approximately 56*b1cdbd2cSJim Jagielski nTotalDuration/nStepDuration calls to Run(). The exact duration 57*b1cdbd2cSJim Jagielski of each step may vary depending on system load an other influences. 58*b1cdbd2cSJim Jagielski */ 59*b1cdbd2cSJim Jagielski PresenterAnimation ( 60*b1cdbd2cSJim Jagielski const sal_uInt64 nStartDelay, 61*b1cdbd2cSJim Jagielski const sal_uInt64 nTotalDuration, 62*b1cdbd2cSJim Jagielski const sal_uInt64 nStepDuration); 63*b1cdbd2cSJim Jagielski virtual ~PresenterAnimation (void); 64*b1cdbd2cSJim Jagielski 65*b1cdbd2cSJim Jagielski /** Return the absolute start time in a system dependent format. 66*b1cdbd2cSJim Jagielski At about this time the Run() method will be called with a value of 0. 67*b1cdbd2cSJim Jagielski */ 68*b1cdbd2cSJim Jagielski sal_uInt64 GetStartTime (void); 69*b1cdbd2cSJim Jagielski 70*b1cdbd2cSJim Jagielski /** Return the absolute end time in a system dependent format. 71*b1cdbd2cSJim Jagielski At about this time the Run() method will be called with a value of 1. 72*b1cdbd2cSJim Jagielski */ 73*b1cdbd2cSJim Jagielski sal_uInt64 GetEndTime (void); 74*b1cdbd2cSJim Jagielski 75*b1cdbd2cSJim Jagielski /** Return the duration of each step in ms. 76*b1cdbd2cSJim Jagielski */ 77*b1cdbd2cSJim Jagielski sal_uInt64 GetStepDuration (void); 78*b1cdbd2cSJim Jagielski 79*b1cdbd2cSJim Jagielski typedef ::boost::function<void(void)> Callback; 80*b1cdbd2cSJim Jagielski 81*b1cdbd2cSJim Jagielski /** Add a callback that is executed before Run() is called for the first 82*b1cdbd2cSJim Jagielski time. 83*b1cdbd2cSJim Jagielski */ 84*b1cdbd2cSJim Jagielski void AddStartCallback (const Callback& rCallback); 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski /** Add a callback that is executed after Run() is called for the last 87*b1cdbd2cSJim Jagielski time. 88*b1cdbd2cSJim Jagielski */ 89*b1cdbd2cSJim Jagielski void AddEndCallback (const Callback& rCallback); 90*b1cdbd2cSJim Jagielski 91*b1cdbd2cSJim Jagielski /** Called with nProgress taking on values between 0 and 1. 92*b1cdbd2cSJim Jagielski @param nProgress 93*b1cdbd2cSJim Jagielski A value between 0 and 1. 94*b1cdbd2cSJim Jagielski @param nCurrentTime 95*b1cdbd2cSJim Jagielski Current time in a system dependent format. 96*b1cdbd2cSJim Jagielski */ 97*b1cdbd2cSJim Jagielski virtual void Run (const double nProgress, const sal_uInt64 nCurrentTime) = 0; 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski /** Called just before Run() is called for the first time to trigger the 100*b1cdbd2cSJim Jagielski callbacks registered via the <method>AddStartCallback()</method>. 101*b1cdbd2cSJim Jagielski */ 102*b1cdbd2cSJim Jagielski void RunStartCallbacks (void); 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski /** Called just after Run() is called for the last time to trigger the 105*b1cdbd2cSJim Jagielski callbacks registered via the <method>AddEndCallback()</method>. 106*b1cdbd2cSJim Jagielski */ 107*b1cdbd2cSJim Jagielski void RunEndCallbacks (void); 108*b1cdbd2cSJim Jagielski 109*b1cdbd2cSJim Jagielski private: 110*b1cdbd2cSJim Jagielski const sal_uInt64 mnStartTime; 111*b1cdbd2cSJim Jagielski const sal_uInt64 mnTotalDuration; 112*b1cdbd2cSJim Jagielski const sal_uInt64 mnStepDuration; 113*b1cdbd2cSJim Jagielski ::boost::scoped_ptr<std::vector<Callback> > mpStartCallbacks; 114*b1cdbd2cSJim Jagielski ::boost::scoped_ptr<std::vector<Callback> > mpEndCallbacks; 115*b1cdbd2cSJim Jagielski }; 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski sal_uInt64 GetCurrentTime (void); GetSeconds(const sal_uInt64 nTime)118*b1cdbd2cSJim Jagielskiinline sal_uInt32 GetSeconds (const sal_uInt64 nTime) { return sal_uInt32(nTime / 1000); } GetNanoSeconds(const sal_uInt64 nTime)119*b1cdbd2cSJim Jagielskiinline sal_uInt32 GetNanoSeconds (const sal_uInt64 nTime) { return sal_uInt32((nTime % 1000) * 1000000); } 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski typedef ::boost::shared_ptr<PresenterAnimation> SharedPresenterAnimation; 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielski } } // end of namespace ::sdext::presenter 125*b1cdbd2cSJim Jagielski 126*b1cdbd2cSJim Jagielski #endif 127