summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-10-07 08:33:41 -0400
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-25 19:25:14 +0200
commit4790923b8c7de719b6c4cb84aff5997a040df2c8 (patch)
treefef08e33460f9d3a8e9e780da738e5a3a051c357 /sfx2
parentca8f1ff34e291b74068dace619e58c37ef169f88 (diff)
sfx2: collapse the sidebar instead of closing on toggle
When toggling a sidebar deck that is open, the default behavior when floating is to close the sidebar altogether. This is both inconsistent with the behaviour when docked and unexpected. Now we simply collapse the sidebar into the TabBar (toolbar) as is done when docked. This is also the behavior desired from LoKit since the sidebar is rendered floating (to allow arbitrary resizing). The collapsed sidebar into toolbar is shown in same-position. Change-Id: I0519c5ad012cc9df31758927a4dbcd774d47fcd3 Reviewed-on: https://gerrit.libreoffice.org/73505 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx48
1 files changed, 38 insertions, 10 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 8f09d3f38af6..aa328608ffe3 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -32,6 +32,7 @@
#include <sfx2/sidebar/ContextList.hxx>
+#include <sfx2/lokhelper.hxx>
#include <sfx2/sfxresid.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/titledockwin.hxx>
@@ -524,16 +525,16 @@ void SidebarController::OpenThenToggleDeck (
pSplitWindow->FadeIn();
else if ( IsDeckVisible( rsDeckId ) )
{
- if ( pSplitWindow )
+ if( !WasFloatingDeckClosed() )
{
- // tdf#67627 Clicking a second time on a Deck icon will close the Deck
- RequestCloseDeck();
+ // tdf#88241 Summoning an undocked sidebar a second time should close sidebar
+ mpParentWindow->Close();
return;
}
- else if( !WasFloatingDeckClosed() )
+ else
{
- // tdf#88241 Summoning an undocked sidebar a second time should close sidebar
- mpParentWindow->Close();
+ // tdf#67627 Clicking a second time on a Deck icon will close the Deck
+ RequestCloseDeck();
return;
}
}
@@ -1134,7 +1135,7 @@ void SidebarController::UpdateDeckOpenState()
// No state requested.
return;
- sal_Int32 nTabBarDefaultWidth = TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor();
+ const sal_Int32 nTabBarDefaultWidth = TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor();
// Update (change) the open state when it either has not yet been initialized
// or when its value differs from the requested state.
@@ -1143,15 +1144,42 @@ void SidebarController::UpdateDeckOpenState()
if (mbIsDeckRequestedOpen.get())
{
- if (mnSavedSidebarWidth <= nTabBarDefaultWidth)
- SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow));
+ if (!mpParentWindow->IsFloatingMode())
+ {
+ if (mnSavedSidebarWidth <= nTabBarDefaultWidth)
+ SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow));
+ else
+ SetChildWindowWidth(mnSavedSidebarWidth);
+ }
else
- SetChildWindowWidth(mnSavedSidebarWidth);
+ {
+ // Show the Deck by resizing back to the original size (before hiding).
+ Size aNewSize(mpParentWindow->GetFloatingWindow()->GetSizePixel());
+ Point aNewPos(mpParentWindow->GetFloatingWindow()->GetPosPixel());
+
+ aNewPos.setX(aNewPos.X() - mnSavedSidebarWidth + nTabBarDefaultWidth);
+ aNewSize.setWidth(mnSavedSidebarWidth);
+
+ mpParentWindow->GetFloatingWindow()->SetPosSizePixel(aNewPos, aNewSize);
+ }
}
else
{
if ( ! mpParentWindow->IsFloatingMode())
mnSavedSidebarWidth = SetChildWindowWidth(nTabBarDefaultWidth);
+ else
+ {
+ // Hide the Deck by resizing to the width of the TabBar.
+ Size aNewSize(mpParentWindow->GetFloatingWindow()->GetSizePixel());
+ Point aNewPos(mpParentWindow->GetFloatingWindow()->GetPosPixel());
+ mnSavedSidebarWidth = aNewSize.Width(); // Save the current width to restore.
+
+ aNewPos.setX(aNewPos.X() + mnSavedSidebarWidth - nTabBarDefaultWidth);
+ aNewSize.setWidth(nTabBarDefaultWidth);
+
+ mpParentWindow->GetFloatingWindow()->SetPosSizePixel(aNewPos, aNewSize);
+ }
+
if (mnWidthOnSplitterButtonDown > nTabBarDefaultWidth)
mnSavedSidebarWidth = mnWidthOnSplitterButtonDown;
mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE);