diff options
author | Carl Hetherington <carl@carlh.net> | 2011-09-05 23:38:18 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-09-05 23:38:18 +0000 |
commit | 24a38b8b08914636c5fd81646460cc083df5ecb9 (patch) | |
tree | 966dd1cb907e5b1e8acbf263b3a23c79c1faa2bc | |
parent | e3692bf3dab4dc7d9a80ca79f98830cc7f1c0793 (diff) |
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
-rw-r--r-- | gtk2_ardour/editor.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 36 | ||||
-rw-r--r-- | gtk2_ardour/insert_time_dialog.cc | 9 | ||||
-rw-r--r-- | gtk2_ardour/insert_time_dialog.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/route_time_axis.cc | 12 | ||||
-rw-r--r-- | libs/ardour/ardour/session_playlists.h | 4 | ||||
-rw-r--r-- | 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<Playlist> pl = (*x)->playlist(); - if (pl) { + vector<boost::shared_ptr<Playlist> > pl; + if (all_playlists) { + RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*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<boost::shared_ptr<Playlist> >::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<Command*> 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")); @@ -109,6 +112,12 @@ InsertTimeDialog::intersected_region_action () } bool +InsertTimeDialog::all_playlists () const +{ + return _all_playlists.get_active (); +} + +bool InsertTimeDialog::move_glued () const { return _move_glued.get_active (); 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<boost::shared_ptr<Playlist> > playlists, playlists_tr; - boost::shared_ptr<Track> tr = track(); RadioMenuItem::Group playlist_group; + boost::shared_ptr<Track> tr = track (); - _session->playlists->get (playlists); - - /* find the playlists for this diskstream */ - for (vector<boost::shared_ptr<Playlist> >::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<boost::shared_ptr<Playlist> > 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<const Source> src) const; uint32_t region_use_count (boost::shared_ptr<Region> region) const; template<class T> void foreach (T *obj, void (T::*func)(boost::shared_ptr<Playlist>)); - void get (std::vector<boost::shared_ptr<Playlist> >&); + void get (std::vector<boost::shared_ptr<Playlist> >&) const; void unassigned (std::list<boost::shared_ptr<Playlist> > & list); void destroy_region (boost::shared_ptr<Region>); boost::shared_ptr<Crossfade> find_crossfade (const PBD::ID &); void sync_all_regions_with_regions (); + std::vector<boost::shared_ptr<Playlist> > playlists_for_track (boost::shared_ptr<Track>) 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<boost::shared_ptr<Playlist> > & list) } void -SessionPlaylists::get (vector<boost::shared_ptr<Playlist> >& s) +SessionPlaylists::get (vector<boost::shared_ptr<Playlist> >& s) const { Glib::Mutex::Lock lm (lock); @@ -450,3 +451,21 @@ SessionPlaylists::region_use_count (boost::shared_ptr<Region> region) const return cnt; } + +/** @return list of Playlists that are associated with a track */ +vector<boost::shared_ptr<Playlist> > +SessionPlaylists::playlists_for_track (boost::shared_ptr<Track> tr) const +{ + vector<boost::shared_ptr<Playlist> > pl; + get (pl); + + vector<boost::shared_ptr<Playlist> > pl_tr; + + for (vector<boost::shared_ptr<Playlist> >::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; +} |