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 #pragma once
21 
27 #include <base/spritesurface.hxx>
29 
30 namespace com::sun::star::geometry { struct AffineMatrix2D; }
31 namespace com::sun::star::geometry { struct RealPoint2D; }
32 namespace com::sun::star::geometry { struct RealSize2D; }
33 namespace com::sun::star::rendering { class XBitmap; }
34 namespace com::sun::star::rendering { class XPolyPolygon2D; }
35 namespace com::sun::star::rendering { struct RenderState; }
36 namespace com::sun::star::rendering { struct ViewState; }
37 
38 
39 namespace canvas
40 {
41  /* Definition of CanvasCustomSpriteHelper class */
42 
47  {
48  public:
51 
61  void init( const css::geometry::RealSize2D& rSpriteSize,
62  const SpriteSurface::Reference& rOwningSpriteCanvas );
63 
69  void disposing();
70 
71  // XCanvas
73  void clearingContent( const Sprite::Reference& rSprite );
74 
76  void checkDrawBitmap( const Sprite::Reference& rSprite,
77  const css::uno::Reference< css::rendering::XBitmap >& xBitmap,
78  const css::rendering::ViewState& viewState,
79  const css::rendering::RenderState& renderState );
80 
81  // XSprite
82  void setAlpha( const Sprite::Reference& rSprite,
83  double alpha );
84  void move( const Sprite::Reference& rSprite,
85  const css::geometry::RealPoint2D& aNewPos,
86  const css::rendering::ViewState& viewState,
87  const css::rendering::RenderState& renderState );
88  void transform( const Sprite::Reference& rSprite,
89  const css::geometry::AffineMatrix2D& aTransformation );
90  void clip( const Sprite::Reference& rSprite,
91  const css::uno::Reference< css::rendering::XPolyPolygon2D >& aClip );
92  void setPriority( const Sprite::Reference& rSprite,
93  double nPriority );
94  void show( const Sprite::Reference& rSprite );
95  void hide( const Sprite::Reference& rSprite );
96 
97  // Sprite
98  bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const;
99  const ::basegfx::B2DPoint& getPosPixel() const { return maPosition; }
100  const ::basegfx::B2DVector& getSizePixel() const { return maSize; }
101  ::basegfx::B2DRange getUpdateArea() const;
102  double getPriority() const { return mfPriority; }
103 
104  // redraw must be implemented by derived - non sensible default implementation
105  // void redraw( const Sprite::Reference& rSprite,
106  // const ::basegfx::B2DPoint& rPos ) const;
107 
108 
109  // Helper methods for derived classes
110 
111 
113  ::basegfx::B2DRange getUpdateArea( const ::basegfx::B2DRange& rUntransformedSpriteBounds ) const;
114 
121  bool isContentFullyOpaque() const { return mbIsContentFullyOpaque; }
122 
124  bool hasTransformChanged() const { return mbTransformDirty; }
125 
127  double getAlpha() const { return mfAlpha; }
128 
130  const css::uno::Reference<
131  css::rendering::XPolyPolygon2D >& getClip() const { return mxClipPoly; }
132 
133  const ::basegfx::B2DHomMatrix& getTransformation() const { return maTransform; }
134 
136  bool isActive() const { return mbActive; }
137 
138  protected:
145  void transformUpdated() const { mbTransformDirty=false; }
146 
147  private:
149  CanvasCustomSpriteHelper& operator=( const CanvasCustomSpriteHelper& ) = delete;
150 
155  virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(
156  css::uno::Reference< css::rendering::XPolyPolygon2D >& xPoly ) const = 0;
157 
169  bool updateClipState( const Sprite::Reference& rSprite );
170 
171 
174 
185 
186  // sprite state
190  css::uno::Reference< css::rendering::XPolyPolygon2D > mxClipPoly;
191  double mfPriority;
192  double mfAlpha;
193  bool mbActive; // true, if not hidden
194 
202 
211 
213  mutable bool mbTransformDirty;
214  };
215 }
216 
217 /* 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
geometry::RealPoint2D maPosition
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.
basegfx::B2DHomMatrix maTransform
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:116