Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / inc / animatedsprite.hxx
blob8a49f831b3cc4cd845ee3a5b39dba7d1392a001d
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_INC_ANIMATEDSPRITE_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_ANIMATEDSPRITE_HXX
23 #include <cppcanvas/customsprite.hxx>
25 #include <basegfx/matrix/b2dhommatrix.hxx>
26 #include <basegfx/vector/b2dsize.hxx>
27 #include <basegfx/point/b2dpoint.hxx>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
30 #include "viewlayer.hxx"
32 #include <boost/optional.hpp>
33 #include <memory>
36 /* Definition of AnimatedSprite class */
38 namespace slideshow
40 namespace internal
42 /** This class provides the sprite for animated shapes.
44 Besides encapsulating the Canvas sprite for animated
45 shapes, this class also handles dynamic sprite resizing
46 and all the gory details of offset calculations and
47 rounding prevention.
49 class AnimatedSprite
51 public:
52 /** Create a new AnimatedSprite, for the given metafile
53 shape.
55 @param rViewLayer
56 The destination view layer, on which the animation should appear
58 @param rSpriteSizePixel
59 The overall size of the sprite in device coordinate
60 space, sufficient to display all transformations,
61 shape changes and clips.
63 @param nSpritePrio
64 Priority of the sprite. Must remain static over the
65 lifetime of this object
67 AnimatedSprite( const ViewLayerSharedPtr& rViewLayer,
68 const ::basegfx::B2DSize& rSpriteSizePixel,
69 double nSpritePrio );
70 AnimatedSprite(const AnimatedSprite&) = delete;
71 AnimatedSprite& operator=(const AnimatedSprite&) = delete;
73 /** Resize the sprite.
75 @param rSpriteSizePixel
76 The new size in pixel
78 void resize( const ::basegfx::B2DSize& rSpriteSizePixel );
80 /** Set an offset for the content output in pixel
82 This method offsets the output on the sprite content
83 canvas by the specified amount of device pixel (for
84 subsequent render operations).
86 void setPixelOffset( const ::basegfx::B2DSize& rPixelOffset );
88 /// Show the sprite
89 void show();
91 /// Hide the sprite
92 void hide();
94 /** Query the content canvas for the current sprite.
96 Note that this method must be called
97 <em>every time</em> something is rendered to the
98 sprite, because XCustomSprite does not guarantee the
99 validity of the canvas after a render operation.
101 Furthermore, the view transformation on the returned
102 canvas is already correctly setup, matching the
103 associated destination canvas.
105 ::cppcanvas::CanvasSharedPtr getContentCanvas() const;
107 /** Move the sprite in device pixel space.
109 If the sprite is not yet created, this method has no
110 effect.
112 void movePixel( const ::basegfx::B2DPoint& rNewPos );
114 /** Set the alpha value of the sprite.
116 If the sprite is not yet created, this method has no
117 effect.
119 void setAlpha( double rAlpha );
121 /** Set a sprite clip in user coordinate space.
123 If the sprite is not yet created, this method has no
124 effect.
126 void clip( const ::basegfx::B2DPolyPolygon& rClip );
128 /** Clears a sprite clip
130 If the sprite is not yet created, this method has no
131 effect.
133 void clip();
135 /** Set a sprite transformation.
137 If the sprite is not yet created, this method has no
138 effect.
140 void transform( const ::basegfx::B2DHomMatrix& rTransform );
142 private:
143 ViewLayerSharedPtr mpViewLayer;
145 ::cppcanvas::CustomSpriteSharedPtr mpSprite;
146 ::basegfx::B2DSize maEffectiveSpriteSizePixel;
147 ::basegfx::B2DSize maContentPixelOffset;
149 double mnSpritePrio;
150 double mnAlpha;
151 ::boost::optional< ::basegfx::B2DPoint > maPosPixel;
152 ::boost::optional< ::basegfx::B2DPolyPolygon > maClip;
153 ::boost::optional< ::basegfx::B2DHomMatrix > maTransform;
155 bool mbSpriteVisible;
158 typedef ::std::shared_ptr< AnimatedSprite > AnimatedSpriteSharedPtr;
163 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_ANIMATEDSPRITE_HXX
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */