From 0ec2b93c28093c80572c43f7be261630bd85f232 Mon Sep 17 00:00:00 2001 From: xuenhua Date: Wed, 1 Jun 2022 15:29:49 +0800 Subject: [PATCH] tdf#149431 Fix the sidebar's width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When click the wider sidebar and then go back to the narrow one in Writer, the narrow one becomes the same width as wider one, it's not suitable and doesn't look good. Fix the width to smallest width unless you drag the splitter. Take the maximum width from the smallest width and mnWidthOnSplitterButtonDown. Change-Id: I60aaab84593d59ac28b96c2d3c3bd62a4bbddbbe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135220 Tested-by: Jenkins Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- sfx2/source/sidebar/SidebarController.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index cff76a95850b..088384641efd 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -506,6 +506,8 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) { // Deck became large enough to be shown. Show it. mnSavedSidebarWidth = nNewWidth; + // Store nNewWidth to mnWidthOnSplitterButtonDown when dragging sidebar Splitter + mnWidthOnSplitterButtonDown = nNewWidth; if (!*mbIsDeckOpen) RequestOpenDeck(); } @@ -653,8 +655,12 @@ void SidebarController::OpenThenToggleDeck ( if (mpCurrentDeck && mpTabBar) { sal_Int32 nRequestedWidth = mpCurrentDeck->GetMinimalWidth() + TabBar::GetDefaultWidth(); - if (mnSavedSidebarWidth < nRequestedWidth) + // if sidebar was dragged + if(mnWidthOnSplitterButtonDown > 0 && mnWidthOnSplitterButtonDown > nRequestedWidth){ + SetChildWindowWidth(mnWidthOnSplitterButtonDown); + }else{ SetChildWindowWidth(nRequestedWidth); + } } } @@ -1060,7 +1066,6 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent&, rEvent, void) case VclEventId::WindowMouseButtonUp: { ProcessNewWidth(mpParentWindow->GetSizePixel().Width()); - mnWidthOnSplitterButtonDown = 0; break; }