Update ooo320-m1
[ooovba.git] / slideshow / source / engine / transitions / slidechangebase.hxx
blob27be5321485b544f787156908b57d5b4657b91c3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: slidechangebase.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_SLIDESHOW_TRANSITIONS_SLIDECHANGEBASE_HXX
32 #define INCLUDED_SLIDESHOW_TRANSITIONS_SLIDECHANGEBASE_HXX
34 #include <osl/mutex.hxx>
36 #include "unoview.hxx"
37 #include "vieweventhandler.hxx"
38 #include "numberanimation.hxx"
39 #include "slide.hxx"
40 #include "screenupdater.hxx"
41 #include "soundplayer.hxx"
43 #include <boost/enable_shared_from_this.hpp>
44 #include <boost/noncopyable.hpp>
45 #include <boost/optional.hpp>
47 namespace cppcanvas
49 class Canvas;
50 class CustomSprite;
53 namespace slideshow {
54 namespace internal {
56 /** Base class for all slide change effects.
58 This class provides the basic sprite and view handling
59 functionality. Derived classes should normally only need to
60 implement the perform() method.
62 class SlideChangeBase : public ViewEventHandler,
63 public NumberAnimation,
64 public boost::enable_shared_from_this<SlideChangeBase>,
65 private ::boost::noncopyable
67 public:
68 // NumberAnimation
69 virtual bool operator()( double x );
70 virtual double getUnderlyingValue() const;
72 // Animation
73 virtual void prefetch( const AnimatableShapeSharedPtr&,
74 const ShapeAttributeLayerSharedPtr& );
75 virtual void start( const AnimatableShapeSharedPtr&,
76 const ShapeAttributeLayerSharedPtr& );
77 virtual void end();
79 // ViewEventHandler
80 virtual void viewAdded( const UnoViewSharedPtr& rView );
81 virtual void viewRemoved( const UnoViewSharedPtr& rView );
82 virtual void viewChanged( const UnoViewSharedPtr& rView );
83 virtual void viewsChanged();
85 protected:
86 /** Create a new SlideChanger, for the given leaving and
87 entering slides.
89 SlideChangeBase(
90 ::boost::optional<SlideSharedPtr> const & leavingSlide,
91 const SlideSharedPtr& pEnteringSlide,
92 const SoundPlayerSharedPtr& pSoundPlayer,
93 const UnoViewContainer& rViewContainer,
94 ScreenUpdater& rScreenUpdater,
95 EventMultiplexer& rEventMultiplexer,
96 bool bCreateLeavingSprites = true,
97 bool bCreateEnteringSprites = true );
99 /// Info on a per-view basis
100 struct ViewEntry
102 ViewEntry() {}
104 explicit ViewEntry( const UnoViewSharedPtr& rView ) :
105 mpView( rView )
109 /// The view this entry is for
110 UnoViewSharedPtr mpView;
111 /// outgoing slide sprite
112 boost::shared_ptr<cppcanvas::CustomSprite> mpOutSprite;
113 /// incoming slide sprite
114 boost::shared_ptr<cppcanvas::CustomSprite> mpInSprite;
115 /// outgoing slide bitmap
116 mutable SlideBitmapSharedPtr mpLeavingBitmap;
117 /// incoming slide bitmap
118 mutable SlideBitmapSharedPtr mpEnteringBitmap;
120 // for algo access
121 const UnoViewSharedPtr& getView() const { return mpView; }
124 typedef ::std::vector<ViewEntry> ViewsVecT;
126 ViewsVecT::const_iterator beginViews() { return maViewData.begin(); }
127 ViewsVecT::const_iterator endViews() { return maViewData.end(); }
129 SlideBitmapSharedPtr getLeavingBitmap( const ViewEntry& rViewEntry ) const;
130 SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const;
132 SlideBitmapSharedPtr createBitmap( const UnoViewSharedPtr& pView,
133 const boost::optional<SlideSharedPtr>& rSlide_ ) const;
135 ::basegfx::B2ISize getEnteringSlideSizePixel( const UnoViewSharedPtr& pView ) const;
136 ::basegfx::B2ISize getLeavingSlideSizePixel( const UnoViewSharedPtr& pView ) const;
138 void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
139 boost::shared_ptr<cppcanvas::Canvas> const& pCanvas );
141 /** Called on derived classes to implement actual slide change.
143 This method is called with the sprite of the slide coming 'in'
145 @param rSprite
146 Current sprite to operate on. This is the sprite of the
147 'entering' slide
149 @param t
150 Current parameter value
152 virtual void performIn(
153 const boost::shared_ptr<cppcanvas::CustomSprite>& rSprite,
154 const ViewEntry& rViewEntry,
155 const boost::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas,
156 double t );
158 /** Called on derived classes to implement actual slide change.
160 This method is called with the sprite of the slide moving 'out'
162 @param rSprite
163 Current sprite to operate on. This is the sprite of the
164 'leaving' slide
166 @param t
167 Current parameter value
169 virtual void performOut(
170 const boost::shared_ptr<cppcanvas::CustomSprite>& rSprite,
171 const ViewEntry& rViewEntry,
172 const boost::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas,
173 double t );
175 ScreenUpdater& getScreenUpdater() const { return mrScreenUpdater; }
177 private:
179 boost::shared_ptr<cppcanvas::CustomSprite> createSprite(
180 UnoViewSharedPtr const & pView,
181 ::basegfx::B2DSize const & rSpriteSize,
182 double nPrio ) const;
184 void addSprites( ViewEntry& rEntry );
185 void clearViewEntry( ViewEntry& rEntry );
187 ViewsVecT::iterator lookupView( UnoViewSharedPtr const & pView );
188 ViewsVecT::const_iterator lookupView( UnoViewSharedPtr const & pView ) const;
190 SoundPlayerSharedPtr mpSoundPlayer;
192 EventMultiplexer& mrEventMultiplexer;
193 ScreenUpdater& mrScreenUpdater;
195 ::boost::optional<SlideSharedPtr> maLeavingSlide;
196 SlideSharedPtr mpEnteringSlide;
198 ViewsVecT maViewData;
199 const UnoViewContainer& mrViewContainer;
201 const bool mbCreateLeavingSprites;
202 const bool mbCreateEnteringSprites;
203 bool mbSpritesVisible;
204 bool mbFinished;
205 bool mbPrefetched;
208 } // namespace internal
209 } // namespace presentation
211 #endif /* INCLUDED_SLIDESHOW_TRANSITIONS_SLIDECHANGEBASE_HXX */