Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hardcoded fonts scaling issues #7493

Merged
merged 24 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/gui_templates.h → include/FontHelper.h
Original file line number Diff line number Diff line change
@@ -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>
*
Expand All @@ -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
{

Expand All @@ -40,4 +44,4 @@ inline QFont adjustedToPixelSize(QFont font, int size)

} // namespace lmms::gui

#endif // LMMS_GUI_TEMPLATES_H
#endif // LMMS_FONT_HELPER_H
4 changes: 2 additions & 2 deletions plugins/AudioFileProcessor/AudioFileProcessorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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());

Expand Down
4 changes: 2 additions & 2 deletions plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "AudioFileProcessorWaveView.h"

#include "ConfigManager.h"
#include "gui_templates.h"
#include "FontHelper.h"
#include "SampleWaveform.h"

#include <QPainter>
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions plugins/CarlaBase/Carla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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(
Expand All @@ -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."));
Expand Down
5 changes: 2 additions & 3 deletions plugins/Eq/EqCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "AudioEngine.h"
#include "embed.h"
#include "Engine.h"
#include "FontHelper.h"
#include "lmms_constants.h"
#include "lmms_math.h"

Expand Down Expand Up @@ -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 ) ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "LcdFloatSpinBox.h"
#include "Knob.h"
#include "GuiApplication.h"
#include "gui_templates.h"
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
#include "PixmapButton.h"


Expand Down
6 changes: 3 additions & 3 deletions plugins/Patman/Patman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions plugins/TapTempo/TapTempoView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QWidget>

#include "Engine.h"
#include "FontHelper.h"
#include "SamplePlayHandle.h"
#include "Song.h"
#include "TapTempo.h"
Expand All @@ -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"));
Expand Down
2 changes: 0 additions & 2 deletions plugins/Vectorscope/VecControlsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ 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);

// Log. scale switch
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);

Expand Down
4 changes: 2 additions & 2 deletions plugins/Vectorscope/VectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "ColorChooser.h"
#include "GuiApplication.h"
#include "FontHelper.h"
#include "MainWindow.h"
#include "VecControls.h"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down
12 changes: 5 additions & 7 deletions plugins/Vestige/Vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() ) );

Expand All @@ -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() ) );

Expand Down Expand Up @@ -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 );

Expand All @@ -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 ) );
Expand Down
4 changes: 2 additions & 2 deletions plugins/VstEffect/VstEffectControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "PixmapButton.h"
#include "embed.h"

#include "gui_templates.h"
#include "FontHelper.h"
#include <QToolBar>
#include <QLabel>

Expand Down Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions plugins/ZynAddSubFx/ZynAddSubFx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "Clipboard.h"

#include "embed.h"
#include "FontHelper.h"
#include "plugin_export.h"

namespace lmms
Expand Down Expand Up @@ -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() ) );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/EffectView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions src/gui/Lv2ViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/gui/MixerChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include "PeakIndicator.h"
#include "Song.h"
#include "ConfigManager.h"

#include "gui_templates.h"
#include "FontHelper.h"

#include <QGraphicsProxyWidget>
#include <QGraphicsScene>
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/SampleTrackWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/gui/SideBarWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QPushButton>

#include "embed.h"
#include "FontHelper.h"

namespace lmms::gui
{
Expand Down Expand Up @@ -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() );

Expand Down
Loading
Loading