Set up ControlUI::combo_map correctly to fix drop-down boxes

in generated plugin UIs (#4221).  Based on work by
jeremybub.


git-svn-id: svn://localhost/ardour2/branches/3.0@10064 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-09-07 14:42:25 +00:00
parent bb91aaa5ec
commit 44b7830064
2 changed files with 10 additions and 11 deletions

View file

@ -481,7 +481,6 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
control_ui = manage (new ControlUI ()); control_ui = manage (new ControlUI ());
control_ui->combo = 0; control_ui->combo = 0;
control_ui->combo_map = 0;
control_ui->control = mcontrol; control_ui->control = mcontrol;
control_ui->update_pending = false; control_ui->update_pending = false;
control_ui->label.set_text (desc.label); control_ui->label.set_text (desc.label);
@ -497,13 +496,15 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
/* Build a combo box */ /* Build a combo box */
boost::shared_ptr<ARDOUR::Plugin::ScalePoints> points control_ui->combo_map = plugin->get_scale_points (port_index);
= plugin->get_scale_points(port_index);
if (points) { if (control_ui->combo_map) {
std::vector<std::string> labels; std::vector<std::string> labels;
for (ARDOUR::Plugin::ScalePoints::const_iterator i = points->begin(); for (
i != points->end(); ++i) { ARDOUR::Plugin::ScalePoints::const_iterator i = control_ui->combo_map->begin();
i != control_ui->combo_map->end();
++i) {
labels.push_back(i->first); labels.push_back(i->first);
} }
@ -744,8 +745,7 @@ GenericPluginUI::update_control_display (ControlUI* cui)
cui->ignore_change++; cui->ignore_change++;
if (cui->combo && cui->combo_map) { if (cui->combo && cui->combo_map) {
std::map<string,float>::iterator it; for (ARDOUR::Plugin::ScalePoints::iterator it = cui->combo_map->begin(); it != cui->combo_map->end(); ++it) {
for (it = cui->combo_map->begin(); it != cui->combo_map->end(); ++it) {
if (it->second == val) { if (it->second == val) {
cui->combo->set_active_text(it->first); cui->combo->set_active_text(it->first);
break; break;
@ -789,8 +789,7 @@ GenericPluginUI::control_combo_changed (ControlUI* cui)
{ {
if (!cui->ignore_change && cui->combo_map) { if (!cui->ignore_change && cui->combo_map) {
string value = cui->combo->get_active_text(); string value = cui->combo->get_active_text();
std::map<string,float> mapping = *cui->combo_map; insert->automation_control (cui->parameter())->set_value ((*cui->combo_map)[value]);
insert->automation_control(cui->parameter())->set_value(mapping[value]);
} }
} }

View file

@ -212,7 +212,7 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox
/* input */ /* input */
Gtk::ComboBoxText* combo; Gtk::ComboBoxText* combo;
std::map<std::string, float>* combo_map; boost::shared_ptr<ARDOUR::Plugin::ScalePoints> combo_map;
Gtk::ToggleButton* button; Gtk::ToggleButton* button;
boost::shared_ptr<AutomationController> controller; boost::shared_ptr<AutomationController> controller;
Gtkmm2ext::ClickBox* clickbox; Gtkmm2ext::ClickBox* clickbox;