diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-08 17:21:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-09-09 11:08:00 +0200 |
commit | ebfd1c859f9da4318999a145d6af0fd33372dc6b (patch) | |
tree | 1f20478302ba4f77c29c823e0d3c9dd0c1b089a4 /svtools | |
parent | 8821bd663ed75fb2c9706b102e1d6f8ccfcf00f5 (diff) |
tdf#135042 update scrolledwindow vadjustment when resized
Change-Id: I94408845b82c7202f74360168c66c4439e985124
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102271
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/valueset.cxx | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 280d8eaff848..a99588187e35 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -921,11 +921,16 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) // calculate number of rows mbScroll = false; + auto nOldLines = mnLines; // Floor( (M+N-1)/N )==Ceiling( M/N ) mnLines = (static_cast<long>(nItemCount) + mnCols - 1) / mnCols; if (mnLines <= 0) mnLines = 1; + bool bAdjustmentOutOfDate = nOldLines != mnLines; + + auto nOldVisLines = mnVisLines; + long nCalcHeight = aWinSize.Height() - nNoneHeight; if (mnUserVisLines) { @@ -942,6 +947,8 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) mnVisLines = mnLines; } + bAdjustmentOutOfDate |= nOldVisLines != mnVisLines; + if (mnLines > mnVisLines) mbScroll = true; @@ -1144,16 +1151,24 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) } // arrange ScrollBar, set values and show it - if (mxScrolledWindow && (nStyle & WB_VSCROLL) && mxScrolledWindow->get_vpolicy() != VclPolicyType::ALWAYS) + if (mxScrolledWindow && (nStyle & WB_VSCROLL)) { - long nPageSize = mnVisLines; - if (nPageSize < 1) - nPageSize = 1; - mxScrolledWindow->vadjustment_configure(mnFirstLine, 0, mnLines, 1, - mnVisLines, nPageSize); - mxScrolledWindow->set_vpolicy(VclPolicyType::ALWAYS); - Size aPrefSize(GetDrawingArea()->get_preferred_size()); - GetDrawingArea()->set_size_request(aPrefSize.Width() - GetScrollWidth(), aPrefSize.Height()); + bool bTurnScrollbarOn = mxScrolledWindow->get_vpolicy() != VclPolicyType::ALWAYS; + if (bAdjustmentOutOfDate || bTurnScrollbarOn) + { + long nPageSize = mnVisLines; + if (nPageSize < 1) + nPageSize = 1; + mxScrolledWindow->vadjustment_configure(mnFirstLine, 0, mnLines, 1, + mnVisLines, nPageSize); + } + + if (bTurnScrollbarOn) + { + mxScrolledWindow->set_vpolicy(VclPolicyType::ALWAYS); + Size aPrefSize(GetDrawingArea()->get_preferred_size()); + GetDrawingArea()->set_size_request(aPrefSize.Width() - GetScrollWidth(), aPrefSize.Height()); + } } } |