diff options
Diffstat (limited to 'gtk2_ardour/selection.cc')
-rw-r--r-- | gtk2_ardour/selection.cc | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index f96d649b04..d6efce7264 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -150,6 +150,116 @@ Selection::clear_lines () } void +Selection::toggle (Redirect* r) +{ + if (find (redirects.begin(), redirects.end(), r) == redirects.end()) { + redirects.push_back (r); + RedirectsChanged(); + } +} + +void +Selection::toggle (Playlist* pl) +{ + if (find (playlists.begin(), playlists.end(), pl) == playlists.end()) { + pl->ref (); + playlists.push_back(pl); + PlaylistsChanged (); + } +} + +void +Selection::toggle (const list<Playlist*>& pllist) +{ + bool changed = false; + + for (list<Playlist*>::const_iterator i = pllist.begin(); i != pllist.end(); ++i) { + if (find (playlists.begin(), playlists.end(), (*i)) == playlists.end()) { + (*i)->ref (); + playlists.push_back (*i); + changed = true; + } + } + + if (changed) { + PlaylistsChanged (); + } +} + +void +Selection::toggle (const list<TimeAxisView*>& track_list) +{ + bool changed = false; + + for (list<TimeAxisView*>::const_iterator i = track_list.begin(); i != track_list.end(); ++i) { + if (find (tracks.begin(), tracks.end(), (*i)) == tracks.end()) { + void (Selection::*pmf)(TimeAxisView*) = &Selection::remove; + (*i)->GoingAway.connect (sigc::bind (mem_fun (*this, pmf), (*i))); + tracks.push_back (*i); + changed = true; + } + } + + if (changed) { + TracksChanged (); + } +} + +void +Selection::toggle (TimeAxisView* track) +{ + if (find (tracks.begin(), tracks.end(), track) == tracks.end()) { + void (Selection::*pmf)(TimeAxisView*) = &Selection::remove; + track->GoingAway.connect (sigc::bind (mem_fun (*this, pmf), track)); + tracks.push_back (track); + TracksChanged(); + } +} + +void +Selection::toggle (AudioRegionView* r) +{ + if (find (audio_regions.begin(), audio_regions.end(), r) == audio_regions.end()) { + audio_regions.add (r); + RegionsChanged (); + } +} + +void +Selection::toggle (vector<AudioRegionView*>& v) +{ + bool changed = false; + + for (vector<AudioRegionView*>::iterator i = v.begin(); i != v.end(); ++i) { + if (find (audio_regions.begin(), audio_regions.end(), (*i)) == audio_regions.end()) { + audio_regions.add ((*i)); + changed = true; + } + } + + if (changed) { + RegionsChanged (); + } +} + +long +Selection::toggle (jack_nframes_t start, jack_nframes_t end) +{ + AudioRangeComparator cmp; + + /* XXX this implementation is incorrect */ + + time.push_back (AudioRange (start, end, next_time_id++)); + time.consolidate (); + time.sort (cmp); + + TimeChanged (); + + return next_time_id - 1; +} + + +void Selection::add (Redirect* r) { if (find (redirects.begin(), redirects.end(), r) == redirects.end()) { @@ -247,6 +357,8 @@ Selection::add (jack_nframes_t start, jack_nframes_t end) { AudioRangeComparator cmp; + /* XXX this implementation is incorrect */ + time.push_back (AudioRange (start, end, next_time_id++)); time.consolidate (); time.sort (cmp); |