diff options
-rw-r--r-- | gtk2_ardour/ardour_ui_dialogs.cc | 8 | ||||
-rw-r--r-- | gtk2_ardour/transport_control.cc | 46 | ||||
-rw-r--r-- | gtk2_ardour/transport_control.h | 6 |
3 files changed, 55 insertions, 5 deletions
diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index dc71efef03..143d9bc4c9 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -163,6 +163,14 @@ ARDOUR_UI::set_session (Session *s) transport_masters_window->set_session (s); rc_option_editor->set_session (s); + roll_controllable->set_session (s); + stop_controllable->set_session (s); + goto_start_controllable->set_session (s); + goto_end_controllable->set_session (s); + auto_loop_controllable->set_session (s); + play_selection_controllable->set_session (s); + rec_controllable->set_session (s); + /* allow wastebasket flush again */ Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), X_("FlushWastebasket")); diff --git a/gtk2_ardour/transport_control.cc b/gtk2_ardour/transport_control.cc index 5d642e6132..a7be5903d7 100644 --- a/gtk2_ardour/transport_control.cc +++ b/gtk2_ardour/transport_control.cc @@ -16,12 +16,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "pbd/i18n.h" + +#include "ardour/location.h" +#include "ardour/session.h" + #include "actions.h" #include "ardour_ui.h" #include "transport_control.h" -#include "pbd/i18n.h" - using namespace Gtk; TransportControlProvider::TransportControlProvider () @@ -43,7 +46,7 @@ TransportControlProvider::TransportControllable::TransportControllable (std::str void TransportControlProvider::TransportControllable::set_value (double val, PBD::Controllable::GroupControlDisposition /*group_override*/) { - if (val < 0.5) { + if (val == 0.0) { /* do nothing: these are radio-style actions */ return; } @@ -86,3 +89,40 @@ TransportControlProvider::TransportControllable::set_value (double val, PBD::Con act->activate (); } } + +double +TransportControlProvider::TransportControllable::get_value () const +{ + if (!_session) { + return 0.0; + } + + ARDOUR::Location* rloc; + + switch (type) { + case Roll: + return (_session->transport_rolling() ? 1.0 : 0.0); + case Stop: + return (!_session->transport_rolling() ? 1.0 : 0.0); + case GotoStart: + if ((rloc = _session->locations()->session_range_location()) != 0) { + return (_session->transport_sample() == rloc->start() ? 1.0 : 0.0); + } + return 0.0; + case GotoEnd: + if ((rloc = _session->locations()->session_range_location()) != 0) { + return (_session->transport_sample() == rloc->end() ? 1.0 : 0.0); + } + return 0.0; + case AutoLoop: + return ((_session->get_play_loop() && _session->transport_rolling())? 1.0 : 0.0); + case PlaySelection: + return ((_session->transport_rolling() && _session->get_play_range()) ? 1.0 : 0.0); + case RecordEnable: + return (_session->actively_recording() ? 1.0 : 0.0); + default: + break; + } + + return 0.0; +} diff --git a/gtk2_ardour/transport_control.h b/gtk2_ardour/transport_control.h index bc38cd3c09..c3f7f0192a 100644 --- a/gtk2_ardour/transport_control.h +++ b/gtk2_ardour/transport_control.h @@ -22,6 +22,8 @@ #include <gtkmm/widget.h> #include "pbd/controllable.h" +#include "ardour/session_handle.h" + /* This is an API implemenetd by AROUR_UI, * and made available to transport-control-UIs */ @@ -34,7 +36,7 @@ public: /* show metronome preferences */ virtual bool click_button_clicked (GdkEventButton *) = 0; - struct TransportControllable : public PBD::Controllable { + struct TransportControllable : public PBD::Controllable, public ARDOUR::SessionHandlePtr { enum ToggleType { Roll = 0, Stop, @@ -47,7 +49,7 @@ public: TransportControllable (std::string name, ToggleType); void set_value (double, PBD::Controllable::GroupControlDisposition group_override); - double get_value (void) const { return 0; } + double get_value (void) const; ToggleType type; }; |