include/svx/sdr/overlay/overlayselection.hxx |    3 -
 sc/source/ui/view/gridwin.cxx                |   70 ++++++++++++++++++++-------
 svx/source/sdr/overlay/overlayselection.cxx  |   10 +++
 3 files changed, 62 insertions(+), 21 deletions(-)

New commits:
commit 0b5eedc5e98adcc9cff578a4a47a9d33adf7e579
Author:     Rafael Lima <rafael.palma.l...@gmail.com>
AuthorDate: Thu Jul 11 22:11:15 2024 +0200
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Fri Aug 30 13:56:55 2024 +0200

    tdf#162006 Use contrast outline for the AutoFill/Cursor handle as well
    
    This patch draws a white line around the AutoFill handle for better 
contrast.
    
    It also adds an internal white outline to the cursor overlay.
    
    See bug ticket for screenshots.
    
    Change-Id: I1567d272fd5a2835192c50973e84cb8c269fb04e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170354
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Tested-by: Jenkins
    (cherry picked from commit 1d1f47e6ca6367bf8fb828dd09cce197a96f643c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172565
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>

diff --git a/include/svx/sdr/overlay/overlayselection.hxx 
b/include/svx/sdr/overlay/overlayselection.hxx
index b83322acbf61..a05de575e430 100644
--- a/include/svx/sdr/overlay/overlayselection.hxx
+++ b/include/svx/sdr/overlay/overlayselection.hxx
@@ -30,7 +30,8 @@ namespace sdr::overlay
         {
             Invert,
             Solid,
-            Transparent
+            Transparent,
+            NoFill
         };
 
         class SVXCORE_DLLPUBLIC OverlaySelection final : public OverlayObject
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index c79a6493f6c6..239b014cd5c9 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6241,8 +6241,8 @@ void ScGridWindow::ImpCreateOverlayObjects()
 {
     UpdateHighlightOverlay();
     UpdateSelectionOverlay();
-    UpdateAutoFillOverlay();
     UpdateCursorOverlay();
+    UpdateAutoFillOverlay();
     UpdateCopySourceOverlay();
     UpdateDragRectOverlay();
     UpdateHeaderOverlay();
@@ -6720,9 +6720,24 @@ void ScGridWindow::UpdateCursorOverlay()
                     std::move(aRanges),
                     false, false));
 
+                // Internal white contrast rectangle
+                std::vector< basegfx::B2DRange > aRangesInternal;
+                basegfx::B2DRange aRBInternal(aPixelRects[0].Right(), 
aPixelRects[2].Bottom(),
+                                              aPixelRects[1].Left() - 1, 
aPixelRects[3].Top() - 1);
+                aRBInternal.transform(aTransform);
+                aRangesInternal.push_back(aRBInternal);
+
+                std::unique_ptr<sdr::overlay::OverlayObject> 
pOverlayInternal(new sdr::overlay::OverlaySelection(
+                    sdr::overlay::OverlayType::NoFill,
+                    COL_WHITE,
+                    std::move(aRangesInternal),
+                    true, false));
+
                 xOverlayManager->add(*pOverlay);
+                xOverlayManager->add(*pOverlayInternal);
                 mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
                 mpOOCursors->append(std::move(pOverlay));
+                mpOOCursors->append(std::move(pOverlayInternal));
             }
         }
     }
@@ -6925,13 +6940,11 @@ void ScGridWindow::UpdateAutoFillOverlay()
     ScDocument& rDoc = mrViewData.GetDocument();
     bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
 
-   // tdf#143733 tdf#145080 - improve border visibility
-   // constants picked for maximum consistency at 100%
-   // size = 6 at 100% (as before), 50% = 4.5, 200% = 9, 400% = 15
-    const float fScaleFactor = 3 * GetDPIScaleFactor();
-    const double fZoom(3 * mrViewData.GetZoomX());
-    // Size should be even
-    Size aFillHandleSize(fZoom + fScaleFactor, fZoom + fScaleFactor);
+    // tdf#162006 Ensures the AutoFill handle is visible at any zoom level
+    // At 100% = Total Size 8 (2px for the external white line; 6px for the 
handle itself)
+    const double fScaleFactor(2 + 2 * GetDPIScaleFactor());
+    const double fZoom(2 + 2 * mrViewData.GetZoomX());
+    Size aFillHandleSize(fScaleFactor + fZoom, fScaleFactor + fZoom);
 
     Point aFillPos = mrViewData.GetScrPos( nX, nY, eWhich, true );
     tools::Long nSizeXPix;
