13
0

Use Ardour widgets consistently in plugin UI.

Several reasons:

* This previously looked horribly inconsistent.

* The Gtk selector was broken for plugins with many presets,
  making it impossible to select presets.  For whatever reason,
  the use of a menu fixes this bug.

* Towards a hierarchical menu for banked presets.
This commit is contained in:
David Robillard 2015-03-06 19:05:29 -05:00
parent 7eb849ad21
commit 0cb096a978
6 changed files with 41 additions and 43 deletions

View File

@ -337,9 +337,7 @@
<ColorAlias name="piano roll black outline" alias="color 33"/>
<ColorAlias name="piano roll white" alias="color 45"/>
<ColorAlias name="play head" alias="color 9"/>
<ColorAlias name="plugin bypass button: fill" alias="color 71"/>
<ColorAlias name="plugin bypass button: fill active" alias="color 42"/>
<ColorAlias name="plugin bypass button: led active" alias="color 9"/>
<ColorAlias name="plugin bypass button: led active" alias="color 8"/>
<ColorAlias name="processor automation line" alias="color 77"/>
<ColorAlias name="processor control button: fill" alias="color 29"/>
<ColorAlias name="processor control button: fill active" alias="color 46"/>

View File

@ -83,8 +83,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
Label* combo_label = manage (new Label (_("<span size=\"large\">Presets</span>")));
combo_label->set_use_markup (true);
latency_button.add (latency_label);
latency_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::latency_button_clicked));
latency_button.signal_clicked.connect (sigc::mem_fun (*this, &PlugUIBase::latency_button_clicked));
set_latency_label ();
smaller_hbox->pack_start (latency_button, false, false, 10);

View File

@ -426,7 +426,7 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
, eqgui (0)
{
_preset_modified.set_size_request (16, -1);
_preset_combo.signal_changed().connect(sigc::mem_fun(*this, &PlugUIBase::preset_selected));
_preset_combo.set_text("(default)");
ARDOUR_UI::instance()->set_tip (_preset_combo, _("Presets (if any) for this plugin\n(Both factory and user-created)"));
ARDOUR_UI::instance()->set_tip (add_button, _("Save a new preset"));
ARDOUR_UI::instance()->set_tip (save_button, _("Save the current preset"));
@ -437,14 +437,14 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
update_preset_list ();
update_preset ();
add_button.set_name ("PluginAddButton");
add_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::add_plugin_setting));
add_button.set_name ("generic button");
add_button.signal_clicked.connect (sigc::mem_fun (*this, &PlugUIBase::add_plugin_setting));
save_button.set_name ("PluginSaveButton");
save_button.signal_clicked().connect(sigc::mem_fun(*this, &PlugUIBase::save_plugin_setting));
save_button.set_name ("generic button");
save_button.signal_clicked.connect(sigc::mem_fun(*this, &PlugUIBase::save_plugin_setting));
delete_button.set_name ("PluginDeleteButton");
delete_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::delete_plugin_setting));
delete_button.set_name ("generic button");
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());
@ -509,7 +509,7 @@ PlugUIBase::set_latency_label ()
t = string_compose (_("latency (%1 ms)"), (float) l / ((float) sr / 1000.0f));
}
latency_label.set_text (t);
latency_button.set_text (t);
}
void
@ -545,20 +545,13 @@ PlugUIBase::processor_active_changed (boost::weak_ptr<Processor> weak_p)
}
void
PlugUIBase::preset_selected ()
PlugUIBase::preset_selected (Plugin::PresetRecord preset)
{
if (_no_load_preset) {
return;
}
if (_preset_combo.get_active_text().length() > 0) {
const Plugin::PresetRecord* pr = plugin->preset_by_label (_preset_combo.get_active_text());
if (pr) {
plugin->load_preset (*pr);
} else {
warning << string_compose(_("Plugin preset %1 not found"),
_preset_combo.get_active_text()) << endmsg;
}
if (!preset.label.empty()) {
plugin->load_preset (preset);
} else {
// blank selected = no preset
plugin->clear_preset();
@ -605,7 +598,7 @@ void
PlugUIBase::save_plugin_setting ()
{
#ifndef NO_PLUGIN_STATE
string const name = _preset_combo.get_active_text ();
string const name = _preset_combo.get_text ();
plugin->remove_preset (name);
Plugin::PresetRecord const r = plugin->save_preset (name);
if (!r.uri.empty ()) {
@ -625,7 +618,7 @@ void
PlugUIBase::delete_plugin_setting ()
{
#ifndef NO_PLUGIN_STATE
plugin->remove_preset (_preset_combo.get_active_text ());
plugin->remove_preset (_preset_combo.get_text ());
#else
if (!seen_saving_message) {
info << string_compose (_("Plugin presets are not supported in this build of %1. Consider paying for a newer version"),
@ -736,18 +729,23 @@ PlugUIBase::toggle_plugin_analysis()
void
PlugUIBase::update_preset_list ()
{
vector<string> preset_labels;
using namespace Menu_Helpers;
vector<ARDOUR::Plugin::PresetRecord> presets = plugin->get_presets();
++_no_load_preset;
// Add a menu entry for each preset
_preset_combo.clear_items();
for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
preset_labels.push_back (i->label);
_preset_combo.AddMenuElem(
MenuElem(i->label, sigc::bind(sigc::mem_fun(*this, &PlugUIBase::preset_selected), *i)));
}
preset_labels.push_back("");
set_popdown_strings (_preset_combo, preset_labels);
// Add an empty entry for un-setting current preset (see preset_selected)
Plugin::PresetRecord no_preset;
_preset_combo.AddMenuElem(
MenuElem("", sigc::bind(sigc::mem_fun(*this, &PlugUIBase::preset_selected), no_preset)));
--_no_load_preset;
}
@ -758,7 +756,11 @@ PlugUIBase::update_preset ()
Plugin::PresetRecord p = plugin->last_preset();
++_no_load_preset;
_preset_combo.set_active_text (p.label);
if (p.uri.empty()) {
_preset_combo.set_text ("(none)");
} else {
_preset_combo.set_text (p.label);
}
--_no_load_preset;
save_button.set_sensitive (!p.uri.empty() && p.user);

View File

@ -49,9 +49,10 @@
#include "ardour/plugin.h"
#include "ardour/variant.h"
#include "automation_controller.h"
#include "ardour_button.h"
#include "ardour_dropdown.h"
#include "ardour_window.h"
#include "automation_controller.h"
namespace ARDOUR {
class PluginInsert;
@ -115,15 +116,15 @@ class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionL
/* UI elements that can subclasses can add to their widgets */
/** a ComboBoxText which lists presets and manages their selection */
Gtk::ComboBoxText _preset_combo;
ArdourDropdown _preset_combo;
/** a label which has a * in if the current settings are different from the preset being shown */
Gtk::Label _preset_modified;
/** a button to add a preset */
Gtk::Button add_button;
ArdourButton add_button;
/** a button to save the current settings as a new user preset */
Gtk::Button save_button;
ArdourButton save_button;
/** a button to delete the current preset (if it is a user one) */
Gtk::Button delete_button;
ArdourButton delete_button;
/** a button to bypass the plugin */
ArdourButton bypass_button;
/** a button to acquire keyboard focus */
@ -132,10 +133,8 @@ class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionL
Gtk::Expander description_expander;
/** an expander containing the plugin analysis graph */
Gtk::Expander plugin_analysis_expander;
/** a label indicating the plugin latency */
Gtk::Label latency_label;
/** a button which, when clicked, opens the latency GUI */
Gtk::Button latency_button;
ArdourButton latency_button;
/** a button which sets all controls' automation setting to Manual */
ArdourButton automation_manual_all_button;
/** a button which sets all controls' automation setting to Play */
@ -157,7 +156,7 @@ class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionL
Gtk::Image* focus_in_image;
int _no_load_preset;
virtual void preset_selected ();
virtual void preset_selected (ARDOUR::Plugin::PresetRecord preset);
void add_plugin_setting ();
void save_plugin_setting ();
void delete_plugin_setting ();

View File

@ -60,12 +60,12 @@ VSTPluginUI::~VSTPluginUI ()
}
void
VSTPluginUI::preset_selected ()
VSTPluginUI::preset_selected (Plugin::PresetRecord preset)
{
#ifdef GDK_WINDOWING_X11
_socket.grab_focus ();
#endif
PlugUIBase::preset_selected ();
PlugUIBase::preset_selected (preset);
}
int

View File

@ -52,7 +52,7 @@ protected:
private:
bool configure_handler (GdkEventConfigure *);
void preset_selected ();
void preset_selected (ARDOUR::Plugin::PresetRecord preset);
};
#endif