diff --git a/include/CustomTextKnob.h b/include/CustomTextKnob.h index 31a58415e6f..2b428faf81f 100644 --- a/include/CustomTextKnob.h +++ b/include/CustomTextKnob.h @@ -42,6 +42,8 @@ class LMMS_EXPORT CustomTextKnob : public Knob CustomTextKnob( const Knob& other ) = delete; + static CustomTextKnob* buildKnobWithSmallPixelFont(KnobType knobNum, QWidget* parent, const QString& description, const QString& label); + inline void setValueText(const QString & _value_text) { m_value_text = _value_text; diff --git a/include/Knob.h b/include/Knob.h index 3c3339a6fe7..a81e5472692 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -81,9 +81,34 @@ class LMMS_EXPORT Knob : public FloatModelEditorBase Knob( QWidget * _parent = nullptr, const QString & _name = QString() ); //!< default ctor Knob( const Knob& other ) = delete; - void setLabel( const QString & txt ); + static Knob* buildLegacyKnob(KnobType knobNum, const QString& label, QWidget* parent, const QString& name = QString()); + static Knob* buildKnobWithSmallPixelFont(KnobType knobNum, const QString& label, QWidget* parent, const QString& name = QString()); + + void setLabel(const QString& txt); void setHtmlLabel( const QString &htmltxt ); + /*! + * Legacy mode affects how the label of the knob is rendered. + * + * In non-legacy mode (the default) 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. + * + * Enabling legacy 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. + */ + bool legacyMode() const { return m_legacyMode; } + + /*! + * Set the button to legacy mode (true) or non-legacy mode (false). + * + * @see legacyMode(). + */ + void setLegacyMode(bool legacyMode); + void setTotalAngle( float angle ); // Begin styled knob accessors @@ -113,7 +138,7 @@ class LMMS_EXPORT Knob : public FloatModelEditorBase protected: - void paintEvent( QPaintEvent * _me ) override; + void paintEvent(QPaintEvent*) override; void changeEvent(QEvent * ev) override; @@ -122,6 +147,7 @@ class LMMS_EXPORT Knob : public FloatModelEditorBase 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 @@ -129,7 +155,10 @@ class LMMS_EXPORT Knob : public FloatModelEditorBase return static_cast( ( value - 0.5 * ( minValue + maxValue ) ) / ( maxValue - minValue ) * m_totalAngle ) % 360; } + void updateFixedSize(); + QString m_label; + bool m_legacyMode = false; bool m_isHtmlLabel; QTextDocument* m_tdRenderer; diff --git a/include/TempoSyncKnob.h b/include/TempoSyncKnob.h index b86320d13d3..70fe48041e3 100644 --- a/include/TempoSyncKnob.h +++ b/include/TempoSyncKnob.h @@ -44,6 +44,9 @@ class LMMS_EXPORT TempoSyncKnob : public Knob TempoSyncKnob( KnobType knobNum, QWidget* parent = nullptr, const QString& name = QString() ); ~TempoSyncKnob() override; + static TempoSyncKnob* buildLegacyKnob(KnobType knobNum, const QString& label, QWidget* parent); + static TempoSyncKnob* buildKnobWithSmallPixelFont(KnobType knobNum, const QString& label, QWidget* parent); + const QString & syncDescription(); void setSyncDescription( const QString & _new_description ); diff --git a/plugins/Amplifier/AmplifierControlDialog.cpp b/plugins/Amplifier/AmplifierControlDialog.cpp index 1fbc3729a08..0e40b43d1c7 100644 --- a/plugins/Amplifier/AmplifierControlDialog.cpp +++ b/plugins/Amplifier/AmplifierControlDialog.cpp @@ -28,6 +28,9 @@ #include "embed.h" #include "Knob.h" +#include + + namespace lmms::gui { @@ -38,23 +41,23 @@ 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, this); newKnob->setModel(model); - newKnob->setLabel(label); + 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 diff --git a/plugins/BassBooster/BassBoosterControlDialog.cpp b/plugins/BassBooster/BassBoosterControlDialog.cpp index 9efa07c0d36..76dfb337dbf 100644 --- a/plugins/BassBooster/BassBoosterControlDialog.cpp +++ b/plugins/BassBooster/BassBoosterControlDialog.cpp @@ -43,7 +43,6 @@ 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 ); @@ -52,17 +51,17 @@ BassBoosterControlDialog::BassBoosterControlDialog( BassBoosterControls* control auto freqKnob = new Knob(KnobType::Bright26, this); freqKnob->setModel( &controls->m_freqModel ); - freqKnob->setLabel( tr( "FREQ" ) ); + freqKnob->setLabel(tr("FREQ")); freqKnob->setHintText( tr( "Frequency:" ) , "Hz" ); auto gainKnob = new Knob(KnobType::Bright26, this); gainKnob->setModel( &controls->m_gainModel ); - gainKnob->setLabel( tr( "GAIN" ) ); + gainKnob->setLabel(tr("GAIN")); gainKnob->setHintText( tr( "Gain:" ) , "" ); auto ratioKnob = new Knob(KnobType::Bright26, this); ratioKnob->setModel( &controls->m_ratioModel ); - ratioKnob->setLabel( tr( "RATIO" ) ); + ratioKnob->setLabel(tr("RATIO")); ratioKnob->setHintText( tr( "Ratio:" ) , "" ); l->addWidget( freqKnob ); diff --git a/plugins/Bitcrush/BitcrushControlDialog.cpp b/plugins/Bitcrush/BitcrushControlDialog.cpp index 64c9b636160..59548d16845 100644 --- a/plugins/Bitcrush/BitcrushControlDialog.cpp +++ b/plugins/Bitcrush/BitcrushControlDialog.cpp @@ -29,6 +29,7 @@ #include "embed.h" #include "BitcrushControlDialog.h" #include "BitcrushControls.h" +#include "FontHelper.h" #include "LedCheckBox.h" #include "Knob.h" @@ -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 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("GAIN"), 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 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("NOISE"), 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 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("GAIN"), 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 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("CLIP"), this); outClip->move( 138, 76 ); outClip->setModel( & controls->m_outClip ); - outClip->setLabel( tr( "CLIP" ) ); outClip->setHintText( tr( "Output clip:" ) , " dBFS"); @@ -94,24 +95,21 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : // rate crushing knobs - auto rate = new Knob(KnobType::Bright26, this); + auto rate = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("FREQ"), 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 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("STEREO"), 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 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("QUANT"), this); levels->move( 92, 32 ); levels->setModel( & controls->m_levels ); - levels->setLabel( tr( "QUANT" ) ); levels->setHintText( tr( "Levels:" ) , "" ); } diff --git a/plugins/CarlaBase/Carla.cpp b/plugins/CarlaBase/Carla.cpp index 37cba078aa1..02b7b7a9206 100644 --- a/plugins/CarlaBase/Carla.cpp +++ b/plugins/CarlaBase/Carla.cpp @@ -1006,28 +1006,29 @@ void CarlaParamsView::refreshKnobs() for (uint32_t i = 0; i < m_carlaInstrument->m_paramModels.size(); ++i) { - bool enabled = m_carlaInstrument->m_paramModels[i]->enabled(); - m_knobs.push_back(new Knob(KnobType::Dark28, m_inputScrollAreaWidgetContent)); - QString name = (*m_carlaInstrument->m_paramModels[i]).displayName(); + const auto currentParamModel = m_carlaInstrument->m_paramModels[i]; + + bool enabled = currentParamModel->enabled(); + const QString name = currentParamModel->displayName(); + m_knobs.push_back(Knob::buildLegacyKnob(KnobType::Dark28, name, m_inputScrollAreaWidgetContent)); m_knobs[i]->setHintText(name, ""); - m_knobs[i]->setLabel(name); m_knobs[i]->setObjectName(name); // this is being used for filtering the knobs. // Set the newly created model to the knob. - m_knobs[i]->setModel(m_carlaInstrument->m_paramModels[i]); + m_knobs[i]->setModel(currentParamModel); m_knobs[i]->setEnabled(enabled); if (enabled) { // Collect group names - if (!groupNameList.contains(m_carlaInstrument->m_paramModels[i]->groupName())) + if (!groupNameList.contains(currentParamModel->groupName())) { - groupNameList.append(m_carlaInstrument->m_paramModels[i]->groupName()); + groupNameList.append(currentParamModel->groupName()); } // Store biggest knob width per group (so we can calc how many // knobs we can horizontaly fit) - uint8_t groupId = m_carlaInstrument->m_paramModels[i]->groupId(); + uint8_t groupId = currentParamModel->groupId(); if (m_maxKnobWidthPerGroup[groupId] < m_knobs[i]->width()) { m_maxKnobWidthPerGroup[groupId] = m_knobs[i]->width(); diff --git a/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp b/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp index a4f44f5d305..1843f39a515 100644 --- a/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp +++ b/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp @@ -49,22 +49,19 @@ CrossoverEQControlDialog::CrossoverEQControlDialog( CrossoverEQControls * contro setFixedSize( 167, 178 ); // knobs - auto xover12 = new Knob(KnobType::Bright26, this); + auto xover12 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, "1/2", this); xover12->move( 29, 11 ); xover12->setModel( & controls->m_xover12 ); - xover12->setLabel( "1/2" ); xover12->setHintText( tr( "Band 1/2 crossover:" ), " Hz" ); - auto xover23 = new Knob(KnobType::Bright26, this); + auto xover23 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, "2/3", this); xover23->move( 69, 11 ); xover23->setModel( & controls->m_xover23 ); - xover23->setLabel( "2/3" ); xover23->setHintText( tr( "Band 2/3 crossover:" ), " Hz" ); - auto xover34 = new Knob(KnobType::Bright26, this); + auto xover34 = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, "3/4", this); xover34->move( 109, 11 ); xover34->setModel( & controls->m_xover34 ); - xover34->setLabel( "3/4" ); xover34->setHintText( tr( "Band 3/4 crossover:" ), " Hz" ); QPixmap const fader_knob(PLUGIN_NAME::getIconPixmap("fader_knob2")); diff --git a/plugins/Delay/DelayControlsDialog.cpp b/plugins/Delay/DelayControlsDialog.cpp index 065b3d1e4e5..085ad880b27 100644 --- a/plugins/Delay/DelayControlsDialog.cpp +++ b/plugins/Delay/DelayControlsDialog.cpp @@ -44,32 +44,28 @@ DelayControlsDialog::DelayControlsDialog( DelayControls *controls ) : setPalette( pal ); setFixedSize( 300, 208 ); - auto sampleDelayKnob = new TempoSyncKnob(KnobType::Bright26, this); + auto sampleDelayKnob = TempoSyncKnob::buildLegacyKnob(KnobType::Bright26, tr("DELAY"), this); sampleDelayKnob->move( 10,14 ); sampleDelayKnob->setVolumeKnob( false ); sampleDelayKnob->setModel( &controls->m_delayTimeModel ); - sampleDelayKnob->setLabel( tr( "DELAY" ) ); sampleDelayKnob->setHintText( tr( "Delay time" ) + " ", " s" ); - auto feedbackKnob = new Knob(KnobType::Bright26, this); + auto feedbackKnob = Knob::buildLegacyKnob(KnobType::Bright26, tr("FDBK"), this); feedbackKnob->move( 11, 58 ); feedbackKnob->setVolumeKnob( true) ; feedbackKnob->setModel( &controls->m_feedbackModel); - feedbackKnob->setLabel( tr( "FDBK" ) ); feedbackKnob->setHintText( tr ( "Feedback amount" ) + " " , "" ); - auto lfoFreqKnob = new TempoSyncKnob(KnobType::Bright26, this); + auto lfoFreqKnob = TempoSyncKnob::buildLegacyKnob(KnobType::Bright26, tr("RATE"), this); lfoFreqKnob->move( 11, 119 ); lfoFreqKnob->setVolumeKnob( false ); lfoFreqKnob->setModel( &controls->m_lfoTimeModel ); - lfoFreqKnob->setLabel( tr( "RATE" ) ); lfoFreqKnob->setHintText( tr ( "LFO frequency") + " ", " s" ); - auto lfoAmtKnob = new TempoSyncKnob(KnobType::Bright26, this); + auto lfoAmtKnob = TempoSyncKnob::buildLegacyKnob(KnobType::Bright26, tr("AMNT"), this); lfoAmtKnob->move( 11, 159 ); lfoAmtKnob->setVolumeKnob( false ); lfoAmtKnob->setModel( &controls->m_lfoAmountModel ); - lfoAmtKnob->setLabel( tr( "AMNT" ) ); lfoAmtKnob->setHintText( tr ( "LFO amount" ) + " " , " s" ); auto outFader diff --git a/plugins/Dispersion/DispersionControlDialog.cpp b/plugins/Dispersion/DispersionControlDialog.cpp index 2879e7613ef..410bc4f53f4 100644 --- a/plugins/Dispersion/DispersionControlDialog.cpp +++ b/plugins/Dispersion/DispersionControlDialog.cpp @@ -31,6 +31,8 @@ #include "LcdSpinBox.h" #include "PixmapButton.h" +#include + namespace lmms::gui { @@ -43,39 +45,41 @@ DispersionControlDialog::DispersionControlDialog(DispersionControls* controls) : QPalette pal; pal.setBrush(backgroundRole(), PLUGIN_NAME::getIconPixmap("artwork")); setPalette(pal); - setFixedSize(207, 50); + + auto layout = new QHBoxLayout(this); LcdSpinBox * m_amountBox = new LcdSpinBox(3, this, "Amount"); m_amountBox->setModel(&controls->m_amountModel); - m_amountBox->move(5, 10); m_amountBox->setLabel(tr("AMOUNT")); m_amountBox->setToolTip(tr("Number of all-pass filters")); Knob * freqKnob = new Knob(KnobType::Bright26, this); - freqKnob->move(59, 8); freqKnob->setModel(&controls->m_freqModel); freqKnob->setLabel(tr("FREQ")); freqKnob->setHintText(tr("Frequency:") , " Hz"); Knob * resoKnob = new Knob(KnobType::Bright26, this); - resoKnob->move(99, 8); resoKnob->setModel(&controls->m_resoModel); resoKnob->setLabel(tr("RESO")); resoKnob->setHintText(tr("Resonance:") , " octaves"); Knob * feedbackKnob = new Knob(KnobType::Bright26, this); - feedbackKnob->move(139, 8); feedbackKnob->setModel(&controls->m_feedbackModel); feedbackKnob->setLabel(tr("FEED")); feedbackKnob->setHintText(tr("Feedback:") , ""); PixmapButton * dcButton = new PixmapButton(this, tr("DC Offset Removal")); - dcButton->move(176, 16); dcButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("dc_active")); dcButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("dc_inactive")); dcButton->setCheckable(true); dcButton->setModel(&controls->m_dcModel); dcButton->setToolTip(tr("Remove DC Offset")); + + layout->addWidget(m_amountBox); + layout->addWidget(freqKnob); + layout->addWidget(resoKnob); + layout->addWidget(feedbackKnob); + layout->addWidget(dcButton); } diff --git a/plugins/DualFilter/DualFilterControlDialog.cpp b/plugins/DualFilter/DualFilterControlDialog.cpp index a674a4a42c2..5273fd82276 100644 --- a/plugins/DualFilter/DualFilterControlDialog.cpp +++ b/plugins/DualFilter/DualFilterControlDialog.cpp @@ -35,10 +35,9 @@ namespace lmms::gui #define makeknob( name, x, y, model, label, hint, unit ) \ - Knob * name = new Knob( KnobType::Bright26, this); \ + Knob * name = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, label, this); \ (name) -> move( x, y ); \ (name) ->setModel( &controls-> model ); \ - (name) ->setLabel( label ); \ (name) ->setHintText( hint, unit ); diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp index bd076b946ba..78b540db04a 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp @@ -58,32 +58,28 @@ DynProcControlDialog::DynProcControlDialog( waveGraph->setGraphColor( QColor( 85, 204, 145 ) ); waveGraph -> setMaximumSize( 204, 205 ); - auto inputKnob = new Knob(KnobType::Bright26, this); + auto inputKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("INPUT"), this); inputKnob -> setVolumeKnob( true ); inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 26, 223 ); inputKnob->setModel( &_controls->m_inputModel ); - inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) , "" ); - auto outputKnob = new Knob(KnobType::Bright26, this); + auto outputKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("OUTPUT"), this); outputKnob -> setVolumeKnob( true ); outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 76, 223 ); outputKnob->setModel( &_controls->m_outputModel ); - outputKnob->setLabel( tr( "OUTPUT" ) ); outputKnob->setHintText( tr( "Output gain:" ) , "" ); - auto attackKnob = new Knob(KnobType::Bright26, this); + auto attackKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("ATTACK"), this); attackKnob -> move( 24, 268 ); attackKnob->setModel( &_controls->m_attackModel ); - attackKnob->setLabel( tr( "ATTACK" ) ); attackKnob->setHintText( tr( "Peak attack time:" ) , "ms" ); - auto releaseKnob = new Knob(KnobType::Bright26, this); + auto releaseKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("RELEASE"), this); releaseKnob -> move( 74, 268 ); releaseKnob->setModel( &_controls->m_releaseModel ); - releaseKnob->setLabel( tr( "RELEASE" ) ); releaseKnob->setHintText( tr( "Peak release time:" ) , "ms" ); //wavegraph control buttons diff --git a/plugins/Flanger/FlangerControlsDialog.cpp b/plugins/Flanger/FlangerControlsDialog.cpp index 3ac5dc9c638..6073e6dffcf 100644 --- a/plugins/Flanger/FlangerControlsDialog.cpp +++ b/plugins/Flanger/FlangerControlsDialog.cpp @@ -29,6 +29,8 @@ #include "LedCheckBox.h" #include "TempoSyncKnob.h" +#include + namespace lmms::gui { @@ -40,55 +42,57 @@ FlangerControlsDialog::FlangerControlsDialog( FlangerControls *controls ) : QPalette pal; pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); - setFixedSize( 233, 75 ); + + auto mainLayout = new QVBoxLayout(this); + auto knobLayout = new QHBoxLayout(); + mainLayout->addLayout(knobLayout); auto delayKnob = new Knob(KnobType::Bright26, this); - delayKnob->move( 10,10 ); delayKnob->setVolumeKnob( false ); delayKnob->setModel( &controls->m_delayTimeModel ); delayKnob->setLabel( tr( "DELAY" ) ); delayKnob->setHintText( tr( "Delay time:" ) + " ", "s" ); auto lfoFreqKnob = new TempoSyncKnob(KnobType::Bright26, this); - lfoFreqKnob->move( 48,10 ); lfoFreqKnob->setVolumeKnob( false ); lfoFreqKnob->setModel( &controls->m_lfoFrequencyModel ); lfoFreqKnob->setLabel( tr( "RATE" ) ); lfoFreqKnob->setHintText( tr( "Period:" ) , " Sec" ); auto lfoAmtKnob = new Knob(KnobType::Bright26, this); - lfoAmtKnob->move( 85,10 ); lfoAmtKnob->setVolumeKnob( false ); lfoAmtKnob->setModel( &controls->m_lfoAmountModel ); lfoAmtKnob->setLabel( tr( "AMNT" ) ); lfoAmtKnob->setHintText( tr( "Amount:" ) , "" ); auto lfoPhaseKnob = new Knob(KnobType::Bright26, this); - lfoPhaseKnob->move( 123,10 ); lfoPhaseKnob->setVolumeKnob( false ); lfoPhaseKnob->setModel( &controls->m_lfoPhaseModel ); lfoPhaseKnob->setLabel( tr( "PHASE" ) ); lfoPhaseKnob->setHintText( tr( "Phase:" ) , " degrees" ); auto feedbackKnob = new Knob(KnobType::Bright26, this); - feedbackKnob->move( 160,10 ); feedbackKnob->setVolumeKnob( true) ; feedbackKnob->setModel( &controls->m_feedbackModel ); feedbackKnob->setLabel( tr( "FDBK" ) ); feedbackKnob->setHintText( tr( "Feedback amount:" ) , "" ); auto whiteNoiseKnob = new Knob(KnobType::Bright26, this); - whiteNoiseKnob->move( 196,10 ); whiteNoiseKnob->setVolumeKnob( true) ; whiteNoiseKnob->setModel( &controls->m_whiteNoiseAmountModel ); whiteNoiseKnob->setLabel( tr( "NOISE" ) ); whiteNoiseKnob->setHintText( tr( "White noise amount:" ) , "" ); - auto invertCb = new LedCheckBox(tr("Invert"), this); - invertCb->move( 10,53 ); - - + knobLayout->addWidget(delayKnob); + knobLayout->addWidget(lfoFreqKnob); + knobLayout->addWidget(lfoAmtKnob); + knobLayout->addWidget(lfoPhaseKnob); + knobLayout->addWidget(feedbackKnob); + knobLayout->addWidget(whiteNoiseKnob); + auto invertCb = new LedCheckBox(tr("Invert"), this); + + mainLayout->addWidget(invertCb, 0, Qt::AlignLeft); } diff --git a/plugins/Lb302/Lb302.cpp b/plugins/Lb302/Lb302.cpp index 9cb82bd7c90..510554eba6d 100644 --- a/plugins/Lb302/Lb302.cpp +++ b/plugins/Lb302/Lb302.cpp @@ -831,22 +831,18 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : m_vcfCutKnob = new Knob( KnobType::Bright26, this ); m_vcfCutKnob->move( 75, 130 ); m_vcfCutKnob->setHintText( tr( "Cutoff Freq:" ), "" ); - m_vcfCutKnob->setLabel( "" ); m_vcfResKnob = new Knob( KnobType::Bright26, this ); m_vcfResKnob->move( 120, 130 ); m_vcfResKnob->setHintText( tr( "Resonance:" ), "" ); - m_vcfResKnob->setLabel( "" ); m_vcfModKnob = new Knob( KnobType::Bright26, this ); m_vcfModKnob->move( 165, 130 ); m_vcfModKnob->setHintText( tr( "Env Mod:" ), "" ); - m_vcfModKnob->setLabel( "" ); m_vcfDecKnob = new Knob( KnobType::Bright26, this ); m_vcfDecKnob->move( 210, 130 ); m_vcfDecKnob->setHintText( tr( "Decay:" ), "" ); - m_vcfDecKnob->setLabel( "" ); m_slideToggle = new LedCheckBox( "", this ); m_slideToggle->move( 10, 180 ); @@ -867,12 +863,10 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : m_slideDecKnob = new Knob( KnobType::Bright26, this ); m_slideDecKnob->move( 210, 75 ); m_slideDecKnob->setHintText( tr( "Slide Decay:" ), "" ); - m_slideDecKnob->setLabel( ""); m_distKnob = new Knob( KnobType::Bright26, this ); m_distKnob->move( 210, 190 ); m_distKnob->setHintText( tr( "DIST:" ), "" ); - m_distKnob->setLabel( tr( "")); // Shapes diff --git a/plugins/MultitapEcho/MultitapEchoControlDialog.cpp b/plugins/MultitapEcho/MultitapEchoControlDialog.cpp index e89137bf0b7..b330e1bdd40 100644 --- a/plugins/MultitapEcho/MultitapEchoControlDialog.cpp +++ b/plugins/MultitapEcho/MultitapEchoControlDialog.cpp @@ -78,22 +78,19 @@ MultitapEchoControlDialog::MultitapEchoControlDialog( MultitapEchoControls * con // knobs - auto stepLength = new TempoSyncKnob(KnobType::Bright26, this); + auto stepLength = TempoSyncKnob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("Length"), this); stepLength->move( 100, 245 ); stepLength->setModel( & controls->m_stepLength ); - stepLength->setLabel( tr( "Length" ) ); stepLength->setHintText( tr( "Step length:" ) , " ms" ); - auto dryGain = new Knob(KnobType::Bright26, this); + auto dryGain = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("Dry"), this); dryGain->move( 150, 245 ); dryGain->setModel( & controls->m_dryGain ); - dryGain->setLabel( tr( "Dry" ) ); dryGain->setHintText( tr( "Dry gain:" ) , " dBFS" ); - auto stages = new Knob(KnobType::Bright26, this); + auto stages = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("Stages"), this); stages->move( 200, 245 ); stages->setModel( & controls->m_stages ); - stages->setLabel( tr( "Stages" ) ); stages->setHintText( tr( "Low-pass stages:" ) , "x" ); // switch led diff --git a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp index e44d5bcc246..19467de634f 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp @@ -47,35 +47,34 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( QPalette pal; pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); - setFixedSize( 240, 80 ); m_baseKnob = new Knob( KnobType::Bright26, this ); - m_baseKnob->setLabel( tr( "BASE" ) ); + m_baseKnob->setLabel(tr("BASE")); m_baseKnob->setModel( &_controls->m_baseModel ); m_baseKnob->setHintText( tr( "Base:" ) , "" ); m_amountKnob = new Knob( KnobType::Bright26, this ); - m_amountKnob->setLabel( tr( "AMNT" ) ); + m_amountKnob->setLabel(tr("AMNT")); m_amountKnob->setModel( &_controls->m_amountModel ); m_amountKnob->setHintText( tr( "Modulation amount:" ) , "" ); m_amountMultKnob = new Knob( KnobType::Bright26, this ); - m_amountMultKnob->setLabel( tr( "MULT" ) ); + m_amountMultKnob->setLabel(tr("MULT")); m_amountMultKnob->setModel( &_controls->m_amountMultModel ); m_amountMultKnob->setHintText( tr( "Amount multiplicator:" ) , "" ); m_attackKnob = new Knob( KnobType::Bright26, this ); - m_attackKnob->setLabel( tr( "ATCK" ) ); + m_attackKnob->setLabel(tr("ATCK")); m_attackKnob->setModel( &_controls->m_attackModel ); m_attackKnob->setHintText( tr( "Attack:" ) , "" ); m_decayKnob = new Knob( KnobType::Bright26, this ); - m_decayKnob->setLabel( tr( "DCAY" ) ); + m_decayKnob->setLabel(tr("DCAY")); m_decayKnob->setModel( &_controls->m_decayModel ); m_decayKnob->setHintText( tr( "Release:" ) , "" ); m_tresholdKnob = new Knob( KnobType::Bright26, this ); - m_tresholdKnob->setLabel( tr( "TRSH" ) ); + m_tresholdKnob->setLabel(tr("TRSH")); m_tresholdKnob->setModel( &_controls->m_tresholdModel ); m_tresholdKnob->setHintText( tr( "Treshold:" ) , "" ); diff --git a/plugins/ReverbSC/ReverbSCControlDialog.cpp b/plugins/ReverbSC/ReverbSCControlDialog.cpp index 615d3823e60..9bc0992e143 100644 --- a/plugins/ReverbSC/ReverbSCControlDialog.cpp +++ b/plugins/ReverbSC/ReverbSCControlDialog.cpp @@ -29,6 +29,8 @@ #include "Knob.h" #include "ReverbSCControls.h" +#include + namespace lmms::gui { @@ -40,31 +42,33 @@ ReverbSCControlDialog::ReverbSCControlDialog( ReverbSCControls* controls ) : QPalette pal; pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); - setFixedSize( 185, 55 ); + + auto knobLayout = new QHBoxLayout(this); auto inputGainKnob = new Knob(KnobType::Bright26, this); - inputGainKnob -> move( 16, 10 ); inputGainKnob->setModel( &controls->m_inputGainModel ); - inputGainKnob->setLabel( tr( "Input" ) ); + inputGainKnob->setLabel(tr("Input")); inputGainKnob->setHintText( tr( "Input gain:" ) , "dB" ); auto sizeKnob = new Knob(KnobType::Bright26, this); - sizeKnob -> move( 57, 10 ); sizeKnob->setModel( &controls->m_sizeModel ); - sizeKnob->setLabel( tr( "Size" ) ); + sizeKnob->setLabel(tr("Size")); sizeKnob->setHintText( tr( "Size:" ) , "" ); auto colorKnob = new Knob(KnobType::Bright26, this); - colorKnob -> move( 98, 10 ); colorKnob->setModel( &controls->m_colorModel ); - colorKnob->setLabel( tr( "Color" ) ); + colorKnob->setLabel(tr("Color")); colorKnob->setHintText( tr( "Color:" ) , "" ); auto outputGainKnob = new Knob(KnobType::Bright26, this); - outputGainKnob -> move( 139, 10 ); outputGainKnob->setModel( &controls->m_outputGainModel ); - outputGainKnob->setLabel( tr( "Output" ) ); + outputGainKnob->setLabel(tr("Output")); outputGainKnob->setHintText( tr( "Output gain:" ) , "dB" ); + + knobLayout->addWidget(inputGainKnob); + knobLayout->addWidget(sizeKnob); + knobLayout->addWidget(colorKnob); + knobLayout->addWidget(outputGainKnob); } diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp index 2b0ca4fecf7..9c6406dab9f 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp @@ -236,41 +236,36 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) controls_layout->setStretchFactor(advanced_widget, 10); // Peak envelope resolution - auto envelopeResolutionKnob = new Knob(KnobType::Small17, this); + auto envelopeResolutionKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Envelope res."), this); envelopeResolutionKnob->setModel(&controls->m_envelopeResolutionModel); - envelopeResolutionKnob->setLabel(tr("Envelope res.")); envelopeResolutionKnob->setToolTip(tr("Increase envelope resolution for better details, decrease for better GUI performance.")); envelopeResolutionKnob->setHintText(tr("Maximum number of envelope points drawn per pixel:"), ""); advanced_layout->addWidget(envelopeResolutionKnob, 0, 0, 1, 1, Qt::AlignCenter); // Spectrum graph resolution - auto spectrumResolutionKnob = new Knob(KnobType::Small17, this); + auto spectrumResolutionKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Spectrum res."), this); spectrumResolutionKnob->setModel(&controls->m_spectrumResolutionModel); - spectrumResolutionKnob->setLabel(tr("Spectrum res.")); spectrumResolutionKnob->setToolTip(tr("Increase spectrum resolution for better details, decrease for better GUI performance.")); spectrumResolutionKnob->setHintText(tr("Maximum number of spectrum points drawn per pixel:"), ""); advanced_layout->addWidget(spectrumResolutionKnob, 1, 0, 1, 1, Qt::AlignCenter); // Peak falloff speed - auto peakDecayFactorKnob = new Knob(KnobType::Small17, this); + auto peakDecayFactorKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Falloff factor"), this); peakDecayFactorKnob->setModel(&controls->m_peakDecayFactorModel); - peakDecayFactorKnob->setLabel(tr("Falloff factor")); peakDecayFactorKnob->setToolTip(tr("Decrease to make peaks fall faster.")); peakDecayFactorKnob->setHintText(tr("Multiply buffered value by"), ""); advanced_layout->addWidget(peakDecayFactorKnob, 0, 1, 1, 1, Qt::AlignCenter); // Averaging weight - auto averagingWeightKnob = new Knob(KnobType::Small17, this); + auto averagingWeightKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Averaging weight"), this); averagingWeightKnob->setModel(&controls->m_averagingWeightModel); - averagingWeightKnob->setLabel(tr("Averaging weight")); averagingWeightKnob->setToolTip(tr("Decrease to make averaging slower and smoother.")); averagingWeightKnob->setHintText(tr("New sample contributes"), ""); advanced_layout->addWidget(averagingWeightKnob, 1, 1, 1, 1, Qt::AlignCenter); // Waterfall history size - auto waterfallHeightKnob = new Knob(KnobType::Small17, this); + auto waterfallHeightKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Waterfall height"), this); waterfallHeightKnob->setModel(&controls->m_waterfallHeightModel); - waterfallHeightKnob->setLabel(tr("Waterfall height")); waterfallHeightKnob->setToolTip(tr("Increase to get slower scrolling, decrease to see fast transitions better. Warning: medium CPU usage.")); waterfallHeightKnob->setHintText(tr("Number of lines to keep:"), ""); advanced_layout->addWidget(waterfallHeightKnob, 0, 2, 1, 1, Qt::AlignCenter); @@ -278,25 +273,22 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) connect(&controls->m_waterfallHeightModel, &FloatModel::dataChanged, [=] {processor->reallocateBuffers();}); // Waterfall gamma correction - auto waterfallGammaKnob = new Knob(KnobType::Small17, this); + auto waterfallGammaKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Waterfall gamma"), this); waterfallGammaKnob->setModel(&controls->m_waterfallGammaModel); - waterfallGammaKnob->setLabel(tr("Waterfall gamma")); waterfallGammaKnob->setToolTip(tr("Decrease to see very weak signals, increase to get better contrast.")); waterfallGammaKnob->setHintText(tr("Gamma value:"), ""); advanced_layout->addWidget(waterfallGammaKnob, 1, 2, 1, 1, Qt::AlignCenter); // FFT window overlap - auto windowOverlapKnob = new Knob(KnobType::Small17, this); + auto windowOverlapKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Window overlap"), this); windowOverlapKnob->setModel(&controls->m_windowOverlapModel); - windowOverlapKnob->setLabel(tr("Window overlap")); windowOverlapKnob->setToolTip(tr("Increase to prevent missing fast transitions arriving near FFT window edges. Warning: high CPU usage.")); windowOverlapKnob->setHintText(tr("Number of times each sample is processed:"), ""); advanced_layout->addWidget(windowOverlapKnob, 0, 3, 1, 1, Qt::AlignCenter); // FFT zero padding - auto zeroPaddingKnob = new Knob(KnobType::Small17, this); + auto zeroPaddingKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Small17, tr("Zero padding"), this); zeroPaddingKnob->setModel(&controls->m_zeroPaddingModel); - zeroPaddingKnob->setLabel(tr("Zero padding")); zeroPaddingKnob->setToolTip(tr("Increase to get smoother-looking spectrum. Warning: high CPU usage.")); zeroPaddingKnob->setHintText(tr("Processing buffer is"), tr(" steps larger than input block")); advanced_layout->addWidget(zeroPaddingKnob, 1, 3, 1, 1, Qt::AlignCenter); diff --git a/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp b/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp index 05c78616e56..845b34ac8d2 100644 --- a/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp +++ b/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp @@ -42,7 +42,7 @@ StereoEnhancerControlDialog::StereoEnhancerControlDialog( auto widthKnob = new Knob(KnobType::Bright26, this); widthKnob->setModel( &_controls->m_widthModel ); - widthKnob->setLabel( tr( "WIDTH" ) ); + widthKnob->setLabel(tr("WIDTH")); widthKnob->setHintText( tr( "Width:" ) , " samples" ); l->addWidget( widthKnob ); diff --git a/plugins/Stk/Mallets/Mallets.cpp b/plugins/Stk/Mallets/Mallets.cpp index 00ddbf422fb..ca615db9004 100644 --- a/plugins/Stk/Mallets/Mallets.cpp +++ b/plugins/Stk/Mallets/Mallets.cpp @@ -453,13 +453,11 @@ MalletsInstrumentView::MalletsInstrumentView( MalletsInstrument * _instrument, connect( &_instrument->m_presetsModel, SIGNAL( dataChanged() ), this, SLOT( changePreset() ) ); - m_spreadKnob = new Knob( KnobType::Vintage32, this ); - m_spreadKnob->setLabel( tr( "Spread" ) ); + m_spreadKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Spread"), this); m_spreadKnob->move( 190, 140 ); m_spreadKnob->setHintText( tr( "Spread:" ), "" ); - m_randomKnob = new Knob(KnobType::Vintage32, this); - m_randomKnob->setLabel(tr("Random")); + m_randomKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Random"), this); m_randomKnob->move(190, 190); m_randomKnob->setHintText(tr("Random:"), ""); @@ -494,28 +492,23 @@ QWidget * MalletsInstrumentView::setupModalBarControls( QWidget * _parent ) auto widget = new QWidget(_parent); widget->setFixedSize( 250, 250 ); - m_hardnessKnob = new Knob( KnobType::Vintage32, widget ); - m_hardnessKnob->setLabel( tr( "Hardness" ) ); + m_hardnessKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Hardness"), widget); m_hardnessKnob->move( 30, 90 ); m_hardnessKnob->setHintText( tr( "Hardness:" ), "" ); - m_positionKnob = new Knob( KnobType::Vintage32, widget ); - m_positionKnob->setLabel( tr( "Position" ) ); + m_positionKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Position"), widget); m_positionKnob->move( 110, 90 ); m_positionKnob->setHintText( tr( "Position:" ), "" ); - m_vibratoGainKnob = new Knob( KnobType::Vintage32, widget ); - m_vibratoGainKnob->setLabel( tr( "Vibrato gain" ) ); + m_vibratoGainKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Vibrato gain"), widget); m_vibratoGainKnob->move( 30, 140 ); m_vibratoGainKnob->setHintText( tr( "Vibrato gain:" ), "" ); - m_vibratoFreqKnob = new Knob( KnobType::Vintage32, widget ); - m_vibratoFreqKnob->setLabel( tr( "Vibrato frequency" ) ); + m_vibratoFreqKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Vibrato frequency"), widget); m_vibratoFreqKnob->move( 110, 140 ); m_vibratoFreqKnob->setHintText( tr( "Vibrato frequency:" ), "" ); - m_stickKnob = new Knob( KnobType::Vintage32, widget ); - m_stickKnob->setLabel( tr( "Stick mix" ) ); + m_stickKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Stick mix"), widget); m_stickKnob->move( 190, 90 ); m_stickKnob->setHintText( tr( "Stick mix:" ), "" ); @@ -530,28 +523,23 @@ QWidget * MalletsInstrumentView::setupTubeBellControls( QWidget * _parent ) auto widget = new QWidget(_parent); widget->setFixedSize( 250, 250 ); - m_modulatorKnob = new Knob( KnobType::Vintage32, widget ); - m_modulatorKnob->setLabel( tr( "Modulator" ) ); + m_modulatorKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Modulator"), widget); m_modulatorKnob->move( 30, 90 ); m_modulatorKnob->setHintText( tr( "Modulator:" ), "" ); - m_crossfadeKnob = new Knob( KnobType::Vintage32, widget ); - m_crossfadeKnob->setLabel( tr( "Crossfade" ) ); + m_crossfadeKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Crossfade"), widget); m_crossfadeKnob->move( 110, 90 ); m_crossfadeKnob->setHintText( tr( "Crossfade:" ), "" ); - m_lfoSpeedKnob = new Knob( KnobType::Vintage32, widget ); - m_lfoSpeedKnob->setLabel( tr( "LFO speed" ) ); + m_lfoSpeedKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("LFO speed"), widget); m_lfoSpeedKnob->move( 30, 140 ); m_lfoSpeedKnob->setHintText( tr( "LFO speed:" ), "" ); - m_lfoDepthKnob = new Knob( KnobType::Vintage32, widget ); - m_lfoDepthKnob->setLabel( tr( "LFO depth" ) ); + m_lfoDepthKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("LFO depth"), widget); m_lfoDepthKnob->move( 110, 140 ); m_lfoDepthKnob->setHintText( tr( "LFO depth:" ), "" ); - m_adsrKnob = new Knob( KnobType::Vintage32, widget ); - m_adsrKnob->setLabel( tr( "ADSR" ) ); + m_adsrKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("ADSR"), widget); m_adsrKnob->move( 190, 90 ); m_adsrKnob->setHintText( tr( "ADSR:" ), "" ); @@ -570,23 +558,19 @@ QWidget * MalletsInstrumentView::setupBandedWGControls( QWidget * _parent ) /* m_strikeLED = new LedCheckBox( tr( "Bowed" ), widget ); m_strikeLED->move( 138, 25 );*/ - m_pressureKnob = new Knob( KnobType::Vintage32, widget ); - m_pressureKnob->setLabel( tr( "Pressure" ) ); + m_pressureKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Pressure"), widget); m_pressureKnob->move( 30, 90 ); m_pressureKnob->setHintText( tr( "Pressure:" ), "" ); -/* m_motionKnob = new Knob( KnobType::Vintage32, widget ); - m_motionKnob->setLabel( tr( "Motion" ) ); +/* m_motionKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Motion"), widget); m_motionKnob->move( 110, 90 ); m_motionKnob->setHintText( tr( "Motion:" ), "" );*/ - m_velocityKnob = new Knob( KnobType::Vintage32, widget ); - m_velocityKnob->setLabel( tr( "Speed" ) ); + m_velocityKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Speed"), widget); m_velocityKnob->move( 30, 140 ); m_velocityKnob->setHintText( tr( "Speed:" ), "" ); -/* m_vibratoKnob = new Knob( KnobType::Vintage32, widget, tr( "Vibrato" ) ); - m_vibratoKnob->setLabel( tr( "Vibrato" ) ); +/* m_vibratoKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Vintage32, tr("Vibrato"), widget); m_vibratoKnob->move( 110, 140 ); m_vibratoKnob->setHintText( tr( "Vibrato:" ), "" );*/ diff --git a/plugins/Vectorscope/VecControlsDialog.cpp b/plugins/Vectorscope/VecControlsDialog.cpp index cd280508980..73fe96c12ec 100644 --- a/plugins/Vectorscope/VecControlsDialog.cpp +++ b/plugins/Vectorscope/VecControlsDialog.cpp @@ -78,6 +78,8 @@ VecControlsDialog::VecControlsDialog(VecControls *controls) : // Persistence knob auto persistenceKnob = new Knob(KnobType::Small17, this); + // Make the font the same size as the other controls + persistenceKnob->setFont(highQualityButton->font()); persistenceKnob->setModel(&controls->m_persistenceModel); persistenceKnob->setLabel(tr("Persist.")); persistenceKnob->setToolTip(tr("Trace persistence: higher amount means the trace will stay bright for longer time.")); diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index 5a7d4afa059..c43338b6839 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -990,9 +990,11 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume sprintf(paramStr.data(), "param%d", i); s_dumpValues = dump[paramStr.data()].split(":"); - vstKnobs[ i ] = new CustomTextKnob( KnobType::Bright26, this, s_dumpValues.at( 1 ) ); - vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); - vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); + const auto & description = s_dumpValues.at(1); + + auto knob = CustomTextKnob::buildKnobWithSmallPixelFont(KnobType::Bright26, this, description, description.left(15)); + knob->setDescription(description + ":" ); + vstKnobs[i] = knob; if( !hasKnobModel ) { diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index c9eb4923451..e19dbac1c41 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -389,9 +389,11 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * sprintf(paramStr.data(), "param%d", i); s_dumpValues = dump[paramStr.data()].split(":"); - vstKnobs[ i ] = new CustomTextKnob( KnobType::Bright26, widget, s_dumpValues.at( 1 ) ); - vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); - vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); + const auto & description = s_dumpValues.at(1); + + auto knob = CustomTextKnob::buildKnobWithSmallPixelFont(KnobType::Bright26, widget, description, description.left(15)); + knob->setDescription(description + ":" ); + vstKnobs[i] = knob; if( !hasKnobModel ) { diff --git a/plugins/WaveShaper/WaveShaperControlDialog.cpp b/plugins/WaveShaper/WaveShaperControlDialog.cpp index 045f84763f6..2a2be239e92 100644 --- a/plugins/WaveShaper/WaveShaperControlDialog.cpp +++ b/plugins/WaveShaper/WaveShaperControlDialog.cpp @@ -59,20 +59,18 @@ WaveShaperControlDialog::WaveShaperControlDialog( waveGraph->setGraphColor( QColor( 85, 204, 145 ) ); waveGraph -> setMaximumSize( 204, 205 ); - auto inputKnob = new Knob(KnobType::Bright26, this); + auto inputKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("INPUT"), this); inputKnob -> setVolumeKnob( true ); inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 26, 225 ); inputKnob->setModel( &_controls->m_inputModel ); - inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) , "" ); - auto outputKnob = new Knob(KnobType::Bright26, this); + auto outputKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("OUTPUT"), this); outputKnob -> setVolumeKnob( true ); outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 76, 225 ); outputKnob->setModel( &_controls->m_outputModel ); - outputKnob->setLabel( tr( "OUTPUT" ) ); outputKnob->setHintText( tr( "Output gain:" ), "" ); auto resetButton = new PixmapButton(this, tr("Reset wavegraph")); diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.cpp b/plugins/ZynAddSubFx/ZynAddSubFx.cpp index 19864932d8a..e43b39febb5 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/ZynAddSubFx.cpp @@ -512,33 +512,26 @@ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ) l->setVerticalSpacing( 16 ); l->setHorizontalSpacing( 10 ); - m_portamento = new Knob( KnobType::Bright26, this ); + m_portamento = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("PORT"), this); m_portamento->setHintText( tr( "Portamento:" ), "" ); - m_portamento->setLabel( tr( "PORT" ) ); - m_filterFreq = new Knob( KnobType::Bright26, this ); + m_filterFreq = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("FREQ"), this); m_filterFreq->setHintText( tr( "Filter frequency:" ), "" ); - m_filterFreq->setLabel( tr( "FREQ" ) ); - m_filterQ = new Knob( KnobType::Bright26, this ); + m_filterQ = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("RES"), this); m_filterQ->setHintText( tr( "Filter resonance:" ), "" ); - m_filterQ->setLabel( tr( "RES" ) ); - m_bandwidth = new Knob( KnobType::Bright26, this ); + m_bandwidth = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("BW"), this); m_bandwidth->setHintText( tr( "Bandwidth:" ), "" ); - m_bandwidth->setLabel( tr( "BW" ) ); - m_fmGain = new Knob( KnobType::Bright26, this ); + m_fmGain = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("FM GAIN"), this); m_fmGain->setHintText( tr( "FM gain:" ), "" ); - m_fmGain->setLabel( tr( "FM GAIN" ) ); - m_resCenterFreq = new Knob( KnobType::Bright26, this ); + m_resCenterFreq = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("RES CF"), this); m_resCenterFreq->setHintText( tr( "Resonance center frequency:" ), "" ); - m_resCenterFreq->setLabel( tr( "RES CF" ) ); - m_resBandwidth = new Knob( KnobType::Bright26, this ); + m_resBandwidth = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("RES BW"), this); m_resBandwidth->setHintText( tr( "Resonance bandwidth:" ), "" ); - m_resBandwidth->setLabel( tr( "RES BW" ) ); m_forwardMidiCC = new LedCheckBox( tr( "Forward MIDI control changes" ), this ); diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 209b0fce1f9..ddf9e72d143 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -38,7 +38,10 @@ namespace lmms::gui { -void KnobControl::setText(const QString &text) { m_knob->setLabel(text); } +void KnobControl::setText(const QString& text) +{ + m_knob->setLabel(text); +} QWidget *KnobControl::topWidget() { return m_knob; } diff --git a/src/gui/EffectView.cpp b/src/gui/EffectView.cpp index a5095ee6d13..ed6b18fa680 100644 --- a/src/gui/EffectView.cpp +++ b/src/gui/EffectView.cpp @@ -64,22 +64,19 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) : m_bypass->setToolTip(tr("On/Off")); - m_wetDry = new Knob( KnobType::Bright26, this ); - m_wetDry->setLabel( tr( "W/D" ) ); + m_wetDry = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("W/D"), this); m_wetDry->move( 40 - m_wetDry->width() / 2, 5 ); m_wetDry->setEnabled( isEnabled ); m_wetDry->setHintText( tr( "Wet Level:" ), "" ); - m_autoQuit = new TempoSyncKnob( KnobType::Bright26, this ); - m_autoQuit->setLabel( tr( "DECAY" ) ); + m_autoQuit = TempoSyncKnob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("DECAY"), this); m_autoQuit->move( 78 - m_autoQuit->width() / 2, 5 ); m_autoQuit->setEnabled( isEnabled && !effect()->m_autoQuitDisabled ); m_autoQuit->setHintText( tr( "Time:" ), "ms" ); - m_gate = new Knob( KnobType::Bright26, this ); - m_gate->setLabel( tr( "GATE" ) ); + m_gate = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("GATE"), this); m_gate->move( 116 - m_gate->width() / 2, 5 ); m_gate->setEnabled( isEnabled && !effect()->m_autoQuitDisabled ); m_gate->setHintText( tr( "Gate:" ), "" ); diff --git a/src/gui/LadspaControlView.cpp b/src/gui/LadspaControlView.cpp index dbc3b8059bc..885bb9b35fe 100644 --- a/src/gui/LadspaControlView.cpp +++ b/src/gui/LadspaControlView.cpp @@ -102,7 +102,7 @@ LadspaControlView::LadspaControlView( QWidget * _parent, { knb->setModel( m_ctl->tempoSyncKnobModel() ); } - knb->setLabel( m_ctl->port()->name ); + knb->setLabel(m_ctl->port()->name); knb->setHintText( tr( "Value:" ), "" ); layout->addWidget( knb ); if( link != nullptr ) diff --git a/src/gui/LfoControllerDialog.cpp b/src/gui/LfoControllerDialog.cpp index 559ac13360c..1d88fd9b07b 100644 --- a/src/gui/LfoControllerDialog.cpp +++ b/src/gui/LfoControllerDialog.cpp @@ -62,23 +62,19 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent setWindowIcon( embed::getIconPixmap( "controller" ) ); setFixedSize( 240, 58 ); - m_baseKnob = new Knob( KnobType::Bright26, this ); - m_baseKnob->setLabel( tr( "BASE" ) ); + m_baseKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("BASE"), this); m_baseKnob->move( CD_LFO_BASE_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_baseKnob->setHintText( tr( "Base:" ), "" ); - m_speedKnob = new TempoSyncKnob( KnobType::Bright26, this ); - m_speedKnob->setLabel( tr( "FREQ" ) ); + m_speedKnob = TempoSyncKnob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("FREQ"), this); m_speedKnob->move( CD_LFO_SPEED_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_speedKnob->setHintText( tr( "LFO frequency:" ), "" ); - m_amountKnob = new Knob( KnobType::Bright26, this ); - m_amountKnob->setLabel( tr( "AMNT" ) ); + m_amountKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("AMNT"), this); m_amountKnob->move( CD_LFO_AMOUNT_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_amountKnob->setHintText( tr( "Modulation amount:" ), "" ); - m_phaseKnob = new Knob( KnobType::Bright26, this ); - m_phaseKnob->setLabel( tr( "PHS" ) ); + m_phaseKnob = Knob::buildKnobWithSmallPixelFont(KnobType::Bright26, tr("PHS"), this); m_phaseKnob->move( CD_LFO_PHASE_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_phaseKnob->setHintText( tr( "Phase offset:" ) , "" + tr( " degrees" ) ); diff --git a/src/gui/MidiCCRackView.cpp b/src/gui/MidiCCRackView.cpp index a0b1496fb54..f3e00442b48 100644 --- a/src/gui/MidiCCRackView.cpp +++ b/src/gui/MidiCCRackView.cpp @@ -79,6 +79,7 @@ MidiCCRackView::MidiCCRackView(InstrumentTrack * track) : auto knobsScrollArea = new QScrollArea(); auto knobsArea = new QWidget(); auto knobsAreaLayout = new QGridLayout(); + knobsAreaLayout->setVerticalSpacing(10); knobsArea->setLayout(knobsAreaLayout); knobsScrollArea->setWidget(knobsArea); @@ -86,24 +87,22 @@ MidiCCRackView::MidiCCRackView(InstrumentTrack * track) : knobsGroupBoxLayout->addWidget(knobsScrollArea); - // Adds the controller knobs + // Adds the controller knobs and sets their models for (int i = 0; i < MidiControllerCount; ++i) { - m_controllerKnob[i] = new Knob(KnobType::Bright26); - m_controllerKnob[i]->setLabel(tr("CC %1").arg(i)); - knobsAreaLayout->addWidget(m_controllerKnob[i], i/4, i%4); + auto knob = new Knob(KnobType::Bright26, this); + knob->setLabel(tr("CC %1").arg(i)); + knob->setModel(m_track->m_midiCCModel[i].get()); + knobsAreaLayout->addWidget(knob, i/4, i%4, Qt::AlignHCenter); + + // TODO It seems that this is not really used/needed? + m_controllerKnob[i] = knob; } // Set all the models // Set the LED button to enable/disable the track midi cc m_midiCCGroupBox->setModel(m_track->m_midiCCEnable.get()); - // Set the model for each Knob - for (int i = 0; i < MidiControllerCount; ++i) - { - m_controllerKnob[i]->setModel(m_track->m_midiCCModel[i].get()); - } - // Connection to update the name of the track on the label connect(m_track, SIGNAL(nameChanged()), this, SLOT(renameWindow())); diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index 95926450680..c807f00aae7 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -56,8 +56,7 @@ EnvelopeAndLfoView::EnvelopeAndLfoView(QWidget * parent) : // Helper lambdas for consistent repeated buiding of certain widgets auto buildKnob = [&](const QString& label, const QString& hintText) { - auto knob = new Knob(KnobType::Bright26, this); - knob->setLabel(label); + auto knob = Knob::buildLegacyKnob(KnobType::Bright26, label, this); knob->setHintText(hintText, ""); return knob; @@ -167,8 +166,7 @@ EnvelopeAndLfoView::EnvelopeAndLfoView(QWidget * parent) : m_lfoAttackKnob = buildKnob(tr("ATT"), tr("Attack:")); lfoKnobsLayout->addWidget(m_lfoAttackKnob); - m_lfoSpeedKnob = new TempoSyncKnob(KnobType::Bright26, this); - m_lfoSpeedKnob->setLabel(tr("SPD")); + m_lfoSpeedKnob = TempoSyncKnob::buildLegacyKnob(KnobType::Bright26, tr("SPD"), this); m_lfoSpeedKnob->setHintText(tr("Frequency:"), ""); lfoKnobsLayout->addWidget(m_lfoSpeedKnob); diff --git a/src/gui/instrument/InstrumentFunctionViews.cpp b/src/gui/instrument/InstrumentFunctionViews.cpp index a60fa64f92d..49390d12f30 100644 --- a/src/gui/instrument/InstrumentFunctionViews.cpp +++ b/src/gui/instrument/InstrumentFunctionViews.cpp @@ -44,7 +44,7 @@ InstrumentFunctionNoteStackingView::InstrumentFunctionNoteStackingView( Instrume m_cc( cc ), m_chordsGroupBox( new GroupBox( tr( "STACKING" ) ) ), m_chordsComboBox( new ComboBox() ), - m_chordRangeKnob( new Knob( KnobType::Bright26 ) ) + m_chordRangeKnob(Knob::buildLegacyKnob(KnobType::Bright26, tr("RANGE"), this)) { auto topLayout = new QHBoxLayout(this); topLayout->setContentsMargins(0, 0, 0, 0); @@ -59,7 +59,6 @@ InstrumentFunctionNoteStackingView::InstrumentFunctionNoteStackingView( Instrume auto chordLabel = new QLabel(tr("Chord:")); chordLabel->setFont(adjustedToPixelSize(chordLabel->font(), DEFAULT_FONT_SIZE)); - m_chordRangeKnob->setLabel( tr( "RANGE" ) ); m_chordRangeKnob->setHintText( tr( "Chord range:" ), " " + tr( "octave(s)" ) ); mainLayout->addWidget( chordLabel, 0, 0 ); @@ -98,13 +97,13 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti m_a( arp ), m_arpGroupBox( new GroupBox( tr( "ARPEGGIO" ) ) ), m_arpComboBox( new ComboBox() ), - m_arpRangeKnob( new Knob( KnobType::Bright26 ) ), - m_arpRepeatsKnob( new Knob( KnobType::Bright26 ) ), - m_arpCycleKnob( new Knob( KnobType::Bright26 ) ), - m_arpSkipKnob( new Knob( KnobType::Bright26 ) ), - m_arpMissKnob( new Knob( KnobType::Bright26 ) ), - m_arpTimeKnob( new TempoSyncKnob( KnobType::Bright26 ) ), - m_arpGateKnob( new Knob( KnobType::Bright26 ) ), + m_arpRangeKnob(Knob::buildLegacyKnob(KnobType::Bright26, tr("RANGE"), this)), + m_arpRepeatsKnob(Knob::buildLegacyKnob(KnobType::Bright26, tr("REP"), this)), + m_arpCycleKnob(Knob::buildLegacyKnob(KnobType::Bright26, tr("CYCLE"), this)), + m_arpSkipKnob(Knob::buildLegacyKnob(KnobType::Bright26, tr("SKIP"), this)), + m_arpMissKnob(Knob::buildLegacyKnob(KnobType::Bright26, tr("MISS"), this)), + m_arpTimeKnob(TempoSyncKnob::buildLegacyKnob(KnobType::Bright26, tr("TIME"), this)), + m_arpGateKnob(Knob::buildLegacyKnob(KnobType::Bright26, tr("GATE"), this)), m_arpDirectionComboBox( new ComboBox() ), m_arpModeComboBox( new ComboBox() ) { @@ -118,31 +117,12 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti mainLayout->setHorizontalSpacing( 20 ); mainLayout->setVerticalSpacing( 1 ); - m_arpRangeKnob->setLabel( tr( "RANGE" ) ); m_arpRangeKnob->setHintText( tr( "Arpeggio range:" ), " " + tr( "octave(s)" ) ); - - - m_arpRepeatsKnob->setLabel( tr( "REP" ) ); m_arpRepeatsKnob->setHintText( tr( "Note repeats:" ) + " ", " " + tr( "time(s)" ) ); - - - m_arpCycleKnob->setLabel( tr( "CYCLE" ) ); m_arpCycleKnob->setHintText( tr( "Cycle notes:" ) + " ", " " + tr( "note(s)" ) ); - - - m_arpSkipKnob->setLabel( tr( "SKIP" ) ); m_arpSkipKnob->setHintText( tr( "Skip rate:" ), tr( "%" ) ); - - - m_arpMissKnob->setLabel( tr( "MISS" ) ); m_arpMissKnob->setHintText( tr( "Miss rate:" ), tr( "%" ) ); - - - m_arpTimeKnob->setLabel( tr( "TIME" ) ); m_arpTimeKnob->setHintText( tr( "Arpeggio time:" ), " " + tr( "ms" ) ); - - - m_arpGateKnob->setLabel( tr( "GATE" ) ); m_arpGateKnob->setHintText( tr( "Arpeggio gate:" ), tr( "%" ) ); auto arpChordLabel = new QLabel(tr("Chord:")); diff --git a/src/gui/instrument/InstrumentSoundShapingView.cpp b/src/gui/instrument/InstrumentSoundShapingView.cpp index 45abace19f0..3091ce3bd59 100644 --- a/src/gui/instrument/InstrumentSoundShapingView.cpp +++ b/src/gui/instrument/InstrumentSoundShapingView.cpp @@ -67,13 +67,11 @@ InstrumentSoundShapingView::InstrumentSoundShapingView(QWidget* parent) : m_filterComboBox = new ComboBox(m_filterGroupBox); filterLayout->addWidget(m_filterComboBox); - m_filterCutKnob = new Knob(KnobType::Bright26, m_filterGroupBox); - m_filterCutKnob->setLabel(tr("FREQ")); + m_filterCutKnob = Knob::buildLegacyKnob(KnobType::Bright26, tr("FREQ"), m_filterGroupBox); m_filterCutKnob->setHintText(tr("Cutoff frequency:"), " " + tr("Hz")); filterLayout->addWidget(m_filterCutKnob); - m_filterResKnob = new Knob(KnobType::Bright26, m_filterGroupBox); - m_filterResKnob->setLabel(tr("Q/RESO")); + m_filterResKnob = Knob::buildLegacyKnob(KnobType::Bright26, tr("Q/RESO"), m_filterGroupBox); m_filterResKnob->setHintText(tr("Q/Resonance:"), ""); filterLayout->addWidget(m_filterResKnob); diff --git a/src/gui/tracks/InstrumentTrackView.cpp b/src/gui/tracks/InstrumentTrackView.cpp index 1d9991c3107..257041e7546 100644 --- a/src/gui/tracks/InstrumentTrackView.cpp +++ b/src/gui/tracks/InstrumentTrackView.cpp @@ -35,6 +35,7 @@ #include "ConfigManager.h" #include "Engine.h" #include "FadeButton.h" +#include "FontHelper.h" #include "Knob.h" #include "MidiCCRackView.h" #include "Mixer.h" @@ -77,19 +78,21 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_mixerChannelNumber = new MixerChannelLcdSpinBox(2, getTrackSettingsWidget(), tr("Mixer channel"), this); m_mixerChannelNumber->show(); - m_volumeKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), - tr( "Volume" ) ); + const auto f = adjustedToPixelSize(font(), 9); + + m_volumeKnob = new Knob(KnobType::Small17, getTrackSettingsWidget(), tr("Volume")); + m_volumeKnob->setFont(f); + m_volumeKnob->setLabel(tr("VOL")); m_volumeKnob->setVolumeKnob( true ); m_volumeKnob->setModel( &_it->m_volumeModel ); m_volumeKnob->setHintText( tr( "Volume:" ), "%" ); - m_volumeKnob->setLabel( tr( "VOL" ) ); m_volumeKnob->show(); - m_panningKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), - tr( "Panning" ) ); + m_panningKnob = new Knob(KnobType::Small17, getTrackSettingsWidget(), tr("Panning")); + m_panningKnob->setFont(f); + m_panningKnob->setLabel(tr("PAN")); m_panningKnob->setModel( &_it->m_panningModel ); m_panningKnob->setHintText(tr("Panning:"), "%"); - m_panningKnob->setLabel( tr( "PAN" ) ); m_panningKnob->show(); m_midiMenu = new QMenu( tr( "MIDI" ), this ); diff --git a/src/gui/tracks/SampleTrackView.cpp b/src/gui/tracks/SampleTrackView.cpp index 8475f7fa9e1..522dc44bc38 100644 --- a/src/gui/tracks/SampleTrackView.cpp +++ b/src/gui/tracks/SampleTrackView.cpp @@ -31,6 +31,7 @@ #include "embed.h" #include "Engine.h" #include "FadeButton.h" +#include "FontHelper.h" #include "Mixer.h" #include "MixerView.h" #include "GuiApplication.h" @@ -61,20 +62,22 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) : m_mixerChannelNumber = new MixerChannelLcdSpinBox(2, getTrackSettingsWidget(), tr("Mixer channel"), this); m_mixerChannelNumber->show(); - m_volumeKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), - tr( "Track volume" ) ); + const auto f = adjustedToPixelSize(font(), 9); + + m_volumeKnob = new Knob(KnobType::Small17, getTrackSettingsWidget(), tr("Track volume")); + m_volumeKnob->setFont(f); + m_volumeKnob->setLabel(tr("VOL")); m_volumeKnob->setVolumeKnob( true ); m_volumeKnob->setModel( &_t->m_volumeModel ); m_volumeKnob->setHintText( tr( "Channel volume:" ), "%" ); - m_volumeKnob->setLabel( tr( "VOL" ) ); m_volumeKnob->show(); - m_panningKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), - tr( "Panning" ) ); + m_panningKnob = new Knob(KnobType::Small17, getTrackSettingsWidget(), tr("Panning")); + m_panningKnob->setFont(f); + m_panningKnob->setLabel(tr("PAN")); m_panningKnob->setModel( &_t->m_panningModel ); m_panningKnob->setHintText( tr( "Panning:" ), "%" ); - m_panningKnob->setLabel( tr( "PAN" ) ); m_panningKnob->show(); m_activityIndicator = new FadeButton( diff --git a/src/gui/widgets/CustomTextKnob.cpp b/src/gui/widgets/CustomTextKnob.cpp index a4edde47ccb..73145c3971e 100644 --- a/src/gui/widgets/CustomTextKnob.cpp +++ b/src/gui/widgets/CustomTextKnob.cpp @@ -23,6 +23,7 @@ */ #include "CustomTextKnob.h" +#include "FontHelper.h" namespace lmms::gui { @@ -36,6 +37,16 @@ CustomTextKnob::CustomTextKnob( QWidget * _parent, const QString & _name, const Knob( _parent, _name ), m_value_text( _value_text ) {} +CustomTextKnob* CustomTextKnob::buildKnobWithSmallPixelFont(KnobType knobNum, QWidget* parent, const QString& description, const QString& label) +{ + auto result = new CustomTextKnob(knobNum, parent, description); + + result->setFont(adjustedToPixelSize(result->font(), SMALL_FONT_SIZE)); + result->setLabel(label); + + return result; +} + QString CustomTextKnob::displayValue() const { return m_description.trimmed() + m_value_text; diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 8941dcc29d4..520b0456f10 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -57,7 +57,24 @@ Knob::Knob( QWidget * _parent, const QString & _name ) : { } +Knob* Knob::buildLegacyKnob(KnobType knobNum, const QString& label, QWidget* parent, const QString& name) +{ + auto result = new Knob(knobNum, parent, name); + result->setLegacyMode(true); + result->setFont(adjustedToPixelSize(result->font(), SMALL_FONT_SIZE)); + result->setLabel(label); + + return result; +} + +Knob* Knob::buildKnobWithSmallPixelFont(KnobType knobNum, const QString& label, QWidget* parent, const QString& name) +{ + auto result = new Knob(knobNum, parent, name); + result->setFont(adjustedToPixelSize(result->font(), SMALL_FONT_SIZE)); + result->setLabel(label); + return result; +} void Knob::initUi( const QString & _name ) @@ -132,16 +149,12 @@ void Knob::onKnobNumUpdated() -void Knob::setLabel( const QString & txt ) +void Knob::setLabel(const QString& txt) { m_label = txt; m_isHtmlLabel = false; - if( m_knobPixmap ) - { - setFixedSize(qMax( m_knobPixmap->width(), - horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), SMALL_FONT_SIZE)), m_label)), - m_knobPixmap->height() + 10); - } + + updateFixedSize(); update(); } @@ -168,8 +181,49 @@ void Knob::setHtmlLabel(const QString &htmltxt) update(); } +void Knob::setLegacyMode(bool legacyMode) +{ + m_legacyMode = legacyMode; + + updateFixedSize(); + update(); +} +void Knob::updateFixedSize() +{ + if (legacyMode()) + { + if (m_knobPixmap) + { + // In legacy mode only the width of the label is taken into account while the height is not + const int labelWidth = horizontalAdvance(QFontMetrics(font()), m_label); + const int width = qMax( m_knobPixmap->width(), labelWidth); + + // Legacy mode assumes that the label will fit into 10 pixels plus some of the pixmap area + setFixedSize(width, m_knobPixmap->height() + 10); + } + } + else + { + // Styled knobs do not use pixmaps and have no labels. Their size is set from the outside and + // they are painted within these limits. Hence we should not compute a new size from a pixmap + // and/or label the case of styled knobs. + if (knobNum() == KnobType::Styled) + { + return; + } + + QSize pixmapSize = m_knobPixmap ? m_knobPixmap->size() : QSize(0, 0); + + auto fm = QFontMetrics(font()); + + const int width = std::max(pixmapSize.width(), horizontalAdvance(fm, m_label)); + const int height = pixmapSize.height() + fm.height(); + + setFixedSize(width, height); + } +} void Knob::setTotalAngle( float angle ) { @@ -450,31 +504,38 @@ void Knob::drawKnob( QPainter * _p ) _p->drawImage( 0, 0, m_cache ); } -void Knob::paintEvent( QPaintEvent * _me ) +void Knob::drawLabel(QPainter& p) { - QPainter p( this ); - - drawKnob( &p ); if( !m_label.isEmpty() ) { if (!m_isHtmlLabel) { - p.setFont(adjustedToPixelSize(p.font(), SMALL_FONT_SIZE)); + auto fm = p.fontMetrics(); + const auto x = (width() - horizontalAdvance(fm, m_label)) / 2; + const auto descent = legacyMode() ? 2 : fm.descent(); + const auto y = height() - descent; + p.setPen(textColor()); - p.drawText(width() / 2 - - horizontalAdvance(p.fontMetrics(), m_label) / 2, - height() - 2, m_label); + p.drawText(x, y, m_label); } else { // TODO setHtmlLabel is never called so this will never be executed. Remove functionality? - m_tdRenderer->setDefaultFont(adjustedToPixelSize(p.font(), SMALL_FONT_SIZE)); + m_tdRenderer->setDefaultFont(font()); p.translate((width() - m_tdRenderer->idealWidth()) / 2, (height() - m_tdRenderer->pageSize().height()) / 2); m_tdRenderer->drawContents(&p); } } } +void Knob::paintEvent(QPaintEvent*) +{ + QPainter p(this); + + drawKnob(&p); + drawLabel(p); +} + void Knob::changeEvent(QEvent * ev) { if (ev->type() == QEvent::EnabledChange) @@ -487,6 +548,14 @@ void Knob::changeEvent(QEvent * ev) m_cache = QImage(); update(); } + else if (ev->type() == QEvent::FontChange) + { + // The size of the label might have changed so update + // the size of this widget. + updateFixedSize(); + + update(); + } } diff --git a/src/gui/widgets/TempoSyncKnob.cpp b/src/gui/widgets/TempoSyncKnob.cpp index 473cee28ca9..c75ba0bef9f 100644 --- a/src/gui/widgets/TempoSyncKnob.cpp +++ b/src/gui/widgets/TempoSyncKnob.cpp @@ -30,6 +30,7 @@ #include "Engine.h" #include "CaptionMenu.h" #include "embed.h" +#include "FontHelper.h" #include "GuiApplication.h" #include "MainWindow.h" #include "MeterDialog.h" @@ -63,6 +64,26 @@ TempoSyncKnob::~TempoSyncKnob() } +TempoSyncKnob* TempoSyncKnob::buildLegacyKnob(KnobType knobNum, const QString& label, QWidget* parent) +{ + auto result = new TempoSyncKnob(knobNum, parent); + + result->setLegacyMode(true); + result->setFont(adjustedToPixelSize(result->font(), SMALL_FONT_SIZE)); + result->setLabel(label); + + return result; +} + +TempoSyncKnob* TempoSyncKnob::buildKnobWithSmallPixelFont(KnobType knobNum, const QString& label, QWidget* parent) +{ + auto result = new TempoSyncKnob(knobNum, parent); + + result->setFont(adjustedToPixelSize(result->font(), SMALL_FONT_SIZE)); + result->setLabel(label); + + return result; +} void TempoSyncKnob::modelChanged()