build fix
[LibreOffice.git] / slideshow / source / engine / transitions / slidechangebase.hxx
blob13e699f8cc4874c3784e98f83815eb51ec1151a7
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 <memory>
33 #include <boost/optional.hpp>
35 namespace cppcanvas
37 class Canvas;
38 class CustomSprite;
41 namespace slideshow {
42 namespace internal {
44 /** Base class for all slide change effects.
46 This class provides the basic sprite and view handling
47 functionality. Derived classes should normally only need to
48 implement the perform() method.
50 class SlideChangeBase : public ViewEventHandler,
51 public NumberAnimation
53 public:
54 SlideChangeBase(const SlideChangeBase&) = delete;
55 SlideChangeBase& operator=(const SlideChangeBase&) = delete;
57 // NumberAnimation
58 virtual bool operator()( double x ) override;
59 virtual double getUnderlyingValue() const override;
61 // Animation
62 virtual void prefetch( const AnimatableShapeSharedPtr&,
63 const ShapeAttributeLayerSharedPtr& ) override;
64 virtual void start( const AnimatableShapeSharedPtr&,
65 const ShapeAttributeLayerSharedPtr& ) override;
66 virtual void end() override;
68 // ViewEventHandler
69 virtual void viewAdded( const UnoViewSharedPtr& rView ) override;
70 virtual void viewRemoved( const UnoViewSharedPtr& rView ) override;
71 virtual void viewChanged( const UnoViewSharedPtr& rView ) override;
72 virtual void viewsChanged() 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 explicit ViewEntry( const UnoViewSharedPtr& rView ) :
92 mpView( rView )
96 /// The view this entry is for
97 UnoViewSharedPtr mpView;
98 /// outgoing slide sprite
99 std::shared_ptr<cppcanvas::CustomSprite> mpOutSprite;
100 /// incoming slide sprite
101 std::shared_ptr<cppcanvas::CustomSprite> mpInSprite;
102 /// outgoing slide bitmap
103 mutable SlideBitmapSharedPtr mpLeavingBitmap;
104 /// incoming slide bitmap
105 mutable SlideBitmapSharedPtr mpEnteringBitmap;
107 // for algo access
108 const UnoViewSharedPtr& getView() const { return mpView; }
111 typedef ::std::vector<ViewEntry> ViewsVecT;
113 ViewsVecT::const_iterator beginViews() { return maViewData.begin(); }
114 ViewsVecT::const_iterator endViews() { return maViewData.end(); }
116 SlideBitmapSharedPtr getLeavingBitmap( const ViewEntry& rViewEntry ) const;
117 SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const;
119 SlideBitmapSharedPtr createBitmap( const UnoViewSharedPtr& pView,
120 const boost::optional<SlideSharedPtr>& rSlide_ ) const;
122 ::basegfx::B2ISize getEnteringSlideSizePixel( const UnoViewSharedPtr& pView ) const;
124 static void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
125 std::shared_ptr<cppcanvas::Canvas> const& pCanvas );
127 /** Called on derived classes to perform actions before first run.
129 This typically involves rendering of the initial slide content.
131 @param rViewEntry the view entry
133 @param rDestinationCanvas the canvas to render on
135 virtual void prepareForRun(
136 const ViewEntry& rViewEntry,
137 const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
139 /** Called on derived classes to implement actual slide change.
141 This method is called with the sprite of the slide coming 'in'
143 @param rSprite
144 Current sprite to operate on. This is the sprite of the
145 'entering' slide
147 @param t
148 Current parameter value
150 virtual void performIn(
151 const std::shared_ptr<cppcanvas::CustomSprite>& rSprite,
152 const ViewEntry& rViewEntry,
153 const std::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas,
154 double t );
156 /** Called on derived classes to implement actual slide change.
158 This method is called with the sprite of the slide moving 'out'
160 @param rSprite
161 Current sprite to operate on. This is the sprite of the
162 'leaving' slide
164 @param t
165 Current parameter value
167 virtual void performOut(
168 const std::shared_ptr<cppcanvas::CustomSprite>& rSprite,
169 const ViewEntry& rViewEntry,
170 const std::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas,
171 double t );
173 ScreenUpdater& getScreenUpdater() const { return mrScreenUpdater; }
175 private:
177 std::shared_ptr<cppcanvas::CustomSprite> createSprite(
178 UnoViewSharedPtr const & pView,
179 ::basegfx::B2DSize const & rSpriteSize,
180 double nPrio ) const;
182 void addSprites( ViewEntry& rEntry );
183 static void clearViewEntry( ViewEntry& rEntry );
185 SoundPlayerSharedPtr mpSoundPlayer;
187 EventMultiplexer& mrEventMultiplexer;
188 ScreenUpdater& mrScreenUpdater;
190 ::boost::optional<SlideSharedPtr> maLeavingSlide;
191 SlideSharedPtr mpEnteringSlide;
193 ViewsVecT maViewData;
194 const UnoViewContainer& mrViewContainer;
196 const bool mbCreateLeavingSprites;
197 const bool mbCreateEnteringSprites;
198 bool mbSpritesVisible;
199 bool mbFinished;
200 bool mbPrefetched;
203 } // namespace internal
204 } // namespace presentation
206 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */