X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui_ed.cc;h=e764779300048b5d025c8705f2f9af41aae259b1;hb=2592a320d42dd4a157ee16101c042d875d3142be;hp=d7c294c6815a14499c78bbd74aac0719ab5ca838;hpb=360a903069c7a0dd5e792312ec0eb8921a2aa49d;p=ardour.git diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index d7c294c681..e764779300 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -478,10 +478,36 @@ ARDOUR_UI::toggle_control_protocol (ControlProtocolInfo* cpi) } } +void +ARDOUR_UI::toggle_control_protocol_feedback (ControlProtocolInfo* cpi, const char* group, const char* action) +{ + if (!session) { + /* this happens when we build the menu bar when control protocol support + has been used in the past for some given protocol - the item needs + to be made active, but there is no session yet. + */ + return; + } + + if (cpi->protocol) { + Glib::RefPtr act = ActionManager::get_action (group, action); + + if (act) { + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); + bool x = tact->get_active(); + + if (tact && x != cpi->protocol->get_feedback()) { + cpi->protocol->set_feedback (!x); + } + } + } +} + void ARDOUR_UI::build_control_surface_menu () { list::iterator i; + bool with_feedback; /* !!! this has to match the top level entry from ardour.menus */ @@ -501,6 +527,8 @@ ARDOUR_UI::build_control_surface_menu () (bind (mem_fun (*this, &ARDOUR_UI::toggle_control_protocol), *i))); Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); + + with_feedback = false; if ((*i)->protocol || (*i)->requested) { tact->set_active (); @@ -509,6 +537,34 @@ ARDOUR_UI::build_control_surface_menu () ui += "\n"; + + if ((*i)->supports_feedback) { + + string submenu_name = action_name; + + submenu_name += "SubMenu"; + + ActionManager::register_action (editor->editor_actions, submenu_name.c_str(), _("Controls")); + + action_name += "Feedback"; + + Glib::RefPtr act = ActionManager::register_toggle_action (editor->editor_actions, action_name.c_str(), _("Feedback"), + (bind (mem_fun (*this, &ARDOUR_UI::toggle_control_protocol_feedback), + *i, + "Editor", + action_name.c_str()))); + + ui += "\n\n\n"; + + if ((*i)->protocol) { + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); + tact->set_active ((*i)->protocol->get_feedback ()); + } + } } }