android: Update app-specific/MIME type icons
[LibreOffice.git] / slideshow / source / engine / transitions / slidechangebase.hxx
blob1d23d9ce7247abfc7aa76160149d394864bd2264
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 <utility>
25 #include <vieweventhandler.hxx>
26 #include <numberanimation.hxx>
27 #include <slide.hxx>
28 #include <screenupdater.hxx>
29 #include <soundplayer.hxx>
31 #include <memory>
32 #include <optional>
34 namespace cppcanvas
36 class Canvas;
37 class CustomSprite;
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
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() override;
61 virtual void start( const AnimatableShapeSharedPtr&,
62 const ShapeAttributeLayerSharedPtr& ) override;
63 virtual void end() override;
65 // ViewEventHandler
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;
71 protected:
72 /** Create a new SlideChanger, for the given leaving and
73 entering slides.
75 SlideChangeBase(
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
86 struct ViewEntry
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;
104 // for algo access
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'
140 @param rSprite
141 Current sprite to operate on. This is the sprite of the
142 'entering' slide
144 @param t
145 Current parameter value
147 virtual void performIn(
148 const cppcanvas::CustomSpriteSharedPtr& rSprite,
149 const ViewEntry& rViewEntry,
150 const cppcanvas::CanvasSharedPtr& rDestinationCanvas,
151 double t );
153 /** Called on derived classes to implement actual slide change.
155 This method is called with the sprite of the slide moving 'out'
157 @param rSprite
158 Current sprite to operate on. This is the sprite of the
159 'leaving' slide
161 @param t
162 Current parameter value
164 virtual void performOut(
165 const cppcanvas::CustomSpriteSharedPtr& rSprite,
166 const ViewEntry& rViewEntry,
167 const cppcanvas::CanvasSharedPtr& rDestinationCanvas,
168 double t );
170 ScreenUpdater& getScreenUpdater() const { return mrScreenUpdater; }
172 private:
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;
196 bool mbFinished;
197 bool mbPrefetched;
200 } // namespace presentation::internal
202 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */