mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
faderport: restore button actions, and correctly indicate current action in GUI
This commit is contained in:
parent
682e152aaf
commit
b8ed62453f
3 changed files with 49 additions and 1 deletions
|
|
@ -793,6 +793,30 @@ FaderPort::Button::set_action (string const& name, bool when_pressed, FaderPort:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
FaderPort::Button::get_action (bool press, FaderPort::ButtonState bs)
|
||||||
|
{
|
||||||
|
ToDoMap::iterator x;
|
||||||
|
|
||||||
|
if (press) {
|
||||||
|
if ((x = on_press.find (bs)) == on_press.end()) {
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
if (x->second.type != NamedAction) {
|
||||||
|
return string ();
|
||||||
|
}
|
||||||
|
return x->second.action_name;
|
||||||
|
} else {
|
||||||
|
if ((x = on_release.find (bs)) == on_release.end()) {
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
if (x->second.type != NamedAction) {
|
||||||
|
return string ();
|
||||||
|
}
|
||||||
|
return x->second.action_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FaderPort::Button::set_action (boost::function<void()> f, bool when_pressed, FaderPort::ButtonState bs)
|
FaderPort::Button::set_action (boost::function<void()> f, bool when_pressed, FaderPort::ButtonState bs)
|
||||||
{
|
{
|
||||||
|
|
@ -1107,3 +1131,9 @@ FaderPort::set_action (ButtonID id, std::string const& action_name, bool on_pres
|
||||||
{
|
{
|
||||||
get_button(id).set_action (action_name, on_press, bs);
|
get_button(id).set_action (action_name, on_press, bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
FaderPort::get_action (ButtonID id, bool press, ButtonState bs)
|
||||||
|
{
|
||||||
|
return get_button(id).get_action (press, bs);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
|
||||||
};
|
};
|
||||||
|
|
||||||
void set_action (ButtonID, std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
void set_action (ButtonID, std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
||||||
|
std::string get_action (ButtonID, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::shared_ptr<ARDOUR::Route> _current_route;
|
boost::shared_ptr<ARDOUR::Route> _current_route;
|
||||||
|
|
@ -221,6 +222,8 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
|
||||||
|
|
||||||
void set_action (std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
void set_action (std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
||||||
void set_action (boost::function<void()> function, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
void set_action (boost::function<void()> function, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
||||||
|
std::string get_action (bool press, FaderPort::ButtonState bs = ButtonState (0));
|
||||||
|
|
||||||
void set_led_state (boost::shared_ptr<MIDI::Port>, int onoff, bool force = false);
|
void set_led_state (boost::shared_ptr<MIDI::Port>, int onoff, bool force = false);
|
||||||
void invoke (ButtonState bs, bool press);
|
void invoke (ButtonState bs, bool press);
|
||||||
bool uses_flash () const { return flash; }
|
bool uses_flash () const { return flash; }
|
||||||
|
|
|
||||||
|
|
@ -426,22 +426,37 @@ FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const
|
||||||
Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_columns));
|
Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_columns));
|
||||||
TreeIter rowp;
|
TreeIter rowp;
|
||||||
TreeModel::Row row;
|
TreeModel::Row row;
|
||||||
|
string current_action = fp.get_action (id, true, bs);
|
||||||
|
int active_row = -1;
|
||||||
|
int n;
|
||||||
|
vector<pair<string,string> >::const_iterator i;
|
||||||
|
|
||||||
rowp = model->append();
|
rowp = model->append();
|
||||||
row = *(rowp);
|
row = *(rowp);
|
||||||
row[action_columns.name] = _("Disabled");
|
row[action_columns.name] = _("Disabled");
|
||||||
row[action_columns.path] = string();
|
row[action_columns.path] = string();
|
||||||
|
|
||||||
for (vector<pair<string,string> >::const_iterator i = actions.begin(); i != actions.end(); ++i) {
|
if (current_action.empty()) {
|
||||||
|
active_row = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) {
|
||||||
rowp = model->append();
|
rowp = model->append();
|
||||||
row = *(rowp);
|
row = *(rowp);
|
||||||
row[action_columns.name] = i->first;
|
row[action_columns.name] = i->first;
|
||||||
row[action_columns.path] = i->second;
|
row[action_columns.path] = i->second;
|
||||||
|
if (current_action == i->second) {
|
||||||
|
active_row = n+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cb.set_model (model);
|
cb.set_model (model);
|
||||||
cb.pack_start (action_columns.name);
|
cb.pack_start (action_columns.name);
|
||||||
|
|
||||||
|
if (active_row >= 0) {
|
||||||
|
cb.set_active (active_row);
|
||||||
|
}
|
||||||
|
|
||||||
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, id));
|
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue