svx/source/sdr/overlay/overlaytools.cxx | 109 ++++++++++++++++---------------- 1 file changed, 55 insertions(+), 54 deletions(-)
New commits: commit 950b2712e78e4c5015aff3762d78558be8a642bd Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Oct 11 19:36:20 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Oct 12 12:30:53 2022 +0200 tdf#150622 use a solid border instead of a hatch for high contrast to do less work for smoother scrolling, etc. Change-Id: I6584bbb18247420d9926bfa90acfbd6afe536c6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141237 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/svx/source/sdr/overlay/overlaytools.cxx b/svx/source/sdr/overlay/overlaytools.cxx index f36d6dacfca1..1ffaff464ce3 100644 --- a/svx/source/sdr/overlay/overlaytools.cxx +++ b/svx/source/sdr/overlay/overlaytools.cxx @@ -28,6 +28,7 @@ #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonHatchPrimitive2D.hxx> +#include <drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> @@ -297,65 +298,42 @@ sal_uInt32 OverlayStaticRectanglePrimitive::getPrimitive2DID() const if(!aInnerRange.isEmpty() && basegfx::fTools::more(getDiscreteUnit(), 0.0) && getTransparence() <= 1.0) { - basegfx::B2DRange aOuterRange(getObjectRange()); - - // grow/shrink inner/outer polygons - aOuterRange.grow(getDiscreteUnit() * getDiscreteGrow()); - aInnerRange.grow(getDiscreteUnit() * -getDiscreteShrink()); - - // convert to polygons - const double fFullGrow(getDiscreteGrow() + getDiscreteShrink()); - const double fRelativeRadiusX(fFullGrow / aOuterRange.getWidth()); - const double fRelativeRadiusY(fFullGrow / aOuterRange.getHeight()); - basegfx::B2DPolygon aOuterPolygon( - basegfx::utils::createPolygonFromRect( - aOuterRange, - fRelativeRadiusX, - fRelativeRadiusY)); - basegfx::B2DPolygon aInnerPolygon( - basegfx::utils::createPolygonFromRect( - aInnerRange)); - - // apply evtl. existing rotation - if(!basegfx::fTools::equalZero(getRotation())) + if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) { - const basegfx::B2DHomMatrix aTransform(basegfx::utils::createRotateAroundPoint( - getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation())); + basegfx::B2DRange aOuterRange(aInnerRange); + // grow/shrink inner/outer polygons + aOuterRange.grow(getDiscreteUnit() * getDiscreteGrow()); + aInnerRange.grow(getDiscreteUnit() * -getDiscreteShrink()); + + // convert to polygons + const double fFullGrow(getDiscreteGrow() + getDiscreteShrink()); + const double fRelativeRadiusX(fFullGrow / aOuterRange.getWidth()); + const double fRelativeRadiusY(fFullGrow / aOuterRange.getHeight()); + basegfx::B2DPolygon aOuterPolygon( + basegfx::utils::createPolygonFromRect( + aOuterRange, + fRelativeRadiusX, + fRelativeRadiusY)); + basegfx::B2DPolygon aInnerPolygon( + basegfx::utils::createPolygonFromRect( + aInnerRange)); + + // apply evtl. existing rotation + if(!basegfx::fTools::equalZero(getRotation())) + { + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createRotateAroundPoint( + getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation())); - aOuterPolygon.transform(aTransform); - aInnerPolygon.transform(aTransform); - } + aOuterPolygon.transform(aTransform); + aInnerPolygon.transform(aTransform); + } - // create filled primitive - basegfx::B2DPolyPolygon aPolyPolygon; + // create filled primitive + basegfx::B2DPolyPolygon aPolyPolygon; - aPolyPolygon.append(aOuterPolygon); - aPolyPolygon.append(aInnerPolygon); + aPolyPolygon.append(aOuterPolygon); + aPolyPolygon.append(aInnerPolygon); - if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) - { - // for high contrast, use hatch - const basegfx::BColor aHighContrastLineColor(Application::GetSettings().GetStyleSettings().GetFontColor().getBColor()); - const basegfx::BColor aEmptyColor(0.0, 0.0, 0.0); - const double fHatchRotation(basegfx::deg2rad(45)); - const double fDiscreteHatchDistance(3.0); - drawinglayer::attribute::FillHatchAttribute aFillHatchAttribute( - drawinglayer::attribute::HatchStyle::Single, - fDiscreteHatchDistance * getDiscreteUnit(), - fHatchRotation - getRotation(), - aHighContrastLineColor, - 3, // same default as VCL, a minimum of three discrete units (pixels) offset - false); - const Primitive2DReference aHatch( - new PolyPolygonHatchPrimitive2D( - aPolyPolygon, - aEmptyColor, - std::move(aFillHatchAttribute))); - - aRetval = Primitive2DContainer { aHatch }; - } - else - { // create fill primitive const Primitive2DReference aFill( new PolyPolygonColorPrimitive2D( @@ -375,6 +353,29 @@ sal_uInt32 OverlayStaticRectanglePrimitive::getPrimitive2DID() const aRetval = Primitive2DContainer { aFillTransparent }; } } + else + { + basegfx::B2DPolygon aInnerPolygon( + basegfx::utils::createPolygonFromRect( + aInnerRange)); + + // apply evtl. existing rotation + if(!basegfx::fTools::equalZero(getRotation())) + { + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createRotateAroundPoint( + getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation())); + + aInnerPolygon.transform(aTransform); + } + + // for high contrast, use a thick stroke + const basegfx::BColor aHighContrastLineColor(Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor()); + const attribute::LineAttribute aLineAttribute(aHighContrastLineColor, getDiscreteUnit() * getDiscreteGrow()); + + const Primitive2DReference aStroke(new PolygonStrokePrimitive2D(aInnerPolygon, aLineAttribute)); + + aRetval = Primitive2DContainer { aStroke }; + } } rContainer.append(std::move(aRetval));