LibreOffice Module slideshow (master) 1
slidechangebase.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
21#define INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
22
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>
30
31#include <memory>
32#include <optional>
33
34namespace cppcanvas
35{
36 class Canvas;
37 class CustomSprite;
38}
39
40namespace slideshow::internal {
41
49 public NumberAnimation
50{
51public:
54
55 // NumberAnimation
56 virtual bool operator()( double x ) override;
57 virtual double getUnderlyingValue() const override;
58
59 // Animation
60 virtual void prefetch() override;
61 virtual void start( const AnimatableShapeSharedPtr&,
62 const ShapeAttributeLayerSharedPtr& ) override;
63 virtual void end() override;
64
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;
70
71protected:
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 );
84
86 struct ViewEntry
87 {
88 explicit ViewEntry( UnoViewSharedPtr rView ) :
89 mpView(std::move( rView ))
90 {
91 }
92
96 std::shared_ptr<cppcanvas::CustomSprite> mpOutSprite;
98 std::shared_ptr<cppcanvas::CustomSprite> mpInSprite;
103
104 // for algo access
105 const UnoViewSharedPtr& getView() const { return mpView; }
106 };
107
108 typedef ::std::vector<ViewEntry> ViewsVecT;
109
110 ViewsVecT::const_iterator beginViews() { return maViewData.begin(); }
111 ViewsVecT::const_iterator endViews() { return maViewData.end(); }
112
113 SlideBitmapSharedPtr getLeavingBitmap( const ViewEntry& rViewEntry ) const;
114 SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const;
115
117 const std::optional<SlideSharedPtr>& rSlide_ ) const;
118
120
121 static void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
122 cppcanvas::CanvasSharedPtr const& pCanvas );
123
132 virtual void prepareForRun(
133 const ViewEntry& rViewEntry,
134 const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
135
147 virtual void performIn(
149 const ViewEntry& rViewEntry,
150 const cppcanvas::CanvasSharedPtr& rDestinationCanvas,
151 double t );
152
164 virtual void performOut(
166 const ViewEntry& rViewEntry,
167 const cppcanvas::CanvasSharedPtr& rDestinationCanvas,
168 double t );
169
171
172private:
173
175 UnoViewSharedPtr const & pView,
176 ::basegfx::B2DSize const & rSpriteSize,
177 double nPrio ) const;
178
179 void addSprites( ViewEntry& rEntry );
180 static void clearViewEntry( ViewEntry& rEntry );
181
183
186
187 ::std::optional<SlideSharedPtr> maLeavingSlide;
189
192
198};
199
200} // namespace presentation::internal
201
202#endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_TRANSITIONS_SLIDECHANGEBASE_HXX
203
204/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class multiplexes user-activated and slide-show global events.
Interface defining a number animation.
Base class for all slide change effects.
::std::vector< ViewEntry > ViewsVecT
static void clearViewEntry(ViewEntry &rEntry)
virtual void end() override
Notify that the animation is about to end.
ViewsVecT::const_iterator endViews()
virtual void start(const AnimatableShapeSharedPtr &, const ShapeAttributeLayerSharedPtr &) override
Notify that the animation is about to begin.
cppcanvas::CustomSpriteSharedPtr createSprite(UnoViewSharedPtr const &pView, ::basegfx::B2DSize const &rSpriteSize, double nPrio) const
::basegfx::B2ISize getEnteringSlideSizePixel(const UnoViewSharedPtr &pView) const
SlideChangeBase(const SlideChangeBase &)=delete
virtual void prefetch() override
Notify that the animation going active soon.
virtual void viewRemoved(const UnoViewSharedPtr &rView) override
Notify removed view.
virtual void viewAdded(const UnoViewSharedPtr &rView) override
Notify new view.
SlideBitmapSharedPtr getEnteringBitmap(const ViewEntry &rViewEntry) const
static void renderBitmap(SlideBitmapSharedPtr const &pSlideBitmap, cppcanvas::CanvasSharedPtr const &pCanvas)
virtual void viewChanged(const UnoViewSharedPtr &rView) override
Notify changed view.
virtual double getUnderlyingValue() const override
Request the underlying value for this animation.
virtual void performIn(const cppcanvas::CustomSpriteSharedPtr &rSprite, const ViewEntry &rViewEntry, const cppcanvas::CanvasSharedPtr &rDestinationCanvas, double t)
Called on derived classes to implement actual slide change.
SlideBitmapSharedPtr createBitmap(const UnoViewSharedPtr &pView, const std::optional< SlideSharedPtr > &rSlide_) const
virtual bool operator()(double x) override
Set the animation to value x.
SlideChangeBase(::std::optional< SlideSharedPtr > leavingSlide, const SlideSharedPtr &pEnteringSlide, SoundPlayerSharedPtr pSoundPlayer, const UnoViewContainer &rViewContainer, ScreenUpdater &rScreenUpdater, EventMultiplexer &rEventMultiplexer, bool bCreateLeavingSprites=true, bool bCreateEnteringSprites=true)
Create a new SlideChanger, for the given leaving and entering slides.
ScreenUpdater & getScreenUpdater() const
virtual void performOut(const cppcanvas::CustomSpriteSharedPtr &rSprite, const ViewEntry &rViewEntry, const cppcanvas::CanvasSharedPtr &rDestinationCanvas, double t)
Called on derived classes to implement actual slide change.
SlideBitmapSharedPtr getLeavingBitmap(const ViewEntry &rViewEntry) const
virtual void viewsChanged() override
Notify that all views changed.
const UnoViewContainer & mrViewContainer
SlideChangeBase & operator=(const SlideChangeBase &)=delete
ViewsVecT::const_iterator beginViews()
virtual void prepareForRun(const ViewEntry &rViewEntry, const cppcanvas::CanvasSharedPtr &rDestinationCanvas)
Called on derived classes to perform actions before first run.
::std::optional< SlideSharedPtr > maLeavingSlide
Interface for handling view events.
std::shared_ptr< ::cppcanvas::CustomSprite > CustomSpriteSharedPtr
std::shared_ptr< Canvas > CanvasSharedPtr
::std::shared_ptr< AnimatableShape > AnimatableShapeSharedPtr
::std::shared_ptr< SoundPlayer > SoundPlayerSharedPtr
::std::shared_ptr< SlideBitmap > SlideBitmapSharedPtr
Definition: slidebitmap.hxx:76
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
::std::shared_ptr< Slide > SlideSharedPtr
Definition: slide.hxx:148
std::shared_ptr< UnoView > UnoViewSharedPtr
std::shared_ptr< cppcanvas::CustomSprite > mpOutSprite
outgoing slide sprite
UnoViewSharedPtr mpView
The view this entry is for.
std::shared_ptr< cppcanvas::CustomSprite > mpInSprite
incoming slide sprite
SlideBitmapSharedPtr mpLeavingBitmap
outgoing slide bitmap
SlideBitmapSharedPtr mpEnteringBitmap
incoming slide bitmap