vcl/source/control/PriorityMergedHBox.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit dce8d2dbc48eb1c7597afec236dc51b4b8aede9c
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Mon May 22 13:28:55 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Tue May 23 17:45:33 2023 +0200

    tdf#140557 notebookbar: be smarter about hidden window size
    
    This fixes a 7.1 regression from 53d73d532281b6734a7d4614bb74fc6cc15510f0
    where notebookbar controls were being hidden (and then shown
    after a refresh of the toolbar), leaving big empty gaps.
    
    I don't know anything about vcl or window layout idiosyncracies,
    so I just read through this code looking for some way to fix
    the problem of the notebookbar not using all of its available space.
    
    The problem was that GetOutputSizePixel was returning zero.
    Why that would be I don't know. Perhaps because it had never
    actually been displayed on screen yet? (This was occurring
    on simply loading Calc.)
    
    Substituting a small DUMMY_WIDTH didn't give a very accurate
    reduction, so there was no space to add back in any items later on.
    
    When adding it back, it adds using a legitimate-seeming width,
    with an (unused this time) fallback to DUMMY_WIDTH.
    
    So, unless getLayoutRequisition cannot be depended upon for
    returning an accurate size, this should be a nice fix.
    It will no longer hide too many controls from the notebookbar.
    
    Change-Id: I1c39fe3532dad501c16f53612f8e26835b72638a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152125
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/vcl/source/control/PriorityMergedHBox.cxx 
b/vcl/source/control/PriorityMergedHBox.cxx
index 65d51cce378c..3e67a13a8f4a 100644
--- a/vcl/source/control/PriorityMergedHBox.cxx
+++ b/vcl/source/control/PriorityMergedHBox.cxx
@@ -69,8 +69,12 @@ void PriorityMergedHBox::Resize()
 
         if (pWindow && pWindow->GetParent() == this && pWindow->IsVisible())
         {
-            if (pWindow->GetOutputSizePixel().Width())
-                nCurrentWidth -= pWindow->GetOutputSizePixel().Width();
+            tools::Long nWindowWidth = pWindow->GetOutputSizePixel().Width();
+            if (!nWindowWidth)
+                nWindowWidth = getLayoutRequisition(*pWindow).Width() + 
get_spacing();
+
+            if (nWindowWidth)
+                nCurrentWidth -= nWindowWidth;
             else
                 nCurrentWidth -= DUMMY_WIDTH;
             pWindow->Hide();

Reply via email to