Tweaked the signal view of the bit grid to use bigger fonts where

possible and center text better. Should be a visual improvement
This commit is contained in:
Collin Kidder
2022-12-13 21:46:59 -05:00
parent 7a6cace651
commit 4a85c4a938
2 changed files with 20 additions and 2 deletions
+19 -2
View File
@@ -233,7 +233,7 @@ void CANDataGrid::paintCommonBeginning()
} }
if (gridMode == GridMode::SIGNAL_VIEW) if (gridMode == GridMode::SIGNAL_VIEW)
{ {
bigTextSize = qMin(viewport.size().height(), viewport.size().width()) / (textRestrict * 4.50); bigTextSize = qMin(viewport.size().height(), viewport.size().width()) / (textRestrict * 3.50);
smallTextSize = qMin(viewport.size().height(), viewport.size().width()) / (textRestrict * 5.5); smallTextSize = qMin(viewport.size().height(), viewport.size().width()) / (textRestrict * 5.5);
} }
sigNameTextSize = qMin(viewport.size().height(), viewport.size().width()) / (textRestrict * 5.0); sigNameTextSize = qMin(viewport.size().height(), viewport.size().width()) / (textRestrict * 5.0);
@@ -247,6 +247,7 @@ void CANDataGrid::paintCommonBeginning()
sigNameFont.setPixelSize(sigNameTextSize); sigNameFont.setPixelSize(sigNameTextSize);
smallMetric = new QFontMetrics(sigNameFont); smallMetric = new QFontMetrics(sigNameFont);
largeMetric = new QFontMetrics(mainFont);
xOffset = smallMetric->maxWidth(); xOffset = smallMetric->maxWidth();
yOffset = smallMetric->height(); yOffset = smallMetric->height();
@@ -441,7 +442,23 @@ void CANDataGrid::paintGridCells()
else painter->drawText(nearX + x * xSector + 12, nearY + (y * ySector) + smallMetric->height() * 2.6, remainder); else painter->drawText(nearX + x * xSector + 12, nearY + (y * ySector) + smallMetric->height() * 2.6, remainder);
} }
else painter->drawText(nearX + x * xSector + 5, nearY + (y * ySector) + smallMetric->height() * 1.6, prevSigName); else
{
//first see if we even have enough room to use a bigger font and use that if so. Otherwise stick with the normal font
textWidth = largeMetric->horizontalAdvance(prevSigName);
if (textWidth < usableWidth)
{
painter->setFont(mainFont);
QSize size = QSize(usableWidth, ySector - smallMetric->height() * 1.0);
painter->drawText(QRect(nearX + x * xSector, nearY + (y * ySector) + smallMetric->height() * 1.0, size.width(), size.height()), Qt::AlignCenter, prevSigName);
painter->setFont(sigNameFont);
}
else
{
QSize size = QSize(usableWidth, ySector - smallMetric->height() * 1.0);
painter->drawText(QRect(nearX + x * xSector, nearY + (y * ySector) + smallMetric->height() * 1.0, size.width(), size.height()), Qt::AlignCenter, prevSigName);
}
}
} }
} }
} }
+1
View File
@@ -99,6 +99,7 @@ private:
QFont boldFont; QFont boldFont;
QFont sigNameFont; QFont sigNameFont;
QFontMetrics *smallMetric; QFontMetrics *smallMetric;
QFontMetrics *largeMetric;
void paintGridCells(); void paintGridCells();
void paintCommonBeginning(); void paintCommonBeginning();