Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * This file incorporates work covered by the following license notice:
9 : *
10 : * Licensed to the Apache Software Foundation (ASF) under one or more
11 : * contributor license agreements. See the NOTICE file distributed
12 : * with this work for additional information regarding copyright
13 : * ownership. The ASF licenses this file to you under the Apache
14 : * License, Version 2.0 (the "License"); you may not use this file
15 : * except in compliance with the License. You may obtain a copy of
16 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 : */
18 :
19 : #include <svx/sdr/overlay/overlayrectangle.hxx>
20 : #include <vcl/outdev.hxx>
21 : #include <basegfx/matrix/b2dhommatrix.hxx>
22 : #include <basegfx/polygon/b2dpolygontools.hxx>
23 : #include <basegfx/polygon/b2dpolygon.hxx>
24 : #include <basegfx/numeric/ftools.hxx>
25 : #include <svx/sdr/overlay/overlaytools.hxx>
26 : #include <svx/sdr/overlay/overlaymanager.hxx>
27 : #include <vcl/svapp.hxx>
28 : #include <vcl/settings.hxx>
29 :
30 :
31 :
32 : namespace sdr
33 : {
34 : namespace overlay
35 : {
36 0 : drawinglayer::primitive2d::Primitive2DSequence OverlayRectangle::createOverlayObjectPrimitive2DSequence()
37 : {
38 0 : const basegfx::B2DRange aHatchRange(getBasePosition(), maSecondPosition);
39 0 : basegfx::BColor aColor(getBaseColor().getBColor());
40 : static double fChange(0.1); // just small optical change, do not make it annoying
41 :
42 0 : if(mbOverlayState)
43 : {
44 0 : aColor += basegfx::B3DTuple(fChange, fChange, fChange);
45 0 : aColor.clamp();
46 : }
47 : else
48 : {
49 0 : aColor -= basegfx::B3DTuple(fChange, fChange, fChange);
50 0 : aColor.clamp();
51 : }
52 :
53 : const drawinglayer::primitive2d::Primitive2DReference aReference(
54 : new drawinglayer::primitive2d::OverlayRectanglePrimitive(
55 : aHatchRange,
56 : aColor,
57 : getTransparence(),
58 : getDiscreteGrow(),
59 : getDiscreteShrink(),
60 0 : getRotation()));
61 :
62 0 : return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
63 : }
64 :
65 0 : 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 : sal_uInt32 nBlinkTime,
74 : bool bAnimate)
75 : : OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
76 : maSecondPosition(rSecondPosition),
77 : mfTransparence(fTransparence),
78 : mfDiscreteGrow(fDiscreteGrow),
79 : mfDiscreteShrink(fDiscreteShrink),
80 : mfRotation(fRotation),
81 : mnBlinkTime(nBlinkTime),
82 0 : mbOverlayState(false)
83 : {
84 0 : if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
85 : {
86 : // no animation in high contrast mode
87 0 : bAnimate = false;
88 : }
89 :
90 : // set AllowsAnimation flag to mark this object as animation capable
91 0 : mbAllowsAnimation = bAnimate;
92 :
93 : // #i53216# check blink time value range
94 0 : mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime);
95 0 : }
96 :
97 0 : void OverlayRectangle::Trigger(sal_uInt32 nTime)
98 : {
99 0 : if(getOverlayManager())
100 : {
101 : // #i53216# produce event after nTime + x
102 0 : SetTime(nTime + mnBlinkTime);
103 :
104 : // switch state
105 0 : if(mbOverlayState)
106 : {
107 0 : mbOverlayState = false;
108 : }
109 : else
110 : {
111 0 : mbOverlayState = true;
112 : }
113 :
114 : // re-insert me as event
115 0 : getOverlayManager()->InsertEvent(this);
116 :
117 : // register change (after change)
118 0 : objectChange();
119 : }
120 0 : }
121 : } // end of namespace overlay
122 : } // end of namespace sdr
123 :
124 :
|