13
0

Save and Delete buttons for plugin presets, remove largely useless edit plugin presets dialog. Should fix #2662.

git-svn-id: svn://localhost/ardour2/branches/3.0@8278 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-12-15 01:06:57 +00:00
parent f09524b9d3
commit 3a1af63fed
9 changed files with 58 additions and 169 deletions

5
.gitignore vendored
View File

@ -121,3 +121,8 @@ build
tags tags
BROWSE BROWSE
core core
gtk2_ardour/po/*.mo
libs/ardour/po/*.mo
gtk2_ardour/*.pot
libs/ardour/libardour.pot

View File

@ -1787,9 +1787,10 @@ widget "*PluginAutomatePlayButton" style:highest "small_red_active_and_selected_
widget "*PluginAutomatePlayButton*" style:highest "small_red_active_and_selected_button" widget "*PluginAutomatePlayButton*" style:highest "small_red_active_and_selected_button"
widget "*PluginAutomateButton" style:highest "small_button" widget "*PluginAutomateButton" style:highest "small_button"
widget "*PluginAutomateButton*" style:highest "small_button" widget "*PluginAutomateButton*" style:highest "small_button"
widget "*PluginAddButton*" style:highest "small_button"
widget "*PluginSaveButton" style:highest "small_button" widget "*PluginSaveButton" style:highest "small_button"
widget "*PluginSaveButton*" style:highest "small_button" widget "*PluginSaveButton*" style:highest "small_button"
widget "*PluginEditButton*" style:highest "small_button" widget "*PluginDeleteButton*" style:highest "small_button"
widget "*PluginLoadButton" style:highest "small_button" widget "*PluginLoadButton" style:highest "small_button"
widget "*PluginLoadButton*" style:highest "small_button" widget "*PluginLoadButton*" style:highest "small_button"

View File

@ -1,105 +0,0 @@
/*
Copyright (C) 2010 Paul Davis
Author: Carl Hetherington <cth@carlh.net>
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.
*/
#include <gtkmm/stock.h>
#include <gtkmm/listviewtext.h>
#include <gtkmm/scrolledwindow.h>
#include "gtkmm2ext/gui_thread.h"
#include "ardour/plugin.h"
#include "edit_plugin_presets_dialog.h"
using namespace std;
using namespace Gtk;
EditPluginPresetsDialog::EditPluginPresetsDialog (boost::shared_ptr<ARDOUR::Plugin> plugin)
: ArdourDialog (_("Edit Presets"))
, _plugin (plugin)
, _list (1, false, SELECTION_MULTIPLE)
, _delete (_("Delete"))
{
_list.set_headers_visible (false);
setup_list ();
HBox* hbox = manage (new HBox);
hbox->set_spacing (6);
ScrolledWindow* scr = manage (new ScrolledWindow);
scr->add (_list);
hbox->pack_start (*scr);
VBox* vbox = manage (new VBox);
vbox->pack_start (_delete, false, false);
hbox->pack_start (*vbox, false, false);
get_vbox()->pack_start (*hbox);
add_button (Stock::CLOSE, RESPONSE_ACCEPT);
set_size_request (250, 300);
update_sensitivity ();
show_all ();
_list.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditPluginPresetsDialog::update_sensitivity));
_delete.signal_clicked().connect (sigc::mem_fun (*this, &EditPluginPresetsDialog::delete_presets));
_plugin->PresetAdded.connect (_preset_added_connection, invalidator (*this), boost::bind (&EditPluginPresetsDialog::setup_list, this), gui_context ());
_plugin->PresetRemoved.connect (_preset_removed_connection, invalidator (*this), boost::bind (&EditPluginPresetsDialog::setup_list, this), gui_context ());
}
void
EditPluginPresetsDialog::update_sensitivity ()
{
ListViewText::SelectionList s = _list.get_selected ();
ListViewText::SelectionList::const_iterator i = s.begin();
while (i != s.end()) {
if (*i >= _plugin->first_user_preset_index()) {
break;
}
++i;
}
_delete.set_sensitive (i != s.end ());
}
void
EditPluginPresetsDialog::delete_presets ()
{
ListViewText::SelectionList const s = _list.get_selected ();
for (ListViewText::SelectionList::const_iterator i = s.begin(); i != s.end(); ++i) {
_plugin->remove_preset (_list.get_text (*i));
}
}
void
EditPluginPresetsDialog::setup_list ()
{
_list.clear_items ();
vector<ARDOUR::Plugin::PresetRecord> presets = _plugin->get_presets ();
for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
_list.append_text (i->label);
}
update_sensitivity ();
}

View File

