bump product version to 5.0.4.1
[LibreOffice.git] / slideshow / source / engine / transitions / slidechangebase.hxx
blob7887ae2ad2eb203f466c5a30b9087bc5d5bff50c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
23 #include <osl/mutex.hxx>
25 #include "unoview.hxx"
26 #include "vieweventhandler.hxx"
27 #include "numberanimation.hxx"
28 #include "slide.hxx"
29 #include "screenupdater.hxx"
30 #include "soundplayer.hxx"
32 #include <boost/enable_shared_from_this.hpp>
33 #include <boost/noncopyable.hpp>
34 #include <boost/optional.hpp>
36 namespace cppcanvas
38 class Canvas;
39 class CustomSprite;
42 namespace slideshow {
43 namespace internal {
45 /** Base class for all slide change effects.
47 This class provides the basic sprite and view handling
48 functionality. Derived classes should normally only need to
49 implement the perform() method.
51 class SlideChangeBase : public ViewEventHandler,
52 public NumberAnimation,
53 public boost::enable_shared_from_this<SlideChangeBase>,
54 private ::boost::noncopyable
56 public:
57 // NumberAnimation
58 virtual bool operator()( double x ) SAL_OVERRIDE;
59 virtual double getUnderlyingValue() const SAL_OVERRIDE;
61 // Animation
62 virtual void prefetch( const AnimatableShapeSharedPtr&,
63 const ShapeAttributeLayerSharedPtr& ) SAL_OVERRIDE;
64 virtual void start( const AnimatableShapeSharedPtr&,
65 const ShapeAttributeLayerSharedPtr& ) SAL_OVERRIDE;
66 virtual void end() SAL_OVERRIDE;
68 // ViewEventHandler
69 virtual void viewAdded( const UnoViewSharedPtr& rView ) SAL_OVERRIDE;
70 virtual void viewRemoved( const UnoViewSharedPtr& rView ) SAL_OVERRIDE;
71 virtual void viewChanged( const UnoViewSharedPtr& rView ) SAL_OVERRIDE;
72 virtual void viewsChanged() SAL_OVERRIDE;
74 protected:
75 /** Create a new SlideChanger, for the given leaving and
76 entering slides.
78 SlideChangeBase(
79 ::boost::optional<SlideSharedPtr> const & leavingSlide,
80 const SlideSharedPtr& pEnteringSlide,
81 const SoundPlayerSharedPtr& pSoundPlayer,
82 const UnoViewContainer& rViewContainer,
83 ScreenUpdater& rScreenUpdater,
84 EventMultiplexer& rEventMultiplexer,
85 bool bCreateLeavingSprites = true,
86 bool bCreateEnteringSprites = true );
88 /// Info on a per-view basis
89 struct ViewEntry
91 ViewEntry() {}
93 explicit ViewEntry( const UnoViewSharedPtr& rView ) :
94 mpView( rView )
98 /// The view this entry is for
99 UnoViewSharedPtr mpView;
100 /// outgoing slide sprite
101 boost::shared_ptr<cppcanvas::CustomSprite> mpOutSprite;
102 /// incoming slide sprite
103 boost::shared_ptr<cppcanvas::CustomSprite> mpInSprite;
104 /// outgoing slide bitmap
105 mutable SlideBitmapSharedPtr mpLeavingBitmap;
106 /// incoming slide bitmap
107 mutable SlideBitmapSharedPtr mpEnteringBitmap;
109 // for algo access
110 const UnoViewSharedPtr& getView() const { return mpView; }
113 typedef ::std::vector<ViewEntry> ViewsVecT;
115 ViewsVecT::const_iterator beginViews() { return maViewData.begin(); }
116 ViewsVecT::const_iterator endViews() { return maViewData.end(); }
118 SlideBitmapSharedPtr getLeavingBitmap( const ViewEntry& rViewEntry ) const;
119 SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const;
121 SlideBitmapSharedPtr createBitmap( const UnoViewSharedPtr& pView,
122 const boost::optional<SlideSharedPtr>& rSlide_ ) const;
124 ::basegfx::B2ISize getEnteringSlideSizePixel( const UnoViewSharedPtr& pView ) const;
126 static void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
127 boost::shared_ptr<cppcanvas::Canvas> const& pCanvas );
129 /** Called on derived classes to perform actions before first run.
131 This typically involves rendering of the initial slide content.
133 @param rViewEntry the view entry
135 @param rDestinationCanvas the canvas to render on
137 virtual void prepareForRun(
138 const ViewEntry& rViewEntry,
139 const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
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 static 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_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */