From 94d3da7e09a70e4384dce7e92b27f3dd3abb385b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 1 Mar 2019 16:51:08 +0100 Subject: GUI updates to handle monitor-section changes This fixes various MS related action sensitivity issues, as well as action-states. Also manually adding a monitor-section to a session now always immediately shows it, regardless of prior ToggleMonitorSection visibility. --- gtk2_ardour/mixer_strip.cc | 42 ++++++++++++++++++++---------------- gtk2_ardour/mixer_strip.h | 1 + gtk2_ardour/monitor_section.cc | 40 ++++++++++++++++++++++------------ gtk2_ardour/rc_option_editor.cc | 3 +-- gtk2_ardour/route_ui.cc | 3 ++- gtk2_ardour/session_option_editor.cc | 2 +- gtk2_ardour/vca_master_strip.cc | 3 ++- gtk2_ardour/vca_time_axis.cc | 4 +++- 8 files changed, 59 insertions(+), 39 deletions(-) diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 1e7c94f906..68e4ab8e5c 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -583,6 +583,7 @@ MixerStrip::set_route (boost::shared_ptr rt) if (monitor_section_button == 0) { Glib::RefPtr act = ActionManager::get_action ("Mixer", "ToggleMonitorSection"); _session->MonitorChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::monitor_changed, this), gui_context()); + _session->MonitorBusAddedOrRemoved.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::monitor_section_added_or_removed, this), gui_context()); monitor_section_button = manage (new ArdourButton); monitor_changed (); @@ -591,8 +592,8 @@ MixerStrip::set_route (boost::shared_ptr rt) mute_solo_table.attach (*monitor_section_button, 1, 2, 0, 1); monitor_section_button->show(); monitor_section_button->unset_flags (Gtk::CAN_FOCUS); + monitor_section_added_or_removed (); } - parameter_changed ("use-monitor-bus"); } else { bottom_button_table.attach (group_button, 1, 2, 0, 1); mute_solo_table.attach (*mute_button, 0, 1, 0, 1); @@ -2115,6 +2116,27 @@ MixerStrip::monitor_changed () } } +void +MixerStrip::monitor_section_added_or_removed () +{ + assert (monitor_section_button); + if (mute_button->get_parent()) { + mute_button->get_parent()->remove(*mute_button); + } + if (monitor_section_button->get_parent()) { + monitor_section_button->get_parent()->remove(*monitor_section_button); + } + if (_session && _session->monitor_out ()) { + mute_solo_table.attach (*mute_button, 0, 1, 0, 1); + mute_solo_table.attach (*monitor_section_button, 1, 2, 0, 1); + mute_button->show(); + monitor_section_button->show(); + } else { + mute_solo_table.attach (*mute_button, 0, 2, 0, 1); + mute_button->show(); + } +} + /** Called when the metering point has changed */ void MixerStrip::meter_changed () @@ -2394,24 +2416,6 @@ MixerStrip::parameter_changed (string p) } else if (p == "track-name-number") { name_changed (); update_track_number_visibility(); - } else if (p == "use-monitor-bus") { - if (monitor_section_button) { - if (mute_button->get_parent()) { - mute_button->get_parent()->remove(*mute_button); - } - if (monitor_section_button->get_parent()) { - monitor_section_button->get_parent()->remove(*monitor_section_button); - } - if (Config->get_use_monitor_bus ()) { - mute_solo_table.attach (*mute_button, 0, 1, 0, 1); - mute_solo_table.attach (*monitor_section_button, 1, 2, 0, 1); - mute_button->show(); - monitor_section_button->show(); - } else { - mute_solo_table.attach (*mute_button, 0, 2, 0, 1); - mute_button->show(); - } - } } } diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index e4cecf3586..1510d38242 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -187,6 +187,7 @@ private: void meter_changed (); void monitor_changed (); + void monitor_section_added_or_removed (); ArdourWidgets::ArdourButton input_button; ArdourWidgets::ArdourButton output_button; diff --git a/gtk2_ardour/monitor_section.cc b/gtk2_ardour/monitor_section.cc index 943507dd36..6c077a0914 100644 --- a/gtk2_ardour/monitor_section.cc +++ b/gtk2_ardour/monitor_section.cc @@ -63,6 +63,11 @@ using namespace std; #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale())) +#define SYNCHRONIZE_TOGGLE_ACTION(action, value) \ + if (action && action->get_active() != value) { \ + action->set_active(value); \ + } + MonitorSection::MonitorSection () : RouteUI ((Session*) 0) , _tearoff (0) @@ -585,6 +590,8 @@ MonitorSection::set_session (Session* s) _plugin_selector->set_session (_session); insert_box->set_session (_session); + Glib::RefPtr global_monitor_actions = ActionManager::get_action_group (X_("Monitor Section")); + if (_session) { /* These are not actually dependent on the Session, but they @@ -613,6 +620,8 @@ MonitorSection::set_session (Session* s) update_processor_box (); } + SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection"), true); + ActionManager::set_sensitive (global_monitor_actions, true); ActionManager::set_sensitive (monitor_actions, true); ActionManager::set_sensitive (solo_actions, true); @@ -624,18 +633,16 @@ MonitorSection::set_session (Session* s) delete _output_selector; _output_selector = 0; + SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection"), false); + ActionManager::set_sensitive (global_monitor_actions, false); ActionManager::set_sensitive (monitor_actions, false); - /* this action needs to always be true in this * scenaro, so that we can turn it back on*/ - ActionManager::get_toggle_action (X_("Monitor"), X_("UseMonitorSection"))->set_sensitive (true); ActionManager::set_sensitive (solo_actions, true); + /* this action needs to always be true in this, so that we can turn it back on */ + ActionManager::get_toggle_action (X_("Monitor"), X_("UseMonitorSection"))->set_sensitive (true); } - /* make sure the state of this action reflects reality */ - ActionManager::get_toggle_action (X_("Monitor"), X_("UseMonitorSection"))->set_active (_route != 0); - populate_buttons (); - } else { /* no session */ @@ -647,6 +654,7 @@ MonitorSection::set_session (Session* s) ActionManager::set_sensitive (monitor_actions, false); ActionManager::set_sensitive (solo_actions, false); + ActionManager::set_sensitive (global_monitor_actions, false); } } @@ -1186,11 +1194,6 @@ MonitorSection::cancel_audition (GdkEventButton*) return true; } -#define SYNCHRONIZE_TOGGLE_ACTION(action, value) \ - if (action && action->get_active() != value) { \ - action->set_active(value); \ - } \ - void MonitorSection::parameter_changed (std::string name) { @@ -1202,8 +1205,6 @@ MonitorSection::parameter_changed (std::string name) SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Solo"), "toggle-mute-overrides-solo"), Config->get_solo_mute_override ()); } else if (name == "exclusive-solo") { SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Solo"), "toggle-exclusive-solo"), Config->get_exclusive_solo ()); - } else if (name == "use-monitor-bus") { - SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection"), Config->get_use_monitor_bus ()); } } @@ -1623,6 +1624,17 @@ MonitorSection::toggle_use_monitor_section () if (!_session) { return; } + bool want_ms = ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection")->get_active(); + bool have_ms = Config->get_use_monitor_bus (); - Config->set_use_monitor_bus (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection")->get_active()); + if (want_ms == have_ms) { + return; + } + + if (want_ms) { + Config->set_use_monitor_bus (true); + ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"))->set_active (true); + } else { + Config->set_use_monitor_bus (false); + } } diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 3660e8c239..4306dc627e 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -3999,7 +3999,6 @@ These settings will only take effect after %1 is restarted.\n\ //trigger some parameter-changed messages which affect widget-visibility or -sensitivity parameter_changed ("send-ltc"); parameter_changed ("sync-source"); - parameter_changed ("use-monitor-bus"); parameter_changed ("open-gui-after-adding-plugin"); XMLNode* node = ARDOUR_UI::instance()->preferences_settings(); @@ -4029,7 +4028,7 @@ RCOptionEditor::parameter_changed (string const & p) bool const s = Config->get_use_monitor_bus (); if (!s) { /* we can't use this if we don't have a monitor bus */ - Config->set_solo_control_is_listen_control (false); + Config->set_solo_control_is_listen_control (false); // XXX } _solo_control_is_listen_control->set_sensitive (s); _listen_position->set_sensitive (s); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 1cde562e2a..1dc24594a6 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -210,6 +210,7 @@ RouteUI::init () _session->SoloChanged.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::solo_changed_so_update_mute, this), gui_context()); _session->TransportStateChange.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::check_rec_enable_sensitivity, this), gui_context()); _session->RecordStateChanged.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::session_rec_enable_changed, this), gui_context()); + _session->MonitorBusAddedOrRemoved.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::set_button_names, this), gui_context()); _session->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&RouteUI::parameter_changed, this, _1), gui_context()); Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&RouteUI::parameter_changed, this, _1), gui_context()); @@ -1995,7 +1996,7 @@ RouteUI::parameter_changed (string const & p) if (p == "disable-disarm-during-roll") { check_rec_enable_sensitivity (); - } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") { + } else if (p == "solo-control-is-listen-control" || p == "listen-position") { set_button_names (); } else if (p == "session-monitoring") { update_monitoring_display (); diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc index a2f0227d3f..ff74caa0d6 100644 --- a/gtk2_ardour/session_option_editor.cc +++ b/gtk2_ardour/session_option_editor.cc @@ -275,7 +275,7 @@ SessionOptionEditor::SessionOptionEditor (Session* s) )); add_option (_("Monitoring"), new CheckOption ( - "have-monitor-section", + "unused", _("Use monitor section in this session"), ActionManager::get_action(X_("Monitor"), "UseMonitorSection") )); diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc index 297ee32fd4..238cd5dabd 100644 --- a/gtk2_ardour/vca_master_strip.cc +++ b/gtk2_ardour/vca_master_strip.cc @@ -159,6 +159,7 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::solo_changed, this), gui_context()); _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::mute_changed, this), gui_context()); + _session->MonitorBusAddedOrRemoved.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::set_button_names, this), gui_context()); s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context()); Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context()); @@ -197,7 +198,7 @@ VCAMasterStrip::self_delete () void VCAMasterStrip::parameter_changed (std::string const & p) { - if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") { + if (p == "solo-control-is-listen-control" || p == "listen-position") { set_button_names (); } else if (p == "mixer-element-visibility") { update_bottom_padding (); diff --git a/gtk2_ardour/vca_time_axis.cc b/gtk2_ardour/vca_time_axis.cc index efa1c3cdea..d4394a65a2 100644 --- a/gtk2_ardour/vca_time_axis.cc +++ b/gtk2_ardour/vca_time_axis.cc @@ -113,6 +113,8 @@ VCATimeAxisView::VCATimeAxisView (PublicEditor& ed, Session* s, ArdourCanvas::Ca controls_ebox.set_name (controls_base_unselected_name); time_axis_frame.set_name (controls_base_unselected_name); + s->MonitorBusAddedOrRemoved.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::set_button_names, this), gui_context()); + s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context()); Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context()); UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &VCATimeAxisView::parameter_changed)); @@ -135,7 +137,7 @@ VCATimeAxisView::parameter_changed (std::string const & p) { if (p == "track-name-number") { update_track_number_visibility(); - } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") { + } else if (p == "solo-control-is-listen-control" || p == "listen-position") { set_button_names (); } } -- cgit v1.2.3