fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / source / inc / animatedsprite.hxx
blobc6c1e4b9af38729b4e2dcbe23b9b360643fa76ab
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 <boost/shared_ptr.hpp>
34 #include <boost/noncopyable.hpp>
37 /* Definition of AnimatedSprite class */
39 namespace slideshow
41 namespace internal
43 /** This class provides the sprite for animated shapes.
45 Besides encapsulating the Canvas sprite for animated
46 shapes, this class also handles dynamic sprite resizing
47 and all the gory details of offset calculations and
48 rounding prevention.
50 class AnimatedSprite : private boost::noncopyable
52 public:
53 /** Create a new AnimatedSprite, for the given metafile
54 shape.
56 @param rViewLayer
57 The destination view layer, on which the animation should appear
59 @param rSpriteSizePixel
60 The overall size of the sprite in device coordinate
61 space, sufficient to display all transformations,
62 shape changes and clips.
64 @param nSpritePrio
65 Priority of the sprite. Must remain static over the
66 lifetime of this object
68 AnimatedSprite( const ViewLayerSharedPtr& rViewLayer,
69 const ::basegfx::B2DSize& rSpriteSizePixel,
70 double nSpritePrio );
72 /** Resize the sprite.
74 @param rSpriteSizePixel
75 The new size in pixel
77 @return true, if the resize was successful. If false
78 is returned, the sprite might be invalid.
80 bool resize( const ::basegfx::B2DSize& rSpriteSizePixel );
82 /** Set an offset for the content output in pixel
84 This method offsets the output on the sprite content
85 canvas by the specified amount of device pixel (for
86 subsequent render operations).
88 void setPixelOffset( const ::basegfx::B2DSize& rPixelOffset );
90 /// Show the sprite
91 void show();
93 /// Hide the sprite
94 void hide();
96 /** Query the content canvas for the current sprite.
98 Note that this method must be called
99 <em>every time</em> something is rendered to the
100 sprite, because XCustomSprite does not guarantee the
101 validity of the canvas after a render operation.
103 Furthermore, the view transformation on the returned
104 canvas is already correctly setup, matching the
105 associated destination canvas.
107 ::cppcanvas::CanvasSharedPtr getContentCanvas() const;
109 /** Move the sprite in device pixel space.
111 If the sprite is not yet created, this method has no
112 effect.
114 void movePixel( const ::basegfx::B2DPoint& rNewPos );
116 /** Set the alpha value of the sprite.
118 If the sprite is not yet created, this method has no
119 effect.
121 void setAlpha( double rAlpha );
123 /** Set a sprite clip in user coordinate space.
125 If the sprite is not yet created, this method has no
126 effect.
128 void clip( const ::basegfx::B2DPolyPolygon& rClip );
130 /** Clears a sprite clip
132 If the sprite is not yet created, this method has no
133 effect.
135 void clip();
137 /** Set a sprite transformation.
139 If the sprite is not yet created, this method has no
140 effect.
142 void transform( const ::basegfx::B2DHomMatrix& rTransform );
144 private:
145 ViewLayerSharedPtr mpViewLayer;
147 ::cppcanvas::CustomSpriteSharedPtr mpSprite;
148 ::basegfx::B2DSize maEffectiveSpriteSizePixel;
149 ::basegfx::B2DSize maContentPixelOffset;
151 double mnSpritePrio;
152 double mnAlpha;
153 ::boost::optional< ::basegfx::B2DPoint > maPosPixel;
154 ::boost::optional< ::basegfx::B2DPolyPolygon > maClip;
155 ::boost::optional< ::basegfx::B2DHomMatrix > maTransform;
157 bool mbSpriteVisible;
160 typedef ::boost::shared_ptr< AnimatedSprite > AnimatedSpriteSharedPtr;
165 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_ANIMATEDSPRITE_HXX
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */