Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6863e01
Knob with correct label rendering
michaelgregorius Sep 28, 2024
845b51f
Switch from `setLabel` to `setLabelLegacy`
michaelgregorius Sep 28, 2024
bbca164
Remove parameter `legacyMode` from `setLabel`
michaelgregorius Sep 28, 2024
21ba9f3
Extract methods
michaelgregorius Sep 28, 2024
01a46d0
Introduce legacy knob builders
michaelgregorius Sep 28, 2024
f72290a
Legacy knob builders in GUI
michaelgregorius Sep 28, 2024
eb6d27f
Remove `Knob::setLabelLegacy`
michaelgregorius Sep 28, 2024
ee2ccb6
Use descent to calculate base line
michaelgregorius Sep 28, 2024
e065d24
Extract `Knob::drawLabel`
michaelgregorius Sep 28, 2024
86a5ca0
Use non-legacy knobs for instrument and sample track
michaelgregorius Sep 28, 2024
b891120
Introduce `buildKnobWithSmallPixelFont`
michaelgregorius Sep 29, 2024
cd43423
Non-legacy knobs for VSTs
michaelgregorius Sep 29, 2024
d31c90e
Fix styled knobs
michaelgregorius Sep 29, 2024
39e1e9f
Code review changes
michaelgregorius Sep 30, 2024
3991612
Code review changes
michaelgregorius Oct 10, 2024
e66d841
Add documentation for legacy mode
michaelgregorius Oct 10, 2024
c4077e9
Code review
michaelgregorius Oct 10, 2024
4d95ec8
Merge remote-tracking branch 'upstream/master' into KnobFlexibleLabels
michaelgregorius Feb 22, 2025
5f55bd8
Decrease the label size of some knobs
michaelgregorius Mar 9, 2025
b2cd6f4
Merge branch 'master' into KnobFlexibleLabels
michaelgregorius Mar 19, 2025
1ecdc89
Merge remote-tracking branch 'upstream/master' into KnobFlexibleLabels
michaelgregorius Mar 22, 2025
794bce5
Adjustments to CrossoverEQControlDialog
michaelgregorius Mar 22, 2025
02602d1
Fix formatting of CrossoverEQControlDialog
michaelgregorius Mar 22, 2025
e32d0ce
Code review changes
michaelgregorius Apr 1, 2025
caac12c
Protected legacy mode methods
michaelgregorius Apr 1, 2025
0e55ba3
Merge remote-tracking branch 'upstream/master' into KnobFlexibleLabels
michaelgregorius Apr 1, 2025
61c436c
Code review: remove indexed access
michaelgregorius Apr 18, 2025
ba2e8a5
Fix u_int16_t to uint16_t
michaelgregorius Apr 18, 2025
24e172a
Merge remote-tracking branch 'upstream/master' into KnobFlexibleLabels
michaelgregorius Apr 19, 2025
84b5458
Fix AudioFileProcessor knobs
michaelgregorius Apr 19, 2025
662bd98
Use legacy knobs in EffectView
michaelgregorius Apr 19, 2025
7037a74
Legacy knobs for instrument & sample
michaelgregorius Apr 19, 2025
181d5cc
Add documentation to Knob builder methods
michaelgregorius Apr 30, 2025
2e576d4
Ensure legancy rendering for legacy knobs
michaelgregorius May 12, 2025
8d1ae33
Merge remote-tracking branch 'upstream/master' into KnobFlexibleLabels
michaelgregorius May 17, 2025
176a165
Remove unused constructor
michaelgregorius May 17, 2025
d404709
Remove Knob::buildKnobWithSmallPixelFont
michaelgregorius May 17, 2025
967f80a
Remove Knob::buildKnobWithFixedPixelFont
michaelgregorius May 17, 2025
2825716
Constructor for knobs with pixel size labels
michaelgregorius May 17, 2025
18e7d3c
Remove TempoSyncKnob::buildKnobWithSmallPixelFont
michaelgregorius May 17, 2025
43a31aa
Remove CustomTextKnob::buildKnobWithSmallPixelFont
michaelgregorius May 17, 2025
440cea1
Knob constructors whichKnob constructors which take labels
michaelgregorius May 17, 2025
41c4f6e
Remove Knob::buildLegacyKnob
michaelgregorius May 17, 2025
9ca18e0
Remove TempoSyncKnob::buildLegacyKnob
michaelgregorius May 17, 2025
ede67e3
Vertical spacing for Peak Controller
michaelgregorius May 17, 2025
4d03777
Peak Controller: use default margins
michaelgregorius May 17, 2025
89cd2f5
Rename the enum `Knob::Mode`
michaelgregorius May 29, 2025
85aa471
Add TempoSyncKnob documentation
michaelgregorius May 29, 2025
a3fe16e
Name adjustments and parameter removal
michaelgregorius May 29, 2025
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
2 changes: 1 addition & 1 deletion include/Controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class KnobControl : public Control
FloatModel* model() override;
AutomatableModelView* modelView() override;

