vcl/source/control/imivctl.hxx  |    4 ++--
 vcl/source/control/imivctl1.cxx |   35 +++++++----------------------------
 2 files changed, 9 insertions(+), 30 deletions(-)

New commits:
commit 42024245c72d44104ebd26bae3c601de7a876eea
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Jul 23 10:41:16 2024 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Jul 24 05:43:52 2024 +0200

    tdf#161501 icon choice ctrl: Draw selection within item bounds
    
    In the same way that the calculated focus rect of an item
    is used for drawing selection and focus indicators, use
    it for mouse-hover highlighting as well, instead of
    drawing a rectangle that reaches beyond the bounds
    of the item itself for the non-native drawing path
    of vertical tab bar items.
    
    With this in place, hovering over an entry other than
    the selected/focused one now shows a rectangle of the same
    size as that for the focused entry, which is more
    consistent and also aligns this with the case
    where the native drawing API for drawing the item is used,
    e.g. on Windows or with the kf5 VCL plugin on Linux.
    
    This also means that a small gap can now be seen
    between selected item and mouse-hovered item when
    hovering over an item next to the currently selected
    one for the gen VCL plugin as well, just as was
    already the case before for the kf5 VCL plugin.
    (Dropping that extra margin will happen in a
    separate commit.)
    
    Change-Id: I578755a8a82ea811765b2e0dc3815fb47f67863c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170891
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx
index d114d66f74e9..d02b0299cd6e 100644
--- a/vcl/source/control/imivctl.hxx
+++ b/vcl/source/control/imivctl.hxx
@@ -299,7 +299,7 @@ public:
     tools::Rectangle           GetOutputRect() const;
 
     void                SetEntryHighlightFrame(SvxIconChoiceCtrlEntry* pEntry);
-    void                DrawHighlightFrame(vcl::RenderContext& rRenderContext, 
const tools::Rectangle& rBmpRect);
+    static void         DrawHighlightFrame(vcl::RenderContext& rRenderContext, 
const tools::Rectangle& rRect);
 
     void                CallEventListeners( VclEventId nEvent, void* pData );
 
diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx
index 83e12b812b23..8ecf9cf16656 100644
--- a/vcl/source/control/imivctl1.cxx
+++ b/vcl/source/control/imivctl1.cxx
@@ -1923,19 +1923,11 @@ bool SvxIconChoiceCtrl_Impl::RequestHelp( const 
HelpEvent& rHEvt )
     return true;
 }
 
-void SvxIconChoiceCtrl_Impl::DrawHighlightFrame(vcl::RenderContext& 
rRenderContext, const tools::Rectangle& rBmpRect)
+void SvxIconChoiceCtrl_Impl::DrawHighlightFrame(vcl::RenderContext& 
rRenderContext,
+                                                const tools::Rectangle& rRect)
 {
-    tools::Rectangle aBmpRect(rBmpRect);
-    tools::Long nBorder = 2;
-    if (aImageSize.Width() < 32)
-        nBorder = 1;
-    aBmpRect.AdjustRight(nBorder );
-    aBmpRect.AdjustLeft( -nBorder );
-    aBmpRect.AdjustBottom(nBorder );
-    aBmpRect.AdjustTop( -nBorder );
-
     DecorationView aDecoView(&rRenderContext);
-    aDecoView.DrawHighlightFrame(aBmpRect, DrawHighlightFrameStyle::Out);
+    aDecoView.DrawHighlightFrame(rRect, DrawHighlightFrameStyle::Out);
 }
 
 void SvxIconChoiceCtrl_Impl::SetEntryHighlightFrame(SvxIconChoiceCtrlEntry* 
pEntry)
commit 22a2ddcb77ea33fb5df0e62849a60d15cfe6e8fa
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Jul 22 11:31:44 2024 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Jul 24 05:43:44 2024 +0200

    tdf#161501 icon choice ctrl: Consistently use bound rect
    
    In `SvxIconChoiceCtrl_Impl::MakeEntryVisible`, always use
    the bound rect as the area to make visible.
    
    I see no reason to not do so when an entry is clicked
    (s `SvxIconChoiceCtrl_Impl::MouseButtonDown`, which is
    the only case that didn't do it yet.
    
    Drop the `bBound` param accordingly.
    
    Change-Id: I7a96e97585521943e7171c278fbd3509037cb7d3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170849
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx
index e693136fb7fa..d114d66f74e9 100644
--- a/vcl/source/control/imivctl.hxx
+++ b/vcl/source/control/imivctl.hxx
@@ -233,7 +233,7 @@ public:
 
     SvxIconChoiceCtrlEntry* GetEntry( const Point& rDocPos );
 
-    void                MakeEntryVisible( SvxIconChoiceCtrlEntry* pEntry, bool 
bBound = true );
+    void                MakeEntryVisible(SvxIconChoiceCtrlEntry* pEntry);
 
     void                Arrange(tools::Long nSetMaxVirtHeight);
 
diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx
index af354bc5ba59..83e12b812b23 100644
--- a/vcl/source/control/imivctl1.cxx
+++ b/vcl/source/control/imivctl1.cxx
@@ -463,7 +463,7 @@ bool SvxIconChoiceCtrl_Impl::MouseButtonDown( const 
MouseEvent& rMEvt)
     ToDocPos( aDocPos );
     SvxIconChoiceCtrlEntry* pEntry = GetEntry( aDocPos );
     if( pEntry )
-        MakeEntryVisible( pEntry, false );
+        MakeEntryVisible(pEntry);
 
     if( !pEntry )
         return false;
@@ -1112,23 +1112,10 @@ SvxIconChoiceCtrlEntry* 
SvxIconChoiceCtrl_Impl::GetEntry( const Point& rDocPos )
     return nullptr;
 }
 
-void SvxIconChoiceCtrl_Impl::MakeEntryVisible( SvxIconChoiceCtrlEntry* pEntry, 
bool bBound )
+void SvxIconChoiceCtrl_Impl::MakeEntryVisible(SvxIconChoiceCtrlEntry* pEntry)
 {
-    if ( bBound )
-    {
-        const tools::Rectangle& rRect = GetEntryBoundRect( pEntry );
-        MakeVisible( rRect );
-    }
-    else
-    {
-        tools::Rectangle aRect = CalcBmpRect( pEntry );
-        aRect.Union( CalcTextRect( pEntry ) );
-        aRect.AdjustTop(TBOFFS_BOUND );
-        aRect.AdjustBottom(TBOFFS_BOUND );
-        aRect.AdjustLeft(LROFFS_BOUND );
-        aRect.AdjustRight(LROFFS_BOUND );
-        MakeVisible( aRect );
-    }
+    const tools::Rectangle& rRect = GetEntryBoundRect( pEntry );
+    MakeVisible(rRect);
 }
 
 const tools::Rectangle& SvxIconChoiceCtrl_Impl::GetEntryBoundRect( 
SvxIconChoiceCtrlEntry* pEntry )

Reply via email to