2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000 Paul Davis
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
#include <cerrno>
|
|
|
|
#include <cmath>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <pbd/stl_delete.h>
|
|
|
|
#include <pbd/xml++.h>
|
|
|
|
#include <pbd/failed_constructor.h>
|
|
|
|
|
2006-08-11 21:36:34 -04:00
|
|
|
#include <gtkmm/widget.h>
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/click_box.h>
|
|
|
|
#include <gtkmm2ext/fastmeter.h>
|
|
|
|
#include <gtkmm2ext/barcontroller.h>
|
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
#include <gtkmm2ext/doi.h>
|
2006-08-03 22:18:45 -04:00
|
|
|
#include <gtkmm2ext/slider_controller.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <midi++/manager.h>
|
|
|
|
|
|
|
|
#include <ardour/plugin.h>
|
|
|
|
#include <ardour/insert.h>
|
|
|
|
#include <ardour/ladspa_plugin.h>
|
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
#include <ardour/vst_plugin.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <lrdf.h>
|
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "prompter.h"
|
|
|
|
#include "plugin_ui.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "gui_thread.h"
|
2006-08-11 21:36:34 -04:00
|
|
|
#include "public_editor.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
2006-06-22 19:40:55 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-11 21:36:34 -04:00
|
|
|
PluginUIWindow::PluginUIWindow (boost::shared_ptr<PluginInsert> insert, bool scrollable)
|
2005-09-25 14:42:24 -04:00
|
|
|
: ArdourDialog ("plugin ui")
|
|
|
|
{
|
2006-08-03 22:18:45 -04:00
|
|
|
if (insert->plugin()->has_editor()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
|
2006-08-03 22:18:45 -04:00
|
|
|
boost::shared_ptr<VSTPlugin> vp;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-03 22:18:45 -04:00
|
|
|
if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (insert->plugin())) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
|
2006-08-03 22:18:45 -04:00
|
|
|
VSTPluginUI* vpu = new VSTPluginUI (insert, vp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
_pluginui = vpu;
|
2005-12-02 14:18:26 -05:00
|
|
|
get_vbox()->add (*vpu);
|
2005-09-25 14:42:24 -04:00
|
|
|
vpu->package (*this);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
#endif
|
|
|
|
error << _("unknown type of editor-supplying plugin (note: no VST support in this version of ardour)")
|
|
|
|
<< endmsg;
|
|
|
|
throw failed_constructor ();
|
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-08-11 21:36:34 -04:00
|
|
|
LadspaPluginUI* pu = new LadspaPluginUI (insert, scrollable);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
_pluginui = pu;
|
2005-12-02 14:18:26 -05:00
|
|
|
get_vbox()->add (*pu);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-09 17:31:36 -04:00
|
|
|
signal_map_event().connect (mem_fun (*pu, &LadspaPluginUI::start_updating));
|
|
|
|
signal_unmap_event().connect (mem_fun (*pu, &LadspaPluginUI::stop_updating));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
set_position (Gtk::WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
set_name ("PluginEditor");
|
2006-04-26 12:04:04 -04:00
|
|
|
add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window*> (this)));
|
2006-08-03 22:18:45 -04:00
|
|
|
insert->GoingAway.connect (mem_fun(*this, &PluginUIWindow::plugin_going_away));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (scrollable) {
|
|
|
|
gint h = _pluginui->get_preferred_height ();
|
|
|
|
if (h > 600) h = 600;
|
|
|
|
set_default_size (450, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-08-11 21:36:34 -04:00
|
|
|
PluginUIWindow::~PluginUIWindow ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
}
|
2006-08-11 21:36:34 -04:00
|
|
|
bool
|
|
|
|
PluginUIWindow::on_key_press_event (GdkEventKey* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-11 21:36:34 -04:00
|
|
|
return PublicEditor::instance().on_key_press_event(event);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-08-11 21:36:34 -04:00
|
|
|
bool
|
|
|
|
PluginUIWindow::on_key_release_event (GdkEventKey* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-11 21:36:34 -04:00
|
|
|
return PublicEditor::instance().on_key_release_event(event);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginUIWindow::plugin_going_away (ARDOUR::Redirect* ignored)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &PluginUIWindow::plugin_going_away), ignored));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-24 22:36:42 -05:00
|
|
|
_pluginui->stop_updating(0);
|
2005-09-25 14:42:24 -04:00
|
|
|
delete_when_idle (this);
|
|
|
|
}
|
|
|
|
|
2006-08-03 22:18:45 -04:00
|
|
|
PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
|
2005-09-25 14:42:24 -04:00
|
|
|
: insert (pi),
|
2006-08-03 22:18:45 -04:00
|
|
|
plugin (insert->plugin()),
|
2006-04-19 16:42:17 -04:00
|
|
|
save_button(_("Add")),
|
|
|
|
bypass_button (_("Bypass"))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-29 14:58:47 -04:00
|
|
|
//combo.set_use_arrows_always(true);
|
2006-08-03 22:18:45 -04:00
|
|
|
set_popdown_strings (combo, plugin->get_presets());
|
2006-04-19 16:42:17 -04:00
|
|
|
combo.set_size_request (100, -1);
|
2005-09-26 10:33:53 -04:00
|
|
|
combo.set_active_text ("");
|
2005-11-15 21:57:22 -05:00
|
|
|
combo.signal_changed().connect(mem_fun(*this, &PlugUIBase::setting_selected));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
save_button.set_name ("PluginSaveButton");
|
2005-10-09 01:03:29 -04:00
|
|
|
save_button.signal_clicked().connect(mem_fun(*this, &PlugUIBase::save_plugin_setting));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
bypass_button.set_name ("PluginBypassButton");
|
2005-10-09 01:03:29 -04:00
|
|
|
bypass_button.signal_toggled().connect (mem_fun(*this, &PlugUIBase::bypass_toggled));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
void
|
|
|
|
PlugUIBase::setting_selected()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-26 21:10:36 -04:00
|
|
|
if (combo.get_active_text().length() > 0) {
|
2006-08-03 22:18:45 -04:00
|
|
|
if (!plugin->load_preset(combo.get_active_text())) {
|
2005-10-26 21:10:36 -04:00
|
|
|
warning << string_compose(_("Plugin preset %1 not found"), combo.get_active_text()) << endmsg;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlugUIBase::save_plugin_setting ()
|
|
|
|
{
|
|
|
|
ArdourPrompter prompter (true);
|
2006-04-19 16:42:17 -04:00
|
|
|
prompter.set_prompt(_("Name of New Preset:"));
|
|
|
|
prompter.add_button (Gtk::Stock::ADD, Gtk::RESPONSE_ACCEPT);
|
2006-04-22 11:28:59 -04:00
|
|
|
prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
prompter.show_all();
|
|
|
|
|
2005-10-26 21:10:36 -04:00
|
|
|
switch (prompter.run ()) {
|
2005-11-24 22:36:42 -05:00
|
|
|
case Gtk::RESPONSE_ACCEPT:
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
string name;
|
|
|
|
|
|
|
|
prompter.get_result(name);
|
|
|
|
|
|
|
|
if (name.length()) {
|
2006-08-03 22:18:45 -04:00
|
|
|
if(plugin->save_preset(name)){
|
|
|
|
set_popdown_strings (combo, plugin->get_presets());
|
2005-09-26 10:33:53 -04:00
|
|
|
combo.set_active_text (name);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2005-10-26 21:10:36 -04:00
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlugUIBase::bypass_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
2006-08-03 22:18:45 -04:00
|
|
|
if ((x = bypass_button.get_active()) == insert->active()) {
|
|
|
|
insert->set_active (!x, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|