[Libreoffice-commits] core.git: svtools/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 9 09:08:55 UTC 2020
svtools/source/control/valueset.cxx | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
New commits:
commit ebfd1c859f9da4318999a145d6af0fd33372dc6b
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 8 17:21:40 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 9 11:08:00 2020 +0200
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 at redhat.com>
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());
+ }
}
}
More information about the Libreoffice-commits
mailing list