@ -1,43 +0,0 @@
/*
Copyright (C) 2010 Paul Davis
Author: Carl Hetherington <cth@carlh.net>
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.
*/
#include "ardour_dialog.h"
namespace ARDOUR {
class Plugin;
}
class EditPluginPresetsDialog : public ArdourDialog
{
public:
EditPluginPresetsDialog (boost::shared_ptr<ARDOUR::Plugin>);
private:
void setup_list ();
void delete_presets ();
void update_sensitivity ();
boost::shared_ptr<ARDOUR::Plugin> _plugin;
Gtk::ListViewText _list;
Gtk::Button _delete;
PBD::ScopedConnection _preset_added_connection;
PBD::ScopedConnection _preset_removed_connection;
};

View File

@ -93,8 +93,9 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
smaller_hbox->pack_start (latency_button, false, false, 10); smaller_hbox->pack_start (latency_button, false, false, 10);
smaller_hbox->pack_start (preset_combo, false, false); smaller_hbox->pack_start (preset_combo, false, false);
smaller_hbox->pack_start (add_button, false, false);
smaller_hbox->pack_start (save_button, false, false); smaller_hbox->pack_start (save_button, false, false);
smaller_hbox->pack_start (edit_button, false, false); smaller_hbox->pack_start (delete_button, false, false);
smaller_hbox->pack_start (bypass_button, false, true); smaller_hbox->pack_start (bypass_button, false, true);
constraint_hbox->set_spacing (5); constraint_hbox->set_spacing (5);

View File

@ -67,7 +67,6 @@
#include "latency_gui.h" #include "latency_gui.h"
#include "plugin_eq_gui.h" #include "plugin_eq_gui.h"
#include "new_plugin_preset_dialog.h" #include "new_plugin_preset_dialog.h"
#include "edit_plugin_presets_dialog.h"
#include "i18n.h" #include "i18n.h"
@ -244,7 +243,6 @@ PluginUIWindow::on_hide ()
void void
PluginUIWindow::set_title(const std::string& title) PluginUIWindow::set_title(const std::string& title)
{ {
//cout << "PluginUIWindow::set_title(\"" << title << "\"" << endl;
Gtk::Window::set_title(title); Gtk::Window::set_title(title);
_title = title; _title = title;
} }
@ -421,24 +419,30 @@ PluginUIWindow::plugin_going_away ()
PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi) PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
: insert (pi), : insert (pi),
plugin (insert->plugin()), plugin (insert->plugin()),
save_button (_("Add")), add_button (_("Add")),
edit_button (_("Edit")), save_button (_("Save")),
delete_button (_("Delete")),
bypass_button (_("Bypass")), bypass_button (_("Bypass")),
latency_gui (0), latency_gui (0),
plugin_analysis_expander (_("Plugin analysis")) plugin_analysis_expander (_("Plugin analysis"))
{ {
//preset_combo.set_use_arrows_always(true); //preset_combo.set_use_arrows_always(true);
update_presets(); update_presets ();
update_sensitivity ();
preset_combo.set_size_request (100, -1); preset_combo.set_size_request (100, -1);
preset_combo.set_active_text (""); preset_combo.set_active_text ("");
preset_combo.signal_changed().connect(sigc::mem_fun(*this, &PlugUIBase::setting_selected)); preset_combo.signal_changed().connect(sigc::mem_fun(*this, &PlugUIBase::setting_selected));
no_load_preset = false; no_load_preset = false;
add_button.set_name ("PluginAddButton");
add_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::add_plugin_setting));
save_button.set_name ("PluginSaveButton"); save_button.set_name ("PluginSaveButton");
save_button.signal_clicked().connect(sigc::mem_fun(*this, &PlugUIBase::save_plugin_setting)); save_button.signal_clicked().connect(sigc::mem_fun(*this, &PlugUIBase::save_plugin_setting));
edit_button.set_name ("PluginEditButton"); delete_button.set_name ("PluginDeleteButton");
edit_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::edit_plugin_settings)); delete_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::delete_plugin_setting));
insert->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&PlugUIBase::processor_active_changed, this, boost::weak_ptr<Processor>(insert)), gui_context()); insert->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&PlugUIBase::processor_active_changed, this, boost::weak_ptr<Processor>(insert)), gui_context());
@ -524,7 +528,7 @@ PlugUIBase::processor_active_changed (boost::weak_ptr<Processor> weak_p)
} }
void void
PlugUIBase::setting_selected() PlugUIBase::setting_selected ()
{ {
if (no_load_preset) { if (no_load_preset) {
return; return;
@ -533,7 +537,8 @@ PlugUIBase::setting_selected()
if (preset_combo.get_active_text().length() > 0) { if (preset_combo.get_active_text().length() > 0) {
const Plugin::PresetRecord* pr = plugin->preset_by_label(preset_combo.get_active_text()); const Plugin::PresetRecord* pr = plugin->preset_by_label(preset_combo.get_active_text());
if (pr) { if (pr) {
plugin->load_preset(pr->uri); plugin->load_preset (pr->uri);
update_sensitivity ();
} else { } else {
warning << string_compose(_("Plugin preset %1 not found"), warning << string_compose(_("Plugin preset %1 not found"),
preset_combo.get_active_text()) << endmsg; preset_combo.get_active_text()) << endmsg;
@ -542,7 +547,7 @@ PlugUIBase::setting_selected()
} }
void void
PlugUIBase::save_plugin_setting () PlugUIBase::add_plugin_setting ()
{ {
NewPluginPresetDialog d (plugin); NewPluginPresetDialog d (plugin);
@ -557,20 +562,32 @@ PlugUIBase::save_plugin_setting ()
} }
if (plugin->save_preset (d.name())) { if (plugin->save_preset (d.name())) {
update_presets ();
no_load_preset = true;
preset_combo.set_active_text (d.name()); preset_combo.set_active_text (d.name());
no_load_preset = false;
} }
break; break;
} }
} }
void void
PlugUIBase::edit_plugin_settings () PlugUIBase::save_plugin_setting ()
{ {
EditPluginPresetsDialog d (plugin); string const name = preset_combo.get_active_text ();
d.run (); plugin->remove_preset (name);
plugin->save_preset (name);
preset_combo.set_active_text (name);
}
void
PlugUIBase::delete_plugin_setting ()
{
plugin->remove_preset (preset_combo.get_active_text ());
vector<ARDOUR::Plugin::PresetRecord> presets = plugin->get_presets();
if (presets.empty ()) {
preset_combo.set_active_text ("");
} else {
preset_combo.set_active_text (presets.front().label);
}
} }
void void
@ -663,4 +680,14 @@ PlugUIBase::update_presets ()
set_popdown_strings (preset_combo, preset_labels); set_popdown_strings (preset_combo, preset_labels);
no_load_preset = false; no_load_preset = false;
update_sensitivity ();
}
void
PlugUIBase::update_sensitivity ()
{
bool const have_preset = !preset_combo.get_model()->children().empty();
save_button.set_sensitive (have_preset);
delete_button.set_sensitive (have_preset);
} }

