Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / engine / transitions / slidechangebase.hxx
blob9db000fc11062377edb6af45d8493018b55155f1
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 <unoview.hxx>
24 #include <vieweventhandler.hxx>
25 #include <numberanimation.hxx>
26 #include <slide.hxx>
27 #include <screenupdater.hxx>
28 #include <soundplayer.hxx>
30 #include <memory>
31 #include <boost/optional.hpp>
33 namespace cppcanvas
35 class Canvas;
36 class CustomSprite;
39 namespace slideshow {
40 namespace internal {
42 /** Base class for all slide change effects.
44 This class provides the basic sprite and view handling
45 functionality. Derived classes should normally only need to
46 implement the perform() method.
48 class SlideChangeBase : public ViewEventHandler,
49 public NumberAnimation
51 public:
52 SlideChangeBase(const SlideChangeBase&) = delete;
53 SlideChangeBase& operator=(const SlideChangeBase&) = delete;
55 // NumberAnimation
56 virtual bool operator()( double x ) override;
57 virtual double getUnderlyingValue() const override;
59 // Animation
60 virtual void prefetch( const AnimatableShapeSharedPtr&,
61 const ShapeAttributeLayerSharedPtr& ) override;
62 virtual void start( const AnimatableShapeSharedPtr&,
63 const ShapeAttributeLayerSharedPtr& ) override;
64 virtual void end() override;
66 // ViewEventHandler
67 virtual void viewAdded( const UnoViewSharedPtr& rView ) override;
68 virtual void viewRemoved( const UnoViewSharedPtr& rView ) override;
69 virtual void viewChanged( const UnoViewSharedPtr& rView ) override;
70 virtual void viewsChanged() override;
72 protected:
73 /** Create a new SlideChanger, for the given leaving and
74 entering slides.
76 SlideChangeBase(
77 ::boost::optional<SlideSharedPtr> const & leavingSlide,
78 const SlideSharedPtr& pEnteringSlide,
79 const SoundPlayerSharedPtr& pSoundPlayer,
80 const UnoViewContainer& rViewContainer,
81 ScreenUpdater& rScreenUpdater,
82 EventMultiplexer& rEventMultiplexer,
83 bool bCreateLeavingSprites = true,
84 bool bCreateEnteringSprites = true );
86 /// Info on a per-view basis
87 struct ViewEntry
89 explicit ViewEntry( const UnoViewSharedPtr& rView ) :
90 mpView( rView )
94 /// The view this entry is for
95 UnoViewSharedPtr mpView;
96 /// outgoing slide sprite
97 std::shared_ptr<cppcanvas::CustomSprite> mpOutSprite;
98 /// incoming slide sprite
99 std::shared_ptr<cppcanvas::CustomSprite> mpInSprite;
100 /// outgoing slide bitmap
101 mutable SlideBitmapSharedPtr mpLeavingBitmap;
102 /// incoming slide bitmap
103 mutable SlideBitmapSharedPtr mpEnteringBitmap;
105 // for algo access
106 const UnoViewSharedPtr& getView() const { return mpView; }
109 typedef ::std::vector<ViewEntry> ViewsVecT;
111 ViewsVecT::const_iterator beginViews() { return maViewData.begin(); }
112 ViewsVecT::const_iterator endViews() { return maViewData.end(); }
114 SlideBitmapSharedPtr getLeavingBitmap( const ViewEntry& rViewEntry ) const;
115 SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const;
117 SlideBitmapSharedPtr createBitmap( const UnoViewSharedPtr& pView,
118 const boost::optional<SlideSharedPtr>& rSlide_ ) const;
120 ::basegfx::B2ISize getEnteringSlideSizePixel( const UnoViewSharedPtr& pView ) const;
122 static void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
123 std::shared_ptr<cppcanvas::Canvas> const& pCanvas );
125 /** Called on derived classes to perform actions before first run.
127 This typically involves rendering of the initial slide content.
129 @param rViewEntry the view entry
131 @param rDestinationCanvas the canvas to render on
133 virtual void prepareForRun(
134 const ViewEntry& rViewEntry,
135 const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
137 /** Called on derived classes to implement actual slide change.
139 This method is called with the sprite of the slide coming 'in'
141 @param rSprite
142 Current sprite to operate on. This is the sprite of the
143 'entering' slide
145 @param t
146 Current parameter value
148 virtual void performIn(
149 const std::shared_ptr<cppcanvas::CustomSprite>& rSprite,
150 const ViewEntry& rViewEntry,
151 const std::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas,
152 double t );
154 /** Called on derived classes to implement actual slide change.
156 This method is called with the sprite of the slide moving 'out'
158 @param rSprite
159 Current sprite to operate on. This is the sprite of the
160 'leaving' slide
162 @param t
163 Current parameter value
165 virtual void performOut(
166 const std::shared_ptr<cppcanvas::CustomSprite>& rSprite,
167 const ViewEntry& rViewEntry,
168 const std::shared_ptr<cppcanvas::Canvas>& rDestinationCanvas,
169 double t );
171 ScreenUpdater& getScreenUpdater() const { return mrScreenUpdater; }
173 private:
175 std::shared_ptr<cppcanvas::CustomSprite> createSprite(
176 UnoViewSharedPtr const & pView,
177 ::basegfx::B2DSize const & rSpriteSize,
178 double nPrio ) const;
180 void addSprites( ViewEntry& rEntry );
181 static void clearViewEntry( ViewEntry& rEntry );
183 SoundPlayerSharedPtr mpSoundPlayer;
185 EventMultiplexer& mrEventMultiplexer;
186 ScreenUpdater& mrScreenUpdater;
188 ::boost::optional<SlideSharedPtr> maLeavingSlide;
189 SlideSharedPtr mpEnteringSlide;
191 ViewsVecT maViewData;
192 const UnoViewContainer& mrViewContainer;
194 const bool mbCreateLeavingSprites;
195 const bool mbCreateEnteringSprites;
196 bool mbSpritesVisible;
197 bool mbFinished;
198 bool mbPrefetched;
201 } // namespace internal
202 } // namespace presentation
204 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */