Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
21 : #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
22 :
23 : #include <osl/mutex.hxx>
24 :
25 : #include "unoview.hxx"
26 : #include "vieweventhandler.hxx"
27 : #include "numberanimation.hxx"
28 : #include "slide.hxx"
29 : #include "screenupdater.hxx"
30 : #include "soundplayer.hxx"
31 :
32 : #include <boost/enable_shared_from_this.hpp>
33 : #include <boost/noncopyable.hpp>
34 : #include <boost/optional.hpp>
35 :
36 : namespace cppcanvas
37 : {
38 : class Canvas;
39 : class CustomSprite;
40 : }
41 :
42 : namespace slideshow {
43 : namespace internal {
44 :
45 : /** Base class for all slide change effects.
46 :
47 : This class provides the basic sprite and view handling
48 : functionality. Derived classes should normally only need to
49 : implement the perform() method.
50 : */
51 0 : class SlideChangeBase : public ViewEventHandler,
52 : public NumberAnimation,
53 : public boost::enable_shared_from_this<SlideChangeBase>,
54 : private ::boost::noncopyable
55 : {
56 : public:
57 : // NumberAnimation
58 : virtual bool operator()( double x ) SAL_OVERRIDE;
59 : virtual double getUnderlyingValue() const SAL_OVERRIDE;
60 :
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;
67 :
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;
73 :
74 : protected:
75 : /** Create a new SlideChanger, for the given leaving and
76 : entering slides.
77 : */
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 );
87 :
88 : /// Info on a per-view basis
89 0 : struct ViewEntry
90 : {
91 : ViewEntry() {}
92 :
93 0 : explicit ViewEntry( const UnoViewSharedPtr& rView ) :
94 0 : mpView( rView )
95 : {
96 0 : }
97 :
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;
108 :
109 : // for algo access
110 0 : const UnoViewSharedPtr& getView() const { return mpView; }
111 : };
112 :
113 : typedef ::std::vector<ViewEntry> ViewsVecT;
114 :
115 0 : ViewsVecT::const_iterator beginViews() { return maViewData.begin(); }
116 0 : ViewsVecT::const_iterator endViews() { return maViewData.end(); }
117 :
118 : SlideBitmapSharedPtr getLeavingBitmap( const ViewEntry& rViewEntry ) const;
119 : SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const;
120 :
121 : SlideBitmapSharedPtr createBitmap( const UnoViewSharedPtr& pView,
122 : const boost::optional<SlideSharedPtr>& rSlide_ ) const;
123 :
124 : ::basegfx::B2ISize getEnteringSlideSizePixel( const UnoViewSharedPtr& pView ) const;
125 :
126 : static void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
127 : boost::shared_ptr<cppcanvas::Canvas> const& pCanvas );
128 :
129 : /** Called on derived classes to perform actions before first run.
130 :
131 : This typically involves rendering of the initial slide content.
132 :
133 : @param rViewEntry the view entry
134 :
135 : @param rDestinationCanvas the canvas to render on
136 : */
137 : virtual void prepareForRun(
138 : const ViewEntry& rViewEntry,
139 : const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
140 :
141 : /** Called on derived classes to implement actual slide change.
142 :
143 : This method is called with the sprite of the slide coming 'in'
144 :
145 : @param rSprite
146 : Current sprite to operate on. This is the sprite of the
147 : 'entering' slide
148 :
149 : @param t
150 : Current parameter value
151 : */
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 );
157 :
158 : /** Called on derived classes to implement actual slide change.
159 :
160 : This method is called with the sprite of the slide moving 'out'
161 :
162 : @param rSprite
163 : Current sprite to operate on. This is the sprite of the
164 : 'leaving' slide
165 :
166 : @param t
167 : Current parameter value
168 : */
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 );
174 :
175 0 : ScreenUpdater& getScreenUpdater() const { return mrScreenUpdater; }
176 :
177 : private:
178 :
179 : boost::shared_ptr<cppcanvas::CustomSprite> createSprite(
180 : UnoViewSharedPtr const & pView,
181 : ::basegfx::B2DSize const & rSpriteSize,
182 : double nPrio ) const;
183 :
184 : void addSprites( ViewEntry& rEntry );
185 : static void clearViewEntry( ViewEntry& rEntry );
186 :
187 : ViewsVecT::iterator lookupView( UnoViewSharedPtr const & pView );
188 : ViewsVecT::const_iterator lookupView( UnoViewSharedPtr const & pView ) const;
189 :
190 : SoundPlayerSharedPtr mpSoundPlayer;
191 :
192 : EventMultiplexer& mrEventMultiplexer;
193 : ScreenUpdater& mrScreenUpdater;
194 :
195 : ::boost::optional<SlideSharedPtr> maLeavingSlide;
196 : SlideSharedPtr mpEnteringSlide;
197 :
198 : ViewsVecT maViewData;
199 : const UnoViewContainer& mrViewContainer;
200 :
201 : const bool mbCreateLeavingSprites;
202 : const bool mbCreateEnteringSprites;
203 : bool mbSpritesVisible;
204 : bool mbFinished;
205 : bool mbPrefetched;
206 : };
207 :
208 : } // namespace internal
209 : } // namespace presentation
210 :
211 : #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
212 :
213 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|