From 24a38b8b08914636c5fd81646460cc083df5ecb9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 5 Sep 2011 23:38:18 +0000 Subject: Add option to insert time on all a track's playlists (#4304). git-svn-id: svn://localhost/ardour2/branches/3.0@10054 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_ops.cc | 36 ++++++++++++++++++++++++---------- gtk2_ardour/insert_time_dialog.cc | 9 +++++++++ gtk2_ardour/insert_time_dialog.h | 2 ++ gtk2_ardour/route_time_axis.cc | 12 ++---------- libs/ardour/ardour/session_playlists.h | 4 +++- libs/ardour/session_playlists.cc | 21 +++++++++++++++++++- 7 files changed, 63 insertions(+), 23 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index c4e99ce1fd..fca0bae86e 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1130,7 +1130,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void fork_region (); void do_insert_time (); - void insert_time (framepos_t, framecnt_t, Editing::InsertTimeOption, bool, bool, bool, bool, bool); + void insert_time (framepos_t, framecnt_t, Editing::InsertTimeOption, bool, bool, bool, bool, bool, bool); void tab_to_transient (bool forward); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 07aeda3369..6d83518f72 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -56,6 +56,7 @@ #include "ardour/strip_silence.h" #include "ardour/route_group.h" #include "ardour/operations.h" +#include "ardour/session_playlists.h" #include "ardour_ui.h" #include "debug.h" @@ -6177,6 +6178,7 @@ Editor::do_insert_time () get_preferred_edit_position(), d.distance(), opt, + d.all_playlists(), d.move_glued(), d.move_markers(), d.move_glued_markers(), @@ -6186,8 +6188,10 @@ Editor::do_insert_time () } void -Editor::insert_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, - bool ignore_music_glue, bool markers_too, bool glued_markers_too, bool locked_markers_too, bool tempo_too) +Editor::insert_time ( + framepos_t pos, framecnt_t frames, InsertTimeOption opt, + bool all_playlists, bool ignore_music_glue, bool markers_too, bool glued_markers_too, bool locked_markers_too, bool tempo_too + ) { bool commit = false; @@ -6198,25 +6202,37 @@ Editor::insert_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, begin_reversible_command (_("insert time")); for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) { + /* regions */ - boost::shared_ptr pl = (*x)->playlist(); - if (pl) { + vector > pl; + if (all_playlists) { + RouteTimeAxisView* rtav = dynamic_cast (*x); + if (rtav) { + pl = _session->playlists->playlists_for_track (rtav->track ()); + } + } else { + if ((*x)->playlist ()) { + pl.push_back ((*x)->playlist ()); + } + } - pl->clear_changes (); - pl->clear_owned_changes (); + for (vector >::iterator i = pl.begin(); i != pl.end(); ++i) { + + (*i)->clear_changes (); + (*i)->clear_owned_changes (); if (opt == SplitIntersected) { - pl->split (pos); + (*i)->split (pos); } - pl->shift (pos, frames, (opt == MoveIntersected), ignore_music_glue); + (*i)->shift (pos, frames, (opt == MoveIntersected), ignore_music_glue); vector cmds; - pl->rdiff (cmds); + (*i)->rdiff (cmds); _session->add_commands (cmds); - _session->add_command (new StatefulDiffCommand (pl)); + _session->add_command (new StatefulDiffCommand (*i)); commit = true; } diff --git a/gtk2_ardour/insert_time_dialog.cc b/gtk2_ardour/insert_time_dialog.cc index bc17a6a7c8..051cd0d394 100644 --- a/gtk2_ardour/insert_time_dialog.cc +++ b/gtk2_ardour/insert_time_dialog.cc @@ -62,6 +62,9 @@ InsertTimeDialog::InsertTimeDialog (PublicEditor& e) get_vbox()->pack_start (*table); + _all_playlists.set_label (_("Insert time on all the track's playlists")); + get_vbox()->pack_start (_all_playlists); + _move_glued.set_label (_("Move glued regions")); get_vbox()->pack_start (_move_glued); _move_markers.set_label (_("Move markers")); @@ -108,6 +111,12 @@ InsertTimeDialog::intersected_region_action () return opt; } +bool +InsertTimeDialog::all_playlists () const +{ + return _all_playlists.get_active (); +} + bool InsertTimeDialog::move_glued () const { diff --git a/gtk2_ardour/insert_time_dialog.h b/gtk2_ardour/insert_time_dialog.h index 15ae77515c..06fbc32b7e 100644 --- a/gtk2_ardour/insert_time_dialog.h +++ b/gtk2_ardour/insert_time_dialog.h @@ -28,6 +28,7 @@ public: InsertTimeDialog (PublicEditor &); Editing::InsertTimeOption intersected_region_action (); + bool all_playlists () const; bool move_glued () const; bool move_markers () const; bool move_glued_markers () const; @@ -40,6 +41,7 @@ private: PublicEditor& _editor; Gtk::ComboBoxText _intersected_combo; + Gtk::CheckButton _all_playlists; Gtk::CheckButton _move_glued; Gtk::CheckButton _move_markers; Gtk::CheckButton _move_glued_markers; diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 66b0192119..69f0e3929b 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1465,18 +1465,10 @@ RouteTimeAxisView::build_playlist_menu () playlist_action_menu->set_name ("ArdourContextMenu"); playlist_items.clear(); - vector > playlists, playlists_tr; - boost::shared_ptr tr = track(); RadioMenuItem::Group playlist_group; + boost::shared_ptr tr = track (); - _session->playlists->get (playlists); - - /* find the playlists for this diskstream */ - for (vector >::iterator i = playlists.begin(); i != playlists.end(); ++i) { - if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) { - playlists_tr.push_back(*i); - } - } + vector > playlists_tr = _session->playlists->playlists_for_track (tr); /* sort the playlists */ PlaylistSorter cmp; diff --git a/libs/ardour/ardour/session_playlists.h b/libs/ardour/ardour/session_playlists.h index 96321f2f9c..5f69ba8001 100644 --- a/libs/ardour/ardour/session_playlists.h +++ b/libs/ardour/ardour/session_playlists.h @@ -42,6 +42,7 @@ class Region; class Source; class Session; class Crossfade; +class Track; class SessionPlaylists : public PBD::ScopedConnectionList { @@ -53,11 +54,12 @@ public: uint32_t source_use_count (boost::shared_ptr src) const; uint32_t region_use_count (boost::shared_ptr region) const; template void foreach (T *obj, void (T::*func)(boost::shared_ptr)); - void get (std::vector >&); + void get (std::vector >&) const; void unassigned (std::list > & list); void destroy_region (boost::shared_ptr); boost::shared_ptr find_crossfade (const PBD::ID &); void sync_all_regions_with_regions (); + std::vector > playlists_for_track (boost::shared_ptr) const; private: friend class Session; diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index a5772c23e3..1e31801271 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -27,6 +27,7 @@ #include "ardour/playlist_factory.h" #include "ardour/session.h" #include "ardour/source.h" +#include "ardour/track.h" #include "i18n.h" using namespace std; @@ -219,7 +220,7 @@ SessionPlaylists::unassigned (std::list > & list) } void -SessionPlaylists::get (vector >& s) +SessionPlaylists::get (vector >& s) const { Glib::Mutex::Lock lm (lock); @@ -450,3 +451,21 @@ SessionPlaylists::region_use_count (boost::shared_ptr region) const return cnt; } + +/** @return list of Playlists that are associated with a track */ +vector > +SessionPlaylists::playlists_for_track (boost::shared_ptr tr) const +{ + vector > pl; + get (pl); + + vector > pl_tr; + + for (vector >::iterator i = pl.begin(); i != pl.end(); ++i) { + if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) { + pl_tr.push_back (*i); + } + } + + return pl_tr; +} -- cgit v1.2.3