tdf#149431 Fix the sidebar's width

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 <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
xuenhua
2022-06-01 15:29:49 +08:00
committed by Caolán McNamara
parent 80d801cf07
commit 0ec2b93c28

View File

@@ -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;
}