Bump version to 6.4-15
[LibreOffice.git] / svx / source / sdr / overlay / overlayrectangle.cxx
blob8b117072f0541f13a82a27c99cc0da7663971798
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 #include <sdr/overlay/overlayrectangle.hxx>
21 #include <vcl/outdev.hxx>
22 #include <basegfx/matrix/b2dhommatrix.hxx>
23 #include <basegfx/polygon/b2dpolygontools.hxx>
24 #include <basegfx/polygon/b2dpolygon.hxx>
25 #include <basegfx/numeric/ftools.hxx>
26 #include <sdr/overlay/overlaytools.hxx>
27 #include <svx/sdr/overlay/overlaymanager.hxx>
28 #include <vcl/svapp.hxx>
29 #include <vcl/settings.hxx>
32 namespace sdr
34 namespace overlay
36 drawinglayer::primitive2d::Primitive2DContainer OverlayRectangle::createOverlayObjectPrimitive2DSequence()
38 const basegfx::B2DRange aHatchRange(getBasePosition(), maSecondPosition);
39 basegfx::BColor aColor(getBaseColor().getBColor());
40 static const double fChange(0.1); // just small optical change, do not make it annoying
42 if(mbOverlayState)
44 aColor += basegfx::B3DTuple(fChange, fChange, fChange);
45 aColor.clamp();
47 else
49 aColor -= basegfx::B3DTuple(fChange, fChange, fChange);
50 aColor.clamp();
53 const drawinglayer::primitive2d::Primitive2DReference aReference(
54 new drawinglayer::primitive2d::OverlayRectanglePrimitive(
55 aHatchRange,
56 aColor,
57 mfTransparence,
58 mfDiscreteGrow,
59 mfDiscreteShrink,
60 mfRotation));
62 return drawinglayer::primitive2d::Primitive2DContainer { aReference };
65 OverlayRectangle::OverlayRectangle(
66 const basegfx::B2DPoint& rBasePosition,
67 const basegfx::B2DPoint& rSecondPosition,
68 const Color& rHatchColor,
69 double fTransparence,
70 double fDiscreteGrow,
71 double fDiscreteShrink,
72 double fRotation,
73 bool bAnimate)
74 : OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
75 maSecondPosition(rSecondPosition),
76 mfTransparence(fTransparence),
77 mfDiscreteGrow(fDiscreteGrow),
78 mfDiscreteShrink(fDiscreteShrink),
79 mfRotation(fRotation),
80 mnBlinkTime(impCheckBlinkTimeValueRange(500)),
81 mbOverlayState(false)
83 if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
85 // no animation in high contrast mode
86 bAnimate = false;
89 // set AllowsAnimation flag to mark this object as animation capable
90 mbAllowsAnimation = bAnimate;
93 void OverlayRectangle::Trigger(sal_uInt32 nTime)
95 if(getOverlayManager())
97 // #i53216# produce event after nTime + x
98 SetTime(nTime + mnBlinkTime);
100 // switch state
101 if(mbOverlayState)
103 mbOverlayState = false;
105 else
107 mbOverlayState = true;
110 // re-insert me as event
111 getOverlayManager()->InsertEvent(*this);
113 // register change (after change)
114 objectChange();
117 } // end of namespace overlay
118 } // end of namespace sdr
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */