vcl/source/control/tabctrl.cxx |   24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

New commits:
commit ca482cf39f25941040596e50d0e1ab7fa25dc1dd
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Oct 27 16:14:50 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Oct 27 20:24:39 2022 +0200

    calculate the header bounds even for !bPaneWithHeader case
    
    so we can pass in the required area for the macOS case
    
    Change-Id: Ibb170e773a57ad0d5d0a591810e4039591337303
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141911
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 0a9d3677fe2f..b5d4d4cde0e2 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -1131,19 +1131,25 @@ void TabControl::Paint( vcl::RenderContext& 
rRenderContext, const tools::Rectang
     {
         const bool bPaneWithHeader = mbShowTabs && 
rRenderContext.IsNativeControlSupported(ControlType::TabPane, 
ControlPart::TabPaneWithHeader);
         tools::Rectangle aHeaderRect(aRect.Left(), 0, aRect.Right(), 
aRect.Top());
-        if (bPaneWithHeader)
+
+        if (mpTabCtrlData->maItemList.size())
         {
-            aRect.SetTop(0);
-            if (mpTabCtrlData->maItemList.size())
+            tools::Long nLeft = LONG_MAX;
+            tools::Long nRight = 0;
+            for (const auto &item : mpTabCtrlData->maItemList)
             {
-                tools::Long nRight = 0;
-                for (const auto &item : mpTabCtrlData->maItemList)
-                    if (item.m_bVisible)
-                        nRight = item.maRect.Right();
-                assert(nRight);
-                aHeaderRect.SetRight(nRight);
+                if (!item.m_bVisible)
+                    continue;
+                nRight = std::max(nRight, item.maRect.Right());
+                nLeft = std::min(nLeft, item.maRect.Left());
             }
+            aHeaderRect.SetLeft(nLeft);
+            aHeaderRect.SetRight(nRight);
         }
+
+        if (bPaneWithHeader)
+            aRect.SetTop(0);
+
         const TabPaneValue aTabPaneValue(aHeaderRect, pCurItem ? 
pCurItem->maRect : tools::Rectangle());
 
         ControlState nState = ControlState::ENABLED;

Reply via email to