bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / sdr / overlay / overlayrectangle.cxx
blob92932f50af51e88c1788578be93ca1eaaa0719d6
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>
33 namespace sdr
35 namespace overlay
37 drawinglayer::primitive2d::Primitive2DSequence OverlayRectangle::createOverlayObjectPrimitive2DSequence()
39 const basegfx::B2DRange aHatchRange(getBasePosition(), maSecondPosition);
40 basegfx::BColor aColor(getBaseColor().getBColor());
41 static double fChange(0.1); // just small optical change, do not make it annoying
43 if(mbOverlayState)
45 aColor += basegfx::B3DTuple(fChange, fChange, fChange);
46 aColor.clamp();
48 else
50 aColor -= basegfx::B3DTuple(fChange, fChange, fChange);
51 aColor.clamp();
54 const drawinglayer::primitive2d::Primitive2DReference aReference(
55 new drawinglayer::primitive2d::OverlayRectanglePrimitive(
56 aHatchRange,
57 aColor,
58 getTransparence(),
59 getDiscreteGrow(),
60 getDiscreteShrink(),
61 getRotation()));
63 return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
66 OverlayRectangle::OverlayRectangle(
67 const basegfx::B2DPoint& rBasePosition,
68 const basegfx::B2DPoint& rSecondPosition,
69 const Color& rHatchColor,
70 double fTransparence,
71 double fDiscreteGrow,
72 double fDiscreteShrink,
73 double fRotation,
74 sal_uInt64 nBlinkTime,
75 bool bAnimate)
76 : OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
77 maSecondPosition(rSecondPosition),
78 mfTransparence(fTransparence),
79 mfDiscreteGrow(fDiscreteGrow),
80 mfDiscreteShrink(fDiscreteShrink),
81 mfRotation(fRotation),
82 mnBlinkTime(impCheckBlinkTimeValueRange(nBlinkTime)),
83 mbOverlayState(false)
85 if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
87 // no animation in high contrast mode
88 bAnimate = false;
91 // set AllowsAnimation flag to mark this object as animation capable
92 mbAllowsAnimation = bAnimate;
95 void OverlayRectangle::Trigger(sal_uInt32 nTime)
97 if(getOverlayManager())
99 // #i53216# produce event after nTime + x
100 SetTime(nTime + mnBlinkTime);
102 // switch state
103 if(mbOverlayState)
105 mbOverlayState = false;
107 else
109 mbOverlayState = true;
112 // re-insert me as event
113 getOverlayManager()->InsertEvent(this);
115 // register change (after change)
116 objectChange();
119 } // end of namespace overlay
120 } // end of namespace sdr
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */