LibreOffice Module canvas (master)  1
canvascustomspritehelper.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_CANVAS_BASE_CANVASCUSTOMSPRITEHELPER_HXX
21 #define INCLUDED_CANVAS_BASE_CANVASCUSTOMSPRITEHELPER_HXX
22 
30 
31 namespace com::sun::star::geometry { struct AffineMatrix2D; }
32 namespace com::sun::star::geometry { struct RealPoint2D; }
33 namespace com::sun::star::geometry { struct RealSize2D; }
34 namespace com::sun::star::rendering { class XBitmap; }
35 namespace com::sun::star::rendering { class XPolyPolygon2D; }
36 namespace com::sun::star::rendering { struct RenderState; }
37 namespace com::sun::star::rendering { struct ViewState; }
38 
39 
40 namespace canvas
41 {
42  /* Definition of CanvasCustomSpriteHelper class */
43 
48  {
49  public:
52 
62  void init( const css::geometry::RealSize2D& rSpriteSize,
63  const SpriteSurface::Reference& rOwningSpriteCanvas );
64 
70  void disposing();
71 
72  // XCanvas
74  void clearingContent( const Sprite::Reference& rSprite );
75 
77  void checkDrawBitmap( const Sprite::Reference& rSprite,
78  const css::uno::Reference< css::rendering::XBitmap >& xBitmap,
79  const css::rendering::ViewState& viewState,
80  const css::rendering::RenderState& renderState );
81 
82  // XSprite
83  void setAlpha( const Sprite::Reference& rSprite,
84  double alpha );
85  void move( const Sprite::Reference& rSprite,
86  const css::geometry::RealPoint2D& aNewPos,
87  const css::rendering::ViewState& viewState,
88  const css::rendering::RenderState& renderState );
89  void transform( const Sprite::Reference& rSprite,
90  const css::geometry::AffineMatrix2D& aTransformation );
91  void clip( const Sprite::Reference& rSprite,
92  const css::uno::Reference< css::rendering::XPolyPolygon2D >& aClip );
93  void setPriority( const Sprite::Reference& rSprite,
94  double nPriority );
95  void show( const Sprite::Reference& rSprite );
96  void hide( const Sprite::Reference& rSprite );
97 
98  // Sprite
99  bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const;
100  const ::basegfx::B2DPoint& getPosPixel() const { return maPosition; }
101  const ::basegfx::B2DVector& getSizePixel() const { return maSize; }
102  ::basegfx::B2DRange getUpdateArea() const;
103  double getPriority() const { return mfPriority; }
104 
105  // redraw must be implemented by derived - non sensible default implementation
106  // void redraw( const Sprite::Reference& rSprite,
107  // const ::basegfx::B2DPoint& rPos ) const;
108 
109 
110  // Helper methods for derived classes
111 
112 
114  ::basegfx::B2DRange getUpdateArea( const ::basegfx::B2DRange& rUntransformedSpriteBounds ) const;
115 
122  bool isContentFullyOpaque() const { return mbIsContentFullyOpaque; }
123 
125  bool hasTransformChanged() const { return mbTransformDirty; }
126 
128  double getAlpha() const { return mfAlpha; }
129 
131  const css::uno::Reference<
132  css::rendering::XPolyPolygon2D >& getClip() const { return mxClipPoly; }
133 
134  const ::basegfx::B2DHomMatrix& getTransformation() const { return maTransform; }
135 
137  bool isActive() const { return mbActive; }
138 
139  protected:
146  void transformUpdated() const { mbTransformDirty=false; }
147 
148  private:
150  CanvasCustomSpriteHelper& operator=( const CanvasCustomSpriteHelper& ) = delete;
151 
156  virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(
157  css::uno::Reference< css::rendering::XPolyPolygon2D >& xPoly ) const = 0;
158 
170  bool updateClipState( const Sprite::Reference& rSprite );
171 
172 
175 
186 
187  // sprite state
191  css::uno::Reference< css::rendering::XPolyPolygon2D > mxClipPoly;
192  double mfPriority;
193  double mfAlpha;
194  bool mbActive; // true, if not hidden
195 
203 
212 
214  mutable bool mbTransformDirty;
215  };
216 }
217 
218 #endif // INCLUDED_CANVAS_BASE_CANVASCUSTOMSPRITEHELPER_HXX
219 
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const ::basegfx::B2DHomMatrix & getTransformation() const
SpriteSurface::Reference mpSpriteCanvas
Owning sprite canvas.
bool isContentFullyOpaque() const
Returns true, if sprite content bitmap is fully opaque.
double getAlpha() const
Retrieve current alpha value.
::basegfx::B2DRange maCurrClipBounds
Currently active clip area.
#define CANVASTOOLS_DLLPUBLIC
const ::basegfx::B2DPoint & getPosPixel() const
Base class for an XSprite helper implementation - to be used in concert with CanvasCustomSpriteBase.
::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(const uno::Reference< rendering::XPolyPolygon2D > &xPoly)
bool mbActive
const css::uno::Reference< css::rendering::XPolyPolygon2D > & getClip() const
Retrieve current clip.
void transformUpdated() const
Notifies that caller is again in sync with current transformation.
bool mbIsCurrClipRectangle
If true, denotes that the current sprite clip is a true rectangle, i.e.
bool hasTransformChanged() const
Returns true, if transformation has changed since last transformUpdated() call.
const ::basegfx::B2DVector & getSizePixel() const
bool mbTransformDirty
True, iff maTransform has changed.
css::uno::Reference< css::rendering::XPolyPolygon2D > mxClipPoly
ViewState
bool isActive() const
Retrieve current activation state.
FILE * init(int, char **)
::basegfx::B2IVector maSize
Definition: dx_9rm.cxx:115