Font size adjustments (#7185)

Adjust and rename the function `pointSize` so that it sets the font size in pixels. Rename `pointSize` to `adjustedToPixelSize` because that's what it does now. It returns a font adjusted to a given pixel size. Rename `fontPointer` to `font` because it's not a pointer but a copy. Rename `fontSize` to simply `size`.

This works if the intended model is that users use global fractional scaling. In that case pixel sized fonts are also scaled so that they should stay legible for different screen sizes and pixel densities.

## Adjust plugins with regards to adjustedToPixelSize

Adjust the plugins with regards to the use of `adjustedToPixelSize`.

Remove the explicit setting of the font size of combo boxes in the following places to make the combo boxes consistent:
* `AudioFileProcessorView.cpp`
* `DualFilterControlDialog.cpp`
* `Monstro.cpp` (does not even seem to use text)
* `Mallets.cpp`

Remove calls to `adjustedToPixelSize` in the following places because they can deal with different font sizes:
* `LadspaBrowser.cpp`

Set an explicit point sized font size for the "Show GUI" button in `ZynAddSubFx.cpp`

Increase the font size of the buttons in the Vestige plugin and reduce code repetition by introducing a single variable for the font size.

I was not able to find out where the font in `VstEffectControlDialog.cpp` is shown. So it is left as is for now.

## Adjust the font sizes in the area of GUI editors and instruments.

Increase the font size to 10 pixels in the following places:
* Effect view: "Controls" button and the display of the effect name at the bottom
* Automation editor: Min and max value display to the left of the editor
* InstrumentFunctionViews: Labels "Chord:", "Direction:" and "Mode:"
* InstrumentMidiIOView: Message display "Specify the velocity normalization base for MIDI-based instruments at 100% note velocity."
* InstrumentSoundShapingView: Message display "Envelopes, LFOs and filters are not supported by the current instrument."
* InstrumentTuningView: Message display "Enables the use of global transposition"

Increase the font size to 12 pixels in the mixer channel view, i.e. the display of the channel name.

Render messages in system font size in the following areas because there should be enough space for almost all sizes:
* Automation editor: Message display "Please open an automation clip by double-clicking on it!"
* Piano roll: Message display "Please open a clip by double-clicking on it!"

Use the application font for the line edit that can be used to change the instrument name.

Remove overrides which explicitly set the font size for LED check boxes in:
* EnvelopeAndLfoView: Labels "FREQ x 100" and "MODULATE ENV AMOUNT"

Remove overrides which explicitly set the font size for combo boxes in:
* InstrumentSoundShapingView: Filter combo box

## Adjust font sizes in widgets

Adjust the font sizes in the area of the custom GUI widgets.

Increase and unify the pixel font size to 10 pixels in the following classes:
* `ComboBox`
* `GroupBox`
* `Knob`
* `LcdFloatSpinBox`
* `LcdWidget`
* `LedCheckBox`
* `Oscilloscope`: Display of "Click to enable"
* `TabWidget`

Shorten the text in `EnvelopeAndLfoView` from "MODULATE ENV AMOUNT" to "MOD ENV AMOUNT" to make it fit with the new font size of `LedCheckBox`.

Remove the setting of the font size in pixels from `MeterDialog` because it's displayed in a layout and can accommodate all font sizes. Note: the dialog can be triggered from a LADSPA plugin with tempo sync, e.g. "Allpass delay line". Right click on the time parameter and select "Tempo Sync > Custom..." from the context menu.

Remove the setting of the font size in `TabBar` as none of the added `TabButton` instances displays text in the first place.

Remove the setting of the font size in `TabWidget::addTab` because the font size is already set in the constructor. It would be an unexpected size effect of setting a tab anyway. Remove a duplicate call to setting the font size in `TabWidget::paintEvent`.

Remove unnecessary includes of `gui_templates.h` wherever this is possible now.

## Direct use of setPixelSize

Directly use `setPixelSize` when drawing the "Note Velocity" and "Note Panning" strings as they will likely never be drawn using point sizes.
This commit is contained in:
Michael Gregorius
2024-04-04 21:40:31 +02:00
committed by GitHub
parent b14f8ab8fd
commit 20fec28bef
34 changed files with 59 additions and 100 deletions

View File

@@ -90,7 +90,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
{
auto ctls_btn = new QPushButton(tr("Controls"), this);
QFont f = ctls_btn->font();
ctls_btn->setFont(pointSize(f, 8));
ctls_btn->setFont(adjustedToPixelSize(f, 10));
ctls_btn->setGeometry( 150, 14, 50, 20 );
connect( ctls_btn, SIGNAL(clicked()),
this, SLOT(editControls()));
@@ -257,7 +257,7 @@ void EffectView::paintEvent( QPaintEvent * )
QPainter p( this );
p.drawPixmap( 0, 0, m_bg );
QFont f = pointSize(font(), 7.5f);
QFont f = adjustedToPixelSize(font(), 10);
f.setBold( true );
p.setFont( f );

View File

@@ -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(pointSize(m_toggleUIButton->font(), 8));
m_toggleUIButton->setFont(adjustedToPixelSize(m_toggleUIButton->font(), 8));
btnBox->addWidget(m_toggleUIButton, 0);
}
btnBox->addStretch(1);

View File

@@ -76,7 +76,7 @@ namespace lmms::gui
m_renameLineEdit = new QLineEdit{mixerName, nullptr};
m_renameLineEdit->setFixedWidth(65);
m_renameLineEdit->setFont(pointSize(font(), 7.5f));
m_renameLineEdit->setFont(adjustedToPixelSize(font(), 12));
m_renameLineEdit->setReadOnly(true);
m_renameLineEdit->installEventFilter(this);

View File

@@ -1040,8 +1040,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
QBrush bgColor = p.background();
p.fillRect( 0, 0, width(), height(), bgColor );
// set font-size to 8
p.setFont(pointSize(p.font(), 8));
p.setFont(adjustedToPixelSize(p.font(), 10));
int grid_height = height() - TOP_MARGIN - SCROLLBAR_SIZE;
@@ -1383,9 +1382,9 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
}
else
{
QFont f = p.font();
QFont f = font();
f.setBold( true );
p.setFont(pointSize(f, 14));
p.setFont(f);
p.setPen( QApplication::palette().color( QPalette::Active,
QPalette::BrightText ) );
p.drawText( VALUES_WIDTH + 20, TOP_MARGIN + 40,

View File

@@ -59,7 +59,6 @@
#include "DetuningHelper.h"
#include "embed.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "InstrumentTrack.h"
#include "MainWindow.h"
#include "MidiClip.h"
@@ -3335,9 +3334,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
m_whiteKeyWidth, noteEditBottom() - keyAreaBottom()), bgColor);
// display note editing info
//QFont f = p.font();
f.setBold( false );
p.setFont(pointSize(f, 10));
f.setBold(false);
f.setPixelSize(10);
p.setFont(f);
p.setPen(m_noteModeColor);
p.drawText( QRect( 0, keyAreaBottom(),
m_whiteKeyWidth, noteEditBottom() - keyAreaBottom()),
@@ -3598,9 +3597,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
}
else
{
QFont f = p.font();
f.setBold( true );
p.setFont(pointSize(f, 14));
QFont f = font();
f.setBold(true);
p.setFont(f);
p.setPen( QApplication::palette().color( QPalette::Active,
QPalette::BrightText ) );
p.drawText(m_whiteKeyWidth + 20, PR_TOP_MARGIN + 40,

View File

@@ -207,15 +207,12 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) :
m_lfoWaveBtnGrp->addButton( random_lfo_btn );
m_x100Cb = new LedCheckBox( tr( "FREQ x 100" ), this );
m_x100Cb->setFont(pointSize(m_x100Cb->font(), 6.5));
m_x100Cb->move( LFO_PREDELAY_KNOB_X, LFO_GRAPH_Y + 36 );
m_x100Cb->setToolTip(tr("Multiply LFO frequency by 100"));
m_controlEnvAmountCb = new LedCheckBox( tr( "MODULATE ENV AMOUNT" ),
this );
m_controlEnvAmountCb = new LedCheckBox(tr("MOD ENV AMOUNT"), this);
m_controlEnvAmountCb->move( LFO_PREDELAY_KNOB_X, LFO_GRAPH_Y + 54 );
m_controlEnvAmountCb->setFont(pointSize(m_controlEnvAmountCb->font(), 6.5));
m_controlEnvAmountCb->setToolTip(
tr( "Control envelope amount by this LFO" ) );
@@ -340,7 +337,7 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * )
// draw LFO-graph
p.drawPixmap(LFO_GRAPH_X, LFO_GRAPH_Y, m_lfoGraph);
p.setFont(pointSize(p.font(), 8));
p.setFont(adjustedToPixelSize(p.font(), 8));
const float gray_amount = 1.0f - fabsf( m_amountKnob->value<float>() );

