Fix hardcoded fonts scaling issues (#7493)

* changed font sizes to better values

* rename gui_templates.h to FontHelper.h

* replace hardcoded values with constants

* make knob labels use small font

* code review from michael

* more consolidation

* Fix text problem in Vectorscope

Fix a problem with cutoff text in Vectorscope. During the constructor
call of `LedCheckBox` the method `LedCheckBox::onTextUpdated` is
triggered which sets a fixed size that fits the pixmap and the text.
After instantiating the two instances in `VecControlsDialog` the
constructor then set a minimum size which overrode the fixed size that
was previously set. This then led to text that was cutoff.

---------

Co-authored-by: Michael Gregorius <michael.gregorius.git@arcor.de>
This commit is contained in:
Rossmaxx
2024-09-28 13:18:02 +05:30
committed by GitHub
parent 6a7b23b278
commit 729593c022
36 changed files with 85 additions and 92 deletions

View File

@@ -1,5 +1,5 @@
/*
* gui_templates.h - GUI-specific templates
* FontHelper.h - Header function to help with fonts
*
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -22,12 +22,16 @@
*
*/
#ifndef LMMS_GUI_TEMPLATES_H
#define LMMS_GUI_TEMPLATES_H
#ifndef LMMS_FONT_HELPER_H
#define LMMS_FONT_HELPER_H
#include <QApplication>
#include <QFont>
constexpr int DEFAULT_FONT_SIZE = 12;
constexpr int SMALL_FONT_SIZE = 10;
constexpr int LARGE_FONT_SIZE = 14;
namespace lmms::gui
{
@@ -40,4 +44,4 @@ inline QFont adjustedToPixelSize(QFont font, int size)
} // namespace lmms::gui
#endif // LMMS_GUI_TEMPLATES_H
#endif // LMMS_FONT_HELPER_H

View File

@@ -31,7 +31,7 @@
#include "ComboBox.h"
#include "DataFile.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "PixmapButton.h"
#include "SampleLoader.h"
#include "Song.h"
@@ -227,7 +227,7 @@ void AudioFileProcessorView::paintEvent(QPaintEvent*)
int idx = a->sample().sampleFile().length();
p.setFont(adjustedToPixelSize(font(), 8));
p.setFont(adjustedToPixelSize(font(), SMALL_FONT_SIZE));
QFontMetrics fm(p.font());

View File

@@ -25,7 +25,7 @@
#include "AudioFileProcessorWaveView.h"
#include "ConfigManager.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "SampleWaveform.h"
#include <QPainter>
@@ -279,7 +279,7 @@ void AudioFileProcessorWaveView::paintEvent(QPaintEvent * pe)
p.fillRect(s_padding, s_padding, m_graph.width(), 14, g);
p.setPen(QColor(255, 255, 255));
p.setFont(adjustedToPixelSize(font(), 8));
p.setFont(adjustedToPixelSize(font(), SMALL_FONT_SIZE));
QString length_text;
const int length = m_sample->sampleDuration().count();

View File

@@ -32,7 +32,7 @@
#include "Knob.h"
#include "MidiEventToByteSeq.h"
#include "MainWindow.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "Song.h"
#include <QApplication>
@@ -627,7 +627,7 @@ CarlaInstrumentView::CarlaInstrumentView(CarlaInstrument* const instrument, QWid
m_toggleUIButton->setCheckable( true );
m_toggleUIButton->setChecked( false );
m_toggleUIButton->setIcon( embed::getIconPixmap( "zoom" ) );
m_toggleUIButton->setFont(adjustedToPixelSize(m_toggleUIButton->font(), 8));
m_toggleUIButton->setFont(adjustedToPixelSize(m_toggleUIButton->font(), SMALL_FONT_SIZE));
connect( m_toggleUIButton, SIGNAL( clicked(bool) ), this, SLOT( toggleUI( bool ) ) );
m_toggleUIButton->setToolTip(
@@ -637,7 +637,7 @@ CarlaInstrumentView::CarlaInstrumentView(CarlaInstrument* const instrument, QWid
m_toggleParamsWindowButton = new QPushButton(tr("Params"), this);
m_toggleParamsWindowButton->setIcon(embed::getIconPixmap("controller"));
m_toggleParamsWindowButton->setCheckable(true);
m_toggleParamsWindowButton->setFont(adjustedToPixelSize(m_toggleParamsWindowButton->font(), 8));
m_toggleParamsWindowButton->setFont(adjustedToPixelSize(m_toggleParamsWindowButton->font(), SMALL_FONT_SIZE));
#if CARLA_VERSION_HEX < CARLA_MIN_PARAM_VERSION
m_toggleParamsWindowButton->setEnabled(false);
m_toggleParamsWindowButton->setToolTip(tr("Available from Carla version 2.1 and up."));

View File

@@ -30,6 +30,7 @@
#include "AudioEngine.h"
#include "embed.h"
#include "Engine.h"
#include "FontHelper.h"
#include "lmms_constants.h"
#include "lmms_math.h"
@@ -148,9 +149,7 @@ void EqHandle::paint( QPainter *painter, const QStyleOptionGraphicsItem *option,
res = tr( "BW: " ) + QString::number( getResonance() );
}
QFont painterFont = painter->font();
painterFont.setPointSizeF( painterFont.pointSizeF() * 0.7 );
painter->setFont( painterFont );
painter->setFont(adjustedToPixelSize(painter->font(), SMALL_FONT_SIZE));
painter->setPen( Qt::black );
painter->drawRect( textRect );
painter->fillRect( textRect, QBrush( QColor( 6, 106, 43, 180 ) ) );

View File

@@ -28,7 +28,6 @@
#include "LcdFloatSpinBox.h"
#include "Knob.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "PixmapButton.h"

View File

@@ -33,7 +33,7 @@
#include "endian_handling.h"
#include "Engine.h"
#include "FileDialog.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "InstrumentTrack.h"
#include "NotePlayHandle.h"
#include "PathUtil.h"
@@ -545,7 +545,7 @@ void PatmanView::updateFilename()
m_displayFilename = "";
int idx = m_pi->m_patchFile.length();
QFontMetrics fm(adjustedToPixelSize(font(), 8));
QFontMetrics fm(adjustedToPixelSize(font(), SMALL_FONT_SIZE));
// simple algorithm for creating a text from the filename that
// matches in the white rectangle
@@ -615,7 +615,7 @@ void PatmanView::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.setFont(adjustedToPixelSize(font() ,8));
p.setFont(adjustedToPixelSize(font(), SMALL_FONT_SIZE));
p.drawText( 8, 116, 235, 16,
Qt::AlignLeft | Qt::TextSingleLine | Qt::AlignVCenter,
m_displayFilename );

View File

@@ -35,6 +35,7 @@
#include <QWidget>
#include "Engine.h"
#include "FontHelper.h"
#include "SamplePlayHandle.h"
#include "Song.h"
#include "TapTempo.h"
@@ -47,11 +48,10 @@ TapTempoView::TapTempoView(TapTempo* plugin)
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
auto font = QFont();
font.setPointSize(24);
m_tapButton = new QPushButton();
m_tapButton->setFixedSize(200, 200);
m_tapButton->setFont(font);
m_tapButton->setFont(adjustedToPixelSize(font, 32));
m_tapButton->setText(tr("0"));
auto precisionCheckBox = new QCheckBox(tr("Precision"));

View File

@@ -64,7 +64,6 @@ VecControlsDialog::VecControlsDialog(VecControls *controls) :
auto highQualityButton = new LedCheckBox(tr("HQ"), this);
highQualityButton->setToolTip(tr("Double the resolution and simulate continuous analog-like trace."));
highQualityButton->setCheckable(true);
highQualityButton->setMinimumSize(70, 12);
highQualityButton->setModel(&controls->m_highQualityModel);
switch_layout->addWidget(highQualityButton);
@@ -72,7 +71,6 @@ VecControlsDialog::VecControlsDialog(VecControls *controls) :
auto logarithmicButton = new LedCheckBox(tr("Log. scale"), this);
logarithmicButton->setToolTip(tr("Display amplitude on logarithmic scale to better see small values."));
logarithmicButton->setCheckable(true);
logarithmicButton->setMinimumSize(70, 12);
logarithmicButton->setModel(&controls->m_logarithmicModel);
switch_layout->addWidget(logarithmicButton);

View File

@@ -30,6 +30,7 @@
#include "ColorChooser.h"
#include "GuiApplication.h"
#include "FontHelper.h"
#include "MainWindow.h"
#include "VecControls.h"
@@ -89,7 +90,6 @@ void VectorView::paintEvent(QPaintEvent *event)
painter.setRenderHint(QPainter::Antialiasing, true);
QFont normalFont, boldFont;
boldFont.setPixelSize(26);
boldFont.setBold(true);
const int labelWidth = 26;
const int labelHeight = 26;
@@ -264,7 +264,7 @@ void VectorView::paintEvent(QPaintEvent *event)
painter.drawLine(QPointF(centerX, centerY), QPointF(displayRight - gridCorner, displayTop + gridCorner));
painter.setPen(QPen(m_controls->m_colorLabels, 1, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin));
painter.setFont(boldFont);
painter.setFont(adjustedToPixelSize(boldFont, 26));
painter.drawText(displayLeft + margin, displayTop,
labelWidth, labelHeight, Qt::AlignLeft | Qt::AlignTop | Qt::TextDontClip,
QString("L"));

View File

@@ -46,7 +46,7 @@
#include "Engine.h"
#include "FileDialog.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "InstrumentPlayHandle.h"
#include "InstrumentTrack.h"
#include "LocaleHelper.h"
@@ -583,12 +583,10 @@ VestigeInstrumentView::VestigeInstrumentView( Instrument * _instrument,
m_selPresetButton->setMenu(menu);
constexpr int buttonFontSize = 12;
m_toggleGUIButton = new QPushButton( tr( "Show/hide GUI" ), this );
m_toggleGUIButton->setGeometry( 20, 130, 200, 24 );
m_toggleGUIButton->setIcon( embed::getIconPixmap( "zoom" ) );
m_toggleGUIButton->setFont(adjustedToPixelSize(m_toggleGUIButton->font(), buttonFontSize));
m_toggleGUIButton->setFont(adjustedToPixelSize(m_toggleGUIButton->font(), LARGE_FONT_SIZE));
connect( m_toggleGUIButton, SIGNAL( clicked() ), this,
SLOT( toggleGUI() ) );
@@ -597,7 +595,7 @@ VestigeInstrumentView::VestigeInstrumentView( Instrument * _instrument,
this);
note_off_all_btn->setGeometry( 20, 160, 200, 24 );
note_off_all_btn->setIcon( embed::getIconPixmap( "stop" ) );
note_off_all_btn->setFont(adjustedToPixelSize(note_off_all_btn->font(), buttonFontSize));
note_off_all_btn->setFont(adjustedToPixelSize(note_off_all_btn->font(), LARGE_FONT_SIZE));
connect( note_off_all_btn, SIGNAL( clicked() ), this,
SLOT( noteOffAll() ) );
@@ -882,7 +880,7 @@ void VestigeInstrumentView::paintEvent( QPaintEvent * )
tr( "No VST plugin loaded" );
QFont f = p.font();
f.setBold( true );
p.setFont(adjustedToPixelSize(f, 10));
p.setFont(adjustedToPixelSize(f, DEFAULT_FONT_SIZE));
p.setPen( QColor( 255, 255, 255 ) );
p.drawText( 10, 100, plugin_name );
@@ -894,7 +892,7 @@ void VestigeInstrumentView::paintEvent( QPaintEvent * )
{
p.setPen( QColor( 0, 0, 0 ) );
f.setBold( false );
p.setFont(adjustedToPixelSize(f, 8));
p.setFont(adjustedToPixelSize(f, SMALL_FONT_SIZE));
p.drawText( 10, 114, tr( "by " ) +
m_vi->m_plugin->vendorString() );
p.setPen( QColor( 255, 255, 255 ) );

View File

@@ -33,7 +33,7 @@
#include "PixmapButton.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include <QToolBar>
#include <QLabel>
@@ -246,7 +246,7 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) :
tb->addWidget(space1);
tbLabel = new QLabel( tr( "Effect by: " ), this );
tbLabel->setFont(adjustedToPixelSize(f, 7));
tbLabel->setFont(adjustedToPixelSize(f, SMALL_FONT_SIZE));
tbLabel->setTextFormat(Qt::RichText);
tbLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
tb->addWidget( tbLabel );

View File

@@ -48,6 +48,7 @@
#include "Clipboard.h"
#include "embed.h"
#include "FontHelper.h"
#include "plugin_export.h"
namespace lmms
@@ -546,8 +547,7 @@ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent )
m_toggleUIButton->setChecked( false );
m_toggleUIButton->setIcon( embed::getIconPixmap( "zoom" ) );
QFont f = m_toggleUIButton->font();
f.setPointSizeF(12);
m_toggleUIButton->setFont(f);
m_toggleUIButton->setFont(adjustedToPixelSize(f, DEFAULT_FONT_SIZE));
connect( m_toggleUIButton, SIGNAL( toggled( bool ) ), this,
SLOT( toggleUI() ) );

View File

@@ -34,7 +34,7 @@
#include "CaptionMenu.h"
#include "embed.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "Knob.h"
#include "LedCheckBox.h"
#include "MainWindow.h"
@@ -91,7 +91,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
{
auto ctls_btn = new QPushButton(tr("Controls"), this);
QFont f = ctls_btn->font();
ctls_btn->setFont(adjustedToPixelSize(f, 10));
ctls_btn->setFont(adjustedToPixelSize(f, DEFAULT_FONT_SIZE));
ctls_btn->setGeometry( 150, 14, 50, 20 );
connect( ctls_btn, SIGNAL(clicked()),
this, SLOT(editControls()));
@@ -258,7 +258,7 @@ void EffectView::paintEvent( QPaintEvent * )
QPainter p( this );
p.drawPixmap( 0, 0, m_bg );
QFont f = adjustedToPixelSize(font(), 10);
QFont f = adjustedToPixelSize(font(), DEFAULT_FONT_SIZE);
f.setBold( true );
p.setFont( f );

View File

@@ -38,7 +38,7 @@
#include "Engine.h"
#include "GuiApplication.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "lmms_math.h"
#include "Lv2ControlBase.h"
#include "Lv2Manager.h"
@@ -157,7 +157,7 @@ Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase) :
m_toggleUIButton->setCheckable(true);
m_toggleUIButton->setChecked(false);
m_toggleUIButton->setIcon(embed::getIconPixmap("zoom"));
m_toggleUIButton->setFont(adjustedToPixelSize(m_toggleUIButton->font(), 8));
m_toggleUIButton->setFont(adjustedToPixelSize(m_toggleUIButton->font(), SMALL_FONT_SIZE));
btnBox->addWidget(m_toggleUIButton, 0);
}
btnBox->addStretch(1);

View File

@@ -31,8 +31,7 @@
#include "PeakIndicator.h"
#include "Song.h"
#include "ConfigManager.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include <QGraphicsProxyWidget>
#include <QGraphicsScene>
@@ -95,7 +94,7 @@ namespace lmms::gui
m_renameLineEdit = new QLineEdit{mixerName, nullptr};
m_renameLineEdit->setFixedWidth(65);
m_renameLineEdit->setFont(adjustedToPixelSize(font(), 12));
m_renameLineEdit->setFont(adjustedToPixelSize(font(), LARGE_FONT_SIZE));
m_renameLineEdit->setReadOnly(true);
m_renameLineEdit->installEventFilter(this);

View File

@@ -92,7 +92,7 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) :
basicControlsLayout->setVerticalSpacing(0);
basicControlsLayout->setContentsMargins(0, 0, 0, 0);
QString labelStyleSheet = "font-size: 6pt;";
QString labelStyleSheet = "font-size: 10px;";
Qt::Alignment labelAlignment = Qt::AlignHCenter | Qt::AlignTop;
Qt::Alignment widgetAlignment = Qt::AlignHCenter | Qt::AlignCenter;

View File

@@ -29,6 +29,7 @@
#include <QPushButton>
#include "embed.h"
#include "FontHelper.h"
namespace lmms::gui
{
@@ -63,8 +64,7 @@ void SideBarWidget::paintEvent( QPaintEvent * )
QFont f = p.font();
f.setBold( true );
f.setUnderline(false);
f.setPointSize( f.pointSize() + 2 );
p.setFont( f );
p.setFont(adjustedToPixelSize(f, LARGE_FONT_SIZE));
p.setPen( palette().highlightedText().color() );

View File

@@ -64,7 +64,7 @@
#include "TimeLineWidget.h"
#include "debug.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
namespace lmms::gui
@@ -1040,7 +1040,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
QBrush bgColor = p.background();
p.fillRect( 0, 0, width(), height(), bgColor );
p.setFont(adjustedToPixelSize(p.font(), 10));
p.setFont(adjustedToPixelSize(p.font(), DEFAULT_FONT_SIZE));
int grid_height = height() - TOP_MARGIN - SCROLLBAR_SIZE;

View File

@@ -59,6 +59,7 @@
#include "DetuningHelper.h"
#include "embed.h"
#include "GuiApplication.h"
#include "FontHelper.h"
#include "InstrumentTrack.h"
#include "MainWindow.h"
#include "MidiClip.h"
@@ -1028,7 +1029,7 @@ void PianoRoll::drawNoteRect( QPainter & p, int x, int y,
QString noteKeyString = getNoteString(n->key());
QFont noteFont(p.font());
noteFont.setPixelSize(noteTextHeight);
noteFont = adjustedToPixelSize(noteFont, noteTextHeight);
QFontMetrics fontMetrics(noteFont);
QSize textSize = fontMetrics.size(Qt::TextSingleLine, noteKeyString);
@@ -3017,8 +3018,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// set font-size to 80% of key line height
QFont f = p.font();
f.setPixelSize(m_keyLineHeight * 0.8);
p.setFont(f); // font size doesn't change without this for some reason
int keyFontSize = m_keyLineHeight * 0.8;
p.setFont(adjustedToPixelSize(f, keyFontSize));
QFontMetrics fontMetrics(p.font());
// G-1 is one of the widest; plus one pixel margin for the shadow
QRect const boundingRect = fontMetrics.boundingRect(QString("G-1")) + QMargins(0, 0, 1, 0);
@@ -3345,8 +3346,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// display note editing info
f.setBold(false);
f.setPixelSize(10);
p.setFont(f);
p.setFont(adjustedToPixelSize(f, SMALL_FONT_SIZE));
p.setPen(m_noteModeColor);
p.drawText( QRect( 0, keyAreaBottom(),
m_whiteKeyWidth, noteEditBottom() - keyAreaBottom()),

View File

@@ -33,7 +33,6 @@
#include "LfoGraph.h"
#include "EnvelopeAndLfoParameters.h"
#include "SampleLoader.h"
#include "gui_templates.h"
#include "Knob.h"
#include "LedCheckBox.h"
#include "DataFile.h"

View File

@@ -30,7 +30,7 @@
#include "InstrumentFunctionViews.h"
#include "ComboBox.h"
#include "GroupBox.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "Knob.h"
#include "TempoSyncKnob.h"
@@ -57,7 +57,7 @@ InstrumentFunctionNoteStackingView::InstrumentFunctionNoteStackingView( Instrume
mainLayout->setVerticalSpacing( 1 );
auto chordLabel = new QLabel(tr("Chord:"));
chordLabel->setFont(adjustedToPixelSize(chordLabel->font(), 10));
chordLabel->setFont(adjustedToPixelSize(chordLabel->font(), DEFAULT_FONT_SIZE));
m_chordRangeKnob->setLabel( tr( "RANGE" ) );
m_chordRangeKnob->setHintText( tr( "Chord range:" ), " " + tr( "octave(s)" ) );
@@ -145,15 +145,14 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti
m_arpGateKnob->setLabel( tr( "GATE" ) );
m_arpGateKnob->setHintText( tr( "Arpeggio gate:" ), tr( "%" ) );
constexpr int labelFontSize = 10;
auto arpChordLabel = new QLabel(tr("Chord:"));
arpChordLabel->setFont(adjustedToPixelSize(arpChordLabel->font(), labelFontSize));
arpChordLabel->setFont(adjustedToPixelSize(arpChordLabel->font(), DEFAULT_FONT_SIZE));
auto arpDirectionLabel = new QLabel(tr("Direction:"));
arpDirectionLabel->setFont(adjustedToPixelSize(arpDirectionLabel->font(), labelFontSize));
arpDirectionLabel->setFont(adjustedToPixelSize(arpDirectionLabel->font(), DEFAULT_FONT_SIZE));
auto arpModeLabel = new QLabel(tr("Mode:"));
arpModeLabel->setFont(adjustedToPixelSize(arpModeLabel->font(), labelFontSize));
arpModeLabel->setFont(adjustedToPixelSize(arpModeLabel->font(), DEFAULT_FONT_SIZE));
mainLayout->addWidget( arpChordLabel, 0, 0 );
mainLayout->addWidget( m_arpComboBox, 1, 0 );

View File

@@ -33,7 +33,6 @@
#include "Engine.h"
#include "embed.h"
#include "GroupBox.h"
#include "gui_templates.h"
#include "LcdSpinBox.h"
#include "MidiClient.h"

View File

@@ -31,7 +31,7 @@
#include "EnvelopeAndLfoView.h"
#include "ComboBox.h"
#include "GroupBox.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "Knob.h"
#include "TabWidget.h"
@@ -83,7 +83,7 @@ InstrumentSoundShapingView::InstrumentSoundShapingView(QWidget* parent) :
m_singleStreamInfoLabel = new QLabel(tr("Envelopes, LFOs and filters are not supported by the current instrument."), this);
m_singleStreamInfoLabel->setWordWrap(true);
// TODO Could also be rendered in system font size...
m_singleStreamInfoLabel->setFont(adjustedToPixelSize(m_singleStreamInfoLabel->font(), 10));
m_singleStreamInfoLabel->setFont(adjustedToPixelSize(m_singleStreamInfoLabel->font(), DEFAULT_FONT_SIZE));
m_singleStreamInfoLabel->setFixedWidth(242);
mainLayout->addWidget(m_singleStreamInfoLabel, 0, Qt::AlignTop);

View File

@@ -137,7 +137,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) :
#endif
QString labelStyleSheet = "font-size: 6pt;";
QString labelStyleSheet = "font-size: 10px;";
Qt::Alignment labelAlignment = Qt::AlignHCenter | Qt::AlignTop;
Qt::Alignment widgetAlignment = Qt::AlignHCenter | Qt::AlignCenter;

View File

@@ -33,7 +33,7 @@
#include "ComboBox.h"
#include "GroupBox.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "InstrumentTrack.h"
#include "LedCheckBox.h"
#include "MainWindow.h"
@@ -60,7 +60,7 @@ InstrumentTuningView::InstrumentTuningView(InstrumentTrack *it, QWidget *parent)
auto tlabel = new QLabel(tr("Enables the use of global transposition"));
tlabel->setWordWrap(true);
tlabel->setFont(adjustedToPixelSize(tlabel->font(), 10));
tlabel->setFont(adjustedToPixelSize(tlabel->font(), DEFAULT_FONT_SIZE));
masterPitchLayout->addWidget(tlabel);
// Microtuner settings

View File

@@ -32,7 +32,7 @@
#include "Oscillator.h"
#include "ColorHelper.h"
#include "gui_templates.h"
#include "FontHelper.h"
namespace lmms
{
@@ -166,8 +166,7 @@ void LfoGraph::drawInfoText(const EnvelopeAndLfoParameters& params)
// First configure the font so that we get correct results for the font metrics used below
QFont f = p.font();
f.setPixelSize(height() * 0.2);
p.setFont(f);
p.setFont(adjustedToPixelSize(f, height() * 0.2));
// This is the position where the text and its rectangle will be rendered
const QPoint textPosition(4, height() - 6);

View File

@@ -50,7 +50,7 @@
#include "CaptionMenu.h"
#include "embed.h"
#include "Engine.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "InstrumentTrack.h"
#include "Song.h"
#include "StringPairDrag.h"
@@ -72,7 +72,7 @@ const int PW_WHITE_KEY_WIDTH = 10; /*!< The width of a white key */
const int PW_BLACK_KEY_WIDTH = 8; /*!< The width of a black key */
const int PW_WHITE_KEY_HEIGHT = 57; /*!< The height of a white key */
const int PW_BLACK_KEY_HEIGHT = 38; /*!< The height of a black key */
const int LABEL_TEXT_SIZE = 7; /*!< The height of the key label text */
const int LABEL_TEXT_SIZE = 8; /*!< The height of the key label text */

View File

@@ -32,7 +32,7 @@
#include <QScreen>
#include "CaptionMenu.h"
#include "gui_templates.h"
#include "FontHelper.h"
#define QT_SUPPORTS_WIDGET_SCREEN (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
#if !QT_SUPPORTS_WIDGET_SCREEN
@@ -53,7 +53,7 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) :
{
setFixedHeight( ComboBox::DEFAULT_HEIGHT );
setFont(adjustedToPixelSize(font(), 10));
setFont(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE));
connect( &m_menu, SIGNAL(triggered(QAction*)),
this, SLOT(setItem(QAction*)));

View File

@@ -31,7 +31,7 @@
#include "GroupBox.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
namespace lmms::gui
@@ -111,7 +111,7 @@ void GroupBox::paintEvent( QPaintEvent * pe )
// draw text
p.setPen( palette().color( QPalette::Active, QPalette::Text ) );
p.setFont(adjustedToPixelSize(font(), 10));
p.setFont(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE));
int const captionX = ledButtonShown() ? 22 : 6;
p.drawText(captionX, m_titleBarHeight, m_caption);

View File

@@ -33,7 +33,7 @@
#include "lmms_math.h"
#include "DeprecationHelper.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
namespace lmms::gui
@@ -139,7 +139,7 @@ void Knob::setLabel( const QString & txt )
if( m_knobPixmap )
{
setFixedSize(qMax<int>( m_knobPixmap->width(),
horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), 10)), m_label)),
horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), SMALL_FONT_SIZE)), m_label)),
m_knobPixmap->height() + 10);
}
@@ -459,7 +459,7 @@ void Knob::paintEvent( QPaintEvent * _me )
{
if (!m_isHtmlLabel)
{
p.setFont(adjustedToPixelSize(p.font(), 10));
p.setFont(adjustedToPixelSize(p.font(), SMALL_FONT_SIZE));
p.setPen(textColor());
p.drawText(width() / 2 -
horizontalAdvance(p.fontMetrics(), m_label) / 2,
@@ -468,7 +468,7 @@ void Knob::paintEvent( QPaintEvent * _me )
else
{
// TODO setHtmlLabel is never called so this will never be executed. Remove functionality?
m_tdRenderer->setDefaultFont(adjustedToPixelSize(p.font(), 10));
m_tdRenderer->setDefaultFont(adjustedToPixelSize(p.font(), SMALL_FONT_SIZE));
p.translate((width() - m_tdRenderer->idealWidth()) / 2, (height() - m_tdRenderer->pageSize().height()) / 2);
m_tdRenderer->drawContents(&p);
}

View File

@@ -41,7 +41,7 @@
#include "DeprecationHelper.h"
#include "embed.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "MainWindow.h"
namespace lmms::gui
@@ -245,7 +245,7 @@ void LcdFloatSpinBox::paintEvent(QPaintEvent*)
// Label
if (!m_label.isEmpty())
{
p.setFont(adjustedToPixelSize(p.font(), 10));
p.setFont(adjustedToPixelSize(p.font(), DEFAULT_FONT_SIZE));
p.setPen(m_wholeDisplay.textShadowColor());
p.drawText(width() / 2 - p.fontMetrics().boundingRect(m_label).width() / 2 + 1, height(), m_label);
p.setPen(m_wholeDisplay.textColor());

View File

@@ -31,7 +31,7 @@
#include "LcdWidget.h"
#include "DeprecationHelper.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
namespace lmms::gui
@@ -209,7 +209,7 @@ void LcdWidget::paintEvent( QPaintEvent* )
// Label
if( !m_label.isEmpty() )
{
p.setFont(adjustedToPixelSize(p.font(), 10));
p.setFont(adjustedToPixelSize(p.font(), DEFAULT_FONT_SIZE));
p.setPen( textShadowColor() );
p.drawText(width() / 2 -
horizontalAdvance(p.fontMetrics(), m_label) / 2 + 1,
@@ -261,7 +261,7 @@ void LcdWidget::updateSize()
setFixedSize(
qMax<int>(
m_cellWidth * m_numDigits + marginX1 + marginX2,
horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), 10)), m_label)
horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE)), m_label)
),
m_cellHeight + (2 * marginY) + 9
);

