Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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/AutomatableModelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LMMS_EXPORT AutomatableModelView : public ModelView
m_description = desc.trimmed();
}

inline void setUnit( const QString& unit )
virtual void setUnit(const QString& unit)
{
m_unit = unit;
}
Expand Down
118 changes: 98 additions & 20 deletions include/FloatModelEditorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#ifndef LMMS_GUI_FLOAT_MODEL_EDITOR_BASE_H
#define LMMS_GUI_FLOAT_MODEL_EDITOR_BASE_H

#include <QWidget>
#include <QPoint>
#include <QWidget>
#include <optional>

#include "AutomatableModelView.h"
Expand Down Expand Up @@ -61,6 +61,34 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
setUnit(txt_after);
}

/**
* Sets the tooltip displayed when the mouse hovers over the control.
*
* Unlike the dynamic floating text from getDynamicFloatingText() which represents the
* current value of the model, this is static text intended to provide a helpful description
* of the control. That is, it's just a traditional tooltip, though it uses SimpleTextFloat
* rather than QWidget's own tooltip for consistency with the dynamic floating text.
*
* If no static tooltip is set (when this method is not called), dynamic floating text
* is used in its place. See @ref InteractionType for more information.
*
* @param tip the static tooltip. If empty, neither a static nor dynamic tooltip will be
* displayed when the mouse hovers over the control.
*/
void setToolTip(const QString& tip)
{
m_staticToolTip.emplace(tip);
}

QString toolTip() const { return m_staticToolTip.value_or(QString{}); }

/**
* Removes the static tooltip set by a previous call to setToolTip().
* The dynamic floating text will be used in its place.
* NOTE: This is currently unused.
*/
void unsetToolTip() { m_staticToolTip.reset(); }

signals:
void sliderPressed();
void sliderReleased();
Expand Down Expand Up @@ -88,42 +116,42 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
virtual float getValue(const QPoint & p);

/**
* This method is called just prior to displaying the floating text
* in order to set its value. If the getCustomFloatingTextUpdate() method
* This method is called just prior to displaying dynamic floating text
* in order to set its value. If the getDynamicFloatingTextUpdate() method
* is not overridden, this method is also called to periodically update
* the floating text.
*
* Floating text is displayed in the following format:
* "[description] [custom text][unit]"
* Dynamic floating text is displayed in the following format:
* "[description] [dynamic text][unit]"
*
* This method controls only the "custom text" portion.
* This method controls only the "dynamic text" portion.
* To modify the other portions, call setDescription() or setUnit().
*/
virtual QString getCustomFloatingText();
virtual QString getDynamicFloatingText();

/**
* This method is called periodically while the floating text is visible
* This method is called periodically while dynamic floating text is visible
* and the value of the float model is changing, allowing dynamic updates
* of the floating text.
*
* Floating text is displayed in the following format:
* "[description] [custom text][unit]"
* Dynamic floating text is displayed in the following format:
* "[description] [dynamic text][unit]"
*
* This method controls only the "custom text" portion.
* This method controls only the "dynamic text" portion.
* To modify the other portions, call setDescription() or setUnit().
*
* @returns the up-to-date value for the floating text, or std::nullopt to indicate
* nothing changed and the previous floating text value should continue being used
* @returns the up-to-date value for the dynamic floating text, or std::nullopt to
* indicate the previous floating text value should continue being used
*/
virtual std::optional<QString> getCustomFloatingTextUpdate()
virtual std::optional<QString> getDynamicFloatingTextUpdate()
{
return getCustomFloatingText();
return getDynamicFloatingText();
}

void doConnections() override;

void showTextFloat(int msecBeforeDisplay, int msecDisplayTime);
void showTextFloat();
void showTextFloat(int msecBeforeDisplay, int msecDisplayTime, bool forceTextUpdate = false);
void showTextFloat(bool forceTextUpdate = false);

const SimpleTextFloat& textFloat() const { return *s_textFloat; }

Expand All @@ -134,18 +162,68 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
return (model()->maxValue() - model()->minValue()) / 100.0f;
}

DirectionOfManipulation directionOfManipulation() const { return m_directionOfManipulation; }

//! Types of user interaction with the control
enum class InteractionType : std::uint8_t
{
//! The user is not interacting with the control.
//! No floating text is shown.
None,

//! The mouse is hovering over the control without any other interaction.
//! If a static tooltip is set (@see setToolTip), it will be displayed,
//! otherwise dynamic floating text will be displayed.
MouseHover,

//! The user is dragging the control to adjust the model's value.
//! This always results in dynamic floating text, not a static tooltip.
MouseDrag,

//! The user is using the mouse wheel on the control to adjust the model's value.
//! This always results in dynamic floating text, not a static tooltip.
MouseWheel
};

