From e5175f51d60c7c5a6842c1fe0b4aa0be2d203971 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 3 Jun 2021 14:30:25 -0600 Subject: [PATCH] make region-selection on click apply across tracks if RippleAll is in use --- gtk2_ardour/editor.h | 2 ++ gtk2_ardour/editor_selection.cc | 64 ++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 152af1807e..5b1c032347 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -773,11 +773,13 @@ private: void sort_track_selection (TrackViewList&); void get_equivalent_regions (RegionView* rv, std::vector &, PBD::PropertyID) const; + void get_all_equivalent_regions (RegionView* rv, std::vector &) const; RegionSelection get_equivalent_regions (RegionSelection &, PBD::PropertyID) const; RegionView* regionview_from_region (boost::shared_ptr) const; RouteTimeAxisView* rtav_from_route (boost::shared_ptr) const; void mapover_tracks_with_unique_playlists (sigc::slot sl, TimeAxisView*, PBD::PropertyID) const; + void mapover_all_tracks_with_unique_playlists (sigc::slot) const; void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, std::vector*) const; void mapover_grouped_routes (sigc::slot sl, RouteUI*, PBD::PropertyID) const; diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index a358e85158..e5d7c5bfc8 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -537,6 +537,38 @@ Editor::mapover_tracks_with_unique_playlists (sigc::slot sl) const +{ + set > playlists; + + set tracks; + + for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { + RouteTimeAxisView* v = dynamic_cast (*i); + + boost::shared_ptr t = v->track(); + if (t) { + if (playlists.insert (t->playlist()).second) { + /* haven't seen this playlist yet */ + tracks.insert (v); + } + } else { + /* not actually a "Track", but a timeaxis view that + we should mapover anyway. + */ + tracks.insert (v); + } + } + + /* call the slots */ + uint32_t const sz = tracks.size (); + + for (set::iterator i = tracks.begin(); i != tracks.end(); ++i) { + sl (**i, sz); + } +} + void Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t, RegionView * basis, vector* all_equivs) const { @@ -576,6 +608,16 @@ Editor::get_equivalent_regions (RegionView* basis, vector& equivale equivalent_regions.push_back (basis); } +void +Editor::get_all_equivalent_regions (RegionView* basis, vector& equivalent_regions) const +{ + mapover_all_tracks_with_unique_playlists (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions)); + + /* add clicked regionview since we skipped all other regions in the same track as the one it was in */ + + equivalent_regions.push_back (basis); +} + RegionSelection Editor::get_equivalent_regions (RegionSelection & basis, PBD::PropertyID prop) const { @@ -646,10 +688,14 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) if (press) { - if (selection->selected (clicked_routeview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); + if (Config->get_edit_mode() == RippleAll) { + get_all_equivalent_regions (clicked_regionview, all_equivalent_regions); } else { - all_equivalent_regions.push_back (clicked_regionview); + if (selection->selected (clicked_routeview)) { + get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); + } else { + all_equivalent_regions.push_back (clicked_regionview); + } } /* add all the equivalent regions, but only on button press */ @@ -665,7 +711,11 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) case Selection::Set: if (!selection->selected (clicked_regionview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); + if (Config->get_edit_mode() == RippleAll) { + get_all_equivalent_regions (clicked_regionview, all_equivalent_regions); + } else { + get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); + } selection->set (all_equivalent_regions); commit = true; } else { @@ -675,7 +725,11 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) else { if (selection->regions.size() > 1) { /* collapse region selection down to just this one region (and its equivalents) */ - get_equivalent_regions(clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); + if (Config->get_edit_mode() == RippleAll) { + get_all_equivalent_regions (clicked_regionview, all_equivalent_regions); + } else { + get_equivalent_regions(clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); + } selection->set(all_equivalent_regions); commit = true; }