View File

@ -102,8 +102,9 @@ class PlugUIBase : public virtual sigc::trackable
boost::shared_ptr<ARDOUR::PluginInsert> insert; boost::shared_ptr<ARDOUR::PluginInsert> insert;
boost::shared_ptr<ARDOUR::Plugin> plugin; boost::shared_ptr<ARDOUR::Plugin> plugin;
Gtk::ComboBoxText preset_combo; Gtk::ComboBoxText preset_combo;
Gtk::Button add_button;
Gtk::Button save_button; Gtk::Button save_button;
Gtk::Button edit_button; Gtk::Button delete_button;
Gtk::ToggleButton bypass_button; Gtk::ToggleButton bypass_button;
Gtk::EventBox focus_button; Gtk::EventBox focus_button;
@ -121,13 +122,15 @@ class PlugUIBase : public virtual sigc::trackable
bool no_load_preset; bool no_load_preset;
void setting_selected(); void setting_selected();
void add_plugin_setting ();
void save_plugin_setting (); void save_plugin_setting ();
void edit_plugin_settings (); void delete_plugin_setting ();
bool focus_toggled(GdkEventButton*); bool focus_toggled(GdkEventButton*);
void bypass_toggled(); void bypass_toggled();
void toggle_plugin_analysis (); void toggle_plugin_analysis ();
void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p); void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
void plugin_going_away (); void plugin_going_away ();
void update_sensitivity ();
PBD::ScopedConnection death_connection; PBD::ScopedConnection death_connection;
PBD::ScopedConnection active_connection; PBD::ScopedConnection active_connection;

View File

@ -51,6 +51,7 @@ VSTPluginUI::VSTPluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<
preset_box.pack_end (bypass_button, false, false, 10); preset_box.pack_end (bypass_button, false, false, 10);
preset_box.pack_end (edit_button, false, false); preset_box.pack_end (edit_button, false, false);
preset_box.pack_end (save_button, false, false); preset_box.pack_end (save_button, false, false);
preset_box.pack_end (add_button, false, false);
preset_box.pack_end (vst_preset_combo, false, false); preset_box.pack_end (vst_preset_combo, false, false);
vst_preset_combo.signal_changed().connect (sigc::mem_fun (*this, &VSTPluginUI::preset_chosen)); vst_preset_combo.signal_changed().connect (sigc::mem_fun (*this, &VSTPluginUI::preset_chosen));

View File

@ -69,7 +69,6 @@ gtk2_ardour_sources = [
'debug.cc', 'debug.cc',
'diamond.cc', 'diamond.cc',
'edit_note_dialog.cc', 'edit_note_dialog.cc',
'edit_plugin_presets_dialog.cc',
'editing.cc', 'editing.cc',
'editor.cc', 'editor.cc',
'editor_actions.cc', 'editor_actions.cc',