[Libreoffice-commits] core.git: cui/source

Armin Le Grand (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 1 19:41:14 UTC 2020


 cui/source/tabpages/grfpage.cxx |   56 ++++++++++++++++++++++++++++++++--------
 1 file changed, 45 insertions(+), 11 deletions(-)

New commits:
commit 2a81384f499ef053ea1b52f05e8f74b13c0b6e0e
Author:     Armin Le Grand <armin.le.grand at me.com>
AuthorDate: Wed Apr 1 19:21:13 2020 +0200
Commit:     Armin Le Grand <Armin.Le.Grand at me.com>
CommitDate: Wed Apr 1 21:40:41 2020 +0200

    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 at me.com>

diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx
index 96e2fcd1b9e2..7f334e2f11fc 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
@@ -698,27 +701,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();
 }


More information about the Libreoffice-commits mailing list