13
0

Use ActionModel::build_action_combo() for Control Surfaces that need it

This commit is contained in:
Johannes Mueller 2019-04-20 14:35:50 +02:00
parent de876acc8b
commit 73f8b8d982
7 changed files with 6 additions and 106 deletions

View File

@ -150,7 +150,7 @@ class CC121 : public ARDOUR::ControlProtocol, public AbstractUI<CC121Request> {
};
enum ButtonState {
ShiftDown = 0x1,
ShiftDown = 0x1,
RewindDown = 0x2,
StopDown = 0x4,
UserDown = 0x8,

View File

@ -428,45 +428,12 @@ CC121GUI::build_foot_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs)
build_action_combo (cb, actions, CC121::Footswitch, bs);
}
bool
CC121GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
{
TreeModel::Row row = *iter;
string path = row[action_model.path()];
if (path == action_path) {
*found = iter;
return true;
}
return false;
}
void
CC121GUI::build_user_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs, CC121::ButtonID id)
{
cb.set_model (action_model.model());
cb.pack_start (action_model.name());
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &CC121GUI::action_changed), &cb, id, bs));
/* set the active "row" to the right value for the current button binding */
string current_action = fp.get_action (id, false, bs); /* lookup release action */
if (current_action.empty()) {
cb.set_active (0); /* "disabled" */
return;
}
TreeModel::iterator iter = action_model.model()->children().end();
action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &CC121GUI::find_action_in_model), current_action, &iter));
if (iter != action_model.model()->children().end()) {
cb.set_active (iter);
} else {
cb.set_active (0);
}
action_model.build_action_combo (cb, current_action);
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &CC121GUI::action_changed), &cb, id, bs));
}
Glib::RefPtr<Gtk::ListStore>

View File

@ -101,9 +101,6 @@ private:
void build_foot_action_combo (Gtk::ComboBox&, CC121::ButtonState);
void action_changed (Gtk::ComboBox*, CC121::ButtonID, CC121::ButtonState);
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
};
}

View File

@ -460,19 +460,6 @@ FPGUI::build_foot_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
build_action_combo (cb, actions, FaderPort::Footswitch, bs);
}
bool
FPGUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
{
TreeModel::Row row = *iter;
string path = row[action_model.path()];
if (path == action_path) {
*found = iter;
return true;
}
return false;
}
void
FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
@ -480,28 +467,12 @@ FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
#ifndef MIXBUS
bs = FaderPort::ButtonState (bs|FaderPort::UserDown);
#endif
cb.set_model (action_model.model());
cb.pack_start (action_model.name());
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs));
/* set the active "row" to the right value for the current button binding */
string current_action = fp.get_action (FaderPort::User, false, bs); /* lookup release action */
if (current_action.empty()) {
cb.set_active (0); /* "disabled" */
return;
}
TreeModel::iterator iter = action_model.model()->children().end();
action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FPGUI::find_action_in_model), current_action, &iter));
if (iter != action_model.model()->children().end()) {
cb.set_active (iter);
} else {
cb.set_active (0);
}
action_model.build_action_combo (cb, current_action);
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs));
}

View File

@ -99,9 +99,6 @@ private:
void build_foot_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
void action_changed (Gtk::ComboBox*, FaderPort::ButtonID, FaderPort::ButtonState);
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
};
}

View File

@ -341,43 +341,13 @@ FP8GUI::active_port_changed (Gtk::ComboBox* combo, bool for_input)
bool
FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const& action_path, TreeModel::iterator* found)
{
TreeModel::Row row = *iter;
string path = row[action_model.path()];
if (path == action_path) {
*found = iter;
return true;
}
return false;
}
void
FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
{
cb.set_model (action_model.model());
cb.pack_start (action_model.name());
/* set the active "row" to the right value for the current button binding */
string current_action = fp.get_button_action (id, false); /* lookup release action */
if (current_action.empty()) {
cb.set_active (0); /* "disabled" */
} else {
TreeModel::iterator iter = action_model.model()->children().end();
action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FP8GUI::find_action_in_model), current_action, &iter));
if (iter != action_model.model()->children().end()) {
cb.set_active (iter);
} else {
cb.set_active (0);
}
}
/* bind signal _after_ setting the current value */
action_model.build_action_combo(cb, current_action);
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FP8GUI::action_changed), &cb, id));
}

View File

@ -98,8 +98,6 @@ private:
const ActionManager::ActionModel& action_model;
std::map<std::string,std::string> action_map; // map from action names to paths
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
};
} }