summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2013-06-02 04:46:58 +0200
committerCaolán McNamara <caolanm@redhat.com>2013-06-05 10:06:52 +0100
commit82584e86a231b0e1547878efdd808de110e8a6ab (patch)
treecb66a6458f67b6aed792be6951564d17099aaf05 /sfx2
parent6d4cd686935f09756f9df7656a5b1f085f8bf89f (diff)
sidebar: Restrict the minimal width of the sidebar.
Change-Id: I99051830c4393b420125332e787c3abdc5a6aa61 (cherry picked from commit e66be44b69ee2a1b99bda32af93ea453c669b319)
Diffstat (limited to 'sfx2')
-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
7 files changed, 44 insertions, 6 deletions
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 ade08bb99e5f..0d1ff571b7c8 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 7c883da914ec..e49465e18253 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