diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index cd7dc46ce8..d0c8ecd1df 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3715,27 +3715,47 @@ Editor::restore_editing_space () ); } +/** + * Make new playlists for a given track and also any others that belong + * to the same active edit group. + * @param v Track. + */ + void -Editor::new_playlists () +Editor::new_playlists (TimeAxisView* v) { begin_reversible_command (_("new playlists")); - mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist)); + mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist), v); commit_reversible_command (); } + +/** + * Use a copy of the current playlist for a given track and also any others that belong + * to the same active edit group. + * @param v Track. + */ + void -Editor::copy_playlists () +Editor::copy_playlists (TimeAxisView* v) { begin_reversible_command (_("copy playlists")); - mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist)); + mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist), v); commit_reversible_command (); } + +/** + * Clear the current playlist for a given track and also any others that belong + * to the same active edit group. + * @param v Track. + */ + void -Editor::clear_playlists () +Editor::clear_playlists (TimeAxisView* v) { begin_reversible_command (_("clear playlists")); - mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist)); + mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v); commit_reversible_command (); } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index f2e0572268..4cfb1b0fda 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -262,9 +262,9 @@ class Editor : public PublicEditor nframes_t leftmost_frame; void clear_playlist (boost::shared_ptr); - void new_playlists (); - void copy_playlists (); - void clear_playlists (); + void new_playlists (TimeAxisView*); + void copy_playlists (TimeAxisView*); + void clear_playlists (TimeAxisView*); TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0); @@ -433,7 +433,7 @@ class Editor : public PublicEditor void get_relevant_audio_tracks (std::set& relevant_tracks); void get_equivalent_regions (RegionView* rv, std::vector&); - void mapover_audio_tracks (sigc::slot sl); + void mapover_audio_tracks (sigc::slot sl, TimeAxisView*); /* functions to be passed to mapover_audio_tracks(), possibly with sigc::bind()-supplied arguments */ diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index c736773dc7..67b4710b7a 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -284,18 +284,47 @@ Editor::get_relevant_audio_tracks (set& relevant_tracks) } } + +/** + * Call a slot for a given `basis' track and also for any track that is in the same + * active edit group. + * @param sl Slot to call. + * @param basis Basis track. + */ + void -Editor::mapover_audio_tracks (slot sl) +Editor::mapover_audio_tracks (slot sl, TimeAxisView* basis) { - set relevant_tracks; - - get_relevant_audio_tracks (relevant_tracks); - - uint32_t sz = relevant_tracks.size(); - - for (set::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) { - sl (**ati, sz); + AudioTimeAxisView* audio_basis = dynamic_cast (basis); + if (audio_basis == 0) { + return; } + + /* work out the tracks that we will call the slot for; use + a set here as it will disallow possible duplicates of the + basis track */ + set tracks; + + /* always call for the basis */ + tracks.insert (audio_basis); + + RouteGroup* group = audio_basis->route()->edit_group(); + if (group && group->is_active()) { + + /* the basis is a member of an active edit group; find other members */ + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + AudioTimeAxisView* v = dynamic_cast (*i); + if (v && v->route()->edit_group() == group) { + 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 @@ -330,7 +359,7 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, void Editor::get_equivalent_regions (RegionView* basis, vector& equivalent_regions) { - mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions)); + mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_trackview()); /* add clicked regionview since we skipped all other regions in the same track as the one it was in */ @@ -387,11 +416,11 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, if (press) { - if (selection->selected (clicked_audio_trackview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions); - } else { - all_equivalent_regions.push_back (clicked_regionview); - } + if (selection->selected (clicked_audio_trackview)) { + get_equivalent_regions (clicked_regionview, all_equivalent_regions); + } else { + all_equivalent_regions.push_back (clicked_regionview); + } /* add all the equivalent regions, but only on button press */ @@ -409,12 +438,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, case Selection::Set: if (!clicked_regionview->get_selected()) { - if (selection->selected (clicked_audio_trackview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions); - } else { - all_equivalent_regions.push_back (clicked_regionview); - } - + get_equivalent_regions (clicked_regionview, all_equivalent_regions); selection->set (all_equivalent_regions); commit = true; } else { diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 55103840d6..779875dabb 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -129,9 +129,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual PlaylistSelector& playlist_selector() const = 0; virtual void route_name_changed (TimeAxisView *) = 0; virtual void clear_playlist (boost::shared_ptr) = 0; - virtual void new_playlists () = 0; - virtual void copy_playlists () = 0; - virtual void clear_playlists () = 0; + virtual void new_playlists (TimeAxisView*) = 0; + virtual void copy_playlists (TimeAxisView*) = 0; + virtual void clear_playlists (TimeAxisView*) = 0; virtual void select_all_tracks () = 0; virtual bool set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove = false) = 0; virtual void set_selected_mixer_strip (TimeAxisView&) = 0; diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index e198397307..93419b813c 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1304,10 +1304,10 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu) playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist))); playlist_items.push_back (SeparatorElem()); - playlist_items.push_back (MenuElem (_("New"), mem_fun(editor, &PublicEditor::new_playlists))); - playlist_items.push_back (MenuElem (_("New Copy"), mem_fun(editor, &PublicEditor::copy_playlists))); + playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(editor, &PublicEditor::new_playlists), this))); + playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this))); playlist_items.push_back (SeparatorElem()); - playlist_items.push_back (MenuElem (_("Clear Current"), mem_fun(editor, &PublicEditor::clear_playlists))); + playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(editor, &PublicEditor::clear_playlists), this))); playlist_items.push_back (SeparatorElem()); playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));