1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_TRANSITIONS_SLIDECHANGEBASE_HXX 25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_TRANSITIONS_SLIDECHANGEBASE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <osl/mutex.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "unoview.hxx" 30cdf0e10cSrcweir #include "vieweventhandler.hxx" 31cdf0e10cSrcweir #include "numberanimation.hxx" 32cdf0e10cSrcweir #include "slide.hxx" 33cdf0e10cSrcweir #include "screenupdater.hxx" 34cdf0e10cSrcweir #include "soundplayer.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <boost/enable_shared_from_this.hpp> 37cdf0e10cSrcweir #include <boost/noncopyable.hpp> 38cdf0e10cSrcweir #include <boost/optional.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace cppcanvas 41cdf0e10cSrcweir { 42cdf0e10cSrcweir class Canvas; 43cdf0e10cSrcweir class CustomSprite; 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir namespace slideshow { 47cdf0e10cSrcweir namespace internal { 48cdf0e10cSrcweir 49cdf0e10cSrcweir /** Base class for all slide change effects. 50cdf0e10cSrcweir 51cdf0e10cSrcweir This class provides the basic sprite and view handling 52cdf0e10cSrcweir functionality. Derived classes should normally only need to 53cdf0e10cSrcweir implement the perform() method. 54cdf0e10cSrcweir */ 55cdf0e10cSrcweir class SlideChangeBase : public ViewEventHandler, 56cdf0e10cSrcweir public NumberAnimation, 57cdf0e10cSrcweir public boost::enable_shared_from_this<SlideChangeBase>, 58cdf0e10cSrcweir private ::boost::noncopyable 59cdf0e10cSrcweir { 60cdf0e10cSrcweir public: 61cdf0e10cSrcweir // NumberAnimation 62cdf0e10cSrcweir virtual bool operator()( double x ); 63cdf0e10cSrcweir virtual double getUnderlyingValue() const; 64cdf0e10cSrcweir 65cdf0e10cSrcweir // Animation 66cdf0e10cSrcweir virtual void prefetch( const AnimatableShapeSharedPtr&, 67cdf0e10cSrcweir const ShapeAttributeLayerSharedPtr& ); 68cdf0e10cSrcweir virtual void start( const AnimatableShapeSharedPtr&, 69cdf0e10cSrcweir const ShapeAttributeLayerSharedPtr& ); 70cdf0e10cSrcweir virtual void end(); 71cdf0e10cSrcweir 72cdf0e10cSrcweir // ViewEventHandler 73cdf0e10cSrcweir virtual void viewAdded( const UnoViewSharedPtr& rView ); 74cdf0e10cSrcweir virtual void viewRemoved( const UnoViewSharedPtr& rView ); 75cdf0e10cSrcweir virtual void viewChanged( const UnoViewSharedPtr& rView ); 76cdf0e10cSrcweir virtual void viewsChanged(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir protected: 79cdf0e10cSrcweir /** Create a new SlideChanger, for the given leaving and 80cdf0e10cSrcweir entering slides. 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir SlideChangeBase( 83cdf0e10cSrcweir ::boost::optional<SlideSharedPtr> const & leavingSlide, 84cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide, 85cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer, 86cdf0e10cSrcweir const UnoViewContainer& rViewContainer, 87cdf0e10cSrcweir ScreenUpdater& rScreenUpdater, 88cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer, 89cdf0e10cSrcweir bool bCreateLeavingSprites = true, 90cdf0e10cSrcweir bool bCreateEnteringSprites = true ); 91cdf0e10cSrcweir 92cdf0e10cSrcweir /// Info on a per-view basis 93cdf0e10cSrcweir struct ViewEntry 94cdf0e10cSrcweir { ViewEntryslideshow::internal::SlideChangeBase::ViewEntry95cdf0e10cSrcweir ViewEntry() {} 96cdf0e10cSrcweir ViewEntryslideshow::internal::SlideChangeBase::ViewEntry97cdf0e10cSrcweir explicit ViewEntry( const UnoViewSharedPtr& rView ) : 98cdf0e10cSrcweir mpView( rView ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir /// The view this entry is for 103cdf0e10cSrcweir UnoViewSharedPtr mpView; 104cdf0e10cSrcweir /// outgoing slide sprite 105cdf0e10cSrcweir boost::shared_ptr<cppcanvas::CustomSprite> mpOutSprite; 106cdf0e10cSrcweir /// incoming slide sprite 107cdf0e10cSrcweir boost::shared_ptr<cppcanvas::CustomSprite> mpInSprite; 108cdf0e10cSrcweir /// outgoing slide bitmap 109cdf0e10cSrcweir mutable SlideBitmapSharedPtr mpLeavingBitmap; 110cdf0e10cSrcweir /// incoming slide bitmap 111cdf0e10cSrcweir mutable SlideBitmapSharedPtr mpEnteringBitmap; 112cdf0e10cSrcweir 113cdf0e10cSrcweir // for algo access getViewslideshow::internal::SlideChangeBase::ViewEntry114cdf0e10cSrcweir const UnoViewSharedPtr& getView() const { return mpView; } 115cdf0e10cSrcweir }; 116cdf0e10cSrcweir 117cdf0e10cSrcweir typedef ::std::vector<ViewEntry> ViewsVecT; 118cdf0e10cSrcweir beginViews()119cdf0e10cSrcweir ViewsVecT::const_iterator beginViews() { return maViewData.begin(); } endViews()120cdf0e10cSrcweir ViewsVecT::const_iterator endViews() { return maViewData.end(); } 121cdf0e10cSrcweir 122cdf0e10cSrcweir SlideBitmapSharedPtr getLeavingBitmap( const ViewEntry& rViewEntry ) const; 123cdf0e10cSrcweir SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const; 124cdf0e10cSrcweir 125cdf0e10cSrcweir SlideBitmapSharedPtr createBitmap( const UnoViewSharedPtr& pView, 126cdf0e10cSrcweir const boost::optional<SlideSharedPtr>& rSlide_ ) const; 127cdf0e10cSrcweir 128cdf0e10cSrcweir ::basegfx::B2ISize getEnteringSlideSizePixel( const UnoViewSharedPtr& pView ) const; 129cdf0e10cSrcweir ::basegfx::B2ISize getLeavingSlideSizePixel( const UnoViewSharedPtr& pView ) const; 130cdf0e10cSrcweir 131cdf0e10cSrcweir void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap, 132cdf0e10cSrcweir boost::shared_ptr<cppcanvas::Canvas> const& pCanvas ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir /** Called on derived classes to implement actual slide change. 135cdf0e10cSrcweir 136cdf0e10cSrcweir This method is called with the sprite of the slide coming 'in' 137cdf0e10cSrcweir 138cdf0e10cSrcweir @param rSprite 139cdf0e10cSrcweir Current sprite to operate on. This is the sprite of the 140cdf0e10cSrcweir 'entering' slide 141cdf0e10cSrcweir 142cdf0e10cSrcweir @param t 143cdf0e10cSrcweir Current parameter value 144cdf0e10cSrcweir */ 145cdf0e10cSrcweir virtual void performIn( 146cdf0e10cSrcweir const boost::shared_ptr<cppcanvas::CustomSprite>& rSprite, 147cdf0e10cSrcweir const ViewEntry& rViewEntry, 148cdf0e10cSrcweir const boost::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas, 149cdf0e10cSrcweir double t ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir /** Called on derived classes to implement actual slide change. 152cdf0e10cSrcweir 153cdf0e10cSrcweir This method is called with the sprite of the slide moving 'out' 154cdf0e10cSrcweir 155cdf0e10cSrcweir @param rSprite 156cdf0e10cSrcweir Current sprite to operate on. This is the sprite of the 157cdf0e10cSrcweir 'leaving' slide 158cdf0e10cSrcweir 159cdf0e10cSrcweir @param t 160cdf0e10cSrcweir Current parameter value 161cdf0e10cSrcweir */ 162cdf0e10cSrcweir virtual void performOut( 163cdf0e10cSrcweir const boost::shared_ptr<cppcanvas::CustomSprite>& rSprite, 164cdf0e10cSrcweir const ViewEntry& rViewEntry, 165cdf0e10cSrcweir const boost::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas, 166cdf0e10cSrcweir double t ); 167cdf0e10cSrcweir getScreenUpdater() const168cdf0e10cSrcweir ScreenUpdater& getScreenUpdater() const { return mrScreenUpdater; } 169cdf0e10cSrcweir 170cdf0e10cSrcweir private: 171cdf0e10cSrcweir 172cdf0e10cSrcweir boost::shared_ptr<cppcanvas::CustomSprite> createSprite( 173cdf0e10cSrcweir UnoViewSharedPtr const & pView, 174cdf0e10cSrcweir ::basegfx::B2DSize const & rSpriteSize, 175cdf0e10cSrcweir double nPrio ) const; 176cdf0e10cSrcweir 177cdf0e10cSrcweir void addSprites( ViewEntry& rEntry ); 178cdf0e10cSrcweir void clearViewEntry( ViewEntry& rEntry ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir ViewsVecT::iterator lookupView( UnoViewSharedPtr const & pView ); 181cdf0e10cSrcweir ViewsVecT::const_iterator lookupView( UnoViewSharedPtr const & pView ) const; 182cdf0e10cSrcweir 183cdf0e10cSrcweir SoundPlayerSharedPtr mpSoundPlayer; 184cdf0e10cSrcweir 185cdf0e10cSrcweir EventMultiplexer& mrEventMultiplexer; 186cdf0e10cSrcweir ScreenUpdater& mrScreenUpdater; 187cdf0e10cSrcweir 188cdf0e10cSrcweir ::boost::optional<SlideSharedPtr> maLeavingSlide; 189cdf0e10cSrcweir SlideSharedPtr mpEnteringSlide; 190cdf0e10cSrcweir 191cdf0e10cSrcweir ViewsVecT maViewData; 192cdf0e10cSrcweir const UnoViewContainer& mrViewContainer; 193cdf0e10cSrcweir 194cdf0e10cSrcweir const bool mbCreateLeavingSprites; 195cdf0e10cSrcweir const bool mbCreateEnteringSprites; 196cdf0e10cSrcweir bool mbSpritesVisible; 197cdf0e10cSrcweir bool mbFinished; 198cdf0e10cSrcweir bool mbPrefetched; 199cdf0e10cSrcweir }; 200cdf0e10cSrcweir 201cdf0e10cSrcweir } // namespace internal 202cdf0e10cSrcweir } // namespace presentation 203cdf0e10cSrcweir 204cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_TRANSITIONS_SLIDECHANGEBASE_HXX */ 205