diff --git a/include/gui_templates.h b/include/FontHelper.h similarity index 81% rename from include/gui_templates.h rename to include/FontHelper.h index bbb5f80da67..ccef24775d3 100644 --- a/include/gui_templates.h +++ b/include/FontHelper.h @@ -1,5 +1,5 @@ /* - * gui_templates.h - GUI-specific templates + * FontHelper.h - Header function to help with fonts * * Copyright (c) 2005-2008 Tobias Doerffel * @@ -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 #include +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 diff --git a/plugins/AudioFileProcessor/AudioFileProcessorView.cpp b/plugins/AudioFileProcessor/AudioFileProcessorView.cpp index b7d5802dc44..298e79c5ed1 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessorView.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessorView.cpp @@ -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()); diff --git a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp index ee5225c20f7..7c5f9387eec 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp @@ -25,7 +25,7 @@ #include "AudioFileProcessorWaveView.h" #include "ConfigManager.h" -#include "gui_templates.h" +#include "FontHelper.h" #include "SampleWaveform.h" #include @@ -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(); diff --git a/plugins/CarlaBase/Carla.cpp b/plugins/CarlaBase/Carla.cpp index e81e655501a..37cba078aa1 100644 --- a/plugins/CarlaBase/Carla.cpp +++ b/plugins/CarlaBase/Carla.cpp @@ -32,7 +32,7 @@ #include "Knob.h" #include "MidiEventToByteSeq.h" #include "MainWindow.h" -#include "gui_templates.h" +#include "FontHelper.h" #include "Song.h" #include @@ -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.")); diff --git a/plugins/Eq/EqCurve.cpp b/plugins/Eq/EqCurve.cpp index df17f71ffbf..417f101f798 100644 --- a/plugins/Eq/EqCurve.cpp +++ b/plugins/Eq/EqCurve.cpp @@ -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 ) ) ); diff --git a/plugins/GranularPitchShifter/GranularPitchShifterControlDialog.cpp b/plugins/GranularPitchShifter/GranularPitchShifterControlDialog.cpp index 71a8d15f716..1231535c293 100755 --- a/plugins/GranularPitchShifter/GranularPitchShifterControlDialog.cpp +++ b/plugins/GranularPitchShifter/GranularPitchShifterControlDialog.cpp @@ -28,7 +28,6 @@ #include "LcdFloatSpinBox.h" #include "Knob.h" #include "GuiApplication.h" -#include "gui_templates.h" #include "PixmapButton.h" diff --git a/plugins/Patman/Patman.cpp b/plugins/Patman/Patman.cpp index 6165bd53785..4ecbe1bb83b 100644 --- a/plugins/Patman/Patman.cpp +++ b/plugins/Patman/Patman.cpp @@ -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 ); diff --git a/plugins/TapTempo/TapTempoView.cpp b/plugins/TapTempo/TapTempoView.cpp index d6c24fcf550..ed451eaa50e 100644 --- a/plugins/TapTempo/TapTempoView.cpp +++ b/plugins/TapTempo/TapTempoView.cpp @@ -35,6 +35,7 @@ #include #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")); diff --git a/plugins/Vectorscope/VecControlsDialog.cpp b/plugins/Vectorscope/VecControlsDialog.cpp index 9aa2cfd8d1f..cd280508980 100644 --- a/plugins/Vectorscope/VecControlsDialog.cpp +++ b/plugins/Vectorscope/VecControlsDialog.cpp @@ -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); diff --git a/plugins/Vectorscope/VectorView.cpp b/plugins/Vectorscope/VectorView.cpp index 2077d12cd26..a9b5e51b225 100644 --- a/plugins/Vectorscope/VectorView.cpp +++ b/plugins/Vectorscope/VectorView.cpp @@ -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")); diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index ffed82af7e3..5a7d4afa059 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -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 ) ); diff --git a/plugins/VstEffect/VstEffectControlDialog.cpp b/plugins/VstEffect/VstEffectControlDialog.cpp index 0fb4913a338..a5b67f5f33a 100644 --- a/plugins/VstEffect/VstEffectControlDialog.cpp +++ b/plugins/VstEffect/VstEffectControlDialog.cpp @@ -33,7 +33,7 @@ #include "PixmapButton.h" #include "embed.h" -#include "gui_templates.h" +#include "FontHelper.h" #include #include @@ -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 ); diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.cpp b/plugins/ZynAddSubFx/ZynAddSubFx.cpp index 51610d87786..19864932d8a 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/ZynAddSubFx.cpp @@ -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() ) ); diff --git a/src/gui/EffectView.cpp b/src/gui/EffectView.cpp index 6f2b984c32a..a5095ee6d13 100644 --- a/src/gui/EffectView.cpp +++ b/src/gui/EffectView.cpp @@ -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 ); diff --git a/src/gui/Lv2ViewBase.cpp b/src/gui/Lv2ViewBase.cpp index fc025e26856..d6a25af834b 100644 --- a/src/gui/Lv2ViewBase.cpp +++ b/src/gui/Lv2ViewBase.cpp @@ -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); diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index b347a04a0e9..82bbedb0378 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -31,8 +31,7 @@ #include "PeakIndicator.h" #include "Song.h" #include "ConfigManager.h" - -#include "gui_templates.h" +#include "FontHelper.h" #include #include @@ -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); diff --git a/src/gui/SampleTrackWindow.cpp b/src/gui/SampleTrackWindow.cpp index 81a2ca89b60..1c7a56828fc 100644 --- a/src/gui/SampleTrackWindow.cpp +++ b/src/gui/SampleTrackWindow.cpp @@ -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; diff --git a/src/gui/SideBarWidget.cpp b/src/gui/SideBarWidget.cpp index c218bedd335..5a73cb47166 100644 --- a/src/gui/SideBarWidget.cpp +++ b/src/gui/SideBarWidget.cpp @@ -29,6 +29,7 @@ #include #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() ); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index a7ca0727972..df67398827e 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -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; diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 1c89f6a0b34..f8472b6888c 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -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()), diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index 1b639e6c326..95926450680 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -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" diff --git a/src/gui/instrument/InstrumentFunctionViews.cpp b/src/gui/instrument/InstrumentFunctionViews.cpp index ad8abe73524..a60fa64f92d 100644 --- a/src/gui/instrument/InstrumentFunctionViews.cpp +++ b/src/gui/instrument/InstrumentFunctionViews.cpp @@ -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 ); diff --git a/src/gui/instrument/InstrumentMidiIOView.cpp b/src/gui/instrument/InstrumentMidiIOView.cpp index e3f10bd1a32..c6b58e09009 100644 --- a/src/gui/instrument/InstrumentMidiIOView.cpp +++ b/src/gui/instrument/InstrumentMidiIOView.cpp @@ -33,7 +33,6 @@ #include "Engine.h" #include "embed.h" #include "GroupBox.h" -#include "gui_templates.h" #include "LcdSpinBox.h" #include "MidiClient.h" diff --git a/src/gui/instrument/InstrumentSoundShapingView.cpp b/src/gui/instrument/InstrumentSoundShapingView.cpp index 7558c4c2637..45abace19f0 100644 --- a/src/gui/instrument/InstrumentSoundShapingView.cpp +++ b/src/gui/instrument/InstrumentSoundShapingView.cpp @@ -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); diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 1fb8596625e..22133813849 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -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; diff --git a/src/gui/instrument/InstrumentTuningView.cpp b/src/gui/instrument/InstrumentTuningView.cpp index daa361aad6b..06121502e8b 100644 --- a/src/gui/instrument/InstrumentTuningView.cpp +++ b/src/gui/instrument/InstrumentTuningView.cpp @@ -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 diff --git a/src/gui/instrument/LfoGraph.cpp b/src/gui/instrument/LfoGraph.cpp index 7edbacb09ea..7444eeb4608 100644 --- a/src/gui/instrument/LfoGraph.cpp +++ b/src/gui/instrument/LfoGraph.cpp @@ -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); diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index 13628d97eea..aeeb1fbbcd5 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -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 */ diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index 0daae1b240b..945d30aa390 100644 --- a/src/gui/widgets/ComboBox.cpp +++ b/src/gui/widgets/ComboBox.cpp @@ -32,7 +32,7 @@ #include #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*))); diff --git a/src/gui/widgets/GroupBox.cpp b/src/gui/widgets/GroupBox.cpp index e7d78acb9dd..e55052823ec 100644 --- a/src/gui/widgets/GroupBox.cpp +++ b/src/gui/widgets/GroupBox.cpp @@ -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); diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index d282f72c20f..8941dcc29d4 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -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( 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); } diff --git a/src/gui/widgets/LcdFloatSpinBox.cpp b/src/gui/widgets/LcdFloatSpinBox.cpp index c71d665689e..37d262e4ba6 100644 --- a/src/gui/widgets/LcdFloatSpinBox.cpp +++ b/src/gui/widgets/LcdFloatSpinBox.cpp @@ -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()); diff --git a/src/gui/widgets/LcdWidget.cpp b/src/gui/widgets/LcdWidget.cpp index 7370a939fe3..4b07af6f73b 100644 --- a/src/gui/widgets/LcdWidget.cpp +++ b/src/gui/widgets/LcdWidget.cpp @@ -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( 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 ); diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index c26e2103948..85039335633 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -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(_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); diff --git a/src/gui/widgets/Oscilloscope.cpp b/src/gui/widgets/Oscilloscope.cpp index 775bd96a8b8..28ddff93841 100644 --- a/src/gui/widgets/Oscilloscope.cpp +++ b/src/gui/widgets/Oscilloscope.cpp @@ -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" ) ); } } diff --git a/src/gui/widgets/TabWidget.cpp b/src/gui/widgets/TabWidget.cpp index a370c1ea9fb..81fae1c043a 100644 --- a/src/gui/widgets/TabWidget.cpp +++ b/src/gui/widgets/TabWidget.cpp @@ -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();