2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <sigc++/bind.h>
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
|
|
|
#include "pbd/stacktrace.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/playlist.h"
|
2009-05-13 20:13:27 -04:00
|
|
|
#include "ardour/rc_configuration.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-31 23:23:35 -04:00
|
|
|
#include "region_view.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "selection.h"
|
|
|
|
#include "selection_templates.h"
|
|
|
|
#include "time_axis_view.h"
|
|
|
|
#include "automation_time_axis.h"
|
2007-10-07 11:51:14 -04:00
|
|
|
#include "public_editor.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
struct AudioRangeComparator {
|
|
|
|
bool operator()(AudioRange a, AudioRange b) {
|
|
|
|
return a.start < b.start;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Selection&
|
|
|
|
Selection::operator= (const Selection& other)
|
|
|
|
{
|
|
|
|
if (&other != this) {
|
2006-07-31 23:23:35 -04:00
|
|
|
regions = other.regions;
|
2005-09-25 14:42:24 -04:00
|
|
|
tracks = other.tracks;
|
|
|
|
time = other.time;
|
|
|
|
lines = other.lines;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator== (const Selection& a, const Selection& b)
|
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
return a.regions == b.regions &&
|
2005-09-25 14:42:24 -04:00
|
|
|
a.tracks == b.tracks &&
|
|
|
|
a.time.track == b.time.track &&
|
|
|
|
a.time.group == b.time.group &&
|
|
|
|
a.time == b.time &&
|
|
|
|
a.lines == b.lines &&
|
2007-08-01 18:18:46 -04:00
|
|
|
a.playlists == b.playlists;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-05-11 11:06:12 -04:00
|
|
|
/** Clear everything from the Selection */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Selection::clear ()
|
|
|
|
{
|
|
|
|
clear_tracks ();
|
2006-07-31 23:23:35 -04:00
|
|
|
clear_regions ();
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_points ();
|
|
|
|
clear_lines();
|
|
|
|
clear_time ();
|
|
|
|
clear_playlists ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::dump_region_layers()
|
|
|
|
{
|
|
|
|
cerr << "region selection layer dump" << endl;
|
2006-07-31 23:23:35 -04:00
|
|
|
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
|
2006-08-24 21:07:15 -04:00
|
|
|
cerr << "layer: " << (int)(*i)->region()->layer() << endl;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-07-31 23:23:35 -04:00
|
|
|
Selection::clear_regions ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
if (!regions.empty()) {
|
|
|
|
regions.clear_all ();
|
2005-09-25 14:42:24 -04:00
|
|
|
RegionsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::clear_tracks ()
|
|
|
|
{
|
|
|
|
if (!tracks.empty()) {
|
|
|
|
tracks.clear ();
|
|
|
|
TracksChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::clear_time ()
|
|
|
|
{
|
|
|
|
time.track = 0;
|
|
|
|
time.group = 0;
|
|
|
|
time.clear();
|
|
|
|
|
|
|
|
TimeChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::clear_playlists ()
|
|
|
|
{
|
|
|
|
/* Selections own their playlists */
|
|
|
|
|
|
|
|
for (PlaylistSelection::iterator i = playlists.begin(); i != playlists.end(); ++i) {
|
2007-03-20 22:39:12 -04:00
|
|
|
/* selections own their own regions, which are copies of the "originals". make them go away */
|
|
|
|
(*i)->drop_regions ();
|
2006-12-14 09:15:43 -05:00
|
|
|
(*i)->release ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!playlists.empty()) {
|
|
|
|
playlists.clear ();
|
|
|
|
PlaylistsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::clear_lines ()
|
|
|
|
{
|
|
|
|
if (!lines.empty()) {
|
|
|
|
lines.clear ();
|
|
|
|
LinesChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
void
|
|
|
|
Selection::clear_markers ()
|
|
|
|
{
|
|
|
|
if (!markers.empty()) {
|
|
|
|
markers.clear ();
|
|
|
|
MarkersChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::toggle (boost::shared_ptr<Playlist> pl)
|
2006-03-05 14:39:16 -05:00
|
|
|
{
|
2006-03-07 21:50:53 -05:00
|
|
|
PlaylistSelection::iterator i;
|
|
|
|
|
|
|
|
if ((i = find (playlists.begin(), playlists.end(), pl)) == playlists.end()) {
|
2006-12-14 09:15:43 -05:00
|
|
|
pl->use ();
|
2006-03-05 14:39:16 -05:00
|
|
|
playlists.push_back(pl);
|
2006-03-07 21:50:53 -05:00
|
|
|
} else {
|
|
|
|
playlists.erase (i);
|
2006-03-05 14:39:16 -05:00
|
|
|
}
|
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
PlaylistsChanged ();
|
2006-03-05 14:39:16 -05:00
|
|
|
}
|
|
|
|
|
2006-08-14 15:19:06 -04:00
|
|
|
void
|
|
|
|
Selection::toggle (const list<TimeAxisView*>& track_list)
|
|
|
|
{
|
|
|
|
for (list<TimeAxisView*>::const_iterator i = track_list.begin(); i != track_list.end(); ++i) {
|
|
|
|
toggle ( (*i) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
void
|
|
|
|
Selection::toggle (TimeAxisView* track)
|
|
|
|
{
|
2006-03-07 21:50:53 -05:00
|
|
|
TrackSelection::iterator i;
|
|
|
|
|
|
|
|
if ((i = find (tracks.begin(), tracks.end(), track)) == tracks.end()) {
|
2006-03-05 14:39:16 -05:00
|
|
|
void (Selection::*pmf)(TimeAxisView*) = &Selection::remove;
|
|
|
|
track->GoingAway.connect (sigc::bind (mem_fun (*this, pmf), track));
|
|
|
|
tracks.push_back (track);
|
2006-03-07 21:50:53 -05:00
|
|
|
} else {
|
|
|
|
tracks.erase (i);
|
2006-03-05 14:39:16 -05:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
|
|
|
|
TracksChanged();
|
2006-03-05 14:39:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-31 23:23:35 -04:00
|
|
|
Selection::toggle (RegionView* r)
|
2006-03-05 14:39:16 -05:00
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
RegionSelection::iterator i;
|
2006-03-05 14:39:16 -05:00
|
|
|
|
2006-07-31 23:23:35 -04:00
|
|
|
if ((i = find (regions.begin(), regions.end(), r)) == regions.end()) {
|
2007-01-18 09:57:05 -05:00
|
|
|
add (r);
|
2006-03-07 21:50:53 -05:00
|
|
|
} else {
|
2007-01-18 09:57:05 -05:00
|
|
|
remove (*i);
|
2006-03-05 14:39:16 -05:00
|
|
|
}
|
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
RegionsChanged ();
|
2006-05-30 22:46:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-31 23:23:35 -04:00
|
|
|
Selection::toggle (vector<RegionView*>& r)
|
2006-05-30 22:46:04 -04:00
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
RegionSelection::iterator i;
|
2006-05-30 22:46:04 -04:00
|
|
|
|
2006-07-31 23:23:35 -04:00
|
|
|
for (vector<RegionView*>::iterator x = r.begin(); x != r.end(); ++x) {
|
|
|
|
if ((i = find (regions.begin(), regions.end(), (*x))) == regions.end()) {
|
2007-01-18 09:57:05 -05:00
|
|
|
add ((*x));
|
2006-05-30 22:46:04 -04:00
|
|
|
} else {
|
2007-01-18 09:57:05 -05:00
|
|
|
remove (*x);
|
2006-05-30 22:46:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegionsChanged ();
|
2006-03-05 14:39:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
2006-09-28 13:23:52 -04:00
|
|
|
Selection::toggle (nframes_t start, nframes_t end)
|
2006-03-05 14:39:16 -05:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::add (boost::shared_ptr<Playlist> pl)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (find (playlists.begin(), playlists.end(), pl) == playlists.end()) {
|
2006-12-14 09:15:43 -05:00
|
|
|
pl->use ();
|
2005-09-25 14:42:24 -04:00
|
|
|
playlists.push_back(pl);
|
|
|
|
PlaylistsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::add (const list<boost::shared_ptr<Playlist> >& pllist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
|
2006-12-14 09:15:43 -05:00
|
|
|
for (list<boost::shared_ptr<Playlist> >::const_iterator i = pllist.begin(); i != pllist.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (find (playlists.begin(), playlists.end(), (*i)) == playlists.end()) {
|
2006-12-14 09:15:43 -05:00
|
|
|
(*i)->use ();
|
2005-09-25 14:42:24 -04:00
|
|
|
playlists.push_back (*i);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
PlaylistsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (const list<TimeAxisView*>& track_list)
|
|
|
|
{
|
2009-06-21 15:59:56 -04:00
|
|
|
list<TimeAxisView*> added = tracks.add (track_list);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-06-21 15:59:56 -04:00
|
|
|
for (list<TimeAxisView*>::const_iterator i = added.begin(); i != added.end(); ++i) {
|
|
|
|
void (Selection::*pmf)(TimeAxisView*) = &Selection::remove;
|
|
|
|
(*i)->GoingAway.connect (sigc::bind (mem_fun (*this, pmf), (*i)));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 15:59:56 -04:00
|
|
|
if (!added.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
TracksChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (TimeAxisView* track)
|
|
|
|
{
|
|
|
|
if (find (tracks.begin(), tracks.end(), track) == tracks.end()) {
|
|
|
|
void (Selection::*pmf)(TimeAxisView*) = &Selection::remove;
|
2005-09-25 16:33:00 -04:00
|
|
|
track->GoingAway.connect (sigc::bind (mem_fun (*this, pmf), track));
|
2005-09-25 14:42:24 -04:00
|
|
|
tracks.push_back (track);
|
|
|
|
TracksChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
void
|
2008-01-15 12:23:57 -05:00
|
|
|
Selection::add (vector<RegionView*>& v)
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
2008-01-15 12:23:57 -05:00
|
|
|
/* XXX This method or the add (const RegionSelection&) needs to go
|
|
|
|
*/
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-01-15 12:23:57 -05:00
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
for (vector<RegionView*>::iterator i = v.begin(); i != v.end(); ++i) {
|
|
|
|
if (find (regions.begin(), regions.end(), (*i)) == regions.end()) {
|
|
|
|
changed = regions.add ((*i));
|
|
|
|
if (Config->get_link_region_and_track_selection() && changed) {
|
|
|
|
add (&(*i)->get_trackview());
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2008-01-15 12:23:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
2005-09-25 14:42:24 -04:00
|
|
|
RegionsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-15 12:23:57 -05:00
|
|
|
Selection::add (const RegionSelection& rs)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-01-15 12:23:57 -05:00
|
|
|
/* XXX This method or the add (const vector<RegionView*>&) needs to go
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-01-15 12:23:57 -05:00
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
for (RegionSelection::const_iterator i = rs.begin(); i != rs.end(); ++i) {
|
2006-07-31 23:23:35 -04:00
|
|
|
if (find (regions.begin(), regions.end(), (*i)) == regions.end()) {
|
2007-01-18 11:45:29 -05:00
|
|
|
changed = regions.add ((*i));
|
2008-01-10 16:20:59 -05:00
|
|
|
if (Config->get_link_region_and_track_selection() && changed) {
|
2007-01-18 11:45:29 -05:00
|
|
|
add (&(*i)->get_trackview());
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2008-01-15 12:23:57 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (changed) {
|
2007-10-07 11:51:14 -04:00
|
|
|
select_edit_group_regions ();
|
2005-09-25 14:42:24 -04:00
|
|
|
RegionsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-15 12:23:57 -05:00
|
|
|
void
|
|
|
|
Selection::add (RegionView* r)
|
|
|
|
{
|
|
|
|
if (find (regions.begin(), regions.end(), r) == regions.end()) {
|
|
|
|
regions.add (r);
|
|
|
|
if (Config->get_link_region_and_track_selection()) {
|
|
|
|
add (&r->get_trackview());
|
|
|
|
}
|
|
|
|
RegionsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
long
|
2006-09-28 13:23:52 -04:00
|
|
|
Selection::add (nframes_t start, nframes_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AudioRangeComparator cmp;
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
/* XXX this implementation is incorrect */
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
time.push_back (AudioRange (start, end, next_time_id++));
|
|
|
|
time.consolidate ();
|
|
|
|
time.sort (cmp);
|
|
|
|
|
|
|
|
TimeChanged ();
|
|
|
|
|
|
|
|
return next_time_id - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-09-28 13:23:52 -04:00
|
|
|
Selection::replace (uint32_t sid, nframes_t start, nframes_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
|
|
|
|
if ((*i).id == sid) {
|
|
|
|
time.erase (i);
|
|
|
|
time.push_back (AudioRange(start,end, sid));
|
|
|
|
|
|
|
|
/* don't consolidate here */
|
|
|
|
|
|
|
|
|
|
|
|
AudioRangeComparator cmp;
|
|
|
|
time.sort (cmp);
|
|
|
|
|
|
|
|
TimeChanged ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-18 20:47:49 -04:00
|
|
|
Selection::add (boost::shared_ptr<Evoral::ControlList> cl)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-09-18 20:47:49 -04:00
|
|
|
boost::shared_ptr<ARDOUR::AutomationList> al
|
|
|
|
= boost::dynamic_pointer_cast<ARDOUR::AutomationList>(cl);
|
|
|
|
if (!al) {
|
|
|
|
warning << "Programming error: Selected list is not an ARDOUR::AutomationList" << endmsg;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (find (lines.begin(), lines.end(), al) == lines.end()) {
|
|
|
|
lines.push_back (al);
|
2005-09-25 14:42:24 -04:00
|
|
|
LinesChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove (TimeAxisView* track)
|
|
|
|
{
|
|
|
|
list<TimeAxisView*>::iterator i;
|
|
|
|
if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) {
|
|
|
|
tracks.erase (i);
|
|
|
|
TracksChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove (const list<TimeAxisView*>& track_list)
|
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
for (list<TimeAxisView*>::const_iterator i = track_list.begin(); i != track_list.end(); ++i) {
|
|
|
|
|
|
|
|
list<TimeAxisView*>::iterator x;
|
|
|
|
|
|
|
|
if ((x = find (tracks.begin(), tracks.end(), (*i))) != tracks.end()) {
|
|
|
|
tracks.erase (x);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
TracksChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::remove (boost::shared_ptr<Playlist> track)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-12-14 09:15:43 -05:00
|
|
|
list<boost::shared_ptr<Playlist> >::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((i = find (playlists.begin(), playlists.end(), track)) != playlists.end()) {
|
|
|
|
playlists.erase (i);
|
|
|
|
PlaylistsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::remove (const list<boost::shared_ptr<Playlist> >& pllist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
|
2006-12-14 09:15:43 -05:00
|
|
|
for (list<boost::shared_ptr<Playlist> >::const_iterator i = pllist.begin(); i != pllist.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-12-14 09:15:43 -05:00
|
|
|
list<boost::shared_ptr<Playlist> >::iterator x;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if ((x = find (playlists.begin(), playlists.end(), (*i))) != playlists.end()) {
|
|
|
|
playlists.erase (x);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
PlaylistsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-31 23:23:35 -04:00
|
|
|
Selection::remove (RegionView* r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-01-17 22:06:15 -05:00
|
|
|
if (regions.remove (r)) {
|
|
|
|
RegionsChanged ();
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (Config->get_link_region_and_track_selection() && !regions.involves (r->get_trackview())) {
|
2007-01-17 22:06:15 -05:00
|
|
|
remove (&r->get_trackview());
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove (uint32_t selection_id)
|
|
|
|
{
|
|
|
|
if (time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
|
|
|
|
if ((*i).id == selection_id) {
|
|
|
|
time.erase (i);
|
|
|
|
|
|
|
|
TimeChanged ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-09-28 13:23:52 -04:00
|
|
|
Selection::remove (nframes_t start, nframes_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-18 20:47:49 -04:00
|
|
|
Selection::remove (boost::shared_ptr<ARDOUR::AutomationList> ac)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-09-18 20:47:49 -04:00
|
|
|
AutomationSelection::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((i = find (lines.begin(), lines.end(), ac)) != lines.end()) {
|
|
|
|
lines.erase (i);
|
|
|
|
LinesChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::set (TimeAxisView* track)
|
|
|
|
{
|
|
|
|
clear_tracks ();
|
|
|
|
add (track);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::set (const list<TimeAxisView*>& track_list)
|
|
|
|
{
|
|
|
|
clear_tracks ();
|
|
|
|
add (track_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::set (boost::shared_ptr<Playlist> playlist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clear_playlists ();
|
|
|
|
add (playlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::set (const list<boost::shared_ptr<Playlist> >& pllist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clear_playlists ();
|
|
|
|
add (pllist);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-10 16:20:59 -05:00
|
|
|
Selection::set (const RegionSelection& rs)
|
|
|
|
{
|
|
|
|
clear_regions();
|
|
|
|
regions = rs;
|
|
|
|
RegionsChanged(); /* EMIT SIGNAL */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::set (RegionView* r, bool also_clear_tracks)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
clear_regions ();
|
2008-01-10 16:20:59 -05:00
|
|
|
if (also_clear_tracks) {
|
|
|
|
clear_tracks ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
add (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-31 23:23:35 -04:00
|
|
|
Selection::set (vector<RegionView*>& v)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
clear_regions ();
|
2008-01-10 16:20:59 -05:00
|
|
|
if (Config->get_link_region_and_track_selection()) {
|
|
|
|
clear_tracks ();
|
|
|
|
// make sure to deselect any automation selections
|
|
|
|
clear_points();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
add (v);
|
|
|
|
}
|
|
|
|
|
|
|
|
long
|
2006-09-28 13:23:52 -04:00
|
|
|
Selection::set (TimeAxisView* track, nframes_t start, nframes_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if ((start == 0 && end == 0) || end < start) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time.empty()) {
|
|
|
|
time.push_back (AudioRange (start, end, next_time_id++));
|
|
|
|
} else {
|
|
|
|
/* reuse the first entry, and remove all the rest */
|
|
|
|
|
|
|
|
while (time.size() > 1) {
|
|
|
|
time.pop_front();
|
|
|
|
}
|
|
|
|
time.front().start = start;
|
|
|
|
time.front().end = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (track) {
|
|
|
|
time.track = track;
|
2009-06-21 15:59:56 -04:00
|
|
|
time.group = track->route_group();
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
time.track = 0;
|
|
|
|
time.group = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
time.consolidate ();
|
|
|
|
|
|
|
|
TimeChanged ();
|
|
|
|
|
|
|
|
return time.front().id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-18 20:47:49 -04:00
|
|
|
Selection::set (boost::shared_ptr<Evoral::ControlList> ac)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
lines.clear();
|
|
|
|
add (ac);
|
|
|
|
}
|
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
bool
|
|
|
|
Selection::selected (Marker* m)
|
|
|
|
{
|
|
|
|
return find (markers.begin(), markers.end(), m) != markers.end();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
|
|
|
Selection::selected (TimeAxisView* tv)
|
|
|
|
{
|
|
|
|
return find (tracks.begin(), tracks.end(), tv) != tracks.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2006-07-31 23:23:35 -04:00
|
|
|
Selection::selected (RegionView* rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
return find (regions.begin(), regions.end(), rv) != regions.end();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Selection::empty ()
|
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
return regions.empty () &&
|
2005-09-25 14:42:24 -04:00
|
|
|
tracks.empty () &&
|
|
|
|
points.empty () &&
|
|
|
|
playlists.empty () &&
|
|
|
|
lines.empty () &&
|
|
|
|
time.empty () &&
|
2007-11-07 20:40:25 -05:00
|
|
|
playlists.empty () &&
|
|
|
|
markers.empty()
|
2005-09-25 14:42:24 -04:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2007-01-17 23:34:00 -05:00
|
|
|
void
|
|
|
|
Selection::toggle (const vector<AutomationSelectable*>& autos)
|
|
|
|
{
|
|
|
|
for (vector<AutomationSelectable*>::const_iterator x = autos.begin(); x != autos.end(); ++x) {
|
2007-01-23 16:45:05 -05:00
|
|
|
if ((*x)->get_selected()) {
|
|
|
|
points.remove (**x);
|
|
|
|
} else {
|
|
|
|
points.push_back (**x);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete *x;
|
2007-01-17 23:34:00 -05:00
|
|
|
}
|
2007-01-23 16:45:05 -05:00
|
|
|
|
|
|
|
PointsChanged (); /* EMIT SIGNAL */
|
2007-01-17 23:34:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::toggle (list<Selectable*>& selectables)
|
|
|
|
{
|
|
|
|
RegionView* rv;
|
|
|
|
AutomationSelectable* as;
|
|
|
|
vector<RegionView*> rvs;
|
|
|
|
vector<AutomationSelectable*> autos;
|
|
|
|
|
|
|
|
for (std::list<Selectable*>::iterator i = selectables.begin(); i != selectables.end(); ++i) {
|
|
|
|
if ((rv = dynamic_cast<RegionView*> (*i)) != 0) {
|
|
|
|
rvs.push_back (rv);
|
|
|
|
} else if ((as = dynamic_cast<AutomationSelectable*> (*i)) != 0) {
|
|
|
|
autos.push_back (as);
|
|
|
|
} else {
|
|
|
|
fatal << _("programming error: ")
|
|
|
|
<< X_("unknown selectable type passed to Selection::toggle()")
|
|
|
|
<< endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rvs.empty()) {
|
|
|
|
toggle (rvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!autos.empty()) {
|
|
|
|
toggle (autos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Selection::set (list<Selectable*>& selectables)
|
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
clear_regions();
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_points ();
|
|
|
|
add (selectables);
|
|
|
|
}
|
|
|
|
|
2006-08-14 15:19:06 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Selection::add (list<Selectable*>& selectables)
|
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
RegionView* rv;
|
2005-09-25 14:42:24 -04:00
|
|
|
AutomationSelectable* as;
|
2006-07-31 23:23:35 -04:00
|
|
|
vector<RegionView*> rvs;
|
2005-09-25 14:42:24 -04:00
|
|
|
vector<AutomationSelectable*> autos;
|
|
|
|
|
|
|
|
for (std::list<Selectable*>::iterator i = selectables.begin(); i != selectables.end(); ++i) {
|
2006-07-31 23:23:35 -04:00
|
|
|
if ((rv = dynamic_cast<RegionView*> (*i)) != 0) {
|
|
|
|
rvs.push_back (rv);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else if ((as = dynamic_cast<AutomationSelectable*> (*i)) != 0) {
|
|
|
|
autos.push_back (as);
|
|
|
|
} else {
|
|
|
|
fatal << _("programming error: ")
|
2007-01-17 23:34:00 -05:00
|
|
|
<< X_("unknown selectable type passed to Selection::add()")
|
2005-09-25 14:42:24 -04:00
|
|
|
<< endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-31 23:23:35 -04:00
|
|
|
if (!rvs.empty()) {
|
|
|
|
add (rvs);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!autos.empty()) {
|
|
|
|
add (autos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::clear_points ()
|
|
|
|
{
|
|
|
|
if (!points.empty()) {
|
|
|
|
points.clear ();
|
|
|
|
PointsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (vector<AutomationSelectable*>& autos)
|
|
|
|
{
|
|
|
|
for (vector<AutomationSelectable*>::iterator i = autos.begin(); i != autos.end(); ++i) {
|
|
|
|
points.push_back (**i);
|
|
|
|
}
|
2006-05-19 16:10:35 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
PointsChanged ();
|
|
|
|
}
|
2007-10-07 11:51:14 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Selection::select_edit_group_regions ()
|
|
|
|
{
|
|
|
|
std::set<RegionView*> regions_to_add;
|
|
|
|
|
|
|
|
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
|
|
|
|
vector<RegionView*> e;
|
|
|
|
editor->get_equivalent_regions (*i, e);
|
|
|
|
for (vector<RegionView*>::iterator j = e.begin(); j != e.end(); ++j) {
|
|
|
|
regions_to_add.insert(*j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::set<RegionView*>::iterator i = regions_to_add.begin(); i != regions_to_add.end(); ++i) {
|
|
|
|
add (*i);
|
|
|
|
}
|
|
|
|
}
|
2007-11-07 20:40:25 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Selection::set (Marker* m)
|
|
|
|
{
|
|
|
|
clear_markers ();
|
|
|
|
add (m);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::toggle (Marker* m)
|
|
|
|
{
|
|
|
|
MarkerSelection::iterator i;
|
|
|
|
|
|
|
|
if ((i = find (markers.begin(), markers.end(), m)) == markers.end()) {
|
|
|
|
add (m);
|
|
|
|
} else {
|
|
|
|
remove (m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove (Marker* m)
|
|
|
|
{
|
|
|
|
MarkerSelection::iterator i;
|
|
|
|
|
|
|
|
if ((i = find (markers.begin(), markers.end(), m)) != markers.end()) {
|
|
|
|
markers.erase (i);
|
|
|
|
MarkersChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (Marker* m)
|
|
|
|
{
|
|
|
|
if (find (markers.begin(), markers.end(), m) == markers.end()) {
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
/* disambiguate which remove() for the compiler */
|
|
|
|
|
|
|
|
void (Selection::*pmf)(Marker*) = &Selection::remove;
|
|
|
|
|
|
|
|
m->GoingAway.connect (bind (mem_fun (*this, pmf), m));
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
markers.push_back (m);
|
|
|
|
MarkersChanged();
|
|
|
|
}
|
|
|
|
}
|
2008-09-19 10:38:46 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (const list<Marker*>& m)
|
|
|
|
{
|
|
|
|
markers.insert (markers.end(), m.begin(), m.end());
|
|
|
|
MarkersChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MarkerSelection::range (nframes64_t& s, nframes64_t& e)
|
|
|
|
{
|
|
|
|
s = max_frames;
|
|
|
|
e = 0;
|
|
|
|
|
|
|
|
for (MarkerSelection::iterator i = begin(); i != end(); ++i) {
|
|
|
|
|
|
|
|
if ((*i)->position() < s) {
|
|
|
|
s = (*i)->position();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*i)->position() > e) {
|
|
|
|
e = (*i)->position();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s = std::min (s, e);
|
|
|
|
e = std::max (s, e);
|
|
|
|
}
|