KnobControl(QWidget* parent = nullptr);
KnobControl(const QString& text, QWidget* parent = nullptr);
~KnobControl() override = default;
};

Expand Down
4 changes: 1 addition & 3 deletions include/CustomTextKnob.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class LMMS_EXPORT CustomTextKnob : public Knob
protected:
inline void setHintText( const QString & _txt_before, const QString & _txt_after ) {} // inaccessible
public:
CustomTextKnob( KnobType _knob_num, QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() );

CustomTextKnob( QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() ); //!< default ctor
CustomTextKnob( KnobType _knob_num, const QString& label, QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() );

CustomTextKnob( const Knob& other ) = delete;

Expand Down
90 changes: 88 additions & 2 deletions include/Knob.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,65 @@ class LMMS_EXPORT Knob : public FloatModelEditorBase
void onKnobNumUpdated(); //!< to be called when you updated @a m_knobNum

public:
/**
* @brief Determines how the label of the knob is rendered.
*
* Labels can be rendered using the font that is set for the knob or using a
* font with a fixed size which is determined by SMALL_FONT_SIZE.
*/
enum class LabelRendering
{
/**
* @brief Renders the label using the font that is set for the widget.
*
* The space that's needed for the label is determined using the font metrics of the knob's font.
*/
WidgetFont,

/**
* @brief Renders the labels in legacy mode. This uses a fixed font size and does not adhere
* to the font size that's set for the widget's font.
*
* @deprecated Do not use this mode in new code as it is considered deprecated and might be removed in the future.
*/
LegacyFixedFontSize
};

/**
* @brief Construct a Knob with the given style and no label.
*
* @param _knob_num Style of the knob
* @param _parent Parent widget
* @param _name Object name of the widget
*/
Knob( KnobType _knob_num, QWidget * _parent = nullptr, const QString & _name = QString() );

/**
* @brief Construct a Knob with the given style and label text.
*
* @param knobNum Style of the knob
* @param labelText Text for the label
* @param parent Parent widget
* @param labelRendering Determines if the label uses the widget font or a font with a fixed size of 12 pixels (LegacyFixedFontSize). The default is to use the widget font.
* @param name Object name of the widget
*/
Knob(KnobType knobNum, const QString& labelText, QWidget* parent = nullptr, LabelRendering labelRendering = LabelRendering::WidgetFont, const QString& name = QString());

/**
* @brief Constructs a knob with a label font in the pixel size.
*
* @param knobNum Style of the knob
* @param labelText Text for the label
* @param labelPixelSize Pixel size for the label
* @param parent Parent widget
* @param name Object name of the widget
*/
Knob(KnobType knobNum, const QString& labelText, int labelPixelSize, QWidget* parent, const QString& name = QString());

Knob( QWidget * _parent = nullptr, const QString & _name = QString() ); //!< default ctor

Knob( const Knob& other ) = delete;

void setLabel( const QString & txt );
void setHtmlLabel( const QString &htmltxt );

void setTotalAngle( float angle );
Expand Down Expand Up @@ -113,23 +167,55 @@ class LMMS_EXPORT Knob : public FloatModelEditorBase


protected:
void paintEvent( QPaintEvent * _me ) override;
void setLabel(const QString& txt);

void paintEvent(QPaintEvent*) override;

void changeEvent(QEvent * ev) override;

/*!
* Affects how the label of the knob is rendered.
*
* The default mode returns false. The height of the label text is taken into account when a new fixed
* size is computed for the Knob. When the label text is painted the descent of the font is used to
* compute the base line. The default mode returns false.
*
* Enabling fixed font size rendering mode leads to the following behavior:
* * The height of the label is not taken into account when the new fixed height of the Knob is computed.
* Instead a fixed size of 10 is added for the label.
* * When the knob is painted the baseline of the font is always set to 2 pixels away from the lower side
* of the Knob's rectangle.
* * The label is always rendered with a size of SMALL_FONT_SIZE.
*/
bool fixedFontSizeLabelRendering() const { return m_fixedFontSizeLabelRendering; }

/*!
* Set the button to legacy rendering mode which uses a fixed font size and that does not take the size
* of the widget's font into account.
*
* This can be thought of as a legacy mode which reinstates the old behavior of the knob.
*
* @see fixedFontSizeLabelRendering().
*/
void setFixedFontSizeLabelRendering();

private:
QLineF calculateLine( const QPointF & _mid, float _radius,
float _innerRadius = 1) const;

void drawKnob( QPainter * _p );
void drawLabel(QPainter& p);
bool updateAngle();

int angleFromValue( float value, float minValue, float maxValue, float totalAngle ) const
{
return static_cast<int>( ( value - 0.5 * ( minValue + maxValue ) ) / ( maxValue - minValue ) * m_totalAngle ) % 360;
}

void updateFixedSize();

QString m_label;
bool m_fixedFontSizeLabelRendering = false;
bool m_isHtmlLabel;
QTextDocument* m_tdRenderer;

Expand Down
23 changes: 23 additions & 0 deletions include/TempoSyncKnob.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ class LMMS_EXPORT TempoSyncKnob : public Knob
Q_OBJECT
public:
TempoSyncKnob( KnobType knobNum, QWidget* parent = nullptr, const QString& name = QString() );

/**
* @brief Construct a TempoSyncKnob with the given style and label text.
*
* @param knobNum Style of the knob
* @param labelText Text for the label
* @param parent Parent widget
* @param labelRendering Determines if the label uses the widget font or a font with a fixed size of 12 pixels (LegacyFixedFontSize). The default is to use the widget font.
* @param name Object name of the widget
*/
TempoSyncKnob(KnobType knobNum, const QString& labelText, QWidget* parent = nullptr, LabelRendering labelRendering = LabelRendering::WidgetFont, const QString& name = QString());

/**
* @brief Constructs a tempo sync knob with a label font in the pixel size.
*
* @param knobNum Style of the knob
* @param labelText Text for the label
* @param labelPixelSize Pixel size for the label
* @param parent Parent widget
* @param name Object name of the widget
*/
TempoSyncKnob(KnobType knobNum, const QString& labelText, int labelPixelSize, QWidget* parent, const QString& name = QString());

~TempoSyncKnob() override;

const QString & syncDescription();
Expand Down
20 changes: 11 additions & 9 deletions plugins/Amplifier/AmplifierControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include "embed.h"
#include "Knob.h"

#include <QGridLayout>


