diff --git a/include/LadspaControl.h b/include/LadspaControl.h index 2ad895b3f..af890efdf 100644 --- a/include/LadspaControl.h +++ b/include/LadspaControl.h @@ -116,6 +116,7 @@ private: friend class LadspaControlView; + friend class LadspaMatrixControlDialog; } ; diff --git a/include/LadspaMatrixControlView.h b/include/LadspaMatrixControlView.h new file mode 100644 index 000000000..80122b543 --- /dev/null +++ b/include/LadspaMatrixControlView.h @@ -0,0 +1,49 @@ +/* + * LadspaMatrixControlView.h - widget for controlling a LADSPA port + * + * Copyright (c) 2006-2008 Danny McRae + * Copyright (c) 2009 Tobias Doerffel + * Copyright (c) 2015 Michael Gregorius + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef LADSPA_MATRIX_CONTROL_VIEW_H +#define LADSPA_MATRIX_CONTROL_VIEW_H + +#include + +#include "ModelView.h" + +class LadspaControl; + + +class LMMS_EXPORT LadspaMatrixControlView : public QWidget, public ModelView +{ + Q_OBJECT +public: + LadspaMatrixControlView( QWidget * parent, LadspaControl * ladspaControl ); + virtual ~LadspaMatrixControlView(); + +private: + LadspaControl * m_ladspaControl; + +} ; + +#endif diff --git a/plugins/LadspaEffect/CMakeLists.txt b/plugins/LadspaEffect/CMakeLists.txt index 5bfbc3284..539647de8 100644 --- a/plugins/LadspaEffect/CMakeLists.txt +++ b/plugins/LadspaEffect/CMakeLists.txt @@ -1,6 +1,6 @@ INCLUDE(BuildPlugin) -BUILD_PLUGIN(ladspaeffect LadspaEffect.cpp LadspaControls.cpp LadspaControlDialog.cpp LadspaSubPluginFeatures.cpp LadspaEffect.h LadspaControls.h LadspaControlDialog.h LadspaSubPluginFeatures.h MOCFILES LadspaEffect.h LadspaControls.h LadspaControlDialog.h EMBEDDED_RESOURCES logo.png) +BUILD_PLUGIN(ladspaeffect LadspaEffect.cpp LadspaControls.cpp LadspaControlDialog.cpp LadspaMatrixControlDialog.cpp LadspaSubPluginFeatures.cpp LadspaEffect.h LadspaControls.h LadspaControlDialog.h LadspaMatrixControlDialog.h LadspaSubPluginFeatures.h MOCFILES LadspaEffect.h LadspaControls.h LadspaControlDialog.h LadspaMatrixControlDialog.h EMBEDDED_RESOURCES logo.png) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ladspa") diff --git a/plugins/LadspaEffect/LadspaControls.h b/plugins/LadspaEffect/LadspaControls.h index ccb96dd74..5594206b7 100644 --- a/plugins/LadspaEffect/LadspaControls.h +++ b/plugins/LadspaEffect/LadspaControls.h @@ -28,6 +28,7 @@ #include "EffectControls.h" #include "LadspaControl.h" #include "LadspaControlDialog.h" +#include "LadspaMatrixControlDialog.h" typedef QVector control_list_t; @@ -56,7 +57,7 @@ public: virtual EffectControlDialog * createView() { - return new LadspaControlDialog( this ); + return new LadspaMatrixControlDialog( this ); } @@ -75,6 +76,7 @@ private: friend class LadspaControlDialog; + friend class LadspaMatrixControlDialog; friend class LadspaEffect; diff --git a/plugins/LadspaEffect/LadspaMatrixControlDialog.cpp b/plugins/LadspaEffect/LadspaMatrixControlDialog.cpp new file mode 100644 index 000000000..bc653c9b4 --- /dev/null +++ b/plugins/LadspaEffect/LadspaMatrixControlDialog.cpp @@ -0,0 +1,165 @@ +/* + * LadspaMatrixControlDialog.h - Dialog for displaying and editing control port + * values for LADSPA plugins in a matrix display + * + * Copyright (c) 2015 Michael Gregorius + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#include +#include +#include +#include +#include + +#include "LadspaEffect.h" +#include "LadspaMatrixControlDialog.h" +#include "LadspaMatrixControlView.h" +#include "LadspaControlView.h" +#include "LedCheckbox.h" + + + +static int const s_linkBaseColumn = 0; +static int const s_parameterNameBaseColumn = 2; +static int const s_channelBaseColumn = 4; + + + + +LadspaMatrixControlDialog::LadspaMatrixControlDialog( LadspaControls * ladspaControls ) : + EffectControlDialog( ladspaControls ), + m_effectGridLayout( NULL ), + m_stereoLink( NULL ) +{ + QVBoxLayout * mainLayout = new QVBoxLayout( this ); + + m_effectGridLayout = new QGridLayout(); + mainLayout->addLayout(m_effectGridLayout); + + updateEffectView( ladspaControls ); + + if( ladspaControls->m_processors > 1 ) + { + mainLayout->addSpacing( 3 ); + QHBoxLayout * center = new QHBoxLayout(); + mainLayout->addLayout( center ); + m_stereoLink = new LedCheckBox( tr( "Link Channels" ), this ); + m_stereoLink->setModel( &ladspaControls->m_stereoLinkModel ); + center->addWidget( m_stereoLink ); + } +} + + + + +LadspaMatrixControlDialog::~LadspaMatrixControlDialog() +{ +} + + + + +void LadspaMatrixControlDialog::updateEffectView( LadspaControls * ladspaControls ) +{ + QList list = findChildren(); + for( QList::iterator it = list.begin(); it != list.end(); ++it ) + { + delete *it; + } + + m_effectControls = ladspaControls; + + QWidget *widget = new QWidget(this); + QGridLayout *gridLayout = new QGridLayout(widget); + widget->setLayout(gridLayout); + + gridLayout->addWidget( new QLabel( "" + tr( "Parameter" ) + "", widget ), 0, s_parameterNameBaseColumn, Qt::AlignRight ); + + bool linkLabelAdded = false; + ch_cnt_t const numberOfChannels = ladspaControls->m_processors; + + gridLayout->setColumnMinimumWidth(1, 20); + + for ( ch_cnt_t i = 0; i < numberOfChannels; ++i ) + { + QString channelString( tr( "Channel %1" ) ); + int currentChannelColumn = s_channelBaseColumn + 2*i; + + gridLayout->addWidget( new QLabel( "" + channelString.arg( QString::number( i + 1 ) ) + "", widget ), 0, currentChannelColumn, Qt::AlignHCenter ); + + control_list_t & controls = ladspaControls->m_controls[i]; + + int currentRow = 1; + control_list_t::iterator end = controls.end(); + for( control_list_t::iterator it = controls.begin(); it != end; ++it ) + { + LadspaControl * ladspaControl = *it; + + if ( i == 0 ) + { + // TODO Assumes that all processors are equal! Change to more general approach, e.g. map from name to row + + // Link + if ( ladspaControl->m_link ) + { + if ( !linkLabelAdded ) + { + gridLayout->addWidget( new QLabel( "" + tr( "Link" ) + "", widget ), 0, s_linkBaseColumn, Qt::AlignHCenter ); + linkLabelAdded = true; + } + LedCheckBox * linkCheckBox = new LedCheckBox( "", widget ); + linkCheckBox->setModel( &ladspaControl->m_linkEnabledModel ); + linkCheckBox->setToolTip( tr( "Link channels" ) ); + gridLayout->addWidget( linkCheckBox, currentRow, s_linkBaseColumn, Qt::AlignHCenter ); + } + + // Parameter name + QString portName = ladspaControl->port()->name; + QLabel *portNameLabel = new QLabel( portName, widget ); + gridLayout->addWidget( portNameLabel, currentRow, s_parameterNameBaseColumn, Qt::AlignRight ); + } + + LadspaMatrixControlView *ladspaMatrixControlView = new LadspaMatrixControlView( widget, ladspaControl ); + gridLayout->addWidget( ladspaMatrixControlView, currentRow, currentChannelColumn, Qt::AlignHCenter ); + gridLayout->setColumnMinimumWidth(currentChannelColumn - 1, 20); + + ++currentRow; + } + } + + QScrollArea *scrollArea = new QScrollArea( this ); + scrollArea->setWidgetResizable( true ); + scrollArea->setWidget( widget ); + scrollArea->setFrameShape( QFrame::NoFrame ); + + m_effectGridLayout->addWidget( scrollArea, 0, 0 ); + m_effectGridLayout->setMargin(0); + + if( numberOfChannels > 1 && m_stereoLink != NULL ) + { + m_stereoLink->setModel( &ladspaControls->m_stereoLinkModel ); + } + + connect( ladspaControls, SIGNAL( effectModelChanged( LadspaControls * ) ), + this, SLOT( updateEffectView( LadspaControls * ) ), + Qt::DirectConnection ); +} diff --git a/plugins/LadspaEffect/LadspaMatrixControlDialog.h b/plugins/LadspaEffect/LadspaMatrixControlDialog.h new file mode 100644 index 000000000..3973ce27a --- /dev/null +++ b/plugins/LadspaEffect/LadspaMatrixControlDialog.h @@ -0,0 +1,56 @@ +/* + * LadspaMatrixControlDialog.h - Dialog for displaying and editing control port + * values for LADSPA plugins in a matrix display + * + * Copyright (c) 2015 Michael Gregorius + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef LADSPA_MATRIX_CONTROL_DIALOG_H +#define LADSPA_MATRIX_CONTROL_DIALOG_H + +#include "EffectControlDialog.h" + + +class QGridLayout; +class LadspaControls; +class LedCheckBox; + + +class LadspaMatrixControlDialog : public EffectControlDialog +{ + Q_OBJECT +public: + LadspaMatrixControlDialog( LadspaControls * _ctl ); + ~LadspaMatrixControlDialog(); + + virtual bool isResizable() const { return true; } + +private slots: + void updateEffectView( LadspaControls * _ctl ); + + +private: + QGridLayout * m_effectGridLayout; + LedCheckBox * m_stereoLink; + +} ; + +#endif diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index f17ef105f..337ec883c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -65,6 +65,7 @@ SET(LMMS_SRCS gui/widgets/LeftRightNav.cpp gui/widgets/Knob.cpp gui/widgets/LadspaControlView.cpp + gui/widgets/LadspaMatrixControlView.cpp gui/widgets/LcdSpinBox.cpp gui/widgets/LcdWidget.cpp gui/widgets/LedCheckbox.cpp diff --git a/src/gui/widgets/LadspaMatrixControlView.cpp b/src/gui/widgets/LadspaMatrixControlView.cpp new file mode 100644 index 000000000..996fa524a --- /dev/null +++ b/src/gui/widgets/LadspaMatrixControlView.cpp @@ -0,0 +1,93 @@ +/* + * LadspaMatrixControlView.cpp - widget for controlling a LADSPA port + * + * Copyright (c) 2006-2008 Danny McRae + * Copyright (c) 2009 Tobias Doerffel + * Copyright (c) 2015 Michael Gregorius + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include "LadspaMatrixControlView.h" + +#include "LadspaControl.h" + +#include "LadspaBase.h" +#include "LedCheckbox.h" +#include "TempoSyncKnob.h" +#include "ToolTip.h" + +#include + + +LadspaMatrixControlView::LadspaMatrixControlView( QWidget * parent, + LadspaControl * ladspaControl ) : + QWidget( parent ), + ModelView( ladspaControl, this ), + m_ladspaControl( ladspaControl ) +{ + QHBoxLayout * layout = new QHBoxLayout( this ); + layout->setMargin( 0 ); + layout->setSpacing( 0 ); + + Knob * knob = NULL; + + buffer_data_t dataType = m_ladspaControl->port()->data_type; + switch( dataType ) + { + case TOGGLED: + { + LedCheckBox * toggle = new LedCheckBox( + "", this, QString::null, LedCheckBox::Green ); + toggle->setModel( m_ladspaControl->toggledModel() ); + layout->addWidget( toggle ); + setFixedSize( toggle->width(), toggle->height() ); + break; + } + + case INTEGER: + case FLOATING: + knob = new Knob( knobBright_26, this, m_ladspaControl->port()->name ); + knob->setModel( m_ladspaControl->knobModel() ); + break; + + case TIME: + knob = new TempoSyncKnob( knobBright_26, this, m_ladspaControl->port()->name ); + knob->setModel( m_ladspaControl->tempoSyncKnobModel() ); + break; + + default: + break; + } + + if( knob != NULL ) + { + knob->setHintText( tr( "Value:" ), "" ); + knob->setWhatsThis( tr( "Sorry, no help available." ) ); + layout->addWidget( knob ); + setFixedSize( knob->width(), knob->height() ); + } +} + + + + +LadspaMatrixControlView::~LadspaMatrixControlView() +{ +}