2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2014-2017 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
* Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
* Copyright (C) 2014-2018 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2015-2017 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <sigc++/bind.h>
|
2014-02-26 10:51:38 -05:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
|
|
|
#include "pbd/stacktrace.h"
|
2016-12-06 23:41:46 -05:00
|
|
|
#include "pbd/types_convert.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
#include "ardour/evoral_types_convert.h"
|
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"
|
2017-05-05 07:31:49 -04:00
|
|
|
#include "ardour/selection.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-07-06 13:37:30 -04:00
|
|
|
#include "control_protocol/control_protocol.h"
|
|
|
|
|
2015-10-03 11:19:38 -04:00
|
|
|
#include "audio_region_view.h"
|
2015-10-27 22:58:55 -04:00
|
|
|
#include "debug.h"
|
2009-12-21 13:23:07 -05:00
|
|
|
#include "gui_thread.h"
|
2009-08-13 15:48:10 -04:00
|
|
|
#include "midi_cut_buffer.h"
|
2015-10-03 11:19:38 -04:00
|
|
|
#include "region_gain_line.h"
|
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"
|
2010-08-10 21:23:03 -04:00
|
|
|
#include "control_point.h"
|
2017-02-17 18:45:37 -05:00
|
|
|
#include "vca_time_axis.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
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 14:42:24 -04:00
|
|
|
|
|
|
|
struct AudioRangeComparator {
|
2015-01-10 20:55:48 -05:00
|
|
|
bool operator()(AudioRange a, AudioRange b) {
|
|
|
|
return a.start < b.start;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
|
|
|
|
2017-06-07 12:14:44 -04:00
|
|
|
Selection::Selection (const PublicEditor* e, bool mls)
|
2009-12-25 16:06:52 -05:00
|
|
|
: tracks (e)
|
|
|
|
, editor (e)
|
2011-06-01 13:00:29 -04:00
|
|
|
, next_time_id (0)
|
2017-06-07 12:14:44 -04:00
|
|
|
, manage_libardour_selection (mls)
|
2009-12-25 16:06:52 -05:00
|
|
|
{
|
|
|
|
clear ();
|
|
|
|
|
|
|
|
/* we have disambiguate which remove() for the compiler */
|
|
|
|
|
2015-07-23 07:23:47 -04:00
|
|
|
void (Selection::*marker_remove)(ArdourMarker*) = &Selection::remove;
|
|
|
|
ArdourMarker::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (marker_remove, this, _1), gui_context());
|
2012-04-22 10:03:07 -04:00
|
|
|
|
|
|
|
void (Selection::*point_remove)(ControlPoint*) = &Selection::remove;
|
2012-04-25 08:58:19 -04:00
|
|
|
ControlPoint::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (point_remove, this, _1), gui_context());
|
2011-06-01 13:00:29 -04:00
|
|
|
}
|
2009-12-25 16:06:52 -05:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
#if 0
|
2005-09-25 14:42:24 -04:00
|
|
|
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;
|
2009-08-12 21:57:03 -04:00
|
|
|
midi_regions = other.midi_regions;
|
|
|
|
midi_notes = other.midi_notes;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
2009-12-17 13:24:23 -05:00
|
|
|
#endif
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
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 == b.time &&
|
|
|
|
a.lines == b.lines &&
|
2009-08-10 15:29:29 -04:00
|
|
|
a.playlists == b.playlists &&
|
2009-08-12 21:57:03 -04:00
|
|
|
a.midi_notes == b.midi_notes &&
|
|
|
|
a.midi_regions == b.midi_regions;
|
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 ();
|
2009-08-12 21:57:03 -04:00
|
|
|
clear_midi_notes ();
|
|
|
|
clear_midi_regions ();
|
2012-02-05 16:00:59 -05:00
|
|
|
clear_markers ();
|
2015-01-10 12:07:31 -05:00
|
|
|
pending_midi_note_selection.clear();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2012-11-26 17:37:34 -05:00
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_objects (bool with_signal)
|
2012-11-26 17:37:34 -05:00
|
|
|
{
|
2016-01-29 16:05:03 -05:00
|
|
|
clear_regions (with_signal);
|
|
|
|
clear_points (with_signal);
|
|
|
|
clear_lines(with_signal);
|
|
|
|
clear_playlists (with_signal);
|
|
|
|
clear_midi_notes (with_signal);
|
|
|
|
clear_midi_regions (with_signal);
|
2012-11-26 17:37:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_time (bool with_signal)
|
2012-11-26 17:37:34 -05:00
|
|
|
{
|
|
|
|
time.clear();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
TimeChanged ();
|
|
|
|
}
|
2012-11-26 17:37:34 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
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
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_regions (bool with_signal)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-31 23:23:35 -04:00
|
|
|
if (!regions.empty()) {
|
|
|
|
regions.clear_all ();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
RegionsChanged();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 15:29:29 -04:00
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_midi_notes (bool with_signal)
|
2009-08-10 15:29:29 -04:00
|
|
|
{
|
2009-08-12 21:57:03 -04:00
|
|
|
if (!midi_notes.empty()) {
|
2009-08-13 15:48:10 -04:00
|
|
|
for (MidiNoteSelection::iterator x = midi_notes.begin(); x != midi_notes.end(); ++x) {
|
|
|
|
delete *x;
|
|
|
|
}
|
2009-08-12 21:57:03 -04:00
|
|
|
midi_notes.clear ();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
MidiNotesChanged ();
|
|
|
|
}
|
2009-08-12 21:57:03 -04:00
|
|
|
}
|
2014-12-12 18:16:50 -05:00
|
|
|
|
2015-10-27 22:58:55 -04:00
|
|
|
// clear note selections for MRV's that have note selections
|
|
|
|
// this will cause the MRV to be removed from the list
|
|
|
|
for (MidiRegionSelection::iterator i = midi_regions.begin();
|
|
|
|
i != midi_regions.end();) {
|
|
|
|
MidiRegionSelection::iterator tmp = i;
|
|
|
|
++tmp;
|
|
|
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i);
|
|
|
|
if (mrv) {
|
|
|
|
mrv->clear_selection();
|
|
|
|
}
|
|
|
|
i = tmp;
|
|
|
|
}
|
2009-08-12 21:57:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_midi_regions (bool with_signal)
|
2009-08-12 21:57:03 -04:00
|
|
|
{
|
|
|
|
if (!midi_regions.empty()) {
|
|
|
|
midi_regions.clear ();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
MidiRegionsChanged ();
|
|
|
|
}
|
2009-08-10 15:29:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_playlists (bool with_signal)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* 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 ();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
PlaylistsChanged();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_lines (bool with_signal)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!lines.empty()) {
|
|
|
|
lines.clear ();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
LinesChanged();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_markers (bool with_signal)
|
2007-11-07 20:40:25 -05:00
|
|
|
{
|
|
|
|
if (!markers.empty()) {
|
|
|
|
markers.clear ();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
MarkersChanged();
|
|
|
|
}
|
2007-11-07 20:40:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2015-01-10 20:55:48 -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
|
|
|
}
|
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
void
|
|
|
|
Selection::toggle (const MidiNoteSelection& midi_note_list)
|
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
for (MidiNoteSelection::const_iterator i = midi_note_list.begin(); i != midi_note_list.end(); ++i) {
|
|
|
|
toggle ((*i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::toggle (MidiCutBuffer* midi)
|
|
|
|
{
|
|
|
|
MidiNoteSelection::iterator i;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
if ((i = find (midi_notes.begin(), midi_notes.end(), midi)) == midi_notes.end()) {
|
|
|
|
midi_notes.push_back (midi);
|
|
|
|
} else {
|
2009-08-13 15:48:10 -04:00
|
|
|
/* remember that we own the MCB */
|
|
|
|
delete *i;
|
2009-08-12 21:57:03 -04:00
|
|
|
midi_notes.erase (i);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
MidiNotesChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2015-01-10 20:55:48 -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
|
|
|
}
|
|
|
|
|
2009-08-10 15:29:29 -04:00
|
|
|
void
|
|
|
|
Selection::toggle (MidiRegionView* mrv)
|
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
MidiRegionSelection::iterator i;
|
2009-08-10 15:29:29 -04:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
if ((i = find (midi_regions.begin(), midi_regions.end(), mrv)) == midi_regions.end()) {
|
2009-08-10 15:29:29 -04:00
|
|
|
add (mrv);
|
|
|
|
} else {
|
2009-08-12 21:57:03 -04:00
|
|
|
midi_regions.erase (i);
|
2009-08-10 15:29:29 -04:00
|
|
|
}
|
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
MidiRegionsChanged ();
|
2009-08-10 15:29:29 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05: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
|
2017-09-18 12:39:17 -04:00
|
|
|
Selection::toggle (samplepos_t start, samplepos_t end)
|
2006-03-05 14:39:16 -05:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_objects(); // enforce object/range exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
AudioRangeComparator cmp;
|
|
|
|
|
|
|
|
/* XXX this implementation is incorrect */
|
|
|
|
|
2012-12-13 16:10:44 -05:00
|
|
|
time.push_back (AudioRange (start, end, ++next_time_id));
|
2006-03-05 14:39:16 -05:00
|
|
|
time.consolidate ();
|
|
|
|
time.sort (cmp);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
TimeChanged ();
|
|
|
|
|
2012-12-13 16:10:44 -05:00
|
|
|
return next_time_id;
|
2006-03-05 14:39:16 -05:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (find (playlists.begin(), playlists.end(), pl) == playlists.end()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
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;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (changed) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2005-09-25 14:42:24 -04:00
|
|
|
PlaylistsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
void
|
|
|
|
Selection::add (const MidiNoteSelection& midi_list)
|
|
|
|
{
|
|
|
|
const MidiNoteSelection::const_iterator b = midi_list.begin();
|
|
|
|
const MidiNoteSelection::const_iterator e = midi_list.end();
|
|
|
|
|
|
|
|
if (!midi_list.empty()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2009-08-12 21:57:03 -04:00
|
|
|
midi_notes.insert (midi_notes.end(), b, e);
|
|
|
|
MidiNotesChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (MidiCutBuffer* midi)
|
|
|
|
{
|
2009-08-13 15:48:10 -04:00
|
|
|
/* we take ownership of the MCB */
|
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
if (find (midi_notes.begin(), midi_notes.end(), midi) == midi_notes.end()) {
|
|
|
|
midi_notes.push_back (midi);
|
|
|
|
MidiNotesChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-15 12:23:57 -05:00
|
|
|
for (vector<RegionView*>::iterator i = v.begin(); i != v.end(); ++i) {
|
|
|
|
if (find (regions.begin(), regions.end(), (*i)) == regions.end()) {
|
|
|
|
changed = regions.add ((*i));
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2008-01-15 12:23:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
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;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-15 12:23:57 -05:00
|
|
|
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));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (changed) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
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()) {
|
2010-09-15 10:37:08 -04:00
|
|
|
bool changed = regions.add (r);
|
2015-01-10 12:07:31 -05:00
|
|
|
if (changed) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2015-01-10 12:07:31 -05:00
|
|
|
RegionsChanged ();
|
|
|
|
}
|
2008-01-15 12:23:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 15:29:29 -04:00
|
|
|
void
|
|
|
|
Selection::add (MidiRegionView* mrv)
|
|
|
|
{
|
2015-10-27 22:58:55 -04:00
|
|
|
DEBUG_TRACE(DEBUG::Selection, string_compose("Selection::add MRV %1\n", mrv));
|
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
if (find (midi_regions.begin(), midi_regions.end(), mrv) == midi_regions.end()) {
|
|
|
|
midi_regions.push_back (mrv);
|
2009-08-10 15:29:29 -04:00
|
|
|
/* XXX should we do this? */
|
2009-08-12 21:57:03 -04:00
|
|
|
MidiRegionsChanged ();
|
2009-08-10 15:29:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
long
|
2017-09-18 12:39:17 -04:00
|
|
|
Selection::add (samplepos_t start, samplepos_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_objects(); // enforce object/range exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
AudioRangeComparator cmp;
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
/* XXX this implementation is incorrect */
|
|
|
|
|
2012-12-13 16:10:44 -05:00
|
|
|
time.push_back (AudioRange (start, end, ++next_time_id));
|
2005-09-25 14:42:24 -04:00
|
|
|
time.consolidate ();
|
|
|
|
time.sort (cmp);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeChanged ();
|
|
|
|
|
2012-12-13 16:10:44 -05:00
|
|
|
return next_time_id;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2012-12-13 14:39:36 -05:00
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
Selection::move_time (samplecnt_t distance)
|
2012-12-13 14:39:36 -05:00
|
|
|
{
|
|
|
|
if (distance == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
|
|
|
|
(*i).start += distance;
|
|
|
|
(*i).end += distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeChanged ();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
Selection::replace (uint32_t sid, samplepos_t start, samplepos_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_objects(); // enforce object/range exclusivity
|
2015-01-10 20:55:48 -05:00
|
|
|
|
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
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
boost::shared_ptr<ARDOUR::AutomationList> al = boost::dynamic_pointer_cast<ARDOUR::AutomationList>(cl);
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
if (!al) {
|
|
|
|
warning << "Programming error: Selected list is not an ARDOUR::AutomationList" << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
2016-03-28 15:45:44 -04:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!cl->empty()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce object/range exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
|
|
|
|
2016-03-28 15:45:44 -04:00
|
|
|
/* The original may change so we must store a copy (not a pointer) here.
|
|
|
|
* e.g AutomationLine rewrites the list with gain mapping.
|
|
|
|
* the downside is that we can't perfom duplicate checks.
|
|
|
|
* This code was changed in response to #6842
|
|
|
|
*/
|
|
|
|
lines.push_back (boost::shared_ptr<ARDOUR::AutomationList> (new ARDOUR::AutomationList(*al)));
|
|
|
|
LinesChanged();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:53:52 -05:00
|
|
|
void
|
|
|
|
Selection::remove (ControlPoint* p)
|
|
|
|
{
|
|
|
|
PointSelection::iterator i = find (points.begin(), points.end(), p);
|
|
|
|
if (i != points.end ()) {
|
|
|
|
points.erase (i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
void
|
|
|
|
Selection::remove (const MidiNoteSelection& midi_list)
|
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
for (MidiNoteSelection::const_iterator i = midi_list.begin(); i != midi_list.end(); ++i) {
|
|
|
|
|
|
|
|
MidiNoteSelection::iterator x;
|
|
|
|
|
|
|
|
if ((x = find (midi_notes.begin(), midi_notes.end(), (*i))) != midi_notes.end()) {
|
|
|
|
midi_notes.erase (x);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
MidiNotesChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove (MidiCutBuffer* midi)
|
|
|
|
{
|
|
|
|
MidiNoteSelection::iterator x;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
if ((x = find (midi_notes.begin(), midi_notes.end(), midi)) != midi_notes.end()) {
|
2009-08-13 15:48:10 -04:00
|
|
|
/* remember that we own the MCB */
|
|
|
|
delete *x;
|
2009-08-12 21:57:03 -04:00
|
|
|
midi_notes.erase (x);
|
|
|
|
MidiNotesChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
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 ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-08-10 15:29:29 -04:00
|
|
|
void
|
|
|
|
Selection::remove (MidiRegionView* mrv)
|
|
|
|
{
|
2015-10-27 22:58:55 -04:00
|
|
|
DEBUG_TRACE(DEBUG::Selection, string_compose("Selection::remove MRV %1\n", mrv));
|
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
MidiRegionSelection::iterator x;
|
2009-08-10 15:29:29 -04:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
if ((x = find (midi_regions.begin(), midi_regions.end(), mrv)) != midi_regions.end()) {
|
|
|
|
midi_regions.erase (x);
|
|
|
|
MidiRegionsChanged ();
|
2009-08-10 15:29:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeChanged ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
Selection::remove (samplepos_t /*start*/, samplepos_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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
void
|
|
|
|
Selection::set (const MidiNoteSelection& midi_list)
|
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!midi_list.empty()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects ();
|
2009-08-12 21:57:03 -04:00
|
|
|
add (midi_list);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2006-12-14 09:15:43 -05:00
|
|
|
Selection::set (boost::shared_ptr<Playlist> playlist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (playlist) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects ();
|
2005-09-25 14:42:24 -04:00
|
|
|
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
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!pllist.empty()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects ();
|
2005-09-25 14:42:24 -04:00
|
|
|
add (pllist);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-10 16:20:59 -05:00
|
|
|
Selection::set (const RegionSelection& rs)
|
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!rs.empty()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects();
|
2008-01-10 16:20:59 -05:00
|
|
|
regions = rs;
|
|
|
|
RegionsChanged(); /* EMIT SIGNAL */
|
|
|
|
}
|
|
|
|
|
2009-08-10 15:29:29 -04:00
|
|
|
void
|
2009-10-14 12:10:01 -04:00
|
|
|
Selection::set (MidiRegionView* mrv)
|
2009-08-10 15:29:29 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (mrv) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects ();
|
2009-08-10 15:29:29 -04:00
|
|
|
add (mrv);
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
void
|
2014-07-06 14:53:56 -04:00
|
|
|
Selection::set (RegionView* r, bool /*also_clear_tracks*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (r) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects ();
|
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
|
|
|
{
|
2017-05-05 07:31:49 -04:00
|
|
|
if (!v.empty()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
|
|
|
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects();
|
2012-01-30 17:53:22 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
add (v);
|
|
|
|
}
|
|
|
|
|
2009-12-13 16:27:19 -05:00
|
|
|
/** Set the start and end time of the time selection, without changing
|
|
|
|
* the list of tracks it applies to.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
long
|
2017-09-18 12:39:17 -04:00
|
|
|
Selection::set (samplepos_t start, samplepos_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_objects(); // enforce region/object exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_time();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((start == 0 && end == 0) || end < start) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time.empty()) {
|
2012-12-13 14:56:43 -05:00
|
|
|
time.push_back (AudioRange (start, end, ++next_time_id));
|
2005-09-25 14:42:24 -04:00
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
time.consolidate ();
|
|
|
|
|
|
|
|
TimeChanged ();
|
|
|
|
|
|
|
|
return time.front().id;
|
|
|
|
}
|
|
|
|
|
2011-04-17 09:55:41 -04:00
|
|
|
/** Set the start and end of the range selection. If more than one range
|
|
|
|
* is currently selected, the start of the earliest range and the end of the
|
|
|
|
* latest range are set. If no range is currently selected, this method
|
|
|
|
* selects a single range from start to end.
|
|
|
|
*
|
|
|
|
* @param start New start time.
|
|
|
|
* @param end New end time.
|
|
|
|
*/
|
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
Selection::set_preserving_all_ranges (samplepos_t start, samplepos_t end)
|
2011-04-17 09:55:41 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_objects(); // enforce region/object exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2011-04-17 09:55:41 -04:00
|
|
|
if ((start == 0 && end == 0) || (end < start)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time.empty ()) {
|
2012-12-13 14:56:43 -05:00
|
|
|
time.push_back (AudioRange (start, end, ++next_time_id));
|
2011-04-17 09:55:41 -04:00
|
|
|
} else {
|
|
|
|
time.sort (AudioRangeComparator ());
|
|
|
|
time.front().start = start;
|
|
|
|
time.back().end = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
time.consolidate ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-04-17 09:55:41 -04:00
|
|
|
TimeChanged ();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
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
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects();
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
add (ac);
|
|
|
|
}
|
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
bool
|
2017-02-24 06:59:07 -05:00
|
|
|
Selection::selected (ArdourMarker* m) const
|
2008-09-19 10:38:46 -04:00
|
|
|
{
|
|
|
|
return find (markers.begin(), markers.end(), m) != markers.end();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
2017-02-24 06:59:07 -05:00
|
|
|
Selection::selected (RegionView* rv) const
|
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
|
|
|
}
|
|
|
|
|
2012-05-31 10:39:48 -04:00
|
|
|
bool
|
2017-02-24 06:59:07 -05:00
|
|
|
Selection::selected (ControlPoint* cp) const
|
2012-05-31 10:39:48 -04:00
|
|
|
{
|
|
|
|
return find (points.begin(), points.end(), cp) != points.end();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
2009-08-12 21:57:03 -04:00
|
|
|
Selection::empty (bool internal_selection)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
bool object_level_empty = regions.empty () &&
|
2005-09-25 14:42:24 -04:00
|
|
|
tracks.empty () &&
|
2009-10-14 12:10:01 -04:00
|
|
|
points.empty () &&
|
|
|
|
playlists.empty () &&
|
2005-09-25 14:42:24 -04:00
|
|
|
lines.empty () &&
|
|
|
|
time.empty () &&
|
2007-11-07 20:40:25 -05:00
|
|
|
playlists.empty () &&
|
2009-08-12 21:57:03 -04:00
|
|
|
markers.empty() &&
|
|
|
|
midi_regions.empty()
|
2005-09-25 14:42:24 -04:00
|
|
|
;
|
2009-08-12 21:57:03 -04:00
|
|
|
|
|
|
|
if (!internal_selection) {
|
|
|
|
return object_level_empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is intended to really only apply when using a Selection
|
|
|
|
as a cut buffer.
|
|
|
|
*/
|
|
|
|
|
2014-11-16 17:04:27 -05:00
|
|
|
return object_level_empty && midi_notes.empty() && points.empty();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-01-17 23:34:00 -05:00
|
|
|
void
|
2010-08-10 21:23:03 -04:00
|
|
|
Selection::toggle (ControlPoint* cp)
|
2007-01-17 23:34:00 -05:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2016-06-05 19:49:51 -04:00
|
|
|
cp->set_selected (!cp->selected ());
|
2012-04-22 10:03:07 -04:00
|
|
|
PointSelection::iterator i = find (points.begin(), points.end(), cp);
|
|
|
|
if (i == points.end()) {
|
|
|
|
points.push_back (cp);
|
|
|
|
} else {
|
|
|
|
points.erase (i);
|
|
|
|
}
|
|
|
|
|
|
|
|
PointsChanged (); /* EMIT SIGNAL */
|
2010-08-10 21:23:03 -04:00
|
|
|
}
|
2007-01-23 16:45:05 -05:00
|
|
|
|
2010-08-10 21:23:03 -04:00
|
|
|
void
|
|
|
|
Selection::toggle (vector<ControlPoint*> const & cps)
|
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2010-08-10 21:23:03 -04:00
|
|
|
for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
|
2012-04-22 10:03:07 -04:00
|
|
|
toggle (*i);
|
2007-01-17 23:34:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-04 21:22:58 -05:00
|
|
|
Selection::toggle (list<Selectable*> const & selectables)
|
2007-01-17 23:34:00 -05:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time(); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2007-01-17 23:34:00 -05:00
|
|
|
RegionView* rv;
|
2010-08-10 21:23:03 -04:00
|
|
|
ControlPoint* cp;
|
2007-01-17 23:34:00 -05:00
|
|
|
vector<RegionView*> rvs;
|
2010-08-10 21:23:03 -04:00
|
|
|
vector<ControlPoint*> cps;
|
2007-01-17 23:34:00 -05:00
|
|
|
|
2010-01-04 21:22:58 -05:00
|
|
|
for (std::list<Selectable*>::const_iterator i = selectables.begin(); i != selectables.end(); ++i) {
|
2007-01-17 23:34:00 -05:00
|
|
|
if ((rv = dynamic_cast<RegionView*> (*i)) != 0) {
|
|
|
|
rvs.push_back (rv);
|
2010-08-10 21:23:03 -04:00
|
|
|
} else if ((cp = dynamic_cast<ControlPoint*> (*i)) != 0) {
|
|
|
|
cps.push_back (cp);
|
2007-01-17 23:34:00 -05:00
|
|
|
} else {
|
|
|
|
fatal << _("programming error: ")
|
|
|
|
<< X_("unknown selectable type passed to Selection::toggle()")
|
|
|
|
<< endmsg;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2007-01-17 23:34:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rvs.empty()) {
|
|
|
|
toggle (rvs);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-01-17 23:34:00 -05:00
|
|
|
|
2010-08-10 21:23:03 -04:00
|
|
|
if (!cps.empty()) {
|
|
|
|
toggle (cps);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-01-17 23:34:00 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2010-01-04 21:22:58 -05:00
|
|
|
Selection::set (list<Selectable*> const & selectables)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects ();
|
2010-08-29 21:24:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
add (selectables);
|
|
|
|
}
|
|
|
|
|
2012-04-22 10:03:07 -04:00
|
|
|
void
|
|
|
|
Selection::add (PointSelection const & s)
|
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2012-04-22 10:03:07 -04:00
|
|
|
for (PointSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
|
|
|
|
points.push_back (*i);
|
|
|
|
}
|
|
|
|
}
|
2006-08-14 15:19:06 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2010-01-04 21:22:58 -05:00
|
|
|
Selection::add (list<Selectable*> const & selectables)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2006-07-31 23:23:35 -04:00
|
|
|
RegionView* rv;
|
2010-08-10 21:23:03 -04:00
|
|
|
ControlPoint* cp;
|
2006-07-31 23:23:35 -04:00
|
|
|
vector<RegionView*> rvs;
|
2010-08-10 21:23:03 -04:00
|
|
|
vector<ControlPoint*> cps;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-01-04 21:22:58 -05:00
|
|
|
for (std::list<Selectable*>::const_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);
|
2010-08-10 21:23:03 -04:00
|
|
|
} else if ((cp = dynamic_cast<ControlPoint*> (*i)) != 0) {
|
|
|
|
cps.push_back (cp);
|
2005-09-25 14:42:24 -04:00
|
|
|
} 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;
|
2014-11-14 04:47:43 -05:00
|
|
|
abort(); /*NOTREACHED*/
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-31 23:23:35 -04:00
|
|
|
if (!rvs.empty()) {
|
|
|
|
add (rvs);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-08-10 21:23:03 -04:00
|
|
|
if (!cps.empty()) {
|
|
|
|
add (cps);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-29 16:05:03 -05:00
|
|
|
Selection::clear_points (bool with_signal)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!points.empty()) {
|
|
|
|
points.clear ();
|
2016-01-29 16:05:03 -05:00
|
|
|
if (with_signal) {
|
|
|
|
PointsChanged ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-10 21:23:03 -04:00
|
|
|
Selection::add (ControlPoint* cp)
|
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2010-08-10 21:23:03 -04:00
|
|
|
cp->set_selected (true);
|
2012-04-22 10:03:07 -04:00
|
|
|
points.push_back (cp);
|
|
|
|
PointsChanged (); /* EMIT SIGNAL */
|
2010-08-10 21:23:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (vector<ControlPoint*> const & cps)
|
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2010-08-10 21:23:03 -04:00
|
|
|
for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
|
2012-11-18 10:18:34 -05:00
|
|
|
(*i)->set_selected (true);
|
|
|
|
points.push_back (*i);
|
2010-08-10 21:23:03 -04:00
|
|
|
}
|
2012-11-18 10:18:34 -05:00
|
|
|
PointsChanged (); /* EMIT SIGNAL */
|
2010-08-10 21:23:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::set (ControlPoint* cp)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2016-06-05 19:49:51 -04:00
|
|
|
if (cp->selected () && points.size () == 1) {
|
2010-08-10 21:23:03 -04:00
|
|
|
return;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-05-19 16:10:35 -04:00
|
|
|
|
2010-08-20 18:46:15 -04:00
|
|
|
for (uint32_t i = 0; i < cp->line().npoints(); ++i) {
|
|
|
|
cp->line().nth (i)->set_selected (false);
|
|
|
|
}
|
|
|
|
|
2012-11-26 17:37:34 -05:00
|
|
|
clear_objects ();
|
2012-04-22 10:03:07 -04:00
|
|
|
add (cp);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-10-07 11:51:14 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
void
|
2015-07-23 07:23:47 -04:00
|
|
|
Selection::set (ArdourMarker* m)
|
2007-11-07 20:40:25 -05:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2013-01-02 18:54:06 -05:00
|
|
|
markers.clear ();
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
add (m);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-07-23 07:23:47 -04:00
|
|
|
Selection::toggle (ArdourMarker* m)
|
2007-11-07 20:40:25 -05:00
|
|
|
{
|
|
|
|
MarkerSelection::iterator i;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
if ((i = find (markers.begin(), markers.end(), m)) == markers.end()) {
|
|
|
|
add (m);
|
|
|
|
} else {
|
|
|
|
remove (m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-07-23 07:23:47 -04:00
|
|
|
Selection::remove (ArdourMarker* m)
|
2007-11-07 20:40:25 -05:00
|
|
|
{
|
|
|
|
MarkerSelection::iterator i;
|
|
|
|
|
|
|
|
if ((i = find (markers.begin(), markers.end(), m)) != markers.end()) {
|
|
|
|
markers.erase (i);
|
|
|
|
MarkersChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-07-23 07:23:47 -04:00
|
|
|
Selection::add (ArdourMarker* m)
|
2007-11-07 20:40:25 -05:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); //enforce region/object exclusivity
|
|
|
|
clear_tracks(); //enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
if (find (markers.begin(), markers.end(), m) == markers.end()) {
|
|
|
|
markers.push_back (m);
|
|
|
|
MarkersChanged();
|
|
|
|
}
|
|
|
|
}
|
2008-09-19 10:38:46 -04:00
|
|
|
|
|
|
|
void
|
2015-07-23 07:23:47 -04:00
|
|
|
Selection::add (const list<ArdourMarker*>& m)
|
2008-09-19 10:38:46 -04:00
|
|
|
{
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_time (); // enforce region/object exclusivity
|
|
|
|
clear_tracks(); // enforce object/track exclusivity
|
2012-11-26 17:37:34 -05:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
markers.insert (markers.end(), m.begin(), m.end());
|
2012-01-26 20:26:44 -05:00
|
|
|
markers.sort ();
|
|
|
|
markers.unique ();
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
MarkersChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
MarkerSelection::range (samplepos_t& s, samplepos_t& e)
|
2008-09-19 10:38:46 -04:00
|
|
|
{
|
2017-09-18 12:39:17 -04:00
|
|
|
s = max_samplepos;
|
2008-09-19 10:38:46 -04:00
|
|
|
e = 0;
|
|
|
|
|
|
|
|
for (MarkerSelection::iterator i = begin(); i != end(); ++i) {
|
|
|
|
|
|
|
|
if ((*i)->position() < s) {
|
|
|
|
s = (*i)->position();
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2008-09-19 10:38:46 -04:00
|
|
|
|
|
|
|
if ((*i)->position() > e) {
|
|
|
|
e = (*i)->position();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s = std::min (s, e);
|
|
|
|
e = std::max (s, e);
|
|
|
|
}
|
2010-08-10 21:23:03 -04:00
|
|
|
|
2010-08-17 22:20:15 -04:00
|
|
|
XMLNode&
|
|
|
|
Selection::get_state () const
|
|
|
|
{
|
|
|
|
/* XXX: not complete; just sufficient to get track selection state
|
|
|
|
so that re-opening plugin windows for editor mixer strips works
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-17 22:20:15 -04:00
|
|
|
XMLNode* node = new XMLNode (X_("Selection"));
|
|
|
|
|
|
|
|
for (TrackSelection::const_iterator i = tracks.begin(); i != tracks.end(); ++i) {
|
2017-08-06 16:16:36 -04:00
|
|
|
StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (*i);
|
2010-08-17 22:20:15 -04:00
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (*i);
|
2017-08-06 16:16:36 -04:00
|
|
|
if (stv) {
|
|
|
|
XMLNode* t = node->add_child (X_("StripableView"));
|
|
|
|
t->set_property (X_("id"), stv->stripable()->id ());
|
2010-08-17 22:20:15 -04:00
|
|
|
} else if (atv) {
|
|
|
|
XMLNode* t = node->add_child (X_("AutomationView"));
|
2017-06-08 17:45:07 -04:00
|
|
|
t->set_property (X_("id"), atv->parent_stripable()->id ());
|
2016-12-06 23:41:46 -05:00
|
|
|
t->set_property (X_("parameter"), EventTypeMap::instance().to_symbol (atv->parameter ()));
|
2010-08-17 22:20:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-21 09:51:12 -04:00
|
|
|
if (!regions.empty()) {
|
|
|
|
XMLNode* parent = node->add_child (X_("Regions"));
|
|
|
|
for (RegionSelection::const_iterator i = regions.begin(); i != regions.end(); ++i) {
|
|
|
|
XMLNode* r = parent->add_child (X_("Region"));
|
|
|
|
r->set_property (X_("id"), (*i)->region ()->id ());
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* midi region views have thir own internal selection. */
|
2017-09-24 12:03:54 -04:00
|
|
|
list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Temporal::Beats> > > > > rid_notes;
|
2015-01-10 12:07:31 -05:00
|
|
|
editor->get_per_region_note_selection (rid_notes);
|
2016-11-14 11:48:20 -05:00
|
|
|
|
2017-09-24 12:03:54 -04:00
|
|
|
list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Temporal::Beats> > > > >::iterator rn_it;
|
2015-01-10 12:07:31 -05:00
|
|
|
for (rn_it = rid_notes.begin(); rn_it != rid_notes.end(); ++rn_it) {
|
2016-11-14 17:16:31 -05:00
|
|
|
XMLNode* n = node->add_child (X_("MIDINotes"));
|
2016-12-06 23:41:46 -05:00
|
|
|
n->set_property (X_("region-id"), (*rn_it).first);
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2017-09-24 12:03:54 -04:00
|
|
|
for (std::set<boost::shared_ptr<Evoral::Note<Temporal::Beats> > >::iterator i = (*rn_it).second.begin(); i != (*rn_it).second.end(); ++i) {
|
2015-01-10 12:07:31 -05:00
|
|
|
XMLNode* nc = n->add_child(X_("note"));
|
2016-12-06 23:41:46 -05:00
|
|
|
nc->set_property(X_("note-id"), (*i)->id());
|
2015-01-10 12:07:31 -05:00
|
|
|
}
|
2014-12-14 08:13:38 -05:00
|
|
|
}
|
|
|
|
|
2014-12-23 12:29:43 -05:00
|
|
|
for (PointSelection::const_iterator i = points.begin(); i != points.end(); ++i) {
|
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (&(*i)->line().trackview);
|
|
|
|
if (atv) {
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2014-12-23 12:29:43 -05:00
|
|
|
XMLNode* r = node->add_child (X_("ControlPoint"));
|
2016-12-06 23:41:46 -05:00
|
|
|
r->set_property (X_("type"), "track");
|
2017-06-08 17:45:07 -04:00
|
|
|
r->set_property (X_("route-id"), atv->parent_stripable()->id ());
|
2016-12-06 23:41:46 -05:00
|
|
|
r->set_property (X_("automation-list-id"), (*i)->line().the_list()->id ());
|
|
|
|
r->set_property (X_("parameter"), EventTypeMap::instance().to_symbol ((*i)->line().the_list()->parameter ()));
|
|
|
|
r->set_property (X_("view-index"), (*i)->view_index());
|
2015-10-03 11:19:38 -04:00
|
|
|
continue;
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2015-10-03 11:19:38 -04:00
|
|
|
AudioRegionGainLine* argl = dynamic_cast<AudioRegionGainLine*> (&(*i)->line());
|
|
|
|
if (argl) {
|
|
|
|
XMLNode* r = node->add_child (X_("ControlPoint"));
|
2016-12-06 23:41:46 -05:00
|
|
|
r->set_property (X_("type"), "region");
|
|
|
|
r->set_property (X_("region-id"), argl->region_view ().region ()->id ());
|
|
|
|
r->set_property (X_("view-index"), (*i)->view_index());
|
2014-12-23 12:29:43 -05:00
|
|
|
}
|
2015-10-03 11:19:38 -04:00
|
|
|
|
2014-12-23 12:29:43 -05:00
|
|
|
}
|
|
|
|
|
2014-12-14 08:13:38 -05:00
|
|
|
for (TimeSelection::const_iterator i = time.begin(); i != time.end(); ++i) {
|
|
|
|
XMLNode* t = node->add_child (X_("AudioRange"));
|
2016-12-06 23:41:46 -05:00
|
|
|
t->set_property (X_("start"), (*i).start);
|
|
|
|
t->set_property (X_("end"), (*i).end);
|
2014-12-14 08:13:38 -05:00
|
|
|
}
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2011-10-19 20:05:31 -04:00
|
|
|
for (MarkerSelection::const_iterator i = markers.begin(); i != markers.end(); ++i) {
|
|
|
|
XMLNode* t = node->add_child (X_("Marker"));
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2011-10-19 20:05:31 -04:00
|
|
|
bool is_start;
|
|
|
|
Location* loc = editor->find_location_from_marker (*i, is_start);
|
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
t->set_property (X_("id"), loc->id());
|
|
|
|
t->set_property (X_("start"), is_start);
|
2011-10-19 20:05:31 -04:00
|
|
|
}
|
|
|
|
|
2010-08-17 22:20:15 -04:00
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Selection::set_state (XMLNode const & node, int)
|
|
|
|
{
|
|
|
|
if (node.name() != X_("Selection")) {
|
|
|
|
return -1;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-12-14 08:13:38 -05:00
|
|
|
clear_regions ();
|
2015-01-16 12:55:05 -05:00
|
|
|
clear_midi_notes ();
|
2014-12-23 12:29:43 -05:00
|
|
|
clear_points ();
|
2014-12-14 08:13:38 -05:00
|
|
|
clear_time ();
|
|
|
|
clear_markers ();
|
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
/* NOTE: stripable/time-axis-view selection is saved/restored by
|
|
|
|
* ARDOUR::CoreSelection, not this Selection object
|
|
|
|
*/
|
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
PBD::ID id;
|
2010-08-17 22:20:15 -04:00
|
|
|
XMLNodeList children = node.children ();
|
2016-12-06 23:41:46 -05:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
|
2017-06-21 09:51:12 -04:00
|
|
|
if ((*i)->name() == X_("Regions")) {
|
|
|
|
RegionSelection selected_regions;
|
|
|
|
XMLNodeList children = (*i)->children ();
|
|
|
|
for (XMLNodeList::const_iterator ci = children.begin(); ci != children.end(); ++ci) {
|
|
|
|
PBD::ID id;
|
2016-12-06 23:41:46 -05:00
|
|
|
|
2017-06-21 09:51:12 -04:00
|
|
|
if (!(*ci)->get_property (X_("id"), id)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegionSelection rs;
|
|
|
|
editor->get_regionviews_by_id (id, rs);
|
|
|
|
|
|
|
|
if (!rs.empty ()) {
|
|
|
|
for (RegionSelection::const_iterator i = rs.begin(); i != rs.end(); ++i) {
|
|
|
|
selected_regions.push_back (*i);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
regionviews haven't been constructed - stash the region IDs
|
|
|
|
so we can identify them in Editor::region_view_added ()
|
|
|
|
*/
|
|
|
|
regions.pending.push_back (id);
|
|
|
|
}
|
2016-12-06 23:41:46 -05:00
|
|
|
}
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2017-06-21 09:51:12 -04:00
|
|
|
if (!selected_regions.empty()) {
|
|
|
|
add (selected_regions);
|
2014-12-14 08:13:38 -05:00
|
|
|
}
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2016-11-14 11:48:20 -05:00
|
|
|
} else if ((*i)->name() == X_("MIDINotes")) {
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
if (!(*i)->get_property (X_("region-id"), id)) {
|
|
|
|
assert (false);
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
RegionSelection rs;
|
|
|
|
|
|
|
|
editor->get_regionviews_by_id (id, rs); // there could be more than one
|
|
|
|
|
2016-10-15 08:50:02 -04:00
|
|
|
std::list<Evoral::event_id_t> notes;
|
2015-01-10 12:07:31 -05:00
|
|
|
XMLNodeList children = (*i)->children ();
|
|
|
|
|
|
|
|
for (XMLNodeList::const_iterator ci = children.begin(); ci != children.end(); ++ci) {
|
2016-12-06 23:41:46 -05:00
|
|
|
Evoral::event_id_t id;
|
|
|
|
if ((*ci)->get_property (X_ ("note-id"), id)) {
|
2016-11-13 22:12:58 -05:00
|
|
|
notes.push_back (id);
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
}
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2015-01-10 12:07:31 -05:00
|
|
|
for (RegionSelection::iterator rsi = rs.begin(); rsi != rs.end(); ++rsi) {
|
|
|
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (*rsi);
|
|
|
|
if (mrv) {
|
|
|
|
mrv->select_notes(notes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rs.empty()) {
|
|
|
|
/* regionviews containing these notes don't yet exist on the canvas.*/
|
|
|
|
pending_midi_note_selection.push_back (make_pair (id, notes));
|
|
|
|
}
|
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
} else if ((*i)->name() == X_("ControlPoint")) {
|
2016-05-04 23:09:37 -04:00
|
|
|
XMLProperty const * prop_type = (*i)->property (X_("type"));
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2015-01-10 12:07:31 -05:00
|
|
|
assert(prop_type);
|
2014-12-23 12:29:43 -05:00
|
|
|
|
|
|
|
if (prop_type->value () == "track") {
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
PBD::ID route_id;
|
|
|
|
PBD::ID alist_id;
|
|
|
|
std::string param;
|
|
|
|
uint32_t view_index;
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
if (!(*i)->get_property (X_("route-id"), route_id) ||
|
|
|
|
!(*i)->get_property (X_("automation-list-id"), alist_id) ||
|
|
|
|
!(*i)->get_property (X_("parameter"), param) ||
|
|
|
|
!(*i)->get_property (X_("view-index"), view_index)) {
|
|
|
|
assert(false);
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2017-08-06 16:16:36 -04:00
|
|
|
StripableTimeAxisView* stv = editor->get_stripable_time_axis_by_id (route_id);
|
2015-01-10 12:07:31 -05:00
|
|
|
vector <ControlPoint *> cps;
|
2014-12-23 12:29:43 -05:00
|
|
|
|
2017-08-06 16:16:36 -04:00
|
|
|
if (stv) {
|
|
|
|
boost::shared_ptr<AutomationTimeAxisView> atv = stv->automation_child (EventTypeMap::instance().from_symbol (param));
|
2014-12-23 12:29:43 -05:00
|
|
|
if (atv) {
|
|
|
|
list<boost::shared_ptr<AutomationLine> > lines = atv->lines();
|
2015-01-10 12:07:31 -05:00
|
|
|
for (list<boost::shared_ptr<AutomationLine> > ::iterator li = lines.begin(); li != lines.end(); ++li) {
|
2016-12-06 23:41:46 -05:00
|
|
|
if ((*li)->the_list()->id() == alist_id) {
|
|
|
|
ControlPoint* cp = (*li)->nth(view_index);
|
2014-12-23 12:29:43 -05:00
|
|
|
if (cp) {
|
2015-01-10 12:07:31 -05:00
|
|
|
cps.push_back (cp);
|
|
|
|
cp->show();
|
2014-12-23 12:29:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
if (!cps.empty()) {
|
|
|
|
add (cps);
|
|
|
|
}
|
2015-10-03 11:19:38 -04:00
|
|
|
} else if (prop_type->value () == "region") {
|
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
PBD::ID region_id;
|
|
|
|
uint32_t view_index;
|
|
|
|
if (!(*i)->get_property (X_("region-id"), region_id) ||
|
|
|
|
!(*i)->get_property (X_("view-index"), view_index)) {
|
2015-10-03 12:44:27 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-10-03 11:19:38 -04:00
|
|
|
RegionSelection rs;
|
|
|
|
editor->get_regionviews_by_id (region_id, rs);
|
|
|
|
|
|
|
|
if (!rs.empty ()) {
|
|
|
|
vector <ControlPoint *> cps;
|
|
|
|
for (RegionSelection::iterator rsi = rs.begin(); rsi != rs.end(); ++rsi) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (*rsi);
|
|
|
|
if (arv) {
|
|
|
|
boost::shared_ptr<AudioRegionGainLine> gl = arv->get_gain_line ();
|
2016-12-06 23:41:46 -05:00
|
|
|
ControlPoint* cp = gl->nth(view_index);
|
2015-10-03 11:19:38 -04:00
|
|
|
if (cp) {
|
|
|
|
cps.push_back (cp);
|
|
|
|
cp->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!cps.empty()) {
|
|
|
|
add (cps);
|
|
|
|
}
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
}
|
2014-12-23 12:29:43 -05:00
|
|
|
|
2018-02-24 07:54:15 -05:00
|
|
|
} else if ((*i)->name() == X_("AudioRange")) {
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t start;
|
|
|
|
samplepos_t end;
|
2014-12-14 08:13:38 -05:00
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
if (!(*i)->get_property (X_("start"), start) || !(*i)->get_property (X_("end"), end)) {
|
|
|
|
assert(false);
|
|
|
|
}
|
2017-06-16 15:28:02 -04:00
|
|
|
|
|
|
|
add (start, end);
|
2014-12-14 08:13:38 -05:00
|
|
|
|
2010-08-17 22:20:15 -04:00
|
|
|
} else if ((*i)->name() == X_("AutomationView")) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
std::string param;
|
2010-08-17 22:20:15 -04:00
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
if (!(*i)->get_property (X_("id"), id) || !(*i)->get_property (X_("parameter"), param)) {
|
|
|
|
assert (false);
|
|
|
|
}
|
2010-08-17 22:20:15 -04:00
|
|
|
|
2017-08-06 16:16:36 -04:00
|
|
|
StripableTimeAxisView* stv = editor->get_stripable_time_axis_by_id (id);
|
2010-09-13 20:34:49 -04:00
|
|
|
|
2017-08-06 16:16:36 -04:00
|
|
|
if (stv) {
|
|
|
|
boost::shared_ptr<AutomationTimeAxisView> atv = stv->automation_child (EventTypeMap::instance().from_symbol (param));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-13 20:34:49 -04:00
|
|
|
/* the automation could be for an entity that was never saved
|
|
|
|
in the session file. Don't freak out if we can't find
|
|
|
|
it.
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-13 20:34:49 -04:00
|
|
|
if (atv) {
|
|
|
|
add (atv.get());
|
|
|
|
}
|
|
|
|
}
|
2011-10-19 20:05:31 -04:00
|
|
|
|
|
|
|
} else if ((*i)->name() == X_("Marker")) {
|
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
bool is_start;
|
|
|
|
if (!(*i)->get_property (X_("id"), id) || !(*i)->get_property (X_("start"), is_start)) {
|
|
|
|
assert(false);
|
|
|
|
}
|
2011-10-19 20:05:31 -04:00
|
|
|
|
2016-12-06 23:41:46 -05:00
|
|
|
ArdourMarker* m = editor->find_marker_from_location_id (id, is_start);
|
2011-10-19 20:05:31 -04:00
|
|
|
if (m) {
|
|
|
|
add (m);
|
|
|
|
}
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2010-08-17 22:20:15 -04:00
|
|
|
}
|
2015-01-10 20:55:48 -05:00
|
|
|
|
2010-08-17 22:20:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-01-03 20:03:36 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove_regions (TimeAxisView* t)
|
|
|
|
{
|
|
|
|
RegionSelection::iterator i = regions.begin();
|
|
|
|
while (i != regions.end ()) {
|
|
|
|
RegionSelection::iterator tmp = i;
|
|
|
|
++tmp;
|
|
|
|
|
|
|
|
if (&(*i)->get_time_axis_view() == t) {
|
|
|
|
remove (*i);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = tmp;
|
|
|
|
}
|
|
|
|
}
|
2017-05-05 07:31:49 -04:00
|
|
|
|
|
|
|
/* TIME AXIS VIEW ... proxy for Stripable/Controllable
|
|
|
|
*
|
|
|
|
* public methods just modify the CoreSelection; PresentationInfo::Changed will
|
|
|
|
* trigger Selection::core_selection_changed() and we will update our own data
|
|
|
|
* structures there.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::toggle (const TrackViewList& track_list)
|
|
|
|
{
|
|
|
|
TrackViewList t = add_grouped_tracks (track_list);
|
|
|
|
|
|
|
|
CoreSelection& selection (editor->session()->selection());
|
|
|
|
PresentationInfo::ChangeSuspender cs;
|
|
|
|
|
|
|
|
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
|
|
|
|
boost::shared_ptr<Stripable> s = (*i)->stripable ();
|
|
|
|
boost::shared_ptr<AutomationControl> c = (*i)->control ();
|
|
|
|
selection.toggle (s, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::toggle (TimeAxisView* track)
|
|
|
|
{
|
|
|
|
TrackViewList tr;
|
|
|
|
tr.push_back (track);
|
|
|
|
toggle (tr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (TrackViewList const & track_list)
|
|
|
|
{
|
|
|
|
TrackViewList t = add_grouped_tracks (track_list);
|
|
|
|
|
|
|
|
CoreSelection& selection (editor->session()->selection());
|
|
|
|
PresentationInfo::ChangeSuspender cs;
|
|
|
|
|
|
|
|
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
|
|
|
|
boost::shared_ptr<Stripable> s = (*i)->stripable ();
|
|
|
|
boost::shared_ptr<AutomationControl> c = (*i)->control ();
|
|
|
|
selection.add (s, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::add (TimeAxisView* track)
|
|
|
|
{
|
|
|
|
TrackViewList tr;
|
|
|
|
tr.push_back (track);
|
|
|
|
add (tr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove (TimeAxisView* track)
|
|
|
|
{
|
|
|
|
TrackViewList tvl;
|
|
|
|
tvl.push_back (track);
|
|
|
|
remove (tvl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::remove (const TrackViewList& t)
|
|
|
|
{
|
|
|
|
CoreSelection& selection (editor->session()->selection());
|
|
|
|
PresentationInfo::ChangeSuspender cs;
|
|
|
|
|
|
|
|
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
|
|
|
|
boost::shared_ptr<Stripable> s = (*i)->stripable ();
|
|
|
|
boost::shared_ptr<AutomationControl> c = (*i)->control ();
|
|
|
|
selection.remove (s, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::set (TimeAxisView* track)
|
|
|
|
{
|
|
|
|
TrackViewList tvl;
|
|
|
|
tvl.push_back (track);
|
|
|
|
set (tvl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::set (const TrackViewList& track_list)
|
|
|
|
{
|
|
|
|
TrackViewList t = add_grouped_tracks (track_list);
|
|
|
|
|
|
|
|
CoreSelection& selection (editor->session()->selection());
|
2017-06-17 09:51:40 -04:00
|
|
|
|
|
|
|
#if 1 // crazy optmization hack
|
|
|
|
/* check is the selection actually changed, ignore NO-OPs
|
|
|
|
*
|
|
|
|
* There are excessive calls from EditorRoutes::selection_changed():
|
|
|
|
* Every click calls selection_changed() even if it doesn't change.
|
|
|
|
* Also re-ordering tracks calls into this due to gtk's odd DnD signal
|
|
|
|
* messaging (row removed, re-added).
|
|
|
|
*
|
|
|
|
* Re-ordering a row results in at least 2 calls to selection_changed()
|
|
|
|
* without actual change. Calling selection.clear_stripables()
|
|
|
|
* and re-adding the same tracks every time in turn emits changed signals.
|
|
|
|
*/
|
|
|
|
bool changed = false;
|
|
|
|
CoreSelection::StripableAutomationControls sac;
|
|
|
|
selection.get_stripables (sac);
|
|
|
|
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
|
|
|
|
boost::shared_ptr<Stripable> s = (*i)->stripable ();
|
|
|
|
boost::shared_ptr<AutomationControl> c = (*i)->control ();
|
|
|
|
bool found = false;
|
|
|
|
for (CoreSelection::StripableAutomationControls::iterator j = sac.begin (); j != sac.end (); ++j) {
|
|
|
|
if (j->stripable == s && j->controllable == c) {
|
|
|
|
found = true;
|
|
|
|
sac.erase (j);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
changed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!changed && sac.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
PresentationInfo::ChangeSuspender cs;
|
|
|
|
|
|
|
|
selection.clear_stripables ();
|
|
|
|
|
|
|
|
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
|
|
|
|
boost::shared_ptr<Stripable> s = (*i)->stripable ();
|
|
|
|
boost::shared_ptr<AutomationControl> c = (*i)->control ();
|
|
|
|
selection.add (s, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::clear_tracks (bool)
|
|
|
|
{
|
2017-06-07 12:14:44 -04:00
|
|
|
if (!manage_libardour_selection) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
Session* s = editor->session();
|
|
|
|
if (s) {
|
|
|
|
CoreSelection& selection (s->selection());
|
|
|
|
selection.clear_stripables ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Selection::selected (TimeAxisView* tv) const
|
|
|
|
{
|
|
|
|
Session* session = editor->session();
|
|
|
|
|
|
|
|
if (!session) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreSelection& selection (session->selection());
|
|
|
|
boost::shared_ptr<Stripable> s = tv->stripable ();
|
|
|
|
boost::shared_ptr<AutomationControl> c = tv->control ();
|
|
|
|
|
|
|
|
if (c) {
|
|
|
|
return selection.selected (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
return selection.selected (s);
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackViewList
|
|
|
|
Selection::add_grouped_tracks (TrackViewList const & t)
|
|
|
|
{
|
|
|
|
TrackViewList added;
|
|
|
|
|
|
|
|
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
|
|
|
|
if (dynamic_cast<VCATimeAxisView*> (*i)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* select anything in the same select-enabled route group */
|
|
|
|
ARDOUR::RouteGroup* rg = (*i)->route_group ();
|
|
|
|
|
|
|
|
if (rg && rg->is_active() && rg->is_select ()) {
|
|
|
|
|
|
|
|
TrackViewList tr = editor->axis_views_from_routes (rg->route_list ());
|
|
|
|
|
|
|
|
for (TrackViewList::iterator j = tr.begin(); j != tr.end(); ++j) {
|
|
|
|
|
|
|
|
/* Do not add the trackview passed in as an
|
|
|
|
* argument, because we want that to be on the
|
|
|
|
* end of the list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (*j != *i) {
|
|
|
|
if (!added.contains (*j)) {
|
|
|
|
added.push_back (*j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now add the the trackview's passed in as actual arguments */
|
|
|
|
added.insert (added.end(), t.begin(), t.end());
|
|
|
|
|
|
|
|
return added;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void dump_tracks (Selection const & s)
|
|
|
|
{
|
|
|
|
cerr << "--TRACKS [" << s.tracks.size() << ']' << ":\n";
|
|
|
|
for (TrackViewList::const_iterator x = s.tracks.begin(); x != s.tracks.end(); ++x) {
|
|
|
|
cerr << (*x)->name() << ' ' << (*x)->stripable() << " C = " << (*x)->control() << endl;
|
|
|
|
}
|
|
|
|
cerr << "///\n";
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
Selection::core_selection_changed (PropertyChange const & what_changed)
|
|
|
|
{
|
|
|
|
PropertyChange pc;
|
|
|
|
|
|
|
|
pc.add (Properties::selected);
|
|
|
|
|
|
|
|
if (!what_changed.contains (pc)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoreSelection& selection (editor->session()->selection());
|
|
|
|
|
|
|
|
if (selection.selected()) {
|
2018-02-24 07:54:15 -05:00
|
|
|
clear_objects(); // enforce object/range exclusivity
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
tracks.clear (); // clear stage for whatever tracks are now selected (maybe none)
|
|
|
|
|
2017-05-05 11:34:32 -04:00
|
|
|
CoreSelection::StripableAutomationControls sac;
|
|
|
|
selection.get_stripables (sac);
|
|
|
|
|
|
|
|
for (CoreSelection::StripableAutomationControls::const_iterator i = sac.begin(); i != sac.end(); ++i) {
|
|
|
|
AxisView* av;
|
|
|
|
TimeAxisView* tav;
|
|
|
|
if ((*i).controllable) {
|
|
|
|
av = editor->axis_view_by_control ((*i).controllable);
|
|
|
|
} else {
|
|
|
|
av = editor->axis_view_by_stripable ((*i).stripable);
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|
|
|
|
|
2017-05-05 11:34:32 -04:00
|
|
|
tav = dynamic_cast<TimeAxisView*>(av);
|
|
|
|
if (tav) {
|
2017-05-05 07:31:49 -04:00
|
|
|
tracks.push_back (tav);
|
|
|
|
}
|
|
|
|
}
|
2018-02-24 07:54:15 -05:00
|
|
|
|
2018-02-11 10:39:45 -05:00
|
|
|
TracksChanged();
|
2017-05-05 07:31:49 -04:00
|
|
|
}
|