From e8d93ae128f7947e64eb8c849b4af9c54c9dd7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 1 Apr 2021 10:31:27 +0100 Subject: [PATCH] Resolves: tdf#141258 turn scrollbars on/off once per layout loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in this scenario the vertical scrollbar is turned off, then turned on back to its original state but the off/on triggers another layout loop later which does the same thing. Turn on/off just once per loop so only one state change can occur so new layout is only triggered if the state really changes. Change-Id: I5736264a74723a15034e5fb467262dca6c0f283c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113447 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/source/window/layout.cxx | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index ccdcc923117f..d5e5839583fd 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1905,31 +1905,36 @@ void VclScrolledWindow::doSetAllocation(const Size &rAllocation, bool bRetryOnFa tools::Long nAvailHeight = rAllocation.Height() - 2 * m_nBorderWidth; tools::Long nAvailWidth = rAllocation.Width() - 2 * m_nBorderWidth; - // vert. ScrollBar - if (GetStyle() & WB_AUTOVSCROLL) - { - m_pVScroll->Show(nAvailHeight < aChildReq.Height()); - } - else if (m_pVScroll->IsVisible() != bool(GetStyle() & WB_VSCROLL)) - m_pVScroll->Show((GetStyle() & WB_VSCROLL) != 0); - if (m_pVScroll->IsVisible()) + // vert. ScrollBar + bool bShowVScroll; + if (GetStyle() & WB_AUTOVSCROLL) + bShowVScroll = nAvailHeight < aChildReq.Height(); + else + bShowVScroll = (GetStyle() & WB_VSCROLL) != 0; + + if (bShowVScroll) nAvailWidth -= getLayoutRequisition(*m_pVScroll).Width(); // horz. ScrollBar + bool bShowHScroll; if (GetStyle() & WB_AUTOHSCROLL) { - bool bShowHScroll = nAvailWidth < aChildReq.Width(); - m_pHScroll->Show(bShowHScroll); + bShowHScroll = nAvailWidth < aChildReq.Width(); if (bShowHScroll) nAvailHeight -= getLayoutRequisition(*m_pHScroll).Height(); if (GetStyle() & WB_AUTOVSCROLL) - m_pVScroll->Show(nAvailHeight < aChildReq.Height()); + bShowVScroll = nAvailHeight < aChildReq.Height(); } - else if (m_pHScroll->IsVisible() != bool(GetStyle() & WB_HSCROLL)) - m_pHScroll->Show((GetStyle() & WB_HSCROLL) != 0); + else + bShowHScroll = (GetStyle() & WB_HSCROLL) != 0; + + if (m_pHScroll->IsVisible() != bShowHScroll) + m_pHScroll->Show(bShowHScroll); + if (m_pVScroll->IsVisible() != bShowVScroll) + m_pVScroll->Show(bShowVScroll); Size aInnerSize(rAllocation); aInnerSize.AdjustWidth(-2 * m_nBorderWidth);