View File

@@ -30,7 +30,7 @@
#include "DeprecationHelper.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
namespace lmms::gui
{
@@ -93,7 +93,7 @@ void LedCheckBox::initUi( LedColor _color )
m_ledOnPixmap = embed::getIconPixmap(names[static_cast<std::size_t>(_color)].toUtf8().constData());
m_ledOffPixmap = embed::getIconPixmap("led_off");
if (m_legacyMode){ setFont(adjustedToPixelSize(font(), 10)); }
if (m_legacyMode){ setFont(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE)); }
setText( m_text );
}
@@ -114,7 +114,7 @@ void LedCheckBox::onTextUpdated()
void LedCheckBox::paintLegacy(QPaintEvent * pe)
{
QPainter p( this );
p.setFont(adjustedToPixelSize(font(), 10));
p.setFont(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE));
p.drawPixmap(0, 0, model()->value() ? m_ledOnPixmap : m_ledOffPixmap);

View File

@@ -28,7 +28,7 @@
#include "Oscilloscope.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "MainWindow.h"
#include "AudioEngine.h"
#include "Engine.h"
@@ -203,7 +203,7 @@ void Oscilloscope::paintEvent( QPaintEvent * )
else
{
p.setPen( QColor( 192, 192, 192 ) );
p.setFont(adjustedToPixelSize(p.font(), 10));
p.setFont(adjustedToPixelSize(p.font(), DEFAULT_FONT_SIZE));
p.drawText( 6, height()-5, tr( "Click to enable" ) );
}
}

View File

@@ -33,7 +33,7 @@
#include "DeprecationHelper.h"
#include "embed.h"
#include "gui_templates.h"
#include "FontHelper.h"
namespace lmms::gui
{
@@ -58,7 +58,7 @@ TabWidget::TabWidget(const QString& caption, QWidget* parent, bool usePixmap,
m_tabheight = caption.isEmpty() ? m_tabbarHeight - 3 : m_tabbarHeight - 4;
setFont(adjustedToPixelSize(font(), 10));
setFont(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE));
setAutoFillBackground(true);
QColor bg_color = QApplication::palette().color(QPalette::Active, QPalette::Window).darker(132);
@@ -214,7 +214,7 @@ void TabWidget::resizeEvent(QResizeEvent*)
void TabWidget::paintEvent(QPaintEvent* pe)
{
QPainter p(this);
p.setFont(adjustedToPixelSize(font(), 10));
p.setFont(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE));
// Draw background
QBrush bg_color = p.background();