diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 403bf964cf..b9e1fb9dbf 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -105,6 +105,8 @@ using namespace Editing; using namespace std; using std::list; +sigc::signal RouteTimeAxisView::signal_ctrl_touched; + RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanvas::Canvas& canvas) : RouteUI(sess) , StripableTimeAxisView(ed, sess, canvas) @@ -130,6 +132,10 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, ArdourCan sess->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::parameter_changed, this, _1), gui_context()); UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::parameter_changed)); + Controllable::ControlTouched.connect ( + ctrl_touched_connection, invalidator (*this), boost::bind (&RouteTimeAxisView::show_touched_automation, this, _1), gui_context () + ); + parameter_changed ("editor-stereo-only-meters"); } @@ -381,8 +387,20 @@ RouteTimeAxisView::setup_processor_menu_and_curves () { _subplugin_menu_map.clear (); subplugin_menu.items().clear (); + ctrl_node_map.clear (); _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu)); _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves)); + + /* update controllable LUT */ + for (list::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) { + if (!(*i)->valid) { + continue; + } + for (vector::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) { + boost::shared_ptr c = boost::dynamic_pointer_cast ((*i)->processor->control((*ii)->what)); + ctrl_node_map[c] = *ii; + } + } } bool @@ -1562,6 +1580,57 @@ RouteTimeAxisView::show_existing_automation (bool apply_to_selection) } } +void +RouteTimeAxisView::maybe_hide_automation (boost::weak_ptr wctrl) +{ + ctrl_autohide_connection.disconnect (); + boost::shared_ptr ac = boost::dynamic_pointer_cast (wctrl.lock ()); + if (!ac) { + return; + } + ProcessorAutomationNode* pan = find_processor_automation_node (ac); + if (pan) { + pan->menu_item->set_active (false); + } +} + +void +RouteTimeAxisView::show_touched_automation (boost::weak_ptr wctrl) +{ + boost::shared_ptr ac = boost::dynamic_pointer_cast (wctrl.lock ()); + if (!ac) { + return; + } + +#if 0 + if (!_editor.show_touched_automation_lane ()) { + return; + } +#endif + + ProcessorAutomationNode* pan = find_processor_automation_node (ac); + if (!pan) { + return; + } + + /* hide any lanes */ + signal_ctrl_touched (); + + if (!pan->menu_item->get_active ()) { + pan->menu_item->set_active (true); + ctrl_autohide_connection = signal_ctrl_touched.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::maybe_hide_automation), wctrl)); + } + + /* now scroll to the ctrl */ + for (Children::iterator j = children.begin(); j != children.end(); ++j) { + boost::shared_ptr atv = boost::dynamic_pointer_cast (*j); + if (atv && atv->control () == ac) { + _editor.ensure_time_axis_view_is_visible (*atv, false); + break; + } + } +} + void RouteTimeAxisView::hide_all_automation (bool apply_to_selection) { @@ -1639,6 +1708,17 @@ RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr return 0; } +RouteTimeAxisView::ProcessorAutomationNode* +RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr ac) +{ + std::map, ProcessorAutomationNode*>::const_iterator i; + i = ctrl_node_map.find (ac); + if (i != ctrl_node_map.end ()) { + return i->second; + } + return 0; +} + /** Add an AutomationTimeAxisView to display automation for a processor's parameter */ void RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr processor, Evoral::Parameter what) diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index a05cd97260..307fbd9387 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -194,6 +194,9 @@ protected: ProcessorAutomationNode* find_processor_automation_node (boost::shared_ptr i, Evoral::Parameter); + ProcessorAutomationNode* + find_processor_automation_node (boost::shared_ptr); + boost::shared_ptr find_processor_automation_curve (boost::shared_ptr i, Evoral::Parameter); @@ -261,6 +264,8 @@ protected: */ std::list processor_automation; + std::map, ProcessorAutomationNode*> ctrl_node_map; + typedef std::vector > ProcessorAutomationCurves; ProcessorAutomationCurves processor_automation_curves; /** parameter -> menu item map for the plugin automation menu */ @@ -299,10 +304,17 @@ private: void update_playlist_tip (); void parameter_changed (std::string const & p); void update_track_number_visibility(); + void show_touched_automation (boost::weak_ptr); + void maybe_hide_automation (boost::weak_ptr); void drop_instrument_ref (); void reread_midnam (); PBD::ScopedConnectionList midnam_connection; + + static sigc::signal signal_ctrl_touched; + + PBD::ScopedConnection ctrl_touched_connection; + sigc::connection ctrl_autohide_connection; }; #endif /* __ardour_route_time_axis_h__ */