include/sfx2/notebookbar/NotebookbarTabControl.hxx | 1 sfx2/source/notebookbar/NotebookbarTabControl.cxx | 24 ++++++++++++++ vcl/source/control/tabctrl.cxx | 36 +++++++++++++-------- 3 files changed, 48 insertions(+), 13 deletions(-)
New commits: commit 055ae711eff085ff6b9db8f47c3193016d0db81e Author: Szymon KÅos <szymon.k...@collabora.com> Date: Sat Apr 22 12:44:00 2017 +0200 Notebookbar: better tab placing for the NotebookbarTabControl Change-Id: Ia44ce20455829048be457584c49fde0996f4a699 Reviewed-on: https://gerrit.libreoffice.org/36814 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Szymon KÅos <szymon.k...@collabora.com> diff --git a/include/sfx2/notebookbar/NotebookbarTabControl.hxx b/include/sfx2/notebookbar/NotebookbarTabControl.hxx index 0d4ce9b9632c..2562af565b11 100644 --- a/include/sfx2/notebookbar/NotebookbarTabControl.hxx +++ b/include/sfx2/notebookbar/NotebookbarTabControl.hxx @@ -25,6 +25,7 @@ public: NotebookbarTabControl( Window* pParent ); virtual void StateChanged(StateChangedType nStateChange) override; + virtual Size calculateRequisition() const override; private: static void FillShortcutsToolBox(css::uno::Reference<css::uno::XComponentContext>& xContext, diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx index e2acfb5ea2c4..3c8f2058e18f 100644 --- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx +++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx @@ -19,6 +19,7 @@ #include <vcl/builderfactory.hxx> #include <vcl/layout.hxx> +#include <vcl/tabpage.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/notebookbar/NotebookbarTabControl.hxx> #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> @@ -260,6 +261,29 @@ IMPL_LINK(NotebookbarTabControl, OpenNotebookbarPopupMenu, NotebookBar*, pNotebo } } +Size NotebookbarTabControl::calculateRequisition() const +{ + Size aSize = NotebookbarTabControlBase::calculateRequisition(); + + for (int i = 0; i < GetPageCount(); i++) + { + vcl::Window* pChild = static_cast<vcl::Window*>(GetTabPage(TabControl::GetPageId(i))); + + if (pChild) + { + Size aChildSize = VclAlignment::getLayoutRequisition(*pChild); + + if (aChildSize.getWidth() < aSize.getWidth()) + aSize.Width() = aChildSize.Width(); + } + } + + if (aSize.Width() < 400) + aSize.Width() = 400; + + return aSize; +} + VCL_BUILDER_FACTORY( NotebookbarTabControl ) /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 0c39d870e6aa..d6e75ed387eb 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2353,6 +2353,7 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) return false; long nMaxWidth = nWidth; + long nShortcutsWidth = m_pShortcuts != nullptr ? m_pShortcuts->GetSizePixel().getWidth() : 0; const long nOffsetX = 2 + GetItemsOffset().X(); const long nOffsetY = 2 + GetItemsOffset().Y(); @@ -2362,10 +2363,14 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) //collect widths std::vector<sal_Int32> aWidths; - for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin(); + aWidths.push_back(ImplGetItemSize( &(*(mpTabCtrlData->maItemList.begin())), nMaxWidth ).Width() + nShortcutsWidth); + for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin() + 1; it != mpTabCtrlData->maItemList.end(); ++it ) { - aWidths.push_back(ImplGetItemSize( &(*it), nMaxWidth ).Width()); + long aSize = ImplGetItemSize( &(*it), nMaxWidth ).getWidth(); + if( !it->maText.isEmpty() && aSize < 100) + aSize = 100; + aWidths.push_back(aSize); } //aBreakIndexes will contain the indexes of the last tab on each row @@ -2375,7 +2380,6 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) nMaxWidth = mnMaxPageWidth; nMaxWidth -= GetItemsOffset().X(); - long nShortcutsWidth = m_pShortcuts != nullptr ? m_pShortcuts->GetSizePixel().getWidth() : 0; long nX = nOffsetX; long nY = nOffsetY; @@ -2394,9 +2398,6 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin(); it != mpTabCtrlData->maItemList.end(); ++it, ++nIndex ) { - if( it == mpTabCtrlData->maItemList.begin() + 1 ) - nX += nShortcutsWidth; - Size aSize = ImplGetItemSize( &(*it), nMaxWidth ); bool bNewLine = false; @@ -2442,6 +2443,12 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) nLineWidthAry[nLines] += aSize.Width(); nX += aSize.Width(); + if( it == mpTabCtrlData->maItemList.begin() ) + { + nLineWidthAry[nLines] += nShortcutsWidth; + nX += nShortcutsWidth; + } + if ( it->mnId == mnCurPageId ) nCurLine = nLines; @@ -2492,18 +2499,21 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) n++; } - if( m_pShortcuts && ( it == mpTabCtrlData->maItemList.begin() ) ) - { - Point aPos(nIDX + nDX + nDX, nLineHeightAry[n-1]); - m_pShortcuts->SetPosPixel(aPos); - } - it->maRect.Left() += nIDX; - it->maRect.Right() += nIDX + nDX; + if( it == mpTabCtrlData->maItemList.begin() ) + it->maRect.Right() += nIDX; + else + it->maRect.Right() += nIDX + nDX; it->maRect.Top() = nLineHeightAry[n-1]; it->maRect.Bottom() = nLineHeightAry[n-1] + nIH; nIDX += nDX; + if( m_pShortcuts && ( it == mpTabCtrlData->maItemList.begin() ) ) + { + Point aPos(it->maRect.Right(), nLineHeightAry[n-1]); + m_pShortcuts->SetPosPixel(aPos); + } + if ( nModDX ) { nIDX++;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits