Kaydet (Commit) 4454feb3 authored tarafından Szymon Kłos's avatar Szymon Kłos

Notebookbar: allow only one tab line

Change-Id: I5f671bdc34e5852af06c99db93e859e8cf837c0d
Reviewed-on: https://gerrit.libreoffice.org/43009Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSzymon Kłos <szymon.klos@collabora.com>
üst 5352dfbb
...@@ -2355,6 +2355,7 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) ...@@ -2355,6 +2355,7 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
long nMaxWidth = nWidth - HAMBURGER_DIM; long nMaxWidth = nWidth - HAMBURGER_DIM;
long nShortcutsWidth = m_pShortcuts != nullptr ? m_pShortcuts->GetSizePixel().getWidth() + 1 : 0; long nShortcutsWidth = m_pShortcuts != nullptr ? m_pShortcuts->GetSizePixel().getWidth() + 1 : 0;
long nFullWidth = nShortcutsWidth;
const long nOffsetX = 2 + GetItemsOffset().X() + nShortcutsWidth; const long nOffsetX = 2 + GetItemsOffset().X() + nShortcutsWidth;
const long nOffsetY = 2 + GetItemsOffset().Y(); const long nOffsetY = 2 + GetItemsOffset().Y();
...@@ -2371,7 +2372,13 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) ...@@ -2371,7 +2372,13 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
{ {
long aSize = ImplGetItemSize( &(*it), nMaxWidth ).getWidth(); long aSize = ImplGetItemSize( &(*it), nMaxWidth ).getWidth();
if( !it->maText.isEmpty() && aSize < 100) if( !it->maText.isEmpty() && aSize < 100)
{
nFullWidth += 100;
aSize = 100; aSize = 100;
}
else
nFullWidth += aSize;
aWidths.push_back(aSize); aWidths.push_back(aSize);
} }
else else
...@@ -2388,13 +2395,8 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) ...@@ -2388,13 +2395,8 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
long nX = nOffsetX; long nX = nOffsetX;
long nY = nOffsetY; long nY = nOffsetY;
sal_uInt16 nLines = 0;
sal_uInt16 nCurLine = 0;
long nLineWidthAry[100]; long nLineWidthAry[100];
sal_uInt16 nLinePosAry[101];
nLineWidthAry[0] = 0; nLineWidthAry[0] = 0;
nLinePosAry[0] = 0;
size_t nIndex = 0; size_t nIndex = 0;
sal_uInt16 nPos = 0; sal_uInt16 nPos = 0;
...@@ -2404,25 +2406,6 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) ...@@ -2404,25 +2406,6 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
{ {
Size aSize = ImplGetItemSize( &(*it), nMaxWidth ); Size aSize = ImplGetItemSize( &(*it), nMaxWidth );
bool bNewLine = false;
if (!aBreakIndexes.empty() && nIndex > aBreakIndexes.front())
{
aBreakIndexes.pop_front();
bNewLine = true;
}
if ( bNewLine && (nWidth > 2+nOffsetX) )
{
if ( nLines == 99 )
break;
nX = nOffsetX;
nY += aSize.Height();
nLines++;
nLineWidthAry[nLines] = 0;
nLinePosAry[nLines] = nPos;
}
if ( !it->mbEnabled ) if ( !it->mbEnabled )
{ {
nPos++; nPos++;
...@@ -2430,7 +2413,7 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) ...@@ -2430,7 +2413,7 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
} }
// set minimum tab size // set minimum tab size
if( !it->maText.isEmpty() && aSize.getWidth() < 100) if( nFullWidth < nMaxWidth && !it->maText.isEmpty() && aSize.getWidth() < 100)
aSize.Width() = 100; aSize.Width() = 100;
if( !it->maText.isEmpty() && aSize.getHeight() < 28 ) if( !it->maText.isEmpty() && aSize.getHeight() < 28 )
...@@ -2441,95 +2424,29 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth ) ...@@ -2441,95 +2424,29 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
mbSmallInvalidate = false; mbSmallInvalidate = false;
it->maRect = aNewRect; it->maRect = aNewRect;
it->mnLine = nLines; it->mnLine = 0;
it->mbFullVisible = true; it->mbFullVisible = true;
nLineWidthAry[nLines] += aSize.Width(); nLineWidthAry[0] += aSize.Width();
nX += aSize.Width(); nX += aSize.Width();
if ( it->mnId == mnCurPageId )
nCurLine = nLines;
nPos++; nPos++;
} }
if ( nLines ) // only one line
{ // two or more lines if(ImplGetSVData()->maNWFData.mbCenteredTabs)
long nLineHeightAry[100]; {
long nIH = mpTabCtrlData->maItemList[0].maRect.Bottom()-2; int nRightSpace = nMaxWidth;//space left on the right by the tabs
for ( sal_uInt16 i = 0; i < nLines+1; i++ )
{
if ( i <= nCurLine )
nLineHeightAry[i] = nIH*(nLines-(nCurLine-i)) + GetItemsOffset().Y();
else
nLineHeightAry[i] = nIH*(i-nCurLine-1) + GetItemsOffset().Y();
}
nLinePosAry[nLines+1] = (sal_uInt16)mpTabCtrlData->maItemList.size();
long nDX = 0;
long nModDX = 0;
long nIDX = 0;
sal_uInt16 i = 0;
sal_uInt16 n = 0;
for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin(); for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
it != mpTabCtrlData->maItemList.end(); ++it ) it != mpTabCtrlData->maItemList.end(); ++it )
{ {
if ( i == nLinePosAry[n] ) nRightSpace -= it->maRect.Right()-it->maRect.Left();
{
if ( n == nLines+1 )
break;
nIDX = 0;
if( nLinePosAry[n+1]-i > 0 )
{
long nAvailableWidth = nWidth - nOffsetX - nLineWidthAry[n] - HAMBURGER_DIM;
nDX = nAvailableWidth / ( nLinePosAry[n+1] - i );
nModDX = nAvailableWidth % ( nLinePosAry[n+1] - i );
}
else
{
// FIXME: this is a case of tabctrl way too small
nDX = 0;
nModDX = 0;
}
n++;
}
it->maRect.Left() += nIDX;
it->maRect.Right() += nIDX + nDX;
it->maRect.Top() = nLineHeightAry[n-1];
it->maRect.Bottom() = nLineHeightAry[n-1] + nIH;
nIDX += nDX;
if ( nModDX )
{
nIDX++;
it->maRect.Right()++;
nModDX--;
}
i++;
} }
} for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
else it != mpTabCtrlData->maItemList.end(); ++it )
{ // only one line
if(ImplGetSVData()->maNWFData.mbCenteredTabs)
{ {
int nRightSpace = nMaxWidth;//space left on the right by the tabs it->maRect.Left() += nRightSpace / 2;
for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin(); it->maRect.Right() += nRightSpace / 2;
it != mpTabCtrlData->maItemList.end(); ++it )
{
nRightSpace -= it->maRect.Right()-it->maRect.Left();
}
for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
it != mpTabCtrlData->maItemList.end(); ++it )
{
it->maRect.Left() += nRightSpace / 2;
it->maRect.Right() += nRightSpace / 2;
}
} }
} }
......
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