[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - svtools/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 10 14:37:35 UTC 2020


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

New commits:
commit e7f829db91f4b9184cbfc29ca2b20050aac6e750
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 8 17:21:40 2020 +0100
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Thu Sep 10 16:37:02 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>
    (cherry picked from commit ebfd1c859f9da4318999a145d6af0fd33372dc6b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102299
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

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());
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list