From 840ef5c14a3d8c9559bb16c9ef69c1c87ed0accd Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 6 Dec 2009 14:41:21 +0000 Subject: ladspa host: added sliders git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1423 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Effect/ladspa/ladspa.pro | 57 +++++++-------- src/plugins/Effect/ladspa/ladspaplugin.cpp | 62 +++++----------- src/plugins/Effect/ladspa/ladspaplugin.h | 4 +- src/plugins/Effect/ladspa/ladspaslider.cpp | 67 +++++++++++++++++ src/plugins/Effect/ladspa/ladspaslider.h | 59 +++++++++++++++ src/plugins/Effect/ladspa/settingsdialog.cpp | 19 +++++ src/plugins/Effect/ladspa/settingsdialog.h | 1 + src/plugins/Effect/ladspa/settingsdialog.ui | 105 +++++++++++++++------------ 8 files changed, 251 insertions(+), 123 deletions(-) create mode 100644 src/plugins/Effect/ladspa/ladspaslider.cpp create mode 100644 src/plugins/Effect/ladspa/ladspaslider.h (limited to 'src/plugins/Effect') diff --git a/src/plugins/Effect/ladspa/ladspa.pro b/src/plugins/Effect/ladspa/ladspa.pro index 1eb686c53..2e50e43c2 100644 --- a/src/plugins/Effect/ladspa/ladspa.pro +++ b/src/plugins/Effect/ladspa/ladspa.pro @@ -1,42 +1,37 @@ include(../../plugins.pri) - HEADERS += ladspaplugin.h \ - effectladspafactory.h \ - settingsdialog.h - + effectladspafactory.h \ + settingsdialog.h \ + ladspaslider.h SOURCES += ladspaplugin.cpp \ - effectladspafactory.cpp \ - settingsdialog.cpp - -TARGET =$$PLUGINS_PREFIX/Effect/ladspa -QMAKE_CLEAN =$$PLUGINS_PREFIX/Effect/libladspa.so + effectladspafactory.cpp \ + settingsdialog.cpp \ + ladspaslider.cpp +TARGET = $$PLUGINS_PREFIX/Effect/ladspa +QMAKE_CLEAN = $$PLUGINS_PREFIX/Effect/libladspa.so INCLUDEPATH += ../../../ CONFIG += release \ -warn_on \ -plugin \ -link_pkgconfig - + warn_on \ + plugin \ + link_pkgconfig TEMPLATE = lib QMAKE_LIBDIR += ../../../../lib -LIBS += -lqmmp -L/usr/lib -I/usr/include - +LIBS += -lqmmp \ + -L/usr/lib \ + -I/usr/include TRANSLATIONS = translations/ladspa_plugin_cs.ts \ - translations/ladspa_plugin_de.ts \ - translations/ladspa_plugin_zh_CN.ts \ - translations/ladspa_plugin_zh_TW.ts \ - translations/ladspa_plugin_uk_UA.ts \ - translations/ladspa_plugin_pl.ts \ - translations/ladspa_plugin_ru.ts \ - translations/ladspa_plugin_it.ts \ - translations/ladspa_plugin_tr.ts \ - translations/ladspa_plugin_lt.ts -#RESOURCES = translations/translations.qrc - -isEmpty(LIB_DIR){ - LIB_DIR = /lib -} + translations/ladspa_plugin_de.ts \ + translations/ladspa_plugin_zh_CN.ts \ + translations/ladspa_plugin_zh_TW.ts \ + translations/ladspa_plugin_uk_UA.ts \ + translations/ladspa_plugin_pl.ts \ + translations/ladspa_plugin_ru.ts \ + translations/ladspa_plugin_it.ts \ + translations/ladspa_plugin_tr.ts \ + translations/ladspa_plugin_lt.ts + +# RESOURCES = translations/translations.qrc +isEmpty(LIB_DIR):LIB_DIR = /lib target.path = $$LIB_DIR/qmmp/Effect INSTALLS += target - - FORMS += settingsdialog.ui diff --git a/src/plugins/Effect/ladspa/ladspaplugin.cpp b/src/plugins/Effect/ladspa/ladspaplugin.cpp index 6af867bd3..99392a5d0 100644 --- a/src/plugins/Effect/ladspa/ladspaplugin.cpp +++ b/src/plugins/Effect/ladspa/ladspaplugin.cpp @@ -22,11 +22,13 @@ #include #include #include -#include +#include +#include #include #include #include #include +#include "ladspaslider.h" #include "ladspaplugin.h" #ifndef PATH_MAX @@ -298,7 +300,6 @@ void LADSPAHost::findPlugins(const QString &path_entry) { LADSPAPlugin *plugin; void *library = 0; - //char *lib_name; LADSPA_Descriptor_Function descriptor_fn; const LADSPA_Descriptor *descriptor; long int k; @@ -370,7 +371,7 @@ LADSPAEffect *LADSPAHost::addPlugin(LADSPAPlugin *plugin) return instance; } -void LADSPAHost::draw_plugin(LADSPAEffect * instance) +void LADSPAHost::draw_plugin(LADSPAEffect *instance) { const LADSPA_Descriptor *plugin = instance->descriptor; const LADSPA_PortRangeHint *hints = plugin->PortRangeHints; @@ -378,20 +379,10 @@ void LADSPAHost::draw_plugin(LADSPAEffect * instance) int dp; unsigned long k; bool no_ui = TRUE; - //GtkWidget *widget, *vbox, *hbox; - //GtkObject *adjustment; + QWidget *widget = new QWidget(); + QFormLayout *formLayout = new QFormLayout(widget); - /*if (instance->window != NULL) - { - /* Just show window */ - /*gtk_widget_show(instance->window); - return; - }*/ - - //instance->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - //gtk_window_set_title(GTK_WINDOW(instance->window), plugin->Name); - - //vbox = gtk_vbox_new(FALSE, 3); + widget->setLayout(formLayout); for (k = 0; k < MAX_KNOBS && k < plugin->PortCount; ++k) { @@ -408,6 +399,9 @@ void LADSPAHost::draw_plugin(LADSPAEffect * instance) g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(toggled), &(instance->knobs[k])); gtk_container_add(GTK_CONTAINER(hbox), widget); gtk_container_add(GTK_CONTAINER(vbox), hbox);*/ + + + //formLayout->addRow(plugin->PortNames[k], slider); continue; } @@ -494,39 +488,19 @@ void LADSPAHost::draw_plugin(LADSPAEffect * instance) start = min * 0.5f + max * 0.5f; instance->knobs[k] = start; - //adjustment = gtk_adjustment_new(start, min, max, step, step * 10.0, 0.0); - //instance->adjustments[k] = GTK_ADJUSTMENT(adjustment); - //widget = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), step, dp); - if (LADSPA_IS_PORT_OUTPUT(plugin->PortDescriptors[k])) - { - //gtk_widget_set_sensitive(widget, FALSE); - } - else - { - //g_signal_connect(adjustment, "value-changed", G_CALLBACK(value_changed), &(instance->knobs[k])); - } - /*gtk_container_add(GTK_CONTAINER(hbox), widget); - widget = gtk_hscale_new(GTK_ADJUSTMENT(adjustment)); - gtk_scale_set_digits(GTK_SCALE(widget), dp); - if (LADSPA_IS_PORT_OUTPUT(plugin->PortDescriptors[k])) - { - gtk_widget_set_sensitive(widget, FALSE); - } - gtk_container_add(GTK_CONTAINER(hbox), widget); + LADSPASlider *slider = new LADSPASlider(min, max, step, &instance->knobs[k], this, widget); - gtk_container_add(GTK_CONTAINER(vbox), hbox);*/ + //slider->setEnabled(!LADSPA_IS_PORT_OUTPUT(plugin->PortDescriptors[k])); + + formLayout->addRow(plugin->PortNames[k], slider); } + widget->setLayout(formLayout); + widget->setFixedSize(widget->sizeHint()); + instance->widget = widget; /*if (no_ui) { widget = gtk_label_new(_("This LADSPA plugin has no user controls")); gtk_container_add(GTK_CONTAINER(vbox), widget); - } - - instance->timeout = gtk_timeout_add(100, update_instance, instance); - - gtk_container_add(GTK_CONTAINER(instance->window), vbox); - - g_signal_connect(G_OBJECT(instance->window), "delete_event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); - gtk_widget_show_all(instance->window);*/ + }*/ } diff --git a/src/plugins/Effect/ladspa/ladspaplugin.h b/src/plugins/Effect/ladspa/ladspaplugin.h index 4d6c726c9..c8d61acb7 100644 --- a/src/plugins/Effect/ladspa/ladspaplugin.h +++ b/src/plugins/Effect/ladspa/ladspaplugin.h @@ -22,10 +22,11 @@ #include #include -#include #include #include +class QWidget; + /** @author Ilya Kotov */ @@ -54,6 +55,7 @@ public: LADSPA_Handle handle; /* left or mono */ LADSPA_Handle handle2; /* right stereo */ LADSPA_Data knobs[MAX_KNOBS]; + QWidget *widget; }; diff --git a/src/plugins/Effect/ladspa/ladspaslider.cpp b/src/plugins/Effect/ladspa/ladspaslider.cpp new file mode 100644 index 000000000..067a3d5ab --- /dev/null +++ b/src/plugins/Effect/ladspa/ladspaslider.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#include +#include +#include +#include "ladspaplugin.h" +#include "ladspaslider.h" + +LADSPASlider::LADSPASlider(double min, double max, double step, LADSPA_Data *value, + LADSPAHost *host, QWidget *parent) : QWidget(parent) +{ + m_min = min; + m_max = max; + m_step = step; + m_host = host; + m_value = value; + m_slider = new QSlider(Qt::Horizontal, this); + m_spinBox = new QDoubleSpinBox(this); + + QHBoxLayout *layout = new QHBoxLayout(this); + layout->addWidget(m_slider); + layout->addWidget(m_spinBox); + layout->setContentsMargins (0, 0, 0, 0); + setLayout(layout); + + m_spinBox->setRange(min, max); + m_spinBox->setSingleStep(step); + m_spinBox->setValue(*value); + + m_slider->setRange(0, (max-min)/step); + m_slider->setSingleStep(1); + m_slider->setPageStep(10); + m_slider->setValue((*value-min)/step); + + connect(m_spinBox, SIGNAL(valueChanged (double)), SLOT(setValue(double))); + connect(m_slider, SIGNAL(sliderMoved (int)),SLOT(setValue(int))); +} + +void LADSPASlider::setValue(double v) +{ + *m_value = v; + m_slider->setValue((v-m_min)/m_step); +} + +void LADSPASlider::setValue(int v) +{ + m_spinBox->setValue(v*m_step + m_min); +} diff --git a/src/plugins/Effect/ladspa/ladspaslider.h b/src/plugins/Effect/ladspa/ladspaslider.h new file mode 100644 index 000000000..c0863b902 --- /dev/null +++ b/src/plugins/Effect/ladspa/ladspaslider.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef LADSPASLIDER_H +#define LADSPASLIDER_H + +#include +#include + +class QDoubleSpinBox; +class QSlider; +class LADSPAHost; + +/** + @author Ilya Kotov +*/ +class LADSPASlider : public QWidget +{ +Q_OBJECT +public: + LADSPASlider(double min, + double max, + double step, + LADSPA_Data *value, + LADSPAHost *host, + QWidget *parent = 0); + +private slots: + void setValue(double); + void setValue(int); + +private: + QDoubleSpinBox *m_spinBox; + QSlider *m_slider; + LADSPA_Data *m_value; + double m_min; + double m_max; + double m_step; + LADSPAHost *m_host; + +}; + +#endif // LADSPASLIDER_H diff --git a/src/plugins/Effect/ladspa/settingsdialog.cpp b/src/plugins/Effect/ladspa/settingsdialog.cpp index 34f1714ed..4d0c33a6f 100644 --- a/src/plugins/Effect/ladspa/settingsdialog.cpp +++ b/src/plugins/Effect/ladspa/settingsdialog.cpp @@ -77,7 +77,26 @@ void SettingsDialog::on_loadButton_clicked() void SettingsDialog::on_unloadButton_clicked() { + LADSPAHost *l = LADSPAHost::instance(); + QModelIndex index = ui.runningListWidget->currentIndex (); + if(index.isValid()) + { + l->unload(l->runningPlugins().at(index.row())); + updateRunningPlugins(); + } +} +void SettingsDialog::on_configureButton_clicked() +{ + LADSPAHost *l = LADSPAHost::instance(); + QModelIndex index = ui.runningListWidget->currentIndex (); + if(index.isValid()) + { + l->runningPlugins().at(index.row())->widget->setParent(this); + l->runningPlugins().at(index.row())->widget->setWindowFlags(Qt::Window); + l->runningPlugins().at(index.row())->widget->show(); + //updateRunningPlugins(); + } } void SettingsDialog::accept() diff --git a/src/plugins/Effect/ladspa/settingsdialog.h b/src/plugins/Effect/ladspa/settingsdialog.h index 055019978..3d6c51b62 100644 --- a/src/plugins/Effect/ladspa/settingsdialog.h +++ b/src/plugins/Effect/ladspa/settingsdialog.h @@ -42,6 +42,7 @@ public slots: private slots: void on_loadButton_clicked(); void on_unloadButton_clicked(); + void on_configureButton_clicked(); private: void updateRunningPlugins(); diff --git a/src/plugins/Effect/ladspa/settingsdialog.ui b/src/plugins/Effect/ladspa/settingsdialog.ui index 38a2d6b28..c47d52a5f 100644 --- a/src/plugins/Effect/ladspa/settingsdialog.ui +++ b/src/plugins/Effect/ladspa/settingsdialog.ui @@ -23,6 +23,13 @@ 6 + + + + false + + + @@ -36,51 +43,8 @@ - - - - Qt::Vertical - - - - 20 - 123 - - - - - - - - Qt::Horizontal - - - - 343 - 23 - - - - - - - - - 0 - 0 - - - - QDialogButtonBox::Ok - - - - - - - false - - + + @@ -96,8 +60,55 @@ - - + + + + Qt::Vertical + + + + 20 + 123 + + + + + + + + + + Qt::Horizontal + + + + 343 + 23 + + + + + + + + Configure + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Ok + + + + -- cgit v1.2.3-13-gbd6f