namespace lmms::gui
{

Expand All @@ -38,23 +41,22 @@ AmplifierControlDialog::AmplifierControlDialog(AmplifierControls* controls) :
QPalette pal;
pal.setBrush(backgroundRole(), PLUGIN_NAME::getIconPixmap("artwork"));
setPalette(pal);
setFixedSize(100, 110);

QGridLayout* gridLayout = new QGridLayout(this);

auto makeKnob = [this](int x, int y, const QString& label, const QString& hintText, const QString& unit, FloatModel* model, bool isVolume)
auto makeKnob = [this](const QString& label, const QString& hintText, const QString& unit, FloatModel* model, bool isVolume)
{
Knob* newKnob = new Knob(KnobType::Bright26, this);
newKnob->move(x, y);
Knob* newKnob = new Knob(KnobType::Bright26, label, this);
newKnob->setModel(model);
newKnob->setLabel(label);
newKnob->setHintText(hintText, unit);
newKnob->setVolumeKnob(isVolume);
return newKnob;
};

makeKnob(16, 10, tr("VOL"), tr("Volume:"), "%", &controls->m_volumeModel, true);
makeKnob(57, 10, tr("PAN"), tr("Panning:"), "%", &controls->m_panModel, false);
makeKnob(16, 65, tr("LEFT"), tr("Left gain:"), "%", &controls->m_leftModel, true);
makeKnob(57, 65, tr("RIGHT"), tr("Right gain:"), "%", &controls->m_rightModel, true);
gridLayout->addWidget(makeKnob(tr("VOL"), tr("Volume:"), "%", &controls->m_volumeModel, true), 0, 0, Qt::AlignHCenter);
gridLayout->addWidget(makeKnob(tr("PAN"), tr("Panning:"), "%", &controls->m_panModel, false), 0, 1, Qt::AlignHCenter);
gridLayout->addWidget(makeKnob(tr("LEFT"), tr("Left gain:"), "%", &controls->m_leftModel, true), 1, 0, Qt::AlignHCenter);
gridLayout->addWidget(makeKnob(tr("RIGHT"), tr("Right gain:"), "%", &controls->m_rightModel, true), 1, 1, Qt::AlignHCenter);
}

} // namespace lmms::gui
6 changes: 3 additions & 3 deletions plugins/AudioFileProcessor/AudioFileProcessorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ AudioFileProcessorView::AudioFileProcessorView(Instrument* instrument,
m_ampKnob->setHintText(tr("Amplify:"), "%");

m_startKnob = new AudioFileProcessorWaveView::knob(this);
m_startKnob->move(45, 108);
m_startKnob->move(50, 108);
m_startKnob->setHintText(tr("Start point:"), "");

m_endKnob = new AudioFileProcessorWaveView::knob(this);
m_endKnob->move(125, 108);
m_endKnob->move(130, 108);
m_endKnob->setHintText(tr("End point:"), "");

m_loopKnob = new AudioFileProcessorWaveView::knob(this);
m_loopKnob->move(85, 108);
m_loopKnob->move(90, 108);
m_loopKnob->setHintText(tr("Loopback point:"), "");

// interpolation selector
Expand Down
1 change: 0 additions & 1 deletion plugins/AudioFileProcessor/AudioFileProcessorWaveView.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class AudioFileProcessorWaveView : public QWidget
m_waveView(0),
m_relatedKnob(0)
{
setFixedSize(37, 47);
}

void setWaveView(const AudioFileProcessorWaveView* wv)
Expand Down
10 changes: 3 additions & 7 deletions plugins/BassBooster/BassBoosterControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,22 @@ BassBoosterControlDialog::BassBoosterControlDialog( BassBoosterControls* control
QPalette pal;
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
setPalette( pal );
setFixedSize( 120, 60 );

auto tl = new QVBoxLayout(this);
tl->addSpacing( 4 );

auto l = new QHBoxLayout;

auto freqKnob = new Knob(KnobType::Bright26, this);
auto freqKnob = new Knob(KnobType::Bright26, tr("FREQ"), this);
freqKnob->setModel( &controls->m_freqModel );
freqKnob->setLabel( tr( "FREQ" ) );
freqKnob->setHintText( tr( "Frequency:" ) , "Hz" );

auto gainKnob = new Knob(KnobType::Bright26, this);
auto gainKnob = new Knob(KnobType::Bright26, tr("GAIN"), this);
gainKnob->setModel( &controls->m_gainModel );
gainKnob->setLabel( tr( "GAIN" ) );
gainKnob->setHintText( tr( "Gain:" ) , "" );

auto ratioKnob = new Knob(KnobType::Bright26, this);
auto ratioKnob = new Knob(KnobType::Bright26, tr("RATIO"), this);
ratioKnob->setModel( &controls->m_ratioModel );
ratioKnob->setLabel( tr( "RATIO" ) );
ratioKnob->setHintText( tr( "Ratio:" ) , "" );

l->addWidget( freqKnob );
Expand Down
26 changes: 12 additions & 14 deletions plugins/Bitcrush/BitcrushControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "embed.h"
#include "BitcrushControlDialog.h"
#include "BitcrushControls.h"
#include "FontHelper.h"
#include "LedCheckBox.h"
#include "Knob.h"

Expand All @@ -46,37 +47,37 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) :
setFixedSize( 181, 128 );

// labels
const auto labelFont = adjustedToPixelSize(font(), DEFAULT_FONT_SIZE);

auto inLabel = new QLabel(tr("IN"), this);
inLabel->setFont(labelFont);
inLabel->move( 24, 15 );

auto outLabel = new QLabel(tr("OUT"), this);
outLabel->setFont(labelFont);
outLabel->move( 139, 15 );

// input knobs
auto inGain = new Knob(KnobType::Bright26, this);
auto inGain = new Knob(KnobType::Bright26, tr("GAIN"), SMALL_FONT_SIZE, this);
inGain->move( 16, 32 );
inGain->setModel( & controls->m_inGain );
inGain->setLabel( tr( "GAIN" ) );
inGain->setHintText( tr( "Input gain:" ) , " dBFS" );

auto inNoise = new Knob(KnobType::Bright26, this);
auto inNoise = new Knob(KnobType::Bright26, tr("NOISE"), SMALL_FONT_SIZE, this);
inNoise->move( 14, 76 );
inNoise->setModel( & controls->m_inNoise );
inNoise->setLabel( tr( "NOISE" ) );
inNoise->setHintText( tr( "Input noise:" ) , "%" );


// output knobs
auto outGain = new Knob(KnobType::Bright26, this);
auto outGain = new Knob(KnobType::Bright26, tr("GAIN"), SMALL_FONT_SIZE, this);
outGain->move( 138, 32 );
outGain->setModel( & controls->m_outGain );
outGain->setLabel( tr( "GAIN" ) );
outGain->setHintText( tr( "Output gain:" ) , " dBFS" );

auto outClip = new Knob(KnobType::Bright26, this);
auto outClip = new Knob(KnobType::Bright26, tr("CLIP"), SMALL_FONT_SIZE, this);
outClip->move( 138, 76 );
outClip->setModel( & controls->m_outClip );
outClip->setLabel( tr( "CLIP" ) );
outClip->setHintText( tr( "Output clip:" ) , " dBFS");


Expand All @@ -94,24 +95,21 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) :


// rate crushing knobs
auto rate = new Knob(KnobType::Bright26, this);
auto rate = new Knob(KnobType::Bright26, tr("FREQ"), SMALL_FONT_SIZE, this);
rate->move( 59, 32 );
rate->setModel( & controls->m_rate );
rate->setLabel( tr( "FREQ" ) );
rate->setHintText( tr( "Sample rate:" ) , " Hz" );

auto stereoDiff = new Knob(KnobType::Bright26, this);
auto stereoDiff = new Knob(KnobType::Bright26, tr("STEREO"), SMALL_FONT_SIZE, this);
stereoDiff->move( 72, 76 );
stereoDiff->setModel( & controls->m_stereoDiff );
stereoDiff->setLabel( tr( "STEREO" ) );
stereoDiff->setHintText( tr( "Stereo difference:" ) , "%" );


// depth crushing knob
auto levels = new Knob(KnobType::Bright26, this);
auto levels = new Knob(KnobType::Bright26, tr("QUANT"), SMALL_FONT_SIZE, this);
levels->move( 92, 32 );
levels->setModel( & controls->m_levels );
levels->setLabel( tr( "QUANT" ) );
levels->setHintText( tr( "Levels:" ) , "" );
}

Expand Down
Loading