/src/libreoffice/include/svx/sdr/overlay/overlayobject.hxx
Line | Count | Source |
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_SVX_SDR_OVERLAY_OVERLAYOBJECT_HXX |
21 | | #define INCLUDED_SVX_SDR_OVERLAY_OVERLAYOBJECT_HXX |
22 | | |
23 | | #include <basegfx/point/b2dpoint.hxx> |
24 | | #include <basegfx/range/b2drange.hxx> |
25 | | #include <tools/color.hxx> |
26 | | #include <svx/sdr/animation/scheduler.hxx> |
27 | | #include <svx/svxdllapi.h> |
28 | | #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> |
29 | | |
30 | | #include <vector> |
31 | | |
32 | | namespace sdr::overlay |
33 | | { |
34 | | class OverlayManager; |
35 | | } |
36 | | |
37 | | namespace sdr::overlay |
38 | | { |
39 | | class SVXCORE_DLLPUBLIC OverlayObject : public sdr::animation::Event |
40 | | { |
41 | | private: |
42 | | OverlayObject(const OverlayObject&) = delete; |
43 | | OverlayObject& operator=(const OverlayObject&) = delete; |
44 | | |
45 | | // Manager is allowed access to private Member mpOverlayManager |
46 | | friend class OverlayManager; |
47 | | |
48 | | // pointer to OverlayManager, if object is added. Changed by |
49 | | // OverlayManager, do not change Yourself. |
50 | | OverlayManager* mpOverlayManager; |
51 | | |
52 | | // Primitive2DContainer of the OverlayObject |
53 | | drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence; |
54 | | |
55 | | // Possible Offset added to the geometry (automatically in |
56 | | // createOverlayObjectPrimitive2DSequence()). Usually zero, may |
57 | | // be used e.g. from calc when GridOffset is needed |
58 | | basegfx::B2DVector maOffset; |
59 | | |
60 | | protected: |
61 | | // access methods to maPrimitive2DSequence. The usage of this methods may allow |
62 | | // later thread-safe stuff to be added if needed. Only to be used by getPrimitive2DSequence() |
63 | | // implementations for buffering the last decomposition. |
64 | | // Resetting is allowed e.g. in ::getOverlayObjectPrimitive2DSequence() implementations |
65 | | // if the conditions have changed to force a re-creation in calling the base implementation. |
66 | | // The only allowed setter of maPrimitive2DSequence is |
67 | | // OverlayObject::getOverlayObjectPrimitive2DSequence() which should be called by calling |
68 | | // the base implementation in derived functions. That one will use the result of |
69 | | // createOverlayObjectPrimitive2DSequence() to provide the geometry. |
70 | 0 | const drawinglayer::primitive2d::Primitive2DContainer& getPrimitive2DSequence() const { return maPrimitive2DSequence; } |
71 | 0 | void resetPrimitive2DSequence() { maPrimitive2DSequence.clear(); } |
72 | | |
73 | | // the creation method for Primitive2DContainer. Called when getPrimitive2DSequence() |
74 | | // sees that maPrimitive2DSequence is empty. Needs to be supported by all |
75 | | // OverlayObject implementations. Default implementation will assert |
76 | | // a missing implementation |
77 | | virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence(); |
78 | | |
79 | | // #i53216# check blink time value range (currently 25 < mnBlinkTime < 10000) |
80 | | static sal_uInt32 impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime); |
81 | | |
82 | | // region in logical coordinates |
83 | | basegfx::B2DRange maBaseRange; |
84 | | |
85 | | // base color of this OverlayObject |
86 | | Color maBaseColor; |
87 | | |
88 | | // Flag for visibility |
89 | | bool mbIsVisible : 1; |
90 | | |
91 | | // Flag to control hittability |
92 | | bool mbIsHittable : 1; |
93 | | |
94 | | // Flag to hold info if this objects supports animation. Default is |
95 | | // false. If true, the Trigger() method should be overridden |
96 | | // to implement the animation effect and to re-initiate the event. |
97 | | bool mbAllowsAnimation : 1; |
98 | | |
99 | | // Flag to control if this OverlayObject allows AntiAliased visualisation. |
100 | | // Default is true, but e.g. for selection visualisation in SC and SW, |
101 | | // it is switched to false |
102 | | bool mbAllowsAntiAliase : 1; |
103 | | |
104 | | // In High Contrast mode all fg and bg are forced to a pair of normal |
105 | | // high contrast colors. If this flag is set, then in High Contrast mode |
106 | | // the colors are instead forced to the high contrast selection fg/bg pair. |
107 | | // Default is false. |
108 | | bool mbHighContrastSelection : 1; |
109 | | |
110 | | // set changed flag. Call after change, since the old range is invalidated |
111 | | // and then the new one is calculated and invalidated, too. This will only |
112 | | // work after the change. |
113 | | void objectChange(); |
114 | | |
115 | | // write access to AntiAliase flag. This is protected since |
116 | | // only implementations are allowed to change this, preferably in their |
117 | | // constructor |
118 | | void allowAntiAliase(bool bNew); |
119 | | |
120 | | public: |
121 | | explicit OverlayObject(Color aBaseColor); |
122 | | virtual ~OverlayObject() override; |
123 | | |
124 | | // get OverlayManager |
125 | 0 | OverlayManager* getOverlayManager() const { return mpOverlayManager; } |
126 | | |
127 | | // the access method for Primitive2DContainer. Will use createPrimitive2DSequence and |
128 | | // setPrimitive2DSequence if needed. Overriding may be used to allow disposal of last |
129 | | // created primitives to react on changed circumstances and to re-create primitives |
130 | | virtual drawinglayer::primitive2d::Primitive2DContainer getOverlayObjectPrimitive2DSequence() const; |
131 | | |
132 | | // access to visibility state |
133 | 0 | bool isVisible() const { return mbIsVisible; } |
134 | | void setVisible(bool bNew); |
135 | | |
136 | | // access to hittable flag |
137 | 0 | bool isHittable() const { return mbIsHittable; } |
138 | | void setHittable(bool bNew); |
139 | | |
140 | | // read access to AntiAliase flag |
141 | 0 | bool allowsAntiAliase() const { return mbAllowsAntiAliase; } |
142 | | |
143 | | // read access to DrawModeSettings flag |
144 | 0 | bool isHighContrastSelection() const { return mbHighContrastSelection; } |
145 | | |
146 | | // read access to baseRange. This may trigger createBaseRange() if |
147 | | // object is changed. |
148 | | const basegfx::B2DRange& getBaseRange() const; |
149 | | |
150 | | // access to baseColor |
151 | 0 | const Color& getBaseColor() const { return maBaseColor; } |
152 | | void setBaseColor(Color aNew); |
153 | | |
154 | | // access to Offset |
155 | 0 | const basegfx::B2DVector& getOffset() const { return maOffset; } |
156 | | void setOffset(const basegfx::B2DVector& rOffset); |
157 | | |
158 | | // execute event from base class sdr::animation::Event. Default |
159 | | // implementation does nothing and does not create a new event. |
160 | | virtual void Trigger(sal_uInt32 nTime) override; |
161 | | |
162 | | // access to AllowsAnimation flag |
163 | 0 | bool allowsAnimation() const { return mbAllowsAnimation; } |
164 | | |
165 | | // stripe definition has changed. The OverlayManager does have |
166 | | // support data to draw graphics in two colors striped. This |
167 | | // method notifies the OverlayObject if that change takes place. |
168 | | // Default implementation does nothing. |
169 | | virtual void stripeDefinitionHasChanged(); |
170 | | }; |
171 | | |
172 | | // typedefs for a vector of OverlayObjects |
173 | | typedef ::std::vector< OverlayObject* > OverlayObjectVector; |
174 | | |
175 | | } // end of namespace sdr::overlay |
176 | | |
177 | | namespace sdr::overlay |
178 | | { |
179 | | class SVXCORE_DLLPUBLIC OverlayObjectWithBasePosition : public OverlayObject |
180 | | { |
181 | | protected: |
182 | | // base position in logical coordinates |
183 | | basegfx::B2DPoint maBasePosition; |
184 | | |
185 | | public: |
186 | | OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor); |
187 | | virtual ~OverlayObjectWithBasePosition() override; |
188 | | |
189 | | // access to basePosition |
190 | 0 | const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; } |
191 | | void setBasePosition(const basegfx::B2DPoint& rNew); |
192 | | }; |
193 | | |
194 | | } // end of namespace sdr::overlay |
195 | | |
196 | | #endif // INCLUDED_SVX_SDR_OVERLAY_OVERLAYOBJECT_HXX |
197 | | |
198 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |