Add bar controller with tempo sync option
Add `TempoSyncBarModelEditor` which adds a tempo sync option to a `BarModelEditor`. Please note that the code was mostly copied and adjusted from the `TempoSyncKnob` class. It was not attempted yet to unify some of the code because with the current design it seems to be a road to "inheritance hell". A better solution might be to refactor the code so that it is more composable. Another option might be to move the tempo sync functionality into a class like `FloatModelEditorBase`. Although this would not be a 100% right place either because `TempoSyncKnobModel` inherits from `FloatModel`. In that case we'd have specialized code in a generic base class. Adjust `LadspaWidgetFactory` so that it now returns an instance of a `TempoSyncBarModelEditor` instead of a `TempoSyncKnob`. Remove the extra layout code from `LadspaMatrixControlDialog.cpp` as most things are bar editors now. Adjust `TempoSyncKnobModel` so we do not have to make `TempoSyncBarModelEditor` a friend of it.
This commit is contained in:
@@ -166,11 +166,7 @@ void LadspaMatrixControlDialog::arrangeControls(QWidget * parent, QGridLayout* g
|
||||
QWidget * controlWidget = LadspaWidgetFactory::createWidget(ladspaControl, this);
|
||||
if (controlWidget)
|
||||
{
|
||||
// Align time based controls, i.e. knobs, in the center.
|
||||
// This defeats the purpose of the widget factory a bit but it makes the design look nicer.
|
||||
auto alignment = ladspaControl->port()->data_type == BufferDataType::Time ? Qt::AlignCenter : Qt::Alignment();
|
||||
|
||||
gridLayout->addWidget(controlWidget, currentRow, currentChannelColumn, alignment);
|
||||
gridLayout->addWidget(controlWidget, currentRow, currentChannelColumn);
|
||||
}
|
||||
|
||||
// Record the maximum row so that we add a vertical spacer after that row
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
// TODO Only for testing! Remove!
|
||||
#include "FloatModelEditorBase.h"
|
||||
#include "LedCheckBox.h"
|
||||
#include "TempoSyncKnob.h"
|
||||
#include "TempoSyncBarModelEditor.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
@@ -44,8 +44,6 @@ namespace lmms::gui
|
||||
|
||||
QWidget * LadspaWidgetFactory::createWidget(LadspaControl * ladspaControl, QWidget * parent)
|
||||
{
|
||||
Knob * knob = nullptr;
|
||||
|
||||
auto const * port = ladspaControl->port();
|
||||
|
||||
QString const name = port->name;
|
||||
@@ -66,21 +64,12 @@ QWidget * LadspaWidgetFactory::createWidget(LadspaControl * ladspaControl, QWidg
|
||||
return new BarModelEditor(name, ladspaControl->knobModel(), parent);
|
||||
|
||||
case BufferDataType::Time:
|
||||
knob = new TempoSyncKnob(KnobType::Bright26, parent, name);
|
||||
knob->setModel(ladspaControl->tempoSyncKnobModel());
|
||||
knob->setLabel(name);
|
||||
break;
|
||||
return new TempoSyncBarModelEditor(name, ladspaControl->tempoSyncKnobModel(), parent);
|
||||
|
||||
default:
|
||||
return new QLabel(QObject::tr("%1 (unsupported)").arg(name), parent);
|
||||
}
|
||||
|
||||
if (knob != nullptr)
|
||||
{
|
||||
knob->setHintText(QObject::tr("Value:"), "");
|
||||
return knob;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user