//! @returns how the user is interacting with the control
InteractionType currentInteraction() const { return m_interaction; }

//! Updates m_interaction based on the event and current state
void updateInteractionState(QEvent* event);

enum class FloatingTextType : std::uint8_t
{
//! No floating text
None,

//! Traditional static tooltip
Static,

//! Dynamic floating text
Dynamic
};

/**
* @returns which type of floating text is currently being displayed based on how the user
* is interacting with the control and whether a static tooltip has been set for the control.
*/
FloatingTextType floatingTextType() const;

QPoint m_lastMousePos; //!< mouse position in last mouseMoveEvent
float m_leftOver;
bool m_buttonPressed;

DirectionOfManipulation m_directionOfManipulation;

private slots:
virtual void enterValue();
void friendlyUpdate();
void toggleScale();

private:
InteractionType m_interaction = InteractionType::None;

DirectionOfManipulation m_directionOfManipulation;

std::optional<QString> m_staticToolTip;

static SimpleTextFloat* s_textFloat;
};

Expand Down
17 changes: 15 additions & 2 deletions include/Knob.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,23 @@ class LMMS_EXPORT VolumeKnob : public Knob
mapPropertyFromModel(float, volumeRatio, setVolumeRatio, m_volumeRatio);

public:
using Knob::Knob;
VolumeKnob(const VolumeKnob&) = delete;
VolumeKnob(const Knob&) = delete;
VolumeKnob(VolumeKnob&&) = delete;
VolumeKnob(Knob&&) = delete;

template<typename... Args>
VolumeKnob(Args&&... args)
: Knob{std::forward<Args>(args)...}
{
AutomatableModelView::setUnit(" dBFS");
}

//! Volume knobs are always dBFS
void setUnit(const QString& unit) override {}

protected:
QString getCustomFloatingText() override;
QString getDynamicFloatingText() override;
void enterValue() override;

private:
Expand Down
6 changes: 3 additions & 3 deletions plugins/Amplifier/AmplifierControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ AmplifierControlDialog::AmplifierControlDialog(AmplifierControls* controls) :
return newKnob;
};