@@ -6970,26 +6983,47 @@ void ScGridWindow::UpdateAutoFillOverlay()
     }
     else if (xOverlayManager.is())
     {
+        const basegfx::B2DHomMatrix 
aTransform(GetOutDev()->GetInverseViewTransformation());
+
+        // Outer rectangle (always white for contrast)
+        std::vector< basegfx::B2DRange > aRangesOuter;
+        basegfx::B2DRange aRBOuter = 
vcl::unotools::b2DRectangleFromRectangle(aFillRect);
+        aRBOuter.transform(aTransform);
+        aRangesOuter.push_back(aRBOuter);
+
+        std::unique_ptr<sdr::overlay::OverlayObject> pOverlayOuter(new 
sdr::overlay::OverlaySelection(
+            sdr::overlay::OverlayType::Solid,
+            COL_WHITE,
+            std::move(aRangesOuter),
+            false, false));
+
+        // Inner rectangle
+        std::vector< basegfx::B2DRange > aRangesInner;
+        tools::Rectangle aRectInner(aFillRect);
+        aRectInner.AdjustTop(1);
+        aRectInner.AdjustBottom(-1);
+        aRectInner.AdjustLeft(1);
+        aRectInner.AdjustRight(-1);
+        basegfx::B2DRange aRBInner = 
vcl::unotools::b2DRectangleFromRectangle(aRectInner);
+        aRBInner.transform(aTransform);
+        aRangesInner.push_back(aRBInner);
+
         Color aHandleColor = 
SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCCELLFOCUS).nColor;
         if (mrViewData.GetActivePart() != eWhich)
             // non-active pane uses a different color.
             aHandleColor = 
SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
-        std::vector< basegfx::B2DRange > aRanges;
-        const basegfx::B2DHomMatrix 
aTransform(GetOutDev()->GetInverseViewTransformation());
-        basegfx::B2DRange aRB = 
vcl::unotools::b2DRectangleFromRectangle(aFillRect);
-
-        aRB.transform(aTransform);
-        aRanges.push_back(aRB);
 
-        std::unique_ptr<sdr::overlay::OverlayObject> pOverlay(new 
sdr::overlay::OverlaySelection(
+        std::unique_ptr<sdr::overlay::OverlayObject> pOverlayInner(new 
sdr::overlay::OverlaySelection(
             sdr::overlay::OverlayType::Solid,
             aHandleColor,
-            std::move(aRanges),
+            std::move(aRangesInner),
             false, false));
 
-        xOverlayManager->add(*pOverlay);
+        xOverlayManager->add(*pOverlayOuter);
+        xOverlayManager->add(*pOverlayInner);
         mpOOAutoFill.reset(new sdr::overlay::OverlayObjectList);
-        mpOOAutoFill->append(std::move(pOverlay));
+        mpOOAutoFill->append(std::move(pOverlayOuter));
+        mpOOAutoFill->append(std::move(pOverlayInner));
     }
 }
 
diff --git a/svx/source/sdr/overlay/overlayselection.cxx 
b/svx/source/sdr/overlay/overlayselection.cxx
index 78a1421943d5..ff0b3a4a12f7 100644
--- a/svx/source/sdr/overlay/overlayselection.cxx
+++ b/svx/source/sdr/overlay/overlayselection.cxx
@@ -153,10 +153,16 @@ namespace sdr::overlay
                                 std::move(aRetval))
                     };
                 }
-                else if(OverlayType::Transparent == maLastOverlayType)
+                else if(maLastOverlayType == OverlayType::Transparent || 
maLastOverlayType == OverlayType::NoFill)
                 {
+                    // Determine transparency level
+                    double fTransparence;
+                    if (maLastOverlayType == OverlayType::NoFill)
+                        fTransparence = 1;
+                    else
+                        fTransparence = mnLastTransparence / 100.0;
+
                     // embed all rectangles in transparent paint
-                    const double fTransparence(mnLastTransparence / 100.0);
                     const drawinglayer::primitive2d::Primitive2DReference 
aUnifiedTransparence(
                         new 
drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
                             std::move(aRetval),

Reply via email to