Kaydet (Commit) e66be44b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

sidebar: Restrict the minimal width of the sidebar.

Change-Id: I99051830c4393b420125332e787c3abdc5a6aa61
üst b441420e
...@@ -97,6 +97,8 @@ public: ...@@ -97,6 +97,8 @@ public:
// XSidebarPanel // XSidebarPanel
virtual css::ui::LayoutSize SAL_CALL getHeightForWidth (sal_Int32 nWidth) virtual css::ui::LayoutSize SAL_CALL getHeightForWidth (sal_Int32 nWidth)
throw(cssu::RuntimeException); throw(cssu::RuntimeException);
virtual sal_Int32 SAL_CALL getMinimalWidth ()
throw(cssu::RuntimeException);
protected: protected:
cssu::Reference<css::frame::XFrame> mxFrame; cssu::Reference<css::frame::XFrame> mxFrame;
......
...@@ -51,6 +51,10 @@ interface XSidebarPanel ...@@ -51,6 +51,10 @@ interface XSidebarPanel
The height is set via the XWindow interface. The height is set via the XWindow interface.
*/ */
LayoutSize getHeightForWidth ( [in] long nWidth); LayoutSize getHeightForWidth ( [in] long nWidth);
/** Minimal possible width of this panel.
*/
long getMinimalWidth();
} ; } ;
} ; } ; } ; } ; } ; } ; } ; } ;
......
...@@ -56,6 +56,7 @@ Deck::Deck ( ...@@ -56,6 +56,7 @@ Deck::Deck (
msIconURL(rDeckDescriptor.msIconURL), msIconURL(rDeckDescriptor.msIconURL),
msHighContrastIconURL(rDeckDescriptor.msHighContrastIconURL), msHighContrastIconURL(rDeckDescriptor.msHighContrastIconURL),
maPanels(), maPanels(),
mnMinimalWidth(0),
mpTitleBar(new DeckTitleBar(rDeckDescriptor.msTitle, this, rCloserAction)), mpTitleBar(new DeckTitleBar(rDeckDescriptor.msTitle, this, rCloserAction)),
mpScrollClipWindow(new Window(this)), mpScrollClipWindow(new Window(this)),
mpScrollContainer(new ScrollContainerWindow(mpScrollClipWindow.get())), mpScrollContainer(new ScrollContainerWindow(mpScrollClipWindow.get())),
...@@ -294,8 +295,11 @@ const SharedPanelContainer& Deck::GetPanels (void) const ...@@ -294,8 +295,11 @@ const SharedPanelContainer& Deck::GetPanels (void) const
void Deck::RequestLayout (void) void Deck::RequestLayout (void)
{ {
mnMinimalWidth = 0;
DeckLayouter::LayoutDeck( DeckLayouter::LayoutDeck(
GetContentArea(), GetContentArea(),
mnMinimalWidth,
maPanels, maPanels,
*GetTitleBar(), *GetTitleBar(),
*mpScrollClipWindow, *mpScrollClipWindow,
......
...@@ -75,6 +75,8 @@ public: ...@@ -75,6 +75,8 @@ public:
void PrintWindowTree (const ::std::vector<Panel*>& rPanels); void PrintWindowTree (const ::std::vector<Panel*>& rPanels);
static void PrintWindowSubTree (Window* pRoot, int nIndentation); static void PrintWindowSubTree (Window* pRoot, int nIndentation);
sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; }
class ScrollContainerWindow : public Window class ScrollContainerWindow : public Window
{ {
public: public:
...@@ -92,6 +94,7 @@ private: ...@@ -92,6 +94,7 @@ private:
Image maIcon; Image maIcon;
const ::rtl::OUString msIconURL; const ::rtl::OUString msIconURL;
const ::rtl::OUString msHighContrastIconURL; const ::rtl::OUString msHighContrastIconURL;
sal_Int32 mnMinimalWidth;
SharedPanelContainer maPanels; SharedPanelContainer maPanels;
::boost::scoped_ptr<DeckTitleBar> mpTitleBar; ::boost::scoped_ptr<DeckTitleBar> mpTitleBar;
::boost::scoped_ptr<Window> mpScrollClipWindow; ::boost::scoped_ptr<Window> mpScrollClipWindow;
......
...@@ -47,6 +47,7 @@ namespace { ...@@ -47,6 +47,7 @@ namespace {
void DeckLayouter::LayoutDeck ( void DeckLayouter::LayoutDeck (
const Rectangle aContentArea, const Rectangle aContentArea,
sal_Int32& rMinimalWidth,
SharedPanelContainer& rPanels, SharedPanelContainer& rPanels,
Window& rDeckTitleBar, Window& rDeckTitleBar,
Window& rScrollClipWindow, Window& rScrollClipWindow,
...@@ -70,6 +71,7 @@ void DeckLayouter::LayoutDeck ( ...@@ -70,6 +71,7 @@ void DeckLayouter::LayoutDeck (
} }
aBox = LayoutPanels( aBox = LayoutPanels(
aBox, aBox,
rMinimalWidth,
aLayoutItems, aLayoutItems,
rScrollClipWindow, rScrollClipWindow,
rScrollContainer, rScrollContainer,
...@@ -84,6 +86,7 @@ void DeckLayouter::LayoutDeck ( ...@@ -84,6 +86,7 @@ void DeckLayouter::LayoutDeck (
Rectangle DeckLayouter::LayoutPanels ( Rectangle DeckLayouter::LayoutPanels (
const Rectangle aContentArea, const Rectangle aContentArea,
sal_Int32& rMinimalWidth,
::std::vector<LayoutItem>& rLayoutItems, ::std::vector<LayoutItem>& rLayoutItems,
Window& rScrollClipWindow, Window& rScrollClipWindow,
Window& rScrollContainer, Window& rScrollContainer,
...@@ -98,7 +101,7 @@ Rectangle DeckLayouter::LayoutPanels ( ...@@ -98,7 +101,7 @@ Rectangle DeckLayouter::LayoutPanels (
// height that is left when all panel titles and separators are // height that is left when all panel titles and separators are
// taken into account. // taken into account.
sal_Int32 nAvailableHeight (aBox.GetHeight()); sal_Int32 nAvailableHeight (aBox.GetHeight());
GetRequestedSizes(rLayoutItems, nAvailableHeight, aBox); GetRequestedSizes(rLayoutItems, nAvailableHeight, rMinimalWidth, aBox);
const sal_Int32 nTotalDecorationHeight (aBox.GetHeight() - nAvailableHeight); const sal_Int32 nTotalDecorationHeight (aBox.GetHeight() - nAvailableHeight);
// Analyze the requested heights. // Analyze the requested heights.
...@@ -120,6 +123,7 @@ Rectangle DeckLayouter::LayoutPanels ( ...@@ -120,6 +123,7 @@ Rectangle DeckLayouter::LayoutPanels (
// Show a vertical scrollbar. // Show a vertical scrollbar.
return LayoutPanels( return LayoutPanels(
aContentArea, aContentArea,
rMinimalWidth,
rLayoutItems, rLayoutItems,
rScrollClipWindow, rScrollClipWindow,
rScrollContainer, rScrollContainer,
...@@ -284,6 +288,7 @@ sal_Int32 DeckLayouter::PlacePanels ( ...@@ -284,6 +288,7 @@ sal_Int32 DeckLayouter::PlacePanels (
void DeckLayouter::GetRequestedSizes ( void DeckLayouter::GetRequestedSizes (
::std::vector<LayoutItem>& rLayoutItems, ::std::vector<LayoutItem>& rLayoutItems,
sal_Int32& rAvailableHeight, sal_Int32& rAvailableHeight,
sal_Int32& rMinimalWidth,
const Rectangle& rContentBox) const Rectangle& rContentBox)
{ {
rAvailableHeight = rContentBox.GetHeight(); rAvailableHeight = rContentBox.GetHeight();
...@@ -316,7 +321,13 @@ void DeckLayouter::GetRequestedSizes ( ...@@ -316,7 +321,13 @@ void DeckLayouter::GetRequestedSizes (
{ {
Reference<ui::XSidebarPanel> xPanel (iItem->mpPanel->GetPanelComponent()); Reference<ui::XSidebarPanel> xPanel (iItem->mpPanel->GetPanelComponent());
if (xPanel.is()) if (xPanel.is())
{
aLayoutSize = xPanel->getHeightForWidth(rContentBox.GetWidth()); aLayoutSize = xPanel->getHeightForWidth(rContentBox.GetWidth());
sal_Int32 nWidth = xPanel->getMinimalWidth();
if (nWidth > rMinimalWidth)
rMinimalWidth = nWidth;
}
else else
aLayoutSize = ui::LayoutSize(MinimalPanelHeight, -1, 0); aLayoutSize = ui::LayoutSize(MinimalPanelHeight, -1, 0);
} }
......
...@@ -44,6 +44,7 @@ class DeckLayouter ...@@ -44,6 +44,7 @@ class DeckLayouter
public: public:
static void LayoutDeck ( static void LayoutDeck (
const Rectangle aContentArea, const Rectangle aContentArea,
sal_Int32& rMinimalWidth,
SharedPanelContainer& rPanels, SharedPanelContainer& rPanels,
Window& pDeckTitleBar, Window& pDeckTitleBar,
Window& pScrollClipWindow, Window& pScrollClipWindow,
...@@ -78,6 +79,7 @@ private: ...@@ -78,6 +79,7 @@ private:
}; };
static Rectangle LayoutPanels ( static Rectangle LayoutPanels (
const Rectangle aContentArea, const Rectangle aContentArea,
sal_Int32& rMinimalWidth,
::std::vector<LayoutItem>& rLayoutItems, ::std::vector<LayoutItem>& rLayoutItems,
Window& rScrollClipWindow, Window& rScrollClipWindow,
Window& rScrollContainer, Window& rScrollContainer,
...@@ -86,6 +88,7 @@ private: ...@@ -86,6 +88,7 @@ private:
static void GetRequestedSizes ( static void GetRequestedSizes (
::std::vector<LayoutItem>& rLayoutItem, ::std::vector<LayoutItem>& rLayoutItem,
sal_Int32& rAvailableHeight, sal_Int32& rAvailableHeight,
sal_Int32& rMinimalWidth,
const Rectangle& rContentBox); const Rectangle& rContentBox);
static void DistributeHeights ( static void DistributeHeights (
::std::vector<LayoutItem>& rLayoutItems, ::std::vector<LayoutItem>& rLayoutItems,
......
...@@ -272,9 +272,13 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv ...@@ -272,9 +272,13 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv
void SAL_CALL SidebarController::requestLayout (void) void SAL_CALL SidebarController::requestLayout (void)
throw(cssu::RuntimeException) throw(cssu::RuntimeException)
{ {
sal_Int32 nMinimalWidth = 0;
if (mpCurrentDeck) if (mpCurrentDeck)
{
mpCurrentDeck->RequestLayout(); mpCurrentDeck->RequestLayout();
RestrictWidth(); nMinimalWidth = mpCurrentDeck->GetMinimalWidth();
}
RestrictWidth(nMinimalWidth);
} }
...@@ -340,14 +344,16 @@ void SidebarController::NotifyResize (void) ...@@ -340,14 +344,16 @@ void SidebarController::NotifyResize (void)
mpTabBar->Show(); mpTabBar->Show();
// Determine if the closer of the deck can be shown. // Determine if the closer of the deck can be shown.
sal_Int32 nMinimalWidth = 0;
if (mpCurrentDeck) if (mpCurrentDeck)
{ {
DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
if (pTitleBar != NULL && pTitleBar->IsVisible()) if (pTitleBar != NULL && pTitleBar->IsVisible())
pTitleBar->SetCloserVisible(CanModifyChildWindowWidth()); pTitleBar->SetCloserVisible(CanModifyChildWindowWidth());
nMinimalWidth = mpCurrentDeck->GetMinimalWidth();
} }
RestrictWidth(); RestrictWidth(nMinimalWidth);
} }
...@@ -1050,7 +1056,7 @@ sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth) ...@@ -1050,7 +1056,7 @@ sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth)
void SidebarController::RestrictWidth (void) void SidebarController::RestrictWidth (sal_Int32 nWidth)
{ {
SfxSplitWindow* pSplitWindow = GetSplitWindow(); SfxSplitWindow* pSplitWindow = GetSplitWindow();
if (pSplitWindow != NULL) if (pSplitWindow != NULL)
...@@ -1059,7 +1065,7 @@ void SidebarController::RestrictWidth (void) ...@@ -1059,7 +1065,7 @@ void SidebarController::RestrictWidth (void)
const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); const sal_uInt16 nSetId (pSplitWindow->GetSet(nId));
pSplitWindow->SetItemSizeRange( pSplitWindow->SetItemSizeRange(
nSetId, nSetId,
Range(TabBar::GetDefaultWidth(), gnMaximumSidebarWidth)); Range(TabBar::GetDefaultWidth() + nWidth, gnMaximumSidebarWidth));
} }
} }
......
...@@ -213,7 +213,7 @@ private: ...@@ -213,7 +213,7 @@ private:
void UpdateTitleBarIcons (void); void UpdateTitleBarIcons (void);
void UpdateDeckOpenState (void); void UpdateDeckOpenState (void);
void RestrictWidth (void); void RestrictWidth (sal_Int32 nWidth);
SfxSplitWindow* GetSplitWindow (void); SfxSplitWindow* GetSplitWindow (void);
void ProcessNewWidth (const sal_Int32 nNewWidth); void ProcessNewWidth (const sal_Int32 nNewWidth);
void UpdateCloseIndicator (const bool bIsIndicatorVisible); void UpdateCloseIndicator (const bool bIsIndicatorVisible);
......
...@@ -248,4 +248,15 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi ...@@ -248,4 +248,15 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi
return ui::LayoutSize(0,0,0); return ui::LayoutSize(0,0,0);
} }
sal_Int32 SAL_CALL SidebarPanelBase::getMinimalWidth () throw(cssu::RuntimeException)
{
if (isLayoutEnabled(mpControl))
{
// widget layout-based sidebar
Size aSize(mpControl->GetOptimalSize());
return aSize.Width();
}
return 0;
}
} } // end of namespace sfx2::sidebar } } // end of namespace sfx2::sidebar
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