View File

@@ -57,7 +57,7 @@ InstrumentFunctionNoteStackingView::InstrumentFunctionNoteStackingView( Instrume
mainLayout->setVerticalSpacing( 1 );
auto chordLabel = new QLabel(tr("Chord:"));
chordLabel->setFont(pointSize(chordLabel->font(), 8));
chordLabel->setFont(adjustedToPixelSize(chordLabel->font(), 10));
m_chordRangeKnob->setLabel( tr( "RANGE" ) );
m_chordRangeKnob->setHintText( tr( "Chord range:" ), " " + tr( "octave(s)" ) );
@@ -145,14 +145,15 @@ 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(pointSize(arpChordLabel->font(), 8));
arpChordLabel->setFont(adjustedToPixelSize(arpChordLabel->font(), labelFontSize));
auto arpDirectionLabel = new QLabel(tr("Direction:"));
arpDirectionLabel->setFont(pointSize(arpDirectionLabel->font(), 8));
arpDirectionLabel->setFont(adjustedToPixelSize(arpDirectionLabel->font(), labelFontSize));
auto arpModeLabel = new QLabel(tr("Mode:"));
arpModeLabel->setFont(pointSize(arpModeLabel->font(), 8));
arpModeLabel->setFont(adjustedToPixelSize(arpModeLabel->font(), labelFontSize));
mainLayout->addWidget( arpChordLabel, 0, 0 );
mainLayout->addWidget( m_arpComboBox, 1, 0 );

View File

@@ -155,7 +155,7 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) :
auto baseVelocityHelp
= new QLabel(tr("Specify the velocity normalization base for MIDI-based instruments at 100% note velocity."));
baseVelocityHelp->setWordWrap( true );
baseVelocityHelp->setFont(pointSize(baseVelocityHelp->font(), 8));
baseVelocityHelp->setFont(adjustedToPixelSize(baseVelocityHelp->font(), 10));
baseVelocityLayout->addWidget( baseVelocityHelp );

