/src/libreoffice/svx/source/sdr/overlay/overlayrollingrectangle.cxx
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 | | #include <sdr/overlay/overlayrollingrectangle.hxx> |
21 | | #include <sdr/overlay/overlaytools.hxx> |
22 | | #include <svx/sdr/overlay/overlaymanager.hxx> |
23 | | #include <basegfx/polygon/b2dpolygontools.hxx> |
24 | | #include <basegfx/polygon/b2dpolygon.hxx> |
25 | | #include <drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx> |
26 | | #include <drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx> |
27 | | #include <svtools/optionsdrawinglayer.hxx> |
28 | | |
29 | | namespace sdr::overlay |
30 | | { |
31 | | drawinglayer::primitive2d::Primitive2DContainer OverlayRollingRectangleStriped::createOverlayObjectPrimitive2DSequence() |
32 | 0 | { |
33 | 0 | drawinglayer::primitive2d::Primitive2DContainer aRetval; |
34 | |
|
35 | 0 | if(getOverlayManager() && (mbShowBounds || mbExtendedLines)) |
36 | 0 | { |
37 | 0 | const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor()); |
38 | 0 | const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor()); |
39 | 0 | const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel()); |
40 | 0 | const basegfx::B2DRange aRollingRectangle(getBasePosition(), getSecondPosition()); |
41 | |
|
42 | 0 | if(mbShowBounds) |
43 | 0 | { |
44 | | // view-independent part, create directly |
45 | 0 | const basegfx::B2DPolygon aPolygon(basegfx::utils::createPolygonFromRect(aRollingRectangle)); |
46 | |
|
47 | 0 | aRetval.resize(2); |
48 | 0 | aRetval[0] = new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D( |
49 | 0 | basegfx::B2DPolyPolygon(aPolygon), |
50 | 0 | aRGBColorA, |
51 | 0 | aRGBColorB, |
52 | 0 | fStripeLengthPixel); |
53 | |
|
54 | 0 | const basegfx::BColor aHilightColor(SvtOptionsDrawinglayer::getHilightColor().getBColor()); |
55 | 0 | const double fTransparence(SvtOptionsDrawinglayer::GetTransparentSelectionPercent() * 0.01); |
56 | |
|
57 | 0 | aRetval[1] = new drawinglayer::primitive2d::PolyPolygonSelectionPrimitive2D( |
58 | 0 | basegfx::B2DPolyPolygon(aPolygon), |
59 | 0 | aHilightColor, |
60 | 0 | fTransparence, |
61 | 0 | 3.0, |
62 | 0 | false); |
63 | 0 | } |
64 | |
|
65 | 0 | if(mbExtendedLines) |
66 | 0 | { |
67 | | // view-dependent part, use helper primitive |
68 | 0 | const drawinglayer::primitive2d::Primitive2DReference aReference( |
69 | 0 | new drawinglayer::primitive2d::OverlayRollingRectanglePrimitive( |
70 | 0 | aRollingRectangle, |
71 | 0 | aRGBColorA, |
72 | 0 | aRGBColorB, |
73 | 0 | fStripeLengthPixel)); |
74 | |
|
75 | 0 | aRetval.push_back(aReference); |
76 | 0 | } |
77 | 0 | } |
78 | |
|
79 | 0 | return aRetval; |
80 | 0 | } |
81 | | |
82 | | void OverlayRollingRectangleStriped::stripeDefinitionHasChanged() |
83 | 0 | { |
84 | | // react on OverlayManager's stripe definition change |
85 | 0 | objectChange(); |
86 | 0 | } |
87 | | |
88 | | OverlayRollingRectangleStriped::OverlayRollingRectangleStriped( |
89 | | const basegfx::B2DPoint& rBasePos, |
90 | | const basegfx::B2DPoint& rSecondPos, |
91 | | bool bExtendedLines, |
92 | | bool bShowBounds) |
93 | 0 | : OverlayObjectWithBasePosition(rBasePos, COL_BLACK), |
94 | 0 | maSecondPosition(rSecondPos), |
95 | 0 | mbExtendedLines(bExtendedLines), |
96 | 0 | mbShowBounds(bShowBounds) |
97 | 0 | { |
98 | 0 | } |
99 | | |
100 | | OverlayRollingRectangleStriped::~OverlayRollingRectangleStriped() |
101 | 0 | { |
102 | 0 | } |
103 | | |
104 | | void OverlayRollingRectangleStriped::setSecondPosition(const basegfx::B2DPoint& rNew) |
105 | 0 | { |
106 | 0 | if(rNew != maSecondPosition) |
107 | 0 | { |
108 | | // remember new value |
109 | 0 | maSecondPosition = rNew; |
110 | | |
111 | | // register change (after change) |
112 | 0 | objectChange(); |
113 | 0 | } |
114 | 0 | } |
115 | | } // end of namespace |
116 | | |
117 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |