From e267c1e1291210447b8d268c3f4cc867b613beb5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 15 Mar 2021 20:57:47 +0100 Subject: [PATCH] Also show route owned controls on touch This add support for special-cased automation controls (Fader, Trim, Panner, Mute) and spills their automation-lane on touch. It also features a small internal API update directly mapping CheckMenuItem. See also bd8c26a0594ff --- gtk2_ardour/route_time_axis.cc | 94 ++++++++++++++++++++++++++-------- gtk2_ardour/route_time_axis.h | 11 ++-- 2 files changed, 80 insertions(+), 25 deletions(-) diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 8703573710..d0a2baaba8 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -387,7 +387,7 @@ RouteTimeAxisView::setup_processor_menu_and_curves () { _subplugin_menu_map.clear (); subplugin_menu.items().clear (); - ctrl_node_map.clear (); + ctrl_item_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)); @@ -398,7 +398,7 @@ RouteTimeAxisView::setup_processor_menu_and_curves () } 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; + ctrl_item_map[c] = (*ii)->menu_item; } } } @@ -1592,9 +1592,17 @@ RouteTimeAxisView::maybe_hide_automation (bool hide, boost::weak_ptrmenu_item->set_active (false); + + Gtk::CheckMenuItem* cmi = find_menu_item_by_ctrl (ac); + if (cmi) { + cmi->set_active (false); + return; + } + + boost::shared_ptr atav = find_atav_by_ctrl (ac); + if (atav) { + atav->set_marked_for_display (false); + request_redraw (); } } @@ -1613,26 +1621,32 @@ RouteTimeAxisView::show_touched_automation (boost::weak_ptr w return; } - ProcessorAutomationNode* pan = find_processor_automation_node (ac); - if (!pan) { - return; + boost::shared_ptr atav; + Gtk::CheckMenuItem* cmi = find_menu_item_by_ctrl (ac); + if (!cmi) { + atav = find_atav_by_ctrl (ac); + if (!atav) { + return; + } } /* hide any lanes */ signal_ctrl_touched (true); - if (!pan->menu_item->get_active ()) { - pan->menu_item->set_active (true); + if (cmi && !cmi->get_active ()) { + cmi->set_active (true); ctrl_autohide_connection = signal_ctrl_touched.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::maybe_hide_automation), wctrl)); + /* search ctrl to scroll to */ + atav = find_atav_by_ctrl (ac, false); + } else if (atav && ! string_to(atav->gui_property ("visible"))) { + atav->set_marked_for_display (true); + ctrl_autohide_connection = signal_ctrl_touched.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::maybe_hide_automation), wctrl)); + request_redraw (); } - /* 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; - } + if (atav) { + _editor.ensure_time_axis_view_is_visible (*atav, false); + return; } } @@ -1713,17 +1727,53 @@ RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr return 0; } -RouteTimeAxisView::ProcessorAutomationNode* -RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr ac) +Gtk::CheckMenuItem* +RouteTimeAxisView::find_menu_item_by_ctrl (boost::shared_ptr ac) { - std::map, ProcessorAutomationNode*>::const_iterator i; - i = ctrl_node_map.find (ac); - if (i != ctrl_node_map.end ()) { + std::map, Gtk::CheckMenuItem*>::const_iterator i; + i = ctrl_item_map.find (ac); + if (i != ctrl_item_map.end ()) { return i->second; } return 0; } +boost::shared_ptr +RouteTimeAxisView::find_atav_by_ctrl (boost::shared_ptr ac, bool route_owned_only) +{ + if (gain_track && gain_track->control () == ac) { + return gain_track; + } + else if (trim_track && trim_track->control () == ac) { + return trim_track; + } + else if (mute_track && mute_track->control () == ac) { + return mute_track; + } + + if (!pan_tracks.empty() && !ARDOUR::Profile->get_mixbus()) { + // XXX this can lead to inconsistent CheckMenuItem state (azimith, width are treated separately) + for (list >::iterator i = pan_tracks.begin(); i != pan_tracks.end(); ++i) { + if ((*i)->control () == ac) { + return *i; + } + } + } + + if (route_owned_only) { + return boost::shared_ptr (); + } + + for (Children::iterator j = children.begin(); j != children.end(); ++j) { + boost::shared_ptr atv = boost::dynamic_pointer_cast (*j); + if (atv && atv->control () == ac) { + return atv; + } + } + return boost::shared_ptr (); +} + + /** 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 53b63f768c..7f4bb2a054 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -196,8 +196,13 @@ protected: ProcessorAutomationNode* find_processor_automation_node (boost::shared_ptr i, Evoral::Parameter); - ProcessorAutomationNode* - find_processor_automation_node (boost::shared_ptr); + /* O(log(N)) lookup of menu-item by AC */ + Gtk::CheckMenuItem* + find_menu_item_by_ctrl (boost::shared_ptr); + + /* O(1) IFF route_owned_only == true, O(N) otherwise */ + boost::shared_ptr + find_atav_by_ctrl (boost::shared_ptr, bool route_owned_only = true); boost::shared_ptr find_processor_automation_curve (boost::shared_ptr i, Evoral::Parameter); @@ -266,7 +271,7 @@ protected: */ std::list processor_automation; - std::map, ProcessorAutomationNode*> ctrl_node_map; + std::map, Gtk::CheckMenuItem*> ctrl_item_map; typedef std::vector > ProcessorAutomationCurves; ProcessorAutomationCurves processor_automation_curves;