Adjusted Qt TAS branch view text placement to better center text into card.

This commit is contained in:
mjbudd77 2022-01-07 06:11:46 -05:00
parent 71c5ebc133
commit cf31b874ed
2 changed files with 16 additions and 7 deletions

View File

@ -119,7 +119,8 @@ void BRANCHES::calcFontData(void)
#else
pxCharWidth = metrics.width(QLatin1Char('2'));
#endif
pxCharHeight = metrics.capHeight();
//pxCharHeight = metrics.capHeight();
pxCharHeight = metrics.ascent();
pxLineSpacing = metrics.lineSpacing();
pxBoxWidth = pxLineSpacing;
@ -127,6 +128,9 @@ void BRANCHES::calcFontData(void)
pxSelWidth = (pxBoxWidth * 7) / 8;
pxSelHeight = (pxBoxHeight * 7) / 8;
pxTextOffsetX = -(pxBoxWidth/2 ) + (pxBoxWidth - pxCharWidth)/2;
pxTextOffsetY = (pxBoxHeight/2) - (pxBoxHeight - pxCharHeight)/2;
pxMinGridWidth = (pxBoxWidth + 2);
pxMaxGridWidth = (pxBoxWidth * 2);
pxGridWidth = pxMinGridWidth;
@ -926,23 +930,26 @@ void BRANCHES::paintEvent(QPaintEvent *event)
// digits
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
{
x = branchCurrentX[i] + pxTextOffsetX;
y = branchCurrentY[i] + pxTextOffsetY;
txt[0] = i + '0';
txt[1] = 0;
if (i == currentBranch)
{
painter.setPen( QColor( 58, 179, 255 ) );
painter.drawText( box[i], Qt::AlignCenter, tr(txt) );
painter.drawText( x, y, tr(txt) );
}
else
{
painter.setPen( QColor( 0, 194, 64 ) );
//if (!bookmarks->bookmarksArray[i].notEmpty && bookmarks->bookmarksArray[i].floatingPhase > 0)
//{
// tempBranchX += bookmarks->bookmarksArray[i].floatingPhase;
//}
painter.drawText( box[i], Qt::AlignCenter, tr(txt) );
if (!bookmarks->bookmarksArray[i].notEmpty && bookmarks->bookmarksArray[i].floatingPhase > 0)
{
x += bookmarks->bookmarksArray[i].floatingPhase;
}
painter.drawText( x, y, tr(txt) );
}
}
if (isSafeToShowBranchesData())

View File

@ -209,6 +209,8 @@ private:
int pxMinGridWidth;
int pxMaxGridWidth;
int pxGridWidth;
int pxTextOffsetX;
int pxTextOffsetY;
// temps
std::vector<int> gridX; // measured in grid units, not in pixels