summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-08 17:21:40 +0100
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2020-09-10 16:37:02 +0200
commite7f829db91f4b9184cbfc29ca2b20050aac6e750 (patch)
treeb58b4cfe5574b51b7eb402278a23cda10d81e399 /svtools
parent7c140177879d259a6d41ea2383105b5eabef958c (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> (cherry picked from commit ebfd1c859f9da4318999a145d6af0fd33372dc6b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102299 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/valueset.cxx33
1 files changed, 24 insertions, 9 deletions
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 4329d415f9a1..00bd7226478a 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -908,11 +908,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)
{
@@ -929,6 +934,8 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext)
mnVisLines = mnLines;
}
+ bAdjustmentOutOfDate |= nOldVisLines != mnVisLines;
+
if (mnLines > mnVisLines)
mbScroll = true;
@@ -1131,16 +1138,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());
+ }
}
}