mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Fonts] Fix pixel sizes and game overlay fonts from review
- Set the sizes the stylesheets carried with setPixelSize() rather than setPointSize(): home buttons (34), banner (24), home group box (20), the placeholder labels (14), the analytics drag handle (10), the EDHREC navigation buttons (24), the user info popup (11/14/11/10/11) and the game overlays (14/16/12). Points at 96 DPI were ~33% larger. - The drag/total counters and tally columns keep the monospace family the stylesheets set, so digit widths stop changing as counts tick and white-space: pre stays aligned. - applyDeckListFont() drops the cached tally rows before re-measuring, so previewing a larger DeckList font no longer leaves the tally clipped. - Tally labels and the constructor/fontsChanged pairs in the shared-deck preview, quick setup, analytics panel, home box and public decks build their font once in a local lambda instead of twice.
This commit is contained in:
parent
70f0f14665
commit
e834339c71
15 changed files with 80 additions and 91 deletions
|
|
@ -26,6 +26,21 @@
|
|||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
QFont deckOverlayFont(int pixelSize, bool bold)
|
||||
{
|
||||
// The drag/total counters and the tally columns are in-game overlays, not
|
||||
// deck list text: keep the monospace family the stylesheets used to set so
|
||||
// digit widths stay stable as counts tick and `white-space: pre` lines up.
|
||||
QFont font(QStringLiteral("monospace"));
|
||||
font.setStyleHint(QFont::Monospace);
|
||||
font.setPixelSize(pixelSize);
|
||||
font.setBold(bold);
|
||||
return font;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// QRubberBand calls raise() in showEvent() and changeEvent() to stay on top of siblings.
|
||||
// This subclass disables that behavior so dragCountLabel can appear above it.
|
||||
class SelectionRubberBand : public QRubberBand
|
||||
|
|
@ -102,40 +117,26 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
|
|||
tallyLayout->setSpacing(2);
|
||||
tallyContainer->hide();
|
||||
|
||||
applyDeckListFont();
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, &GameView::applyDeckListFont);
|
||||
applyDeckOverlayFonts();
|
||||
}
|
||||
|
||||
void GameView::applyDeckListFont()
|
||||
void GameView::applyDeckOverlayFonts()
|
||||
{
|
||||
// Family comes from the DeckList theme role; the pixel sizes and bold
|
||||
// weights previously carried by the stylesheets stay caller-side.
|
||||
QFont dragFont = themeManager->appFont(AppFont::DeckList);
|
||||
dragFont.setPointSize(14);
|
||||
dragFont.setWeight(QFont::Bold);
|
||||
dragCountLabel->setFont(dragFont);
|
||||
|
||||
QFont totalFont = themeManager->appFont(AppFont::DeckList);
|
||||
totalFont.setPointSize(16);
|
||||
totalFont.setWeight(QFont::Bold);
|
||||
totalCountLabel->setFont(totalFont);
|
||||
|
||||
QFont tallyFont = themeManager->appFont(AppFont::DeckList);
|
||||
tallyFont.setPointSize(12);
|
||||
tallyContainer->setFont(tallyFont);
|
||||
dragCountLabel->setFont(deckOverlayFont(14, true));
|
||||
totalCountLabel->setFont(deckOverlayFont(16, true));
|
||||
tallyContainer->setFont(deckOverlayFont(12, false));
|
||||
for (int i = 0; i < tallyLayout->count(); ++i) {
|
||||
if (auto *label = qobject_cast<QLabel *>(tallyLayout->itemAt(i)->widget())) {
|
||||
QFont labelFont = themeManager->appFont(AppFont::DeckList);
|
||||
// Count column (odd positions) keeps the 14px bold emphasis.
|
||||
if (i % 2 == 1) {
|
||||
labelFont.setPointSize(14);
|
||||
labelFont.setWeight(QFont::Bold);
|
||||
} else {
|
||||
labelFont.setPointSize(12);
|
||||
}
|
||||
label->setFont(labelFont);
|
||||
// Count column (odd positions) keeps the bold emphasis.
|
||||
const bool count = i % 2 == 1;
|
||||
label->setFont(deckOverlayFont(count ? 14 : 12, count));
|
||||
}
|
||||
}
|
||||
|
||||
// The container keeps the size computed from the previous fonts, so force
|
||||
// rebuildTallyLabels() to re-measure it instead of reusing cachedTallyRows.
|
||||
cachedTallyRows.clear();
|
||||
updateTotalSelectionCount();
|
||||
}
|
||||
|
||||
void GameView::resizeEvent(QResizeEvent *event)
|
||||
|
|
@ -266,18 +267,13 @@ QSize GameView::rebuildTallyLabels(const QList<TallyRow> &entries)
|
|||
for (const TallyRow &entry : entries) {
|
||||
auto *nameLabel = new QLabel(entry.name, tallyContainer);
|
||||
nameLabel->setStyleSheet(nameStyle);
|
||||
QFont nameFont = themeManager->appFont(AppFont::DeckList);
|
||||
nameFont.setPointSize(12);
|
||||
nameLabel->setFont(nameFont);
|
||||
nameLabel->setFont(deckOverlayFont(12, false));
|
||||
nameLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
tallyLayout->addWidget(nameLabel, row, 0);
|
||||
|
||||
auto *countLabel = new QLabel(entry.value, tallyContainer);
|
||||
countLabel->setStyleSheet(countStyle);
|
||||
QFont countFont = themeManager->appFont(AppFont::DeckList);
|
||||
countFont.setPointSize(14);
|
||||
countFont.setWeight(QFont::Bold);
|
||||
countLabel->setFont(countFont);
|
||||
countLabel->setFont(deckOverlayFont(14, true));
|
||||
countLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
tallyLayout->addWidget(countLabel, row, 1);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue