From 458db0525cf4cafab10904acf78b76a802081e8b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 20 Apr 2011 05:07:41 +0000 Subject: [PATCH] reinstate MIDI binding for shuttle controller git-svn-id: svn://localhost/ardour2/branches/3.0@9394 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 5 ++--- gtk2_ardour/ardour_ui.h | 1 - gtk2_ardour/shuttle_control.cc | 23 ++++++++--------------- gtk2_ardour/shuttle_control.h | 7 +++++-- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index ce323d8397..843be588d3 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -156,7 +156,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) auto_loop_controllable (new TransportControllable ("transport auto loop", *this, TransportControllable::AutoLoop)), play_selection_controllable (new TransportControllable ("transport play selection", *this, TransportControllable::PlaySelection)), rec_controllable (new TransportControllable ("transport rec-enable", *this, TransportControllable::RecordEnable)), - shuttle_controller_binding_proxy (shuttle_controllable), roll_button (roll_controllable), stop_button (stop_controllable), @@ -555,7 +554,7 @@ ARDOUR_UI::set_transport_controllable_state (const XMLNode& node) rec_controllable->set_id (prop->value()); } if ((prop = node.property ("shuttle")) != 0) { - shuttle_box->controllable().set_id (prop->value()); + shuttle_box->controllable()->set_id (prop->value()); } } @@ -580,7 +579,7 @@ ARDOUR_UI::get_transport_controllable_state () node->add_property (X_("play_selection"), buf); rec_controllable->id().print (buf, sizeof (buf)); node->add_property (X_("rec"), buf); - shuttle_box->controllable().id().print (buf, sizeof (buf)); + shuttle_box->controllable()->id().print (buf, sizeof (buf)); node->add_property (X_("shuttle"), buf); return *node; diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index ddb2ec3bdd..23c5775670 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -413,7 +413,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr boost::shared_ptr rec_controllable; boost::shared_ptr shuttle_controllable; boost::shared_ptr join_play_range_controllable; - BindingProxy shuttle_controller_binding_proxy; void set_transport_controllable_state (const XMLNode&); XMLNode& get_transport_controllable_state (); diff --git a/gtk2_ardour/shuttle_control.cc b/gtk2_ardour/shuttle_control.cc index 9182cc0efd..5ff771ecf1 100644 --- a/gtk2_ardour/shuttle_control.cc +++ b/gtk2_ardour/shuttle_control.cc @@ -40,9 +40,10 @@ using std::min; using std::max; ShuttleControl::ShuttleControl () - : _controllable (*this) + : _controllable (new ShuttleControllable (*this)) + , binding_proxy (_controllable) { - ARDOUR_UI::instance()->set_tip (*this, _("Shuttle speed control")); + ARDOUR_UI::instance()->set_tip (*this, _("Shuttle speed control (Context-click for options)")); pattern = 0; last_shuttle_request = 0; @@ -74,6 +75,7 @@ ShuttleControl::set_session (Session *s) if (_session) { set_sensitive (true); + _session->add_controllable (_controllable); } else { set_sensitive (false); } @@ -205,11 +207,9 @@ ShuttleControl::on_button_press_event (GdkEventButton* ev) return true; } -#if 0 - if (shuttle_controller_binding_proxy.button_press_handler (ev)) { + if (binding_proxy.button_press_handler (ev)) { return true; } -#endif if (Keyboard::is_context_menu_event (ev)) { show_shuttle_context_menu (); @@ -370,7 +370,7 @@ ShuttleControl::use_shuttle_fract (bool force) speed = shuttle_max_speed * fract; } - + _session->request_transport_speed_nonzero (speed); } @@ -418,7 +418,7 @@ ShuttleControl::on_expose_event (GdkEventExpose* event) } } } else { - snprintf (buf, sizeof (buf), _("stop")); + snprintf (buf, sizeof (buf), _("Stopped")); } last_speed_displayed = speed; @@ -479,13 +479,6 @@ ShuttleControl::update_speed_display () } } -/* - set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display")); - set_tip (speed_display_box, _("Current transport speed")); - - -*/ - ShuttleControl::ShuttleControllable::ShuttleControllable (ShuttleControl& s) : PBD::Controllable (X_("Shuttle")) , sc (s) @@ -512,7 +505,7 @@ ShuttleControl::ShuttleControllable::set_value (double val) fract = ((val - 0.5)/0.5); } } - + sc.set_shuttle_fract (fract); } diff --git a/gtk2_ardour/shuttle_control.h b/gtk2_ardour/shuttle_control.h index 4256d87536..76b7406589 100644 --- a/gtk2_ardour/shuttle_control.h +++ b/gtk2_ardour/shuttle_control.h @@ -21,6 +21,8 @@ #include +#include "gtkmm2ext/binding_proxy.h" + #include "pbd/controllable.h" #include "ardour/session_handle.h" @@ -52,20 +54,21 @@ class ShuttleControl : public Gtk::DrawingArea, public ARDOUR::SessionHandlePtr ShuttleControl& sc; }; - ShuttleControllable& controllable() { return _controllable; } + boost::shared_ptr controllable() const { return _controllable; } protected: float shuttle_max_speed; float last_speed_displayed; bool shuttle_grabbed; double shuttle_fract; - ShuttleControllable _controllable; + boost::shared_ptr _controllable; cairo_pattern_t* pattern; ARDOUR::microseconds_t last_shuttle_request; PBD::ScopedConnection parameter_connection; Gtk::Menu* shuttle_unit_menu; Gtk::Menu* shuttle_style_menu; Gtk::Menu* shuttle_context_menu; + BindingProxy binding_proxy; void build_shuttle_context_menu (); void show_shuttle_context_menu ();