From 61872c56631b313fec4ed3a1cb998335bb346731 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 6 Oct 2007 16:24:08 +0000 Subject: [PATCH] Fix things so that selecting a region always selects equivalent regions in the same edit group, even if the appropriate tracks aren't selected at the time. git-svn-id: svn://localhost/ardour2/trunk@2523 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 30 ++++++++++++++++---- gtk2_ardour/editor.h | 8 +++--- gtk2_ardour/editor_selection.cc | 49 ++++++++++++++++++++++++--------- gtk2_ardour/public_editor.h | 6 ++-- gtk2_ardour/route_time_axis.cc | 6 ++-- 5 files changed, 70 insertions(+), 29 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index fa69990a82..3b10d655e6 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3615,27 +3615,45 @@ 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_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist)); + mapover_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_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist)); + mapover_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_tracks (mem_fun (*this, &Editor::mapped_clear_playlist)); + mapover_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 70559da165..2367f5a325 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -264,9 +264,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* v); + void copy_playlists (TimeAxisView* v); + void clear_playlists (TimeAxisView* v); TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0); @@ -438,7 +438,7 @@ class Editor : public PublicEditor void get_relevant_tracks (std::set& relevant_tracks); void get_equivalent_regions (RegionView* rv, std::vector&); - void mapover_tracks (sigc::slot sl); + void mapover_tracks (sigc::slot sl, TimeAxisView*); /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */ diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 41b6d32a0b..9341bc30b0 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -285,17 +285,45 @@ Editor::get_relevant_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_tracks (slot sl) +Editor::mapover_tracks (slot sl, TimeAxisView* basis) { - set relevant_tracks; + RouteTimeAxisView* route_basis = dynamic_cast (basis); + if (route_basis == 0) { + return; + } - get_relevant_tracks (relevant_tracks); + /* 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; - uint32_t sz = relevant_tracks.size(); + /* always call for the basis */ + tracks.insert (route_basis); - for (set::iterator rti = relevant_tracks.begin(); rti != relevant_tracks.end(); ++rti) { - sl (**rti, sz); + RouteGroup* group = route_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) { + RouteTimeAxisView* 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); } } @@ -331,7 +359,7 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, void Editor::get_equivalent_regions (RegionView* basis, vector& equivalent_regions) { - mapover_tracks (bind (mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions)); + mapover_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 */ @@ -410,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_routeview)) { - 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 5031387290..a47f5b88d8 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -216,9 +216,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 fa9afaafa7..d2e316f626 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1414,10 +1414,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)));