Kaydet (Commit) 94d7d8bc authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Jan Holesovsky

sfx2: LOK: resize the sidebar after layouting to avoid scrollbars

By resizing the deck we ensure that if the contents do not fit
in the existing height, they will after we expand to the minimum
height. Also, the minimum height is now the correct one.

This prevents seeing vertical scrollbar in LOK, which is very
slow and unfriendly, instead renders the full sidebar and lets
the client scroll, if necessary.

Change-Id: Idc2a622a65074b7afb26263624f2df0b5968f40d
üst 7c3ba6b5
......@@ -83,6 +83,9 @@ public:
std::vector<sal_Int32> maSeparators;
};
private:
void RequestLayoutInternal();
private:
const OUString msId;
sal_Int32 mnMinimalWidth;
......
......@@ -148,7 +148,7 @@ void Deck::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*r
void Deck::DataChanged (const DataChangedEvent&)
{
RequestLayout();
RequestLayoutInternal();
}
bool Deck::EventNotify(NotifyEvent& rEvent)
......@@ -215,10 +215,10 @@ void Deck::ResetPanels(const SharedPanelContainer& rPanelContainer)
}
maPanels = rPanelContainer;
RequestLayout();
RequestLayoutInternal();
}
void Deck::RequestLayout()
void Deck::RequestLayoutInternal()
{
mnMinimalWidth = 0;
mnMinimalHeight = 0;
......@@ -228,6 +228,17 @@ void Deck::RequestLayout()
*mpFiller, *mpVerticalScrollBar);
}
void Deck::RequestLayout()
{
RequestLayoutInternal();
if (comphelper::LibreOfficeKit::isActive() && mnMinimalHeight > 0)
{
const Size aParentSize = Size(GetParent()->GetSizePixel().Width(), mnMinimalHeight);
GetParent()->SetSizePixel(aParentSize);
setPosSizePixel(0, 0, aParentSize.Width(), aParentSize.Height());
}
}
vcl::Window* Deck::GetPanelParentWindow()
{
return mpScrollContainer.get();
......
......@@ -169,9 +169,6 @@ tools::Rectangle LayoutPanels (
nTotalPreferredHeight += rItem.maLayoutSize.Preferred;
}
// rMinimalHeight = nTotalMinimumHeight;
rMinimalHeight = aBox.GetHeight();
if (nTotalMinimumHeight > nAvailableHeight
&& ! bShowVerticalScrollBar)
{
......@@ -244,6 +241,7 @@ tools::Rectangle LayoutPanels (
const sal_Int32 nUsedHeight (PlacePanels(rLayoutItems, nWidth, eMode, rScrollContainer));
aBox.Top() += nUsedHeight;
rMinimalHeight = nUsedHeight;
return aBox;
}
......
......@@ -414,13 +414,15 @@ void SidebarController::NotifyResize()
// Place the deck first.
if (bIsDeckVisible)
{
// No TabBar in LOK.
if (comphelper::LibreOfficeKit::isActive())
{
// The minimal deck height is unreliable because of
// the fluid way the panels are stretched. Fix minimum manually.
// const sal_Int32 nMinimalHeight = mpCurrentDeck->GetMinimalHeight();
mpCurrentDeck->setPosSizePixel(nDeckX, 0, nWidth, 600);
// No TabBar in LOK (use nWidth in full).
// Use the minimum height that is large enough to let the
// layouter expand the panes maximally (that have a minimal
// height before the scrollbar is shown), so we never get
// scrollbars (we want scrolling to be done on the rendered
// image in the client, which is much faster).
mpCurrentDeck->setPosSizePixel(nDeckX, 0, nWidth, 650);
}
else
mpCurrentDeck->setPosSizePixel(nDeckX, 0, nWidth - nTabBarDefaultWidth, nHeight);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment