// Get the requested heights of the panels and the available // height that is left when all panel titles and separators are // taken into account.
sal_Int32 nAvailableHeight (aBox.GetHeight());
GetRequestedSizes(rLayoutItems, nAvailableHeight, rMinimalWidth, aBox); const sal_Int32 nTotalDecorationHeight (aBox.GetHeight() - nAvailableHeight);
// Analyze the requested heights. // Determine the height that is available for panel content // and count the different layouts.
sal_Int32 nTotalPreferredHeight (0);
sal_Int32 nTotalMinimumHeight (0);
if (nTotalMinimumHeight > nAvailableHeight && !bShowVerticalScrollBar
&& !comphelper::LibreOfficeKit::isActive())
{ // Not enough space, even when all panels are shrunk to their // minimum height. // Show a vertical scrollbar.
LayoutPanels(
rContentArea,
rMinimalWidth,
rMinimalHeight,
rLayoutItems,
rVerticalScrollBar, true); return;
}
// We are now in one of three modes. // - The preferred height fits into the available size: // Use the preferred size, distribute the remaining height by // enlarging panels. // - The total minimum height fits into the available size: // Use the minimum size, distribute the remaining height by // enlarging panels. // - The total minimum height does not fit into the available // size: // Use the unmodified preferred height for all panels.
LayoutMode eMode(MinimumOrLarger); if (bShowVerticalScrollBar)
{
eMode = Preferred;
sal_Int32 nPanelHeight(0); if (bExpanded)
{ // Determine the height of the panel depending on layout // mode and distributed heights. switch(eMode)
{ case MinimumOrLarger:
nPanelHeight = iItem->maLayoutSize.Minimum + iItem->mnDistributedHeight; break; case PreferredOrLarger:
nPanelHeight = iItem->maLayoutSize.Preferred + iItem->mnDistributedHeight; break; case Preferred:
nPanelHeight = iItem->maLayoutSize.Preferred; break; default:
OSL_ASSERT(false); break;
}
} if (bShowTitlebar)
nPanelHeight += pTitleBar->get_preferred_size().Height();
rPanel.SetHeightPixel(nPanelHeight);
nY += nPanelHeight;
} else
{
rPanel.Show(false);
}
if (!bExpanded)
{ // Add a separator below the collapsed panel, if it is the // last panel in the deck. if (iItem == rLayoutItems.end()-1)
{ // Separator below the panel title bar.
rPanel.set_margin_bottom(nDeckSeparatorHeight);
nY += nDeckSeparatorHeight;
}
}
}
for (auto& rItem : rLayoutItems)
{
rItem.maLayoutSize = ui::LayoutSize(0,0,0);
if (rItem.mpPanel == nullptr) continue;
if (rItem.mpPanel->IsLurking())
{
rItem.mbShowTitleBar = false; continue;
}
if (rLayoutItems.size() == 1
&& rItem.mpPanel->IsTitleBarOptional())
{ // There is only one panel and its title bar is // optional => hide it.
rAvailableHeight -= nDeckSeparatorHeight;
rItem.mbShowTitleBar = false;
} else
{ // Show the title bar and a separator above and below // the title bar.
PanelTitleBar* pTitleBar = rItem.mpPanel->GetTitleBar(); const sal_Int32 nPanelTitleBarHeight = pTitleBar->get_preferred_size().Height();
sal_Int32 nWidth = rMinimalWidth; try
{ // The demo sidebar extension "Analog Clock" fails with // java.lang.AbstractMethodError here
nWidth = xPanel->getMinimalWidth();
} catch (...)
{
}
uno::Reference<frame::XDesktop2> xDesktop
= frame::Desktop::create(comphelper::getProcessComponentContext());
uno::Reference<frame::XFrame> xFrame = xDesktop->getActiveFrame(); if (xFrame.is())
{
SidebarController* pController
= SidebarController::GetSidebarControllerForFrame(xFrame); if (pController && pController->getMaximumWidth() < nWidth)
{ // Add 100 extra pixels to still have the sidebar resizable // (See also documentation of XSidebarPanel::getMinimalWidth)
pController->setMaximumWidth(nWidth + 100);
}
}
// Compute the weights as difference between panel base height // (either its minimum or preferred height) and the container height.
sal_Int32 nTotalWeight (0);
sal_Int32 nNoMaximumCount (0);
for (auto& rItem : rLayoutItems)
{ if (rItem.maLayoutSize.Maximum == 0) continue; if (rItem.maLayoutSize.Maximum < 0)
++nNoMaximumCount;
if (nRemainingHeightToDistribute == 0) return;
OSL_ASSERT(nRemainingHeightToDistribute > 0);
// It is possible that not all of the height could be distributed // because of Maximum heights being smaller than expected. // Distribute the remaining height between the panels that have no // Maximum (ie Maximum==-1). if (nNoMaximumCount == 0)
{ // There are no panels with unrestricted height. return;
}
tools::Rectangle PlaceDeckTitle( const SidebarDockingWindow* pDockingWindow,
DeckTitleBar& rDeckTitleBar, const tools::Rectangle& rAvailableSpace)
{ if (pDockingWindow->IsFloatingMode())
{ // When the side bar is undocked then the outer system window displays the deck title.
rDeckTitleBar.Show(false); return rAvailableSpace;
} else
{
rDeckTitleBar.Show(true); const sal_Int32 nDeckTitleBarHeight(rDeckTitleBar.get_preferred_size().Height()); return tools::Rectangle(
rAvailableSpace.Left(),
rAvailableSpace.Top() + nDeckTitleBarHeight,
rAvailableSpace.Right(),
rAvailableSpace.Bottom());
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.