View File

@@ -77,7 +77,6 @@ InstrumentSoundShapingView::InstrumentSoundShapingView( QWidget * _parent ) :
m_filterComboBox = new ComboBox( m_filterGroupBox );
m_filterComboBox->setGeometry( 14, 22, 120, ComboBox::DEFAULT_HEIGHT );
m_filterComboBox->setFont(pointSize(m_filterComboBox->font(), 8));
m_filterCutKnob = new Knob( KnobType::Bright26, m_filterGroupBox );
@@ -94,7 +93,8 @@ 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 );
m_singleStreamInfoLabel->setFont(pointSize(m_singleStreamInfoLabel->font(), 8));
// TODO Could also be rendered in system font size...
m_singleStreamInfoLabel->setFont(adjustedToPixelSize(m_singleStreamInfoLabel->font(), 10));
m_singleStreamInfoLabel->setGeometry( TARGETS_TABWIDGET_X,
TARGETS_TABWIDGET_Y,

View File

@@ -44,7 +44,6 @@
#include "GroupBox.h"
#include "MixerChannelLcdSpinBox.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "Instrument.h"
#include "InstrumentFunctions.h"
#include "InstrumentFunctionViews.h"
@@ -103,7 +102,6 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) :
// setup line edit for changing instrument track name
m_nameLineEdit = new QLineEdit;
m_nameLineEdit->setFont(pointSize(m_nameLineEdit->font(), 9));
connect( m_nameLineEdit, SIGNAL( textChanged( const QString& ) ),
this, SLOT( textChanged( const QString& ) ) );

