diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2020-04-28 15:48:50 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-04-29 09:06:45 +0200 |
commit | 56b207065ce0b4c86178131ae43fbbc31165727e (patch) | |
tree | c02a9cc74c0c62812533dedc372188b45c399561 | |
parent | add --enable-sal-log to CPLinux-LOKit.conf to help debugging release packages (diff) | |
download | core-56b207065ce0b4c86178131ae43fbbc31165727e.tar.gz core-56b207065ce0b4c86178131ae43fbbc31165727e.zip |
tdf#132381: Avoid XOR paint in Crop dialog
Change-Id: I9d3709f9d2a09de1eaace916dc6033de13dbff86
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93048
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | cui/source/tabpages/grfpage.cxx | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx index d42f42a7f045..083f362c1acf 100644 --- a/cui/source/tabpages/grfpage.cxx +++ b/cui/source/tabpages/grfpage.cxx @@ -35,6 +35,11 @@ #include <strings.hrc> #include <vcl/builderfactory.hxx> #include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <svtools/unitconv.hxx> +#include <svtools/optionsdrawinglayer.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> #define CM_1_TO_TWIP 567 #define TWIP_TO_INCH 1440 @@ -698,27 +703,58 @@ void SvxCropExample::SetDrawingArea(weld::DrawingArea* pDrawingArea) void SvxCropExample::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&) { - rRenderContext.Push(PushFlags::MAPMODE | PushFlags::RASTEROP); + rRenderContext.Push(PushFlags::MAPMODE); rRenderContext.SetMapMode(m_aMapMode); - Size aWinSize(rRenderContext.PixelToLogic(GetOutputSizePixel())); + // Win BG + const Size aWinSize(rRenderContext.PixelToLogic(GetOutputSizePixel())); rRenderContext.SetLineColor(); rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor()); rRenderContext.DrawRect(::tools::Rectangle(Point(), aWinSize)); - rRenderContext.SetLineColor(COL_WHITE); - ::tools::Rectangle aRect(Point((aWinSize.Width() - m_aFrameSize.Width())/2, - (aWinSize.Height() - m_aFrameSize.Height())/2), - m_aFrameSize); + // use AA, the Graphic may be a metafile/svg and would then look ugly + rRenderContext.SetAntialiasing(AntialiasingFlags::EnableB2dDraw); + + // draw Graphic + ::tools::Rectangle aRect( + Point((aWinSize.Width() - m_aFrameSize.Width())/2, (aWinSize.Height() - m_aFrameSize.Height())/2), + m_aFrameSize); m_aGrf.Draw(&rRenderContext, aRect.TopLeft(), aRect.GetSize()); - rRenderContext.SetFillColor(COL_TRANSPARENT); - rRenderContext.SetRasterOp(RasterOp::Invert); - aRect.AdjustLeft(m_aTopLeft.Y() ); - aRect.AdjustTop(m_aTopLeft.X() ); + // Remove one more case that uses XOR paint (RasterOp::Invert). + // Get colors and logic DashLength from settings, use equal to + // PolygonMarkerPrimitive2D, may be changed to that primitive later. + // Use this to guarantee good visibility - that was the purpose of + // the former used XOR paint. + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + const Color aColA(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor()); + const Color aColB(aSvtOptionsDrawinglayer.GetStripeColorB().getBColor()); + const double fStripeLength(aSvtOptionsDrawinglayer.GetStripeLength()); + const basegfx::B2DVector aDashVector(rRenderContext.GetInverseViewTransformation() * basegfx::B2DVector(fStripeLength, 0.0)); + const double fLogicDashLength(aDashVector.getX()); + + // apply current crop settings + aRect.AdjustLeft(m_aTopLeft.Y()); + aRect.AdjustTop(m_aTopLeft.X()); aRect.AdjustRight(-m_aBottomRight.Y()); aRect.AdjustBottom(-m_aBottomRight.X()); - rRenderContext.DrawRect(aRect); + + // apply dash with direct paint callbacks + basegfx::utils::applyLineDashing( + basegfx::utils::createPolygonFromRect( + basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom())), + std::vector< double >(2, fLogicDashLength), + [&aColA,&rRenderContext](const basegfx::B2DPolygon& rSnippet) + { + rRenderContext.SetLineColor(aColA); + rRenderContext.DrawPolyLine(rSnippet); + }, + [&aColB,&rRenderContext](const basegfx::B2DPolygon& rSnippet) + { + rRenderContext.SetLineColor(aColB); + rRenderContext.DrawPolyLine(rSnippet); + }, + 2.0 * fLogicDashLength); rRenderContext.Pop(); } |