[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/source
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jul 9 11:04:33 UTC 2019
vcl/source/control/tabctrl.cxx | 114 +++++++++++++++++++++--------------------
1 file changed, 59 insertions(+), 55 deletions(-)
New commits:
commit 6e12c2f0f59fb191924df44e1214640a2c3d781d
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Mon Jul 8 16:11:14 2019 +0000
Commit: Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Tue Jul 9 13:03:47 2019 +0200
tdf#126266 adjust calculations for invisble tabs
This skips invisible tabs in many more places and at least fixes
the osx bug of the missing tabs of the NBB. It also fixes the
multiple highlighted tabs assertion for multiple rows from
TabControl::ImplGetItem.
I'm quite sure the tab rect calculation for multiple rows still
has the wrong height, so there might be minor overlapping.
Change-Id: I3a0a06ee73204b98e367563700fce4a49c066c1a
Reviewed-on: https://gerrit.libreoffice.org/75230
Tested-by: Xisco FaulĂ <xiscofauli at libreoffice.org>
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
(cherry picked from commit d55654fa962002b2f78b44a01dc4aa25428b1ca2)
Reviewed-on: https://gerrit.libreoffice.org/75246
Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 190cb218b6be..d45b71512dc7 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -368,6 +368,29 @@ namespace MinimumRaggednessWrap
}
};
+static void lcl_AdjustSingleLineTabs(long nMaxWidth, ImplTabCtrlData *pTabCtrlData)
+{
+ if (!ImplGetSVData()->maNWFData.mbCenteredTabs)
+ return;
+
+ int nRightSpace = nMaxWidth; // space left on the right by the tabs
+ for (auto const& item : pTabCtrlData->maItemList)
+ {
+ if (!item.m_bVisible)
+ continue;
+ nRightSpace -= item.maRect.Right() - item.maRect.Left();
+ }
+ nRightSpace /= 2;
+
+ for (auto& item : pTabCtrlData->maItemList)
+ {
+ if (!item.m_bVisible)
+ continue;
+ item.maRect.AdjustLeft(nRightSpace);
+ item.maRect.AdjustRight(nRightSpace);
+ }
+}
+
bool TabControl::ImplPlaceTabs( long nWidth )
{
if ( nWidth <= 0 )
@@ -387,7 +410,9 @@ bool TabControl::ImplPlaceTabs( long nWidth )
std::vector<sal_Int32> aWidths;
for (auto & item : mpTabCtrlData->maItemList)
{
- aWidths.push_back(ImplGetItemSize( &item, nMaxWidth ).Width());
+ if (!item.m_bVisible)
+ continue;
+ aWidths.push_back(ImplGetItemSize(&item, nMaxWidth).Width());
}
//aBreakIndexes will contain the indexes of the last tab on each row
@@ -407,7 +432,6 @@ bool TabControl::ImplPlaceTabs( long nWidth )
nLinePosAry[0] = 0;
size_t nIndex = 0;
- sal_uInt16 nPos = 0;
for (auto & item : mpTabCtrlData->maItemList)
{
@@ -432,7 +456,7 @@ bool TabControl::ImplPlaceTabs( long nWidth )
nY += aSize.Height();
nLines++;
nLineWidthAry[nLines] = 0;
- nLinePosAry[nLines] = nPos;
+ nLinePosAry[nLines] = nIndex;
}
tools::Rectangle aNewRect( Point( nX, nY ), aSize );
@@ -448,14 +472,20 @@ bool TabControl::ImplPlaceTabs( long nWidth )
if (item.id() == mnCurPageId)
nCurLine = nLines;
- ++nPos;
++nIndex;
}
- if ( nLines )
- { // two or more lines
+ if (nLines) // two or more lines
+ {
long nLineHeightAry[100];
- long nIH = mpTabCtrlData->maItemList[0].maRect.Bottom()-2;
+ long nIH = 0;
+ for (const auto& item : mpTabCtrlData->maItemList)
+ {
+ if (!item.m_bVisible)
+ continue;
+ nIH = item.maRect.Bottom() - 1;
+ break;
+ }
for ( sal_uInt16 i = 0; i < nLines+1; i++ )
{
@@ -476,6 +506,9 @@ bool TabControl::ImplPlaceTabs( long nWidth )
for (auto & item : mpTabCtrlData->maItemList)
{
+ if (!item.m_bVisible)
+ continue;
+
if ( i == nLinePosAry[n] )
{
if ( n == nLines+1 )
@@ -499,7 +532,7 @@ bool TabControl::ImplPlaceTabs( long nWidth )
item.maRect.AdjustLeft(nIDX );
item.maRect.AdjustRight(nIDX + nDX );
item.maRect.SetTop( nLineHeightAry[n-1] );
- item.maRect.SetBottom( nLineHeightAry[n-1] + nIH );
+ item.maRect.SetBottom(nLineHeightAry[n-1] + nIH - 1);
nIDX += nDX;
if ( nModDX )
@@ -512,22 +545,8 @@ bool TabControl::ImplPlaceTabs( long nWidth )
i++;
}
}
- else
- { // only one line
- if(ImplGetSVData()->maNWFData.mbCenteredTabs)
- {
- int nRightSpace = nMaxWidth;//space left on the right by the tabs
- for (auto const& item : mpTabCtrlData->maItemList)
- {
- nRightSpace -= item.maRect.Right()-item.maRect.Left();
- }
- for (auto & item : mpTabCtrlData->maItemList)
- {
- item.maRect.AdjustLeft(nRightSpace / 2 );
- item.maRect.AdjustRight(nRightSpace / 2 );
- }
- }
- }
+ else // only one line
+ lcl_AdjustSingleLineTabs(nMaxWidth, mpTabCtrlData.get());
return true;
}
@@ -1068,6 +1087,8 @@ void TabControl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectang
if (GetStyle() & WB_NOBORDER)
return;
+ Control::Paint(rRenderContext, rRect);
+
HideFocus();
// reformat if needed
@@ -1233,8 +1254,6 @@ void TabControl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectang
ImplShowFocus();
mbSmallInvalidate = true;
-
- Control::Paint(rRenderContext, rRect);
}
void TabControl::setAllocation(const Size &rAllocation)
@@ -1754,7 +1773,13 @@ void TabControl::SetPageVisible( sal_uInt16 nPageId, bool bVisible )
return;
pItem->m_bVisible = bVisible;
- pItem->maRect.SetEmpty();
+ if (!bVisible)
+ {
+ if (pItem->mbFullVisible)
+ mbSmallInvalidate = false;
+ pItem->mbFullVisible = false;
+ pItem->maRect.SetEmpty();
+ }
mbFormat = true;
// SetCurPageId will change to a valid page
@@ -2320,25 +2345,16 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
//fdo#66435 throw Knuth/Tex minimum raggedness algorithm at the problem
//of ugly bare tabs on lines of their own
- //collect widths
- std::vector<sal_Int32> aWidths;
for (auto & item : mpTabCtrlData->maItemList)
{
+ long nTabWidth = 0;
if (item.m_bVisible)
{
- long aSize = ImplGetItemSize( &item, nMaxWidth ).getWidth();
- if( !item.maText.isEmpty() && aSize < 100)
- {
- nFullWidth += 100;
- aSize = 100;
- }
- else
- nFullWidth += aSize;
-
- aWidths.push_back(aSize);
+ nTabWidth = ImplGetItemSize(&item, nMaxWidth).getWidth();
+ if (!item.maText.isEmpty() && nTabWidth < 100)
+ nTabWidth = 100;
}
- else
- aWidths.push_back(0);
+ nFullWidth += nTabWidth;
}
nMaxWidth -= GetItemsOffset().X();
@@ -2375,20 +2391,8 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
nX += aSize.Width();
}
- // only one line
- if(ImplGetSVData()->maNWFData.mbCenteredTabs)
- {
- int nRightSpace = nMaxWidth;//space left on the right by the tabs
- for (auto const& item : mpTabCtrlData->maItemList)
- {
- nRightSpace -= item.maRect.Right()-item.maRect.Left();
- }
- for (auto & item : mpTabCtrlData->maItemList)
- {
- item.maRect.AdjustLeft(nRightSpace / 2 );
- item.maRect.AdjustRight(nRightSpace / 2 );
- }
- }
+ // we always have only one line of tabs
+ lcl_AdjustSingleLineTabs(nMaxWidth, mpTabCtrlData.get());
// position the shortcutbox
if (m_pShortcuts)
More information about the Libreoffice-commits
mailing list