View File

@@ -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(pointSize(tlabel->font(), 8));
tlabel->setFont(adjustedToPixelSize(tlabel->font(), 10));
masterPitchLayout->addWidget(tlabel);
// Microtuner settings

View File

@@ -807,7 +807,7 @@ void PianoView::paintEvent( QPaintEvent * )
QPainter p( this );
// set smaller font for printing number of every octave
p.setFont(pointSize(p.font(), LABEL_TEXT_SIZE));
p.setFont(adjustedToPixelSize(p.font(), LABEL_TEXT_SIZE));
// draw bar above the keyboard (there will be the labels

View File

@@ -53,7 +53,7 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) :
{
setFixedHeight( ComboBox::DEFAULT_HEIGHT );
setFont(pointSize(font(), 9));
setFont(adjustedToPixelSize(font(), 10));
connect( &m_menu, SIGNAL(triggered(QAction*)),
this, SLOT(setItem(QAction*)));

View File

@@ -111,7 +111,7 @@ void GroupBox::paintEvent( QPaintEvent * pe )
// draw text
p.setPen( palette().color( QPalette::Active, QPalette::Text ) );
p.setFont(pointSize(font(), 8));
p.setFont(adjustedToPixelSize(font(), 10));
int const captionX = ledButtonShown() ? 22 : 6;
p.drawText(captionX, m_titleBarHeight, m_caption);

View File

@@ -139,7 +139,7 @@ void Knob::setLabel( const QString & txt )
if( m_knobPixmap )
{
setFixedSize(qMax<int>( m_knobPixmap->width(),
horizontalAdvance(QFontMetrics(pointSize(font(), 6.5)), m_label)),
horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), 10)), m_label)),
m_knobPixmap->height() + 10);
}
@@ -459,7 +459,7 @@ void Knob::paintEvent( QPaintEvent * _me )
{
if (!m_isHtmlLabel)
{
p.setFont(pointSize(p.font(), 6.5f));
p.setFont(adjustedToPixelSize(p.font(), 10));
p.setPen(textColor());
p.drawText(width() / 2 -
horizontalAdvance(p.fontMetrics(), m_label) / 2,
@@ -467,7 +467,8 @@ void Knob::paintEvent( QPaintEvent * _me )
}
else
{
m_tdRenderer->setDefaultFont(pointSize(p.font(), 6.5f));
// TODO setHtmlLabel is never called so this will never be executed. Remove functionality?
m_tdRenderer->setDefaultFont(adjustedToPixelSize(p.font(), 10));
p.translate((width() - m_tdRenderer->idealWidth()) / 2, (height() - m_tdRenderer->pageSize().height()) / 2);
m_tdRenderer->drawContents(&p);
}

View File

@@ -245,7 +245,7 @@ void LcdFloatSpinBox::paintEvent(QPaintEvent*)
// Label
if (!m_label.isEmpty())
{
p.setFont(pointSize(p.font(), 6.5f));
p.setFont(adjustedToPixelSize(p.font(), 10));
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

@@ -209,7 +209,7 @@ void LcdWidget::paintEvent( QPaintEvent* )
// Label
if( !m_label.isEmpty() )
{
p.setFont(pointSize(p.font(), 6.5f));
p.setFont(adjustedToPixelSize(p.font(), 10));
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(pointSize(font(), 6.5f)), m_label)
horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), 10)), m_label)
),
m_cellHeight + (2 * marginY) + 9
);

View File

@@ -92,7 +92,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(pointSize(font(), 7)); }
if (m_legacyMode){ setFont(adjustedToPixelSize(font(), 10)); }
setText( m_text );
}
@@ -113,7 +113,7 @@ void LedCheckBox::onTextUpdated()
void LedCheckBox::paintLegacy(QPaintEvent * pe)
{
QPainter p( this );
p.setFont(pointSize(font(), 7));
p.setFont(adjustedToPixelSize(font(), 10));
p.drawPixmap(0, 0, model()->value() ? m_ledOnPixmap : m_ledOffPixmap);

View File

@@ -30,7 +30,6 @@
#include "MeterDialog.h"
#include "MeterModel.h"
#include "gui_templates.h"
#include "LcdSpinBox.h"
namespace lmms::gui
@@ -60,7 +59,6 @@ MeterDialog::MeterDialog( QWidget * _parent, bool _simple ) :
{
auto num_label = new QLabel(tr("Meter Numerator"), num);
QFont f = num_label->font();
num_label->setFont(pointSize(f, 7));
num_layout->addSpacing( 5 );
num_layout->addWidget( num_label );
}
@@ -84,7 +82,6 @@ MeterDialog::MeterDialog( QWidget * _parent, bool _simple ) :
{
auto den_label = new QLabel(tr("Meter Denominator"), den);
QFont f = den_label->font();
den_label->setFont(pointSize(f, 7));
den_layout->addSpacing( 5 );
den_layout->addWidget( den_label );
}

View File

@@ -203,7 +203,7 @@ void Oscilloscope::paintEvent( QPaintEvent * )
else
{
p.setPen( QColor( 192, 192, 192 ) );
p.setFont(pointSize(p.font(), 7));
p.setFont(adjustedToPixelSize(p.font(), 10));
p.drawText( 6, height()-5, tr( "Click to enable" ) );
}
}

View File

@@ -25,7 +25,6 @@
#include "TabBar.h"
#include "TabButton.h"
#include "gui_templates.h"
namespace lmms::gui
@@ -90,8 +89,6 @@ TabButton * TabBar::addTab( QWidget * _w, const QString & _text, int _id,
_w->setFixedSize( _w->parentWidget()->size() );
}
b->setFont(pointSize(b->font(), 8));
return( b );
}

View File

@@ -58,7 +58,7 @@ TabWidget::TabWidget(const QString& caption, QWidget* parent, bool usePixmap,
m_tabheight = caption.isEmpty() ? m_tabbarHeight - 3 : m_tabbarHeight - 4;
setFont(pointSize(font(), 8));
setFont(adjustedToPixelSize(font(), 10));
setAutoFillBackground(true);
QColor bg_color = QApplication::palette().color(QPalette::Active, QPalette::Window).darker(132);
@@ -70,8 +70,6 @@ TabWidget::TabWidget(const QString& caption, QWidget* parent, bool usePixmap,
void TabWidget::addTab(QWidget* w, const QString& name, const char* pixmap, int idx)
{
setFont(pointSize(font(), 8));
// Append tab when position is not given
if (idx < 0/* || m_widgets.contains(idx) == true*/)
{
@@ -216,7 +214,7 @@ void TabWidget::resizeEvent(QResizeEvent*)
void TabWidget::paintEvent(QPaintEvent* pe)
{
QPainter p(this);
p.setFont(pointSize(font(), 7));
p.setFont(adjustedToPixelSize(font(), 10));
// Draw background
QBrush bg_color = p.background();
@@ -232,7 +230,6 @@ void TabWidget::paintEvent(QPaintEvent* pe)
// Draw title, if any
if (!m_caption.isEmpty())
{
p.setFont(pointSize(p.font(), 8));
p.setPen(tabTitleText());
p.drawText(5, 11, m_caption);
}