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>
25 #include <vieweventhandler.hxx>
26 #include <numberanimation.hxx>
28 #include <screenupdater.hxx>
29 #include <soundplayer.hxx>
40 namespace slideshow::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
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() override
;
61 virtual void start( const AnimatableShapeSharedPtr
&,
62 const ShapeAttributeLayerSharedPtr
& ) override
;
63 virtual void end() override
;
66 virtual void viewAdded( const UnoViewSharedPtr
& rView
) override
;
67 virtual void viewRemoved( const UnoViewSharedPtr
& rView
) override
;
68 virtual void viewChanged( const UnoViewSharedPtr
& rView
) override
;
69 virtual void viewsChanged() override
;
72 /** Create a new SlideChanger, for the given leaving and
76 ::std::optional
<SlideSharedPtr
> leavingSlide
,
77 const SlideSharedPtr
& pEnteringSlide
,
78 SoundPlayerSharedPtr pSoundPlayer
,
79 const UnoViewContainer
& rViewContainer
,
80 ScreenUpdater
& rScreenUpdater
,
81 EventMultiplexer
& rEventMultiplexer
,
82 bool bCreateLeavingSprites
= true,
83 bool bCreateEnteringSprites
= true );
85 /// Info on a per-view basis
88 explicit ViewEntry( UnoViewSharedPtr rView
) :
89 mpView(std::move( rView
))
93 /// The view this entry is for
94 UnoViewSharedPtr mpView
;
95 /// outgoing slide sprite
96 std::shared_ptr
<cppcanvas::CustomSprite
> mpOutSprite
;
97 /// incoming slide sprite
98 std::shared_ptr
<cppcanvas::CustomSprite
> mpInSprite
;
99 /// outgoing slide bitmap
100 mutable SlideBitmapSharedPtr mpLeavingBitmap
;
101 /// incoming slide bitmap
102 mutable SlideBitmapSharedPtr mpEnteringBitmap
;
105 const UnoViewSharedPtr
& getView() const { return mpView
; }
108 typedef ::std::vector
<ViewEntry
> ViewsVecT
;
110 ViewsVecT::const_iterator
beginViews() { return maViewData
.begin(); }
111 ViewsVecT::const_iterator
endViews() { return maViewData
.end(); }
113 SlideBitmapSharedPtr
getLeavingBitmap( const ViewEntry
& rViewEntry
) const;
114 SlideBitmapSharedPtr
getEnteringBitmap( const ViewEntry
& rViewEntry
) const;
116 SlideBitmapSharedPtr
createBitmap( const UnoViewSharedPtr
& pView
,
117 const std::optional
<SlideSharedPtr
>& rSlide_
) const;
119 ::basegfx::B2ISize
getEnteringSlideSizePixel( const UnoViewSharedPtr
& pView
) const;
121 static void renderBitmap( SlideBitmapSharedPtr
const& pSlideBitmap
,
122 cppcanvas::CanvasSharedPtr
const& pCanvas
);
124 /** Called on derived classes to perform actions before first run.
126 This typically involves rendering of the initial slide content.
128 @param rViewEntry the view entry
130 @param rDestinationCanvas the canvas to render on
132 virtual void prepareForRun(
133 const ViewEntry
& rViewEntry
,
134 const cppcanvas::CanvasSharedPtr
& rDestinationCanvas
);
136 /** Called on derived classes to implement actual slide change.
138 This method is called with the sprite of the slide coming 'in'
141 Current sprite to operate on. This is the sprite of the
145 Current parameter value
147 virtual void performIn(
148 const cppcanvas::CustomSpriteSharedPtr
& rSprite
,
149 const ViewEntry
& rViewEntry
,
150 const cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
153 /** Called on derived classes to implement actual slide change.
155 This method is called with the sprite of the slide moving 'out'
158 Current sprite to operate on. This is the sprite of the
162 Current parameter value
164 virtual void performOut(
165 const cppcanvas::CustomSpriteSharedPtr
& rSprite
,
166 const ViewEntry
& rViewEntry
,
167 const cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
170 ScreenUpdater
& getScreenUpdater() const { return mrScreenUpdater
; }
174 cppcanvas::CustomSpriteSharedPtr
createSprite(
175 UnoViewSharedPtr
const & pView
,
176 ::basegfx::B2DSize
const & rSpriteSize
,
177 double nPrio
) const;
179 void addSprites( ViewEntry
& rEntry
);
180 static void clearViewEntry( ViewEntry
& rEntry
);
182 SoundPlayerSharedPtr mpSoundPlayer
;
184 EventMultiplexer
& mrEventMultiplexer
;
185 ScreenUpdater
& mrScreenUpdater
;
187 ::std::optional
<SlideSharedPtr
> maLeavingSlide
;
188 SlideSharedPtr mpEnteringSlide
;
190 ViewsVecT maViewData
;
191 const UnoViewContainer
& mrViewContainer
;
193 const bool mbCreateLeavingSprites
;
194 const bool mbCreateEnteringSprites
;
195 bool mbSpritesVisible
;
200 } // namespace presentation::internal
202 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */