From e5c819956a95a1dc9dee8f805dc55757dc51233d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 27 Feb 2020 22:25:37 +0100 Subject: [PATCH] Punch/Loop GUI control sensitivity --- gtk2_ardour/ardour_ui.h | 1 + gtk2_ardour/ardour_ui2.cc | 8 ++++++++ gtk2_ardour/ardour_ui_dialogs.cc | 3 +++ gtk2_ardour/transport_control_ui.cc | 3 ++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 58a216a93b..bc61f054d5 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -646,6 +646,7 @@ private: void import_metadata (); void set_transport_sensitivity (bool); + void set_punch_sensitivity (); //stuff for ProTools-style numpad void transport_numpad_event (int num); diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 70ff8f7c39..e7306bea00 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -810,6 +810,14 @@ ARDOUR_UI::set_transport_sensitivity (bool yn) shuttle_box.set_sensitive (yn); } +void +ARDOUR_UI::set_punch_sensitivity () +{ + bool can_punch = _session && _session->punch_is_possible() && _session->locations()->auto_punch_location (); + ActionManager::get_action ("Transport", "TogglePunchIn")->set_sensitive (can_punch); + ActionManager::get_action ("Transport", "TogglePunchOut")->set_sensitive (can_punch); +} + void ARDOUR_UI::editor_realized () { diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index dcdbb3f3b1..e826f9500a 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -192,6 +192,9 @@ ARDOUR_UI::set_session (Session *s) _session->TransportStateChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::map_transport_state, this), gui_context()); _session->DirtyChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_dirty_changed, this), gui_context()); + _session->PunchLoopConstraintChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::set_punch_sensitivity, this), gui_context()); + _session->auto_punch_location_changed.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::set_punch_sensitivity, this), gui_context ()); + _session->Xrun.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::xrun_handler, this, _1), gui_context()); _session->SoloActive.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::soloing_changed, this, _1), gui_context()); _session->AuditionActive.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::auditioning_changed, this, _1), gui_context()); diff --git a/gtk2_ardour/transport_control_ui.cc b/gtk2_ardour/transport_control_ui.cc index 05c91f3f6b..c3b6fb552a 100644 --- a/gtk2_ardour/transport_control_ui.cc +++ b/gtk2_ardour/transport_control_ui.cc @@ -179,6 +179,7 @@ TransportControlUI::set_session (ARDOUR::Session *s) _session->StepEditStatusChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&TransportControlUI::step_edit_status_change, this, _1), gui_context()); _session->TransportStateChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&TransportControlUI::map_transport_state, this), gui_context()); _session->auto_loop_location_changed.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&TransportControlUI::set_loop_sensitivity, this), gui_context ()); + _session->PunchLoopConstraintChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&TransportControlUI::set_loop_sensitivity, this), gui_context ()); rec_button.set_sensitive (true); } @@ -287,7 +288,7 @@ TransportControlUI::set_loop_sensitivity () if (!_session || _session->config.get_external_sync()) { auto_loop_button.set_sensitive (false); } else { - auto_loop_button.set_sensitive (_session && _session->locations()->auto_loop_location()); + auto_loop_button.set_sensitive (_session && _session->loop_is_possible() && _session->locations()->auto_loop_location()); } }