svtools/source/control/valueset.cxx |   33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

New commits:
commit ebfd1c859f9da4318999a145d6af0fd33372dc6b
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Sep 8 17:21:40 2020 +0100
Commit:     Caolán McNamara <caol...@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 <caol...@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());
+            }
         }
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to