From adb196dcde08317ec1d366ac299f0d9b3d1bffcf Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 19 Jan 2024 02:23:15 +0100 Subject: [PATCH] Show automation lane on touch, now spills related ctrls --- gtk2_ardour/route_time_axis.cc | 86 ++++++++++++++++++++++++++-------- gtk2_ardour/route_time_axis.h | 2 +- 2 files changed, 67 insertions(+), 21 deletions(-) diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 018773d65e..57eb44a0f4 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -50,6 +50,7 @@ #include "ardour/amp.h" #include "ardour/meter.h" +#include "ardour/pan_controllable.h" #include "ardour/pannable.h" #include "ardour/panner.h" #include "ardour/plugin_insert.h" @@ -1586,6 +1587,25 @@ RouteTimeAxisView::ensure_pan_views (bool show) pan_tracks.push_back (automation_child (pan_control->parameter ())); } } + + /* remove ATAV of no longer relevant pan ctrls (e.g. witdh, height); */ + bool removed_one; + do { + removed_one = false; + for (auto const& j : children) { + std::shared_ptr atv = std::dynamic_pointer_cast (j); + if (!atv || !std::dynamic_pointer_cast (atv->control ())) { + continue; + } + if (std::find (pan_tracks.begin (), pan_tracks.end(), atv) != pan_tracks.end ()) { + continue; + } + /* this invalidates the iterator */ + remove_child (atv); + removed_one = true; + break; + } + } while (removed_one); } @@ -1644,28 +1664,31 @@ RouteTimeAxisView::show_existing_automation (bool apply_to_selection) } void -RouteTimeAxisView::maybe_hide_automation (bool hide, std::weak_ptr wctrl) +RouteTimeAxisView::maybe_hide_automation (bool hide, WeakAutomationControlList wctrls) { ctrl_autohide_connection.disconnect (); if (!hide) { /* disconnect only, leave lane visible */ return; } - std::shared_ptr ac = std::dynamic_pointer_cast (wctrl.lock ()); - if (!ac) { - return; - } - Gtk::CheckMenuItem* cmi = find_menu_item_by_ctrl (ac); - if (cmi) { - cmi->set_active (false); - return; - } + for (auto const& wctrl: wctrls) { + std::shared_ptr ac = std::dynamic_pointer_cast (wctrl.lock ()); + if (!ac) { + continue; + } - std::shared_ptr atav = find_atav_by_ctrl (ac); - if (atav) { - atav->set_marked_for_display (false); - request_redraw (); + Gtk::CheckMenuItem* cmi = find_menu_item_by_ctrl (ac); + if (cmi) { + cmi->set_active (false); + continue; + } + + std::shared_ptr atav = find_atav_by_ctrl (ac); + if (atav) { + atav->set_marked_for_display (false); + request_redraw (); + } } } @@ -1679,7 +1702,7 @@ RouteTimeAxisView::show_touched_automation (std::weak_ptr wct if (!_editor.show_touched_automation ()) { if (ctrl_autohide_connection.connected ()) { - signal_ctrl_touched (true); + signal_ctrl_touched (true); /* EMIT SIGNAL */ } return; } @@ -1694,22 +1717,46 @@ RouteTimeAxisView::show_touched_automation (std::weak_ptr wct } /* hide any lanes */ - signal_ctrl_touched (true); + signal_ctrl_touched (true); /* EMIT SIGNAL */ + + WeakAutomationControlList wctrls; 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)); + wctrls.push_back (ac); /* 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)); + wctrls.push_back (ac); request_redraw (); } + for (auto const& i: ac->visually_linked_controls ()) { + std::shared_ptr wac = i.lock (); + if (!wac) { + continue; + } + cmi = find_menu_item_by_ctrl (wac); + if (cmi && !cmi->get_active ()) { + cmi->set_active (true); + wctrls.push_back (wac); + continue; + } + std::shared_ptr datav = find_atav_by_ctrl (wac, false); + if (datav && ! string_to(datav->gui_property ("visible"))) { + datav->set_marked_for_display (true); + wctrls.push_back (wac); + request_redraw (); + } + } + + if (!wctrls.empty ()) { + ctrl_autohide_connection = signal_ctrl_touched.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::maybe_hide_automation), wctrls)); + } + if (atav) { _editor.ensure_time_axis_view_is_visible (*atav, false); - return; } } @@ -1811,7 +1858,6 @@ RouteTimeAxisView::find_atav_by_ctrl (std::shared_ptr } if (!pan_tracks.empty() && !ARDOUR::Profile->get_mixbus()) { - // XXX this can lead to inconsistent CheckMenuItem state (azimuth, width are treated separately) for (list >::iterator i = pan_tracks.begin(); i != pan_tracks.end(); ++i) { if ((*i)->control () == ac) { return *i; diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index d6583a7141..4147eba0d3 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -301,7 +301,7 @@ private: void parameter_changed (std::string const & p); void update_track_number_visibility(); void show_touched_automation (std::weak_ptr); - void maybe_hide_automation (bool, std::weak_ptr); + void maybe_hide_automation (bool, ARDOUR::WeakAutomationControlList); void drop_instrument_ref (); void reread_midnam ();