1
0
Fork 0

Improve rendering of longer parking names.

This commit is contained in:
James Turner 2016-07-16 17:49:12 +01:00
parent e765d1c0fa
commit 07109d79f5

View file

@ -399,13 +399,27 @@ void AirportDiagram::drawParking(QPainter* painter, const ParkingData& p) const
painter->drawPath(useLeftIcon ? m_parkingIconLeftPath : m_parkingIconPath);
painter->fillRect(labelRect, Qt::white);
// ensure the selection colour is quite visible, by not filling
// with white when selected
if (p.parking != m_selectedParking) {
painter->fillRect(labelRect, Qt::white);
}
QFont f = painter->font();
f.setPixelSize(20);
painter->setFont(f);
QString parkingName = QString::fromStdString(p.parking->name());
int textFlags = Qt::AlignVCenter | Qt::AlignHCenter | Qt::TextWordWrap;
QRectF bounds = painter->boundingRect(labelRect, textFlags, parkingName);
if (bounds.height() > labelRect.height()) {
f.setPixelSize(10);
painter->setFont(f);
}
// draw text
painter->setPen(Qt::black);
painter->drawText(labelRect,
Qt::AlignVCenter | Qt::AlignHCenter,
QString::fromStdString(p.parking->name()));
painter->drawText(labelRect, textFlags, parkingName);
}
AirportDiagram::ParkingData AirportDiagram::findParkingData(const FGParkingRef &pk) const
@ -424,10 +438,6 @@ void AirportDiagram::drawParkings(QPainter* painter) const
painter->save();
QTransform t = painter->transform();
QFont f = painter->font();
f.setPixelSize(16);
painter->setFont(f);
Q_FOREACH(const ParkingData& p, m_parking) {
if (p.parking == m_selectedParking) {
continue; // skip and draw last
@ -505,7 +515,6 @@ void AirportDiagram::mouseReleaseEvent(QMouseEvent* me)
}
}
Q_FOREACH(const HelipadData& pad, m_helipads) {
QPainterPath pp = pathForHelipad(pad, t);
if (pp.contains(me->pos())) {