summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2013-06-02 04:46:58 +0200
committerJan Holesovsky <kendy@suse.cz>2013-06-02 04:54:55 +0200
commite66be44b69ee2a1b99bda32af93ea453c669b319 (patch)
tree707027d8074f61a6e6fc8fab3c7a797117d1b8f3
parentb441420e072a1f09098f89ed646e423c60e1895b (diff)
sidebar: Restrict the minimal width of the sidebar.
Change-Id: I99051830c4393b420125332e787c3abdc5a6aa61
-rw-r--r--include/sfx2/sidebar/SidebarPanelBase.hxx2
-rw-r--r--offapi/com/sun/star/ui/XSidebarPanel.idl4
-rw-r--r--sfx2/source/sidebar/Deck.cxx4
-rw-r--r--sfx2/source/sidebar/Deck.hxx3
-rw-r--r--sfx2/source/sidebar/DeckLayouter.cxx13
-rw-r--r--sfx2/source/sidebar/DeckLayouter.hxx3
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx14
-rw-r--r--sfx2/source/sidebar/SidebarController.hxx2
-rw-r--r--sfx2/source/sidebar/SidebarPanelBase.cxx11
9 files changed, 50 insertions, 6 deletions
diff --git a/include/sfx2/sidebar/SidebarPanelBase.hxx b/include/sfx2/sidebar/SidebarPanelBase.hxx
index 330533a4947e..a7e8db165543 100644
--- a/include/sfx2/sidebar/SidebarPanelBase.hxx
+++ b/include/sfx2/sidebar/SidebarPanelBase.hxx
@@ -97,6 +97,8 @@ public:
// XSidebarPanel
virtual css::ui::LayoutSize SAL_CALL getHeightForWidth (sal_Int32 nWidth)
throw(cssu::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMinimalWidth ()
+ throw(cssu::RuntimeException);
protected:
cssu::Reference<css::frame::XFrame> mxFrame;
diff --git a/offapi/com/sun/star/ui/XSidebarPanel.idl b/offapi/com/sun/star/ui/XSidebarPanel.idl
index 1852c97b1f76..25d3f95890ff 100644
--- a/offapi/com/sun/star/ui/XSidebarPanel.idl
+++ b/offapi/com/sun/star/ui/XSidebarPanel.idl
@@ -51,6 +51,10 @@ interface XSidebarPanel
The height is set via the XWindow interface.
*/
LayoutSize getHeightForWidth ( [in] long nWidth);
+
+ /** Minimal possible width of this panel.
+ */
+ long getMinimalWidth();
} ;
} ; } ; } ; } ;
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index 9a16ad5fae75..52969b2cda1a 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -56,6 +56,7 @@ Deck::Deck (
msIconURL(rDeckDescriptor.msIconURL),
msHighContrastIconURL(rDeckDescriptor.msHighContrastIconURL),
maPanels(),
+ mnMinimalWidth(0),
mpTitleBar(new DeckTitleBar(rDeckDescriptor.msTitle, this, rCloserAction)),
mpScrollClipWindow(new Window(this)),
mpScrollContainer(new ScrollContainerWindow(mpScrollClipWindow.get())),
@@ -294,8 +295,11 @@ const SharedPanelContainer& Deck::GetPanels (void) const
void Deck::RequestLayout (void)
{
+ mnMinimalWidth = 0;
+
DeckLayouter::LayoutDeck(
GetContentArea(),
+ mnMinimalWidth,
maPanels,
*GetTitleBar(),
*mpScrollClipWindow,
diff --git a/sfx2/source/sidebar/Deck.hxx b/sfx2/source/sidebar/Deck.hxx
index f49d38f19fe6..0dc86ff9bafa 100644
--- a/sfx2/source/sidebar/Deck.hxx
+++ b/sfx2/source/sidebar/Deck.hxx
@@ -75,6 +75,8 @@ public:
void PrintWindowTree (const ::std::vector<Panel*>& rPanels);
static void PrintWindowSubTree (Window* pRoot, int nIndentation);
+ sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; }
+
class ScrollContainerWindow : public Window
{
public:
@@ -92,6 +94,7 @@ private:
Image maIcon;
const ::rtl::OUString msIconURL;
const ::rtl::OUString msHighContrastIconURL;
+ sal_Int32 mnMinimalWidth;
SharedPanelContainer maPanels;
::boost::scoped_ptr<DeckTitleBar> mpTitleBar;
::boost::scoped_ptr<Window> mpScrollClipWindow;
diff --git a/sfx2/source/sidebar/DeckLayouter.cxx b/sfx2/source/sidebar/DeckLayouter.cxx
index d68ae296d340..858fe93790a4 100644
--- a/sfx2/source/sidebar/DeckLayouter.cxx
+++ b/sfx2/source/sidebar/DeckLayouter.cxx
@@ -47,6 +47,7 @@ namespace {
void DeckLayouter::LayoutDeck (
const Rectangle aContentArea,
+ sal_Int32& rMinimalWidth,
SharedPanelContainer& rPanels,
Window& rDeckTitleBar,
Window& rScrollClipWindow,
@@ -70,6 +71,7 @@ void DeckLayouter::LayoutDeck (
}
aBox = LayoutPanels(
aBox,
+ rMinimalWidth,
aLayoutItems,
rScrollClipWindow,
rScrollContainer,
@@ -84,6 +86,7 @@ void DeckLayouter::LayoutDeck (
Rectangle DeckLayouter::LayoutPanels (
const Rectangle aContentArea,
+ sal_Int32& rMinimalWidth,
::std::vector<LayoutItem>& rLayoutItems,
Window& rScrollClipWindow,
Window& rScrollContainer,
@@ -98,7 +101,7 @@ Rectangle DeckLayouter::LayoutPanels (
// height that is left when all panel titles and separators are
// taken into account.
sal_Int32 nAvailableHeight (aBox.GetHeight());
- GetRequestedSizes(rLayoutItems, nAvailableHeight, aBox);
+ GetRequestedSizes(rLayoutItems, nAvailableHeight, rMinimalWidth, aBox);
const sal_Int32 nTotalDecorationHeight (aBox.GetHeight() - nAvailableHeight);
// Analyze the requested heights.
@@ -120,6 +123,7 @@ Rectangle DeckLayouter::LayoutPanels (
// Show a vertical scrollbar.
return LayoutPanels(
aContentArea,
+ rMinimalWidth,
rLayoutItems,
rScrollClipWindow,
rScrollContainer,
@@ -284,6 +288,7 @@ sal_Int32 DeckLayouter::PlacePanels (
void DeckLayouter::GetRequestedSizes (
::std::vector<LayoutItem>& rLayoutItems,
sal_Int32& rAvailableHeight,
+ sal_Int32& rMinimalWidth,
const Rectangle& rContentBox)
{
rAvailableHeight = rContentBox.GetHeight();
@@ -316,7 +321,13 @@ void DeckLayouter::GetRequestedSizes (
{
Reference<ui::XSidebarPanel> xPanel (iItem->mpPanel->GetPanelComponent());
if (xPanel.is())
+ {
aLayoutSize = xPanel->getHeightForWidth(rContentBox.GetWidth());
+
+ sal_Int32 nWidth = xPanel->getMinimalWidth();
+ if (nWidth > rMinimalWidth)
+ rMinimalWidth = nWidth;
+ }
else
aLayoutSize = ui::LayoutSize(MinimalPanelHeight, -1, 0);
}
diff --git a/sfx2/source/sidebar/DeckLayouter.hxx b/sfx2/source/sidebar/DeckLayouter.hxx
index e1df7f277ec4..a284c0827007 100644
--- a/sfx2/source/sidebar/DeckLayouter.hxx
+++ b/sfx2/source/sidebar/DeckLayouter.hxx
@@ -44,6 +44,7 @@ class DeckLayouter
public:
static void LayoutDeck (
const Rectangle aContentArea,
+ sal_Int32& rMinimalWidth,
SharedPanelContainer& rPanels,
Window& pDeckTitleBar,
Window& pScrollClipWindow,
@@ -78,6 +79,7 @@ private:
};
static Rectangle LayoutPanels (
const Rectangle aContentArea,
+ sal_Int32& rMinimalWidth,
::std::vector<LayoutItem>& rLayoutItems,
Window& rScrollClipWindow,
Window& rScrollContainer,
@@ -86,6 +88,7 @@ private:
static void GetRequestedSizes (
::std::vector<LayoutItem>& rLayoutItem,
sal_Int32& rAvailableHeight,
+ sal_Int32& rMinimalWidth,
const Rectangle& rContentBox);
static void DistributeHeights (
::std::vector<LayoutItem>& rLayoutItems,
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index bce2f6f1b610..970e96ad5c20 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -272,9 +272,13 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv
void SAL_CALL SidebarController::requestLayout (void)
throw(cssu::RuntimeException)
{
+ sal_Int32 nMinimalWidth = 0;
if (mpCurrentDeck)
+ {
mpCurrentDeck->RequestLayout();
- RestrictWidth();
+ nMinimalWidth = mpCurrentDeck->GetMinimalWidth();
+ }
+ RestrictWidth(nMinimalWidth);
}
@@ -340,14 +344,16 @@ void SidebarController::NotifyResize (void)
mpTabBar->Show();
// Determine if the closer of the deck can be shown.
+ sal_Int32 nMinimalWidth = 0;
if (mpCurrentDeck)
{
DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
if (pTitleBar != NULL && pTitleBar->IsVisible())
pTitleBar->SetCloserVisible(CanModifyChildWindowWidth());
+ nMinimalWidth = mpCurrentDeck->GetMinimalWidth();
}
- RestrictWidth();
+ RestrictWidth(nMinimalWidth);
}
@@ -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();
if (pSplitWindow != NULL)
@@ -1059,7 +1065,7 @@ void SidebarController::RestrictWidth (void)
const sal_uInt16 nSetId (pSplitWindow->GetSet(nId));
pSplitWindow->SetItemSizeRange(
nSetId,
- Range(TabBar::GetDefaultWidth(), gnMaximumSidebarWidth));
+ Range(TabBar::GetDefaultWidth() + nWidth, gnMaximumSidebarWidth));
}
}
diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx
index 5f2c82b5bb66..bdebeb83608d 100644
--- a/sfx2/source/sidebar/SidebarController.hxx
+++ b/sfx2/source/sidebar/SidebarController.hxx
@@ -213,7 +213,7 @@ private:
void UpdateTitleBarIcons (void);
void UpdateDeckOpenState (void);
- void RestrictWidth (void);
+ void RestrictWidth (sal_Int32 nWidth);
SfxSplitWindow* GetSplitWindow (void);
void ProcessNewWidth (const sal_Int32 nNewWidth);
void UpdateCloseIndicator (const bool bIsIndicatorVisible);
diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx
index 263e9706e924..a4e037a8c4a1 100644
--- a/sfx2/source/sidebar/SidebarPanelBase.cxx
+++ b/sfx2/source/sidebar/SidebarPanelBase.cxx
@@ -248,4 +248,15 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi
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