From 05457ee55290cbc6fc09b98df9d5e71b84f158d0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 17 Oct 2012 01:03:14 +0000 Subject: [PATCH] crossport control surface work from mb2 branch git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@13295 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.h | 1 + gtk2_ardour/ardour_ui_ed.cc | 58 +++++++++++- libs/ardour/ardour/control_protocol_manager.h | 4 +- libs/ardour/control_protocol_manager.cc | 91 ++++++++----------- libs/ardour/session_state.cc | 2 +- .../generic_midi_control_protocol.cc | 13 ++- 6 files changed, 102 insertions(+), 67 deletions(-) diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index efbfb9e83b..51ee99125b 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -745,6 +745,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI void map_meter_falloff (); void toggle_control_protocol (ARDOUR::ControlProtocolInfo*); + void control_protocol_status_change (ARDOUR::ControlProtocolInfo*); void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo*, const char* group_name, std::string action_name); bool first_idle (); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index f1d683fd88..babddb4e13 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -640,13 +640,61 @@ ARDOUR_UI::install_actions () ActionManager::add_action_group (common_actions); } +void +ARDOUR_UI::control_protocol_status_change (ControlProtocolInfo* cpi) +{ + string action_name = "Toggle"; + action_name += legalize_for_path (cpi->name); + action_name += "Surface"; + + Glib::RefPtr act = ActionManager::get_action (X_("Editor"), action_name.c_str()); + + if (!act) { + return; + } + + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); + + if (!tact) { + return; + } + + if (tact->get_active() == (cpi->protocol != 0)) { + /* action state matches current protocol state, ignore this + bogus toggle (e.g. caused by initial ::set_active() call + */ + return; + } + + if (cpi->protocol == 0) { + tact->set_active (false); + } else { + tact->set_active (true); + } +} + void ARDOUR_UI::toggle_control_protocol (ControlProtocolInfo* cpi) { - 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. + string action_name = "Toggle"; + action_name += legalize_for_path (cpi->name); + action_name += "Surface"; + + Glib::RefPtr act = ActionManager::get_action (X_("Editor"), action_name.c_str()); + + if (!act) { + return; + } + + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); + + if (!tact) { + return; + } + + if (tact->get_active() == (cpi->protocol != 0)) { + /* action state matches current protocol state, ignore this + bogus toggle (e.g. caused by initial ::set_active() call */ return; } @@ -790,7 +838,7 @@ ARDOUR_UI::build_control_surface_menu () *i, "Editor", action_name))); - + ui += "\n