vcl/source/control/imivctl.hxx  |    8 +-------
 vcl/source/control/imivctl1.cxx |   34 ++++++++++++++--------------------
 2 files changed, 15 insertions(+), 27 deletions(-)

New commits:
commit 72408ffd0673894da48ae344653af3b5c6c93775
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Jul 22 09:49:38 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Jul 24 05:43:19 2024 +0200

    tdf#161501 icon choice ctrl: Merge two methods
    
    Merge `SetBoundingRect_Impl` into
    `SvxIconChoiceCtrl_Impl::FindBoundingRect` as that is the
    only caller.
    
    `SvxIconChoiceCtrl_Impl::SetBoundingRect_Impl` was ignoring
    the bounding size being passed.
    To be sure, still call `CalcBoundingSize` at the beginning
    even though the return value itself is not used,
    as the call to `SvxIconChoiceCtrl_Impl::CalcBoundingHeight`
    that it does can result in class members like
    `nMaxBoundHeight` getting updated.
    
    Change-Id: I53b70bb8ddbf53afd9f95c38ce3dd05922e1110c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170846
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx
index 9bd81e4fda5a..e693136fb7fa 100644
--- a/vcl/source/control/imivctl.hxx
+++ b/vcl/source/control/imivctl.hxx
@@ -248,11 +248,6 @@ public:
     tools::Long                CalcBoundingHeight() const;
     Size                CalcBoundingSize() const;
     void                FindBoundingRect( SvxIconChoiceCtrlEntry* pEntry );
-    void                SetBoundingRect_Impl(
-                            SvxIconChoiceCtrlEntry* pEntry,
-                            const Point& rPos,
-                            const Size& rBoundingSize
-                        );
     // recalculates all invalid BoundRects
     void                RecalcAllBoundingRectsSmart();
     const tools::Rectangle&    GetEntryBoundRect( SvxIconChoiceCtrlEntry* );
diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx
index d3e91f194a3f..f32af05ac19c 100644
--- a/vcl/source/control/imivctl1.cxx
+++ b/vcl/source/control/imivctl1.cxx
@@ -1312,15 +1312,10 @@ void 
SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart()
 
 void SvxIconChoiceCtrl_Impl::FindBoundingRect( SvxIconChoiceCtrlEntry* pEntry )
 {
-    Size aSize( CalcBoundingSize() );
+    CalcBoundingSize();
     Point aPos(pGridMap->GetGridRect(pGridMap->GetUnoccupiedGrid()).TopLeft());
-    SetBoundingRect_Impl( pEntry, aPos, aSize );
-}
 
-void SvxIconChoiceCtrl_Impl::SetBoundingRect_Impl( SvxIconChoiceCtrlEntry* 
pEntry, const Point& rPos,
-    const Size& /*rBoundingSize*/ )
-{
-    tools::Rectangle aGridRect( rPos, Size(nGridDX, nGridDY) );
+    tools::Rectangle aGridRect(aPos, Size(nGridDX, nGridDY));
     pEntry->aGridRect = aGridRect;
     Center( pEntry );
     AdjustVirtSize( pEntry->aRect );
commit 3f1c3a0faa6e0023e326f88d1bd9b84aef386a7e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Jul 22 09:21:28 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Jul 24 05:43:10 2024 +0200

    tdf#161501 Drop bSelected param for SvxIconChoiceCtrl_Impl::PaintEmphasis
    
    The method doesn't do anything for `bSelected = true`,
    so drop the param, and only call it for the `bSelected = false`
    case in `SvxIconChoiceCtrl_Impl::PaintEntry` instead.
    
    Change-Id: I5e180a42f2960531d16e5df35ce0a4e9c63a1f91
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170845
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx
index e616215bc7ef..9bd81e4fda5a 100644
--- a/vcl/source/control/imivctl.hxx
+++ b/vcl/source/control/imivctl.hxx
@@ -263,8 +263,7 @@ public:
                         }
     static bool         IsBoundingRectValid( const tools::Rectangle& rRect ) { 
return ( rRect.Right() != LONG_MAX ); }
 
-    static void         PaintEmphasis(const tools::Rectangle& rRect1, bool 
bSelected,
-                                      vcl::RenderContext& rRenderContext );
+    static void         PaintEmphasis(const tools::Rectangle& rRect1, 
vcl::RenderContext& rRenderContext);
 
     void                PaintItem(const tools::Rectangle& rRect, 
IcnViewFieldType eItem, SvxIconChoiceCtrlEntry* pEntry,
                             sal_uInt16 nPaintFlags, vcl::RenderContext& 
rRenderContext);
diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx
index 5a79779e4dd2..d3e91f194a3f 100644
--- a/vcl/source/control/imivctl1.cxx
+++ b/vcl/source/control/imivctl1.cxx
@@ -959,20 +959,17 @@ void SvxIconChoiceCtrl_Impl::LoseFocus()
 }
 
 // priorities of the emphasis:  bSelected
-void SvxIconChoiceCtrl_Impl::PaintEmphasis(const tools::Rectangle& rTextRect, 
bool bSelected,
+void SvxIconChoiceCtrl_Impl::PaintEmphasis(const tools::Rectangle& rTextRect,
                                            vcl::RenderContext& rRenderContext)
 {
-    if (!bSelected)
-    {
-        Color aOldFillColor(rRenderContext.GetFillColor());
-        const Color& rFillColor = rRenderContext.GetFont().GetFillColor();
-        rRenderContext.SetFillColor(rFillColor);
-        // draw text rectangle
-        if (rFillColor != COL_TRANSPARENT)
-            rRenderContext.DrawRect(rTextRect);
+    Color aOldFillColor(rRenderContext.GetFillColor());
+    const Color& rFillColor = rRenderContext.GetFont().GetFillColor();
+    rRenderContext.SetFillColor(rFillColor);
+    // draw text rectangle
+    if (rFillColor != COL_TRANSPARENT)
+        rRenderContext.DrawRect(rTextRect);
 
-        rRenderContext.SetFillColor(aOldFillColor);
-    }
+    rRenderContext.SetFillColor(aOldFillColor);
 }
 
 
@@ -1051,8 +1048,6 @@ void 
SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Po
         nBmpPaintFlags |= PAINTFLAG_HOR_CENTERED;
     sal_uInt16 nTextPaintFlags = bLargeIconMode ? PAINTFLAG_HOR_CENTERED : 
PAINTFLAG_VER_CENTERED;
 
-    PaintEmphasis(aTextRect, bSelected, rRenderContext);
-
     // Background of selected entry
     tools::Rectangle aFocusRect(CalcFocusRect(pEntry));
     bool bNativeSelection = 
rRenderContext.IsNativeControlSupported(ControlType::WindowBackground, 
ControlPart::Entire);
@@ -1085,6 +1080,10 @@ void 
SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Po
                                                       pView->HasFocus() ? 1 : 
2, false, false, false);
         }
     }
+    else
+    {
+        PaintEmphasis(aTextRect, rRenderContext);
+    }
 
     if (pEntry->IsFocused())
         DrawFocusRect(rRenderContext, pEntry);

Reply via email to