summaryrefslogtreecommitdiffstats
path: root/cui
diff options
context:
space:
mode:
authorArmin Le Grand <armin.le.grand@me.com>2020-04-01 19:21:13 +0200
committerAndras Timar <andras.timar@collabora.com>2020-05-13 17:56:15 +0200
commit5566618ad375617313abfb23829b3ea70bde0ee1 (patch)
treec592a82a614441fbb9c97a2df7f847c79274ec78 /cui
parentMerge both x64 and x86 CRT merge modules into x64 MSI (diff)
downloadcore-5566618ad375617313abfb23829b3ea70bde0ee1.tar.gz
core-5566618ad375617313abfb23829b3ea70bde0ee1.zip
Avoid XOR paint in Crop dialog
Change-Id: I9d3709f9d2a09de1eaace916dc6033de13dbff86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91528 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/tabpages/grfpage.cxx56
1 files changed, 45 insertions, 11 deletions
diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx
index 586f9806ce8d..091ef70faddf 100644
--- a/cui/source/tabpages/grfpage.cxx
+++ b/cui/source/tabpages/grfpage.cxx
@@ -35,6 +35,9 @@
#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
@@ -694,27 +697,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();
}