diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-12-10 00:29:31 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-04-30 18:06:30 +0200 |
commit | f14bd82933246211266ae1db2bb1e00857b02c3f (patch) | |
tree | 3ce823e0454d3711f65467bfdc06eccb32420ab9 | |
parent | be9296d7219c95312191feebec05d25dfea75fc7 (diff) |
sfx: LOK: don't shrink sidebar height below minimum
This avoids scrolling within the sidebar and makes
it possible to scroll the rendred sidebar image
in the client, which is more responsive and lighter.
Change-Id: I0713c699ba82bfc5fe503c9351402c67aef4494e
-rw-r--r-- | include/sfx2/sidebar/Deck.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/sidebar/DeckLayouter.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/Deck.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/sidebar/DeckLayouter.cxx | 36 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 17 |
5 files changed, 43 insertions, 17 deletions
diff --git a/include/sfx2/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx index c4cc7027961e..a38757de1ce1 100644 --- a/include/sfx2/sidebar/Deck.hxx +++ b/include/sfx2/sidebar/Deck.hxx @@ -71,6 +71,7 @@ public: static void PrintWindowSubTree (vcl::Window* pRoot, int nIndentation); sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; } + sal_Int32 GetMinimalHeight() const { return mnMinimalHeight; } class ScrollContainerWindow : public vcl::Window { @@ -85,6 +86,7 @@ public: private: const OUString msId; sal_Int32 mnMinimalWidth; + sal_Int32 mnMinimalHeight; SharedPanelContainer maPanels; VclPtr<DeckTitleBar> mpTitleBar; VclPtr<vcl::Window> mpScrollClipWindow; diff --git a/include/sfx2/sidebar/DeckLayouter.hxx b/include/sfx2/sidebar/DeckLayouter.hxx index 27a94dd7b3e9..4ce568ef10b8 100644 --- a/include/sfx2/sidebar/DeckLayouter.hxx +++ b/include/sfx2/sidebar/DeckLayouter.hxx @@ -42,6 +42,7 @@ namespace DeckLayouter void LayoutDeck ( const tools::Rectangle& rContentArea, sal_Int32& rMinimalWidth, + sal_Int32& rMinimalHeight, SharedPanelContainer& rPanels, vcl::Window& pDeckTitleBar, vcl::Window& pScrollClipWindow, diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx index b3ab0d22ad84..83873d7c9950 100644 --- a/sfx2/source/sidebar/Deck.cxx +++ b/sfx2/source/sidebar/Deck.cxx @@ -46,6 +46,7 @@ Deck::Deck(const DeckDescriptor& rDeckDescriptor, vcl::Window* pParentWindow, : Window(pParentWindow, 0) , msId(rDeckDescriptor.msId) , mnMinimalWidth(0) + , mnMinimalHeight(0) , maPanels() , mpTitleBar(VclPtr<DeckTitleBar>::Create(rDeckDescriptor.msTitle, this, rCloserAction)) , mpScrollClipWindow(VclPtr<vcl::Window>::Create(this)) @@ -220,8 +221,9 @@ void Deck::ResetPanels(const SharedPanelContainer& rPanelContainer) void Deck::RequestLayout() { mnMinimalWidth = 0; + mnMinimalHeight = 0; - DeckLayouter::LayoutDeck(GetContentArea(), mnMinimalWidth, maPanels, + DeckLayouter::LayoutDeck(GetContentArea(), mnMinimalWidth, mnMinimalHeight, maPanels, *GetTitleBar(), *mpScrollClipWindow, *mpScrollContainer, *mpFiller, *mpVerticalScrollBar); } diff --git a/sfx2/source/sidebar/DeckLayouter.cxx b/sfx2/source/sidebar/DeckLayouter.cxx index 9ca553dd66c1..04dca5eb8989 100644 --- a/sfx2/source/sidebar/DeckLayouter.cxx +++ b/sfx2/source/sidebar/DeckLayouter.cxx @@ -49,13 +49,19 @@ namespace { sal_Int32 mnWeight; bool mbShowTitleBar; - LayoutItem() - : mpPanel(),maLayoutSize(0,0,0),mnDistributedHeight(0),mnWeight(0),mbShowTitleBar(true) - {} + LayoutItem(const VclPtr<Panel>& rPanel) + : mpPanel(rPanel) + , maLayoutSize(0, 0, 0) + , mnDistributedHeight(0) + , mnWeight(0) + , mbShowTitleBar(true) + { + } }; tools::Rectangle LayoutPanels ( const tools::Rectangle& rContentArea, sal_Int32& rMinimalWidth, + sal_Int32& rMinimalHeight, ::std::vector<LayoutItem>& rLayoutItems, vcl::Window& rScrollClipWindow, vcl::Window& rScrollContainer, @@ -95,6 +101,7 @@ namespace { void DeckLayouter::LayoutDeck ( const tools::Rectangle& rContentArea, sal_Int32& rMinimalWidth, + sal_Int32& rMinimalHeight, SharedPanelContainer& rPanels, vcl::Window& rDeckTitleBar, vcl::Window& rScrollClipWindow, @@ -110,14 +117,14 @@ void DeckLayouter::LayoutDeck ( { // Prepare the layout item container. ::std::vector<LayoutItem> aLayoutItems; - aLayoutItems.resize(rPanels.size()); - for (sal_Int32 nIndex(0),nCount(rPanels.size()); nIndex<nCount; ++nIndex) - { - aLayoutItems[nIndex].mpPanel = rPanels[nIndex]; - } + aLayoutItems.reserve(rPanels.size()); + for (const auto& rPanel : rPanels) + aLayoutItems.emplace_back(rPanel); + aBox = LayoutPanels( aBox, rMinimalWidth, + rMinimalHeight, aLayoutItems, rScrollClipWindow, rScrollContainer, @@ -132,6 +139,7 @@ namespace { tools::Rectangle LayoutPanels ( const tools::Rectangle& rContentArea, sal_Int32& rMinimalWidth, + sal_Int32& rMinimalHeight, ::std::vector<LayoutItem>& rLayoutItems, vcl::Window& rScrollClipWindow, vcl::Window& rScrollContainer, @@ -155,15 +163,14 @@ tools::Rectangle LayoutPanels ( sal_Int32 nTotalPreferredHeight (0); sal_Int32 nTotalMinimumHeight (0); - for(::std::vector<LayoutItem>::const_iterator iItem(rLayoutItems.begin()), - iEnd(rLayoutItems.end()); - iItem!=iEnd; - ++iItem) + for (const LayoutItem& rItem : rLayoutItems) { - nTotalMinimumHeight += iItem->maLayoutSize.Minimum; - nTotalPreferredHeight += iItem->maLayoutSize.Preferred; + nTotalMinimumHeight += rItem.maLayoutSize.Minimum; + nTotalPreferredHeight += rItem.maLayoutSize.Preferred; } + // rMinimalHeight = nTotalMinimumHeight; + rMinimalHeight = aBox.GetHeight(); if (nTotalMinimumHeight > nAvailableHeight && ! bShowVerticalScrollBar) @@ -174,6 +181,7 @@ tools::Rectangle LayoutPanels ( return LayoutPanels( rContentArea, rMinimalWidth, + rMinimalHeight, rLayoutItems, rScrollClipWindow, rScrollContainer, diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 3018f24c03f3..fb1d3ae17b05 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -388,7 +388,13 @@ void SidebarController::NotifyResize() { // No TabBar in LOK. if (comphelper::LibreOfficeKit::isActive()) - mpCurrentDeck->setPosSizePixel(nDeckX, 0, nWidth, nHeight); + { + const sal_Int32 nMinimalHeight = mpCurrentDeck->GetMinimalHeight(); + if (nMinimalHeight > 0) + mpCurrentDeck->setPosSizePixel(nDeckX, 0, nWidth, nMinimalHeight); + else + mpCurrentDeck->setPosSizePixel(nDeckX, 0, nWidth, nHeight); + } else mpCurrentDeck->setPosSizePixel(nDeckX, 0, nWidth - nTabBarDefaultWidth, nHeight); mpCurrentDeck->Show(); @@ -1184,7 +1190,14 @@ void SidebarController::UpdateDeckOpenState() mnSavedSidebarWidth = aNewSize.Width(); // Save the current width to restore. aNewPos.setX(aNewPos.X() + mnSavedSidebarWidth - nTabBarDefaultWidth); - aNewSize.setWidth(nTabBarDefaultWidth); + if (comphelper::LibreOfficeKit::isActive()) + { + // Hide by collapsing, otherwise with 0x0 the client might expect + // to get valid dimensions on rendering and not collapse the sidebar. + aNewSize.setWidth(1); + } + else + aNewSize.setWidth(nTabBarDefaultWidth); mpParentWindow->GetFloatingWindow()->SetPosSizePixel(aNewPos, aNewSize); |