1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
27 #include <screenupdater.hxx>
28 #include <soundplayer.hxx>
31 #include <boost/optional.hpp>
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
52 SlideChangeBase(const SlideChangeBase
&) = delete;
53 SlideChangeBase
& operator=(const SlideChangeBase
&) = delete;
56 virtual bool operator()( double x
) override
;
57 virtual double getUnderlyingValue() const override
;
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
;
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
;
73 /** Create a new SlideChanger, for the given leaving and
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
89 explicit ViewEntry( const UnoViewSharedPtr
& 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
;
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'
142 Current sprite to operate on. This is the sprite of the
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
,
154 /** Called on derived classes to implement actual slide change.
156 This method is called with the sprite of the slide moving 'out'
159 Current sprite to operate on. This is the sprite of the
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
,
171 ScreenUpdater
& getScreenUpdater() const { return mrScreenUpdater
; }
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
;
201 } // namespace internal
202 } // namespace presentation
204 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */