From 3c0d04344321db2f7dc1db13ea72590884704f9f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 27 Oct 2021 12:20:11 +0100 Subject: make fat valueset selection rectangles solid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit as used in writer's bullets and numbering valuesets Change-Id: I4ac028fa9ef71163f29024352bb4fb7aeef0865a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124273 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- svtools/source/control/valueset.cxx | 106 +++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 39 deletions(-) (limited to 'svtools') diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 13f2abfa0df5..0a73e0418c72 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -20,8 +20,11 @@ #include #include +#include +#include #include #include +#include #include #include #include @@ -1272,68 +1275,93 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, } else { - if (bDrawSel) - { - rRenderContext.SetLineColor(aDoubleColor); - tools::PolyPolygon aPolyPoly(1); - aPolyPoly.Insert(aRect); - rRenderContext.DrawTransparent(aPolyPoly, nTransparencePercent); - } - if (mbDoubleSel) + rRenderContext.SetLineColor(aDoubleColor); + tools::Rectangle aFocusRect; + + if (!mbDoubleSel) { - aRect.AdjustLeft( 1 ); - aRect.AdjustTop( 1 ); - aRect.AdjustRight( -1 ); - aRect.AdjustBottom( -1 ); + // an outer rectangle surrounding a "focus" rectangle, surrounding + // an inner rectangle. Focus rectangle is always drawn, but rendered + // empty when there is no focus. e.g. as seen in color valuesets if (bDrawSel) { tools::PolyPolygon aPolyPoly(1); aPolyPoly.Insert(aRect); rRenderContext.DrawTransparent(aPolyPoly, nTransparencePercent); } - } - aRect.AdjustLeft( 1 ); - aRect.AdjustTop( 1 ); - aRect.AdjustRight( -1 ); - aRect.AdjustBottom( -1 ); - tools::Rectangle aRect2 = aRect; - aRect.AdjustLeft( 1 ); - aRect.AdjustTop( 1 ); - aRect.AdjustRight( -1 ); - aRect.AdjustBottom( -1 ); - if (bDrawSel) - { - tools::PolyPolygon aPolyPoly(1); - aPolyPoly.Insert(aRect); - rRenderContext.DrawTransparent(aPolyPoly, nTransparencePercent); - } - if (mbDoubleSel) - { + aRect.AdjustLeft( 1 ); aRect.AdjustTop( 1 ); aRect.AdjustRight( -1 ); aRect.AdjustBottom( -1 ); + + aFocusRect = aRect; + + aRect.AdjustLeft( 1 ); + aRect.AdjustTop( 1 ); + aRect.AdjustRight( -1 ); + aRect.AdjustBottom( -1 ); + if (bDrawSel) { tools::PolyPolygon aPolyPoly(1); aPolyPoly.Insert(aRect); rRenderContext.DrawTransparent(aPolyPoly, nTransparencePercent); } - } - if (bDrawSel) - { - rRenderContext.SetLineColor(aSingleColor); + if (bDrawSel) + rRenderContext.SetLineColor(aSingleColor); + else + rRenderContext.SetLineColor(COL_LIGHTGRAY); + + rRenderContext.DrawRect(aFocusRect); } else { - rRenderContext.SetLineColor(COL_LIGHTGRAY); + // a thick bordered rectangle surrounding an optional "focus" + // rectangle which is only drawn when focused, as seen in format, + // bullets and numbering in writer + const int nAdjust = 2; + + aRect.AdjustLeft(nAdjust); + aRect.AdjustTop(nAdjust); + aRect.AdjustRight(-nAdjust); + aRect.AdjustBottom(-nAdjust); + + aFocusRect = aRect; + + if (bDrawSel) + { + const basegfx::B2DPolygon aRectPoly( + basegfx::utils::createPolygonFromRect( + vcl::unotools::b2DRectangleFromRectangle(aRect))); + + const int nThickness = nAdjust * 2; + + if (!rRenderContext.DrawPolyLineDirect(basegfx::B2DHomMatrix(), + aRectPoly, + nThickness, + nTransparencePercent / 100.0, + nullptr, + basegfx::B2DLineJoin::Miter)) + { + SAL_WARN("svtools", "presumably impossible in practice, but fallback to see something"); + rRenderContext.DrawPolyLine(aRectPoly, nThickness, basegfx::B2DLineJoin::Miter); + } + } + + if (bFocus) + { + if (bDrawSel) + rRenderContext.SetLineColor(aSingleColor); + else + rRenderContext.SetLineColor(COL_LIGHTGRAY); + rRenderContext.DrawRect(aFocusRect); + } } - tools::PolyPolygon aPolyPoly(1); - aPolyPoly.Insert(aRect2); - rRenderContext.DrawTransparent(aPolyPoly, nTransparencePercent); + if (bFocus) - InvertFocusRect(rRenderContext, aRect2); + InvertFocusRect(rRenderContext, aFocusRect); } ImplDrawItemText(rRenderContext, pItem->maText); -- cgit