LibreOffice Module canvas (master)  1
inc/base/sprite.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 
22 #include <rtl/ref.hxx>
23 #include <com/sun/star/lang/XComponent.hpp>
25 
26 namespace basegfx
27 {
28  class B2DVector;
29  class B2DRange;
30 }
31 
32 namespace canvas
33 {
34  /* Definition of Sprite interface (as we mix with UNO here, has to
35  be XInterface - reference holders to a Sprite must be able to
36  control lifetime of reference target)
37  */
38 
50  class Sprite : public css::lang::XComponent
51  {
52  public:
53  typedef ::rtl::Reference< Sprite > Reference;
54 
65  virtual bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const = 0;
66 
69  virtual bool isContentChanged() const = 0;
70 
73  virtual ::basegfx::B2DPoint getPosPixel() const = 0;
74 
77  virtual ::basegfx::B2DVector getSizePixel() const = 0;
78 
84  virtual ::basegfx::B2DRange getUpdateArea() const = 0;
85 
88  virtual double getPriority() const = 0;
89 
90  protected:
91  ~Sprite() {}
92  };
93 
97  {
98  bool operator()( const Sprite::Reference& rLHS,
99  const Sprite::Reference& rRHS )
100  {
101  const double nPrioL( rLHS->getPriority() );
102  const double nPrioR( rRHS->getPriority() );
103 
104  // if prios are equal, tie-break on ptr value
105  return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR;
106  }
107  };
108 }
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator()(const Sprite::Reference &rLHS, const Sprite::Reference &rRHS)
Functor providing a StrictWeakOrdering for sprite references.
virtual ::basegfx::B2DRange getUpdateArea() const =0
Get area that is currently covered by the sprite.
virtual ::basegfx::B2DVector getSizePixel() const =0
Query size of the sprite in pixel.
::rtl::Reference< Sprite > Reference
virtual bool isAreaUpdateOpaque(const ::basegfx::B2DRange &rUpdateArea) const =0
Query whether sprite update will fully cover the given area.
Helper interface to connect SpriteCanvas with various sprite implementations.
virtual bool isContentChanged() const =0
Query whether content has changed.
virtual double getPriority() const =0
Query sprite priority.
virtual ::basegfx::B2DPoint getPosPixel() const =0
Query position of the left, top pixel of the sprite.