gridLayout->addWidget(makeKnob(tr("VOL"), tr("Volume:"), "%", &controls->m_volumeModel, true), 0, 0, Qt::AlignHCenter);
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);
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);
gridLayout->setSizeConstraint(QLayout::SetFixedSize);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/AudioFileProcessor/AudioFileProcessorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ AudioFileProcessorView::AudioFileProcessorView(Instrument* instrument,

m_ampKnob = new VolumeKnob(KnobType::Bright26, this);
m_ampKnob->move(5, 108);
m_ampKnob->setHintText(tr("Amplify:"), "%");
m_ampKnob->setDescription(tr("Amplify:"));

m_startKnob = new AudioFileProcessorWaveView::knob(this);
m_startKnob->move(50, 108);
Expand Down
10 changes: 5 additions & 5 deletions plugins/Delay/DelayControlsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,29 @@ DelayControlsDialog::DelayControlsDialog( DelayControls *controls ) :
auto sampleDelayKnob = new TempoSyncKnob(KnobType::Bright26, tr("DELAY"), this, Knob::LabelRendering::LegacyFixedFontSize);
sampleDelayKnob->move( 10,14 );
sampleDelayKnob->setModel( &controls->m_delayTimeModel );
sampleDelayKnob->setHintText( tr( "Delay time" ) + " ", " s" );
sampleDelayKnob->setHintText(tr("Delay time:"), " s");
Comment thread
messmerd marked this conversation as resolved.

auto feedbackKnob = new VolumeKnob(KnobType::Bright26, tr("FDBK"), this, Knob::LabelRendering::LegacyFixedFontSize);
feedbackKnob->move( 11, 58 );
feedbackKnob->setModel( &controls->m_feedbackModel);
feedbackKnob->setHintText( tr ( "Feedback amount" ) + " " , "" );
feedbackKnob->setDescription(tr("Feedback amount:"));

auto lfoFreqKnob = new TempoSyncKnob(KnobType::Bright26, tr("RATE"), this, Knob::LabelRendering::LegacyFixedFontSize);
lfoFreqKnob->move( 11, 119 );
lfoFreqKnob->setModel( &controls->m_lfoTimeModel );
lfoFreqKnob->setHintText( tr ( "LFO frequency") + " ", " s" );
lfoFreqKnob->setHintText(tr("LFO frequency:"), " s");

auto lfoAmtKnob = new TempoSyncKnob(KnobType::Bright26, tr("AMNT"), this, Knob::LabelRendering::LegacyFixedFontSize);
lfoAmtKnob->move( 11, 159 );
lfoAmtKnob->setModel( &controls->m_lfoAmountModel );
lfoAmtKnob->setHintText( tr ( "LFO amount" ) + " " , " s" );
lfoAmtKnob->setHintText(tr("LFO amount:"), " s");

auto outFader
= new EqFader(&controls->m_outGainModel, tr("Out gain"), this, &controls->m_outPeakL, &controls->m_outPeakR);
outFader->setMaximumHeight( 196 );
outFader->move( 263, 45 );
outFader->setDisplayConversion( false );
outFader->setHintText( tr( "Gain" ), "dBFS" );
outFader->setHintText(tr("Gain:"), " dBFS");

auto pad = new XyPad(this, &controls->m_feedbackModel, &controls->m_delayTimeModel);
pad->resize( 200, 200 );
Expand Down
4 changes: 2 additions & 2 deletions plugins/DualFilter/DualFilterControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ DualFilterControlDialog::DualFilterControlDialog( DualFilterControls* controls )

makeKnob(24, 26, &controls->m_cut1Model, tr("FREQ"), tr("Cutoff frequency"), "Hz");
makeKnob(74, 26, &controls->m_res1Model, tr("RESO"), tr("Resonance"), "");
makeKnob(124, 26, &controls->m_gain1Model, tr("GAIN"), tr("Gain"), "%", true);
makeKnob(124, 26, &controls->m_gain1Model, tr("GAIN"), tr("Gain"), "", true);
makeKnob(173, 37, &controls->m_mixModel, tr("MIX"), tr("Mix"), "");
makeKnob(222, 26, &controls->m_cut2Model, tr("FREQ"), tr("Cutoff frequency"), "Hz");
makeKnob(272, 26, &controls->m_res2Model, tr("RESO"), tr("Resonance"), "");
makeKnob(322, 26, &controls->m_gain2Model, tr("GAIN"), tr("Gain"), "%", true);
makeKnob(322, 26, &controls->m_gain2Model, tr("GAIN"), tr("Gain"), "", true);

auto enabled1Toggle = new LedCheckBox("", this, tr("Filter 1 enabled"), LedCheckBox::LedColor::Green);
auto enabled2Toggle = new LedCheckBox("", this, tr("Filter 2 enabled"), LedCheckBox::LedColor::Green);
Expand Down
4 changes: 2 additions & 2 deletions plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ DynProcControlDialog::DynProcControlDialog(
inputKnob->setVolumeRatio(1.0);
inputKnob -> move( 26, 223 );
inputKnob->setModel( &_controls->m_inputModel );
inputKnob->setHintText( tr( "Input gain:" ) , "" );
inputKnob->setDescription(tr("Input gain:"));

auto outputKnob = new VolumeKnob(KnobType::Bright26, tr("OUTPUT"), SMALL_FONT_SIZE, this);
outputKnob->setVolumeRatio(1.0);
outputKnob -> move( 76, 223 );
outputKnob->setModel( &_controls->m_outputModel );
outputKnob->setHintText( tr( "Output gain:" ) , "" );
outputKnob->setDescription(tr("Output gain:"));

auto attackKnob = new Knob(KnobType::Bright26, tr("ATTACK"), SMALL_FONT_SIZE, this);
attackKnob -> move( 24, 268 );
Expand Down
4 changes: 2 additions & 2 deletions plugins/Flanger/FlangerControlsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ FlangerControlsDialog::FlangerControlsDialog( FlangerControls *controls ) :

auto feedbackKnob = new VolumeKnob(KnobType::Bright26, tr("FDBK"), this);
feedbackKnob->setModel( &controls->m_feedbackModel );
feedbackKnob->setHintText( tr( "Feedback amount:" ) , "" );
feedbackKnob->setDescription(tr("Feedback amount:"));

auto whiteNoiseKnob = new VolumeKnob(KnobType::Bright26, tr("NOISE"), this);
whiteNoiseKnob->setModel( &controls->m_whiteNoiseAmountModel );
whiteNoiseKnob->setHintText( tr( "White noise amount:" ) , "" );
whiteNoiseKnob->setDescription(tr("White noise amount:"));

knobLayout->addWidget(delayKnob);
knobLayout->addWidget(lfoFreqKnob);
Expand Down
6 changes: 3 additions & 3 deletions plugins/Monstro/Monstro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ QWidget * MonstroView::setupOperatorsView( QWidget * _parent )
return pb;
};

m_osc1VolKnob = makeKnob<VolumeKnob>(view, KNOBCOL1, O1ROW, tr("Volume"), "%", "osc1Knob");
m_osc1VolKnob = makeKnob<VolumeKnob>(view, KNOBCOL1, O1ROW, tr("Volume"), "", "osc1Knob");
m_osc1PanKnob = makeKnob(view, KNOBCOL2, O1ROW, tr("Panning"), "", "osc1Knob");
m_osc1CrsKnob = makeKnob(view, KNOBCOL3, O1ROW, tr("Coarse detune"), tr(" semitones"), "osc1Knob");
m_osc1FtlKnob = makeKnob(view, KNOBCOL4, O1ROW, tr("Fine tune left"), tr(" cents"), "osc1Knob");
Expand All @@ -1686,7 +1686,7 @@ QWidget * MonstroView::setupOperatorsView( QWidget * _parent )
m_osc1SSRButton = makeTinyLed(230, 34, tr("Send sync on pulse rise"));
m_osc1SSFButton = makeTinyLed(230, 44, tr("Send sync on pulse fall"));

m_osc2VolKnob = makeKnob<VolumeKnob>(view, KNOBCOL1, O2ROW, tr("Volume"), "%", "osc2Knob");
m_osc2VolKnob = makeKnob<VolumeKnob>(view, KNOBCOL1, O2ROW, tr("Volume"), "", "osc2Knob");
m_osc2PanKnob = makeKnob(view, KNOBCOL2, O2ROW, tr("Panning"), "", "osc2Knob");
m_osc2CrsKnob = makeKnob(view, KNOBCOL3, O2ROW, tr("Coarse detune"), tr(" semitones" ), "osc2Knob");
m_osc2FtlKnob = makeKnob(view, KNOBCOL4, O2ROW, tr("Fine tune left"), tr(" cents" ), "osc2Knob");
Expand All @@ -1699,7 +1699,7 @@ QWidget * MonstroView::setupOperatorsView( QWidget * _parent )
m_osc2SyncHButton = makeTinyLed(212, O2ROW - 3, tr("Hard sync oscillator 2"));
m_osc2SyncRButton = makeTinyLed(191, O2ROW - 3, tr("Reverse sync oscillator 2"));

m_osc3VolKnob = makeKnob<VolumeKnob>(view, KNOBCOL1, O3ROW, tr("Volume"), "%", "osc3Knob");
m_osc3VolKnob = makeKnob<VolumeKnob>(view, KNOBCOL1, O3ROW, tr("Volume"), "", "osc3Knob");
m_osc3PanKnob = makeKnob(view, KNOBCOL2, O3ROW, tr("Panning"), "", "osc3Knob");
m_osc3CrsKnob = makeKnob(view, KNOBCOL3, O3ROW, tr("Coarse detune"), tr(" semitones"), "osc3Knob");
m_osc3SpoKnob = makeKnob(view, KNOBCOL4, O3ROW, tr("Stereo phase offset"), tr(" deg"), "osc3Knob");
Expand Down
5 changes: 2 additions & 3 deletions plugins/Organic/Organic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument,
m_volKnob = new OrganicVolumeKnob(this);
m_volKnob->move( 60, 201 );
m_volKnob->setFixedSize( 37, 47 );
m_volKnob->setHintText( tr( "Volume:" ), "%" );
m_volKnob->setDescription(tr("Volume:"));
m_volKnob->setObjectName( "volKnob" );

// randomise
Expand Down Expand Up @@ -482,8 +482,7 @@ void OrganicInstrumentView::modelChanged()
auto volKnob = new VolumeKnob(KnobType::Styled, this);
volKnob->move( x + i * colWidth, y + rowHeight*1 );
volKnob->setFixedSize( 21, 21 );
volKnob->setHintText( tr( "Osc %1 volume:" ).arg(
i + 1 ), "%" );
volKnob->setDescription(tr("Osc %1 volume:").arg(i + 1));

// setup panning-knob
Knob * panKnob = new OrganicKnob( this );
Expand Down
3 changes: 1 addition & 2 deletions plugins/TripleOscillator/TripleOscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument,
auto vk = new VolumeKnob(KnobType::Styled, this);
vk->setFixedSize( 28, 35 );
vk->move( 6, knob_y );
vk->setHintText( tr( "Osc %1 volume:" ).arg(
i+1 ), "%" );
vk->setDescription(tr("Osc %1 volume:").arg(i + 1));

// setup panning-knob
Knob * pk = new TripleOscKnob( this );
Expand Down
2 changes: 1 addition & 1 deletion plugins/Vibed/Vibed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ VibedView::VibedView(Instrument* instrument, QWidget* parent) :
setPalette(pal);

m_volumeKnob.move(103, 142);
m_volumeKnob.setHintText(tr("String volume:"), "");
m_volumeKnob.setDescription(tr("String volume:"));

m_stiffnessKnob.move(129, 142);
m_stiffnessKnob.setHintText(tr("String stiffness:"), "");
Expand Down
Loading
Loading