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

View File

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