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_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>
36 /* Definition of AnimatedSprite class */
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
52 /** Create a new AnimatedSprite, for the given metafile
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.
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
,
70 AnimatedSprite(const AnimatedSprite
&) = delete;
71 AnimatedSprite
& operator=(const AnimatedSprite
&) = delete;
73 /** Resize the sprite.
75 @param rSpriteSizePixel
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
);
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
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
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
126 void clip( const ::basegfx::B2DPolyPolygon
& rClip
);
128 /** Clears a sprite clip
130 If the sprite is not yet created, this method has no
135 /** Set a sprite transformation.
137 If the sprite is not yet created, this method has no
140 void transform( const ::basegfx::B2DHomMatrix
& rTransform
);
143 ViewLayerSharedPtr mpViewLayer
;
145 ::cppcanvas::CustomSpriteSharedPtr mpSprite
;
146 ::basegfx::B2DSize maEffectiveSpriteSizePixel
;
147 ::basegfx::B2DSize maContentPixelOffset
;
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: */