diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-04-22 12:44:00 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-04-22 13:50:57 +0200 |
commit | 055ae711eff085ff6b9db8f47c3193016d0db81e (patch) | |
tree | 97a2640bbefec5d04733f9fcf94f3b1317fb28fd /vcl | |
parent | d22bcb3867b2c61c11b5a563dcc5cf122d31bbff (diff) |
Notebookbar: better tab placing for the NotebookbarTabControl
Change-Id: Ia44ce20455829048be457584c49fde0996f4a699
Reviewed-on: https://gerrit.libreoffice.org/36814
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 36 |
1 files changed, 23 insertions, 13 deletions
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++; |