diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-04-01 10:31:27 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-04-06 10:17:43 +0200 |
commit | 68ee7f1e3c54aab34e42b81cf47f75beef11fc3c (patch) | |
tree | 43dfad5b515b33c002962b3cd8464252b4f37e70 /vcl | |
parent | 1406fb1d7d04bb217259b807dd6069aac605f84e (diff) |
Resolves: tdf#141258 turn scrollbars on/off once per layout loop
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/+/113370
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/layout.cxx | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 2cf77e81a688..9406aa4585f5 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1913,31 +1913,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 + bool bShowVScroll; 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); + bShowVScroll = nAvailHeight < aChildReq.Height(); + else + bShowVScroll = (GetStyle() & WB_VSCROLL) != 0; - if (m_pVScroll->IsVisible()) + 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); |