2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <sigc++/bind.h>
23 #include "pbd/error.h"
24 #include "pbd/stacktrace.h"
26 #include "ardour/playlist.h"
27 #include "ardour/rc_configuration.h"
29 #include "gui_thread.h"
30 #include "midi_cut_buffer.h"
31 #include "region_view.h"
32 #include "selection.h"
33 #include "selection_templates.h"
34 #include "time_axis_view.h"
35 #include "automation_time_axis.h"
36 #include "public_editor.h"
37 #include "control_point.h"
42 using namespace ARDOUR;
45 PBD::Signal0<void> Selection::ClearMidiNoteSelection;
47 struct AudioRangeComparator {
48 bool operator()(AudioRange a, AudioRange b) {
49 return a.start < b.start;
53 Selection::Selection (const PublicEditor* e)
57 , _no_tracks_changed (false)
61 /* we have disambiguate which remove() for the compiler */
63 void (Selection::*track_remove)(TimeAxisView*) = &Selection::remove;
64 TimeAxisView::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (track_remove, this, _1), gui_context());
66 void (Selection::*marker_remove)(Marker*) = &Selection::remove;
67 Marker::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (marker_remove, this, _1), gui_context());
69 void (Selection::*point_remove)(ControlPoint*) = &Selection::remove;
70 ControlPoint::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (point_remove, this, _1), gui_context());
75 Selection::operator= (const Selection& other)
78 regions = other.regions;
79 tracks = other.tracks;
82 midi_regions = other.midi_regions;
83 midi_notes = other.midi_notes;
90 operator== (const Selection& a, const Selection& b)
92 return a.regions == b.regions &&
93 a.tracks == b.tracks &&
96 a.playlists == b.playlists &&
97 a.midi_notes == b.midi_notes &&
98 a.midi_regions == b.midi_regions;
101 /** Clear everything from the Selection */
112 clear_midi_regions ();
117 Selection::clear_objects ()
124 clear_midi_regions ();
128 Selection::clear_tracks ()
130 if (!tracks.empty()) {
131 for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) {
132 (*x)->set_selected (false);
135 if (!_no_tracks_changed) {
142 Selection::clear_time ()
150 Selection::dump_region_layers()
152 cerr << "region selection layer dump" << endl;
153 for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
154 cerr << "layer: " << (int)(*i)->region()->layer() << endl;
160 Selection::clear_regions ()
162 if (!regions.empty()) {
163 regions.clear_all ();
169 Selection::clear_midi_notes ()
171 if (!midi_notes.empty()) {
172 for (MidiNoteSelection::iterator x = midi_notes.begin(); x != midi_notes.end(); ++x) {
179 /* The note selection is actually stored in MidiRegionView, emit signal to
180 tell them to clear their selection. */
181 ClearMidiNoteSelection(); /* EMIT SIGNAL */
185 Selection::clear_midi_regions ()
187 if (!midi_regions.empty()) {
188 midi_regions.clear ();
189 MidiRegionsChanged ();
194 Selection::clear_playlists ()
196 /* Selections own their playlists */
198 for (PlaylistSelection::iterator i = playlists.begin(); i != playlists.end(); ++i) {
199 /* selections own their own regions, which are copies of the "originals". make them go away */
200 (*i)->drop_regions ();
204 if (!playlists.empty()) {
211 Selection::clear_lines ()
213 if (!lines.empty()) {
220 Selection::clear_markers ()
222 if (!markers.empty()) {
229 Selection::toggle (boost::shared_ptr<Playlist> pl)
231 clear_time(); //enforce object/range exclusivity
232 clear_tracks(); //enforce object/track exclusivity
234 PlaylistSelection::iterator i;
236 if ((i = find (playlists.begin(), playlists.end(), pl)) == playlists.end()) {
238 playlists.push_back(pl);
247 Selection::toggle (const TrackViewList& track_list)
249 for (TrackViewList::const_iterator i = track_list.begin(); i != track_list.end(); ++i) {
255 Selection::toggle (TimeAxisView* track)
257 TrackSelection::iterator i;
259 if ((i = find (tracks.begin(), tracks.end(), track)) == tracks.end()) {
260 track->set_selected (true);
261 tracks.push_back (track);
263 track->set_selected (false);
267 if (!_no_tracks_changed) {
273 Selection::toggle (const MidiNoteSelection& midi_note_list)
275 clear_time(); //enforce object/range exclusivity
276 clear_tracks(); //enforce object/track exclusivity
278 for (MidiNoteSelection::const_iterator i = midi_note_list.begin(); i != midi_note_list.end(); ++i) {
284 Selection::toggle (MidiCutBuffer* midi)
286 MidiNoteSelection::iterator i;
288 if ((i = find (midi_notes.begin(), midi_notes.end(), midi)) == midi_notes.end()) {
289 midi_notes.push_back (midi);
291 /* remember that we own the MCB */
293 midi_notes.erase (i);
301 Selection::toggle (RegionView* r)
303 clear_time(); //enforce object/range exclusivity
304 clear_tracks(); //enforce object/track exclusivity
306 RegionSelection::iterator i;
308 if ((i = find (regions.begin(), regions.end(), r)) == regions.end()) {
318 Selection::toggle (MidiRegionView* mrv)
320 clear_time(); //enforce object/range exclusivity
321 clear_tracks(); //enforce object/track exclusivity
323 MidiRegionSelection::iterator i;
325 if ((i = find (midi_regions.begin(), midi_regions.end(), mrv)) == midi_regions.end()) {
328 midi_regions.erase (i);
331 MidiRegionsChanged ();
335 Selection::toggle (vector<RegionView*>& r)
337 clear_time(); //enforce object/range exclusivity
338 clear_tracks(); //enforce object/track exclusivity
340 RegionSelection::iterator i;
342 for (vector<RegionView*>::iterator x = r.begin(); x != r.end(); ++x) {
343 if ((i = find (regions.begin(), regions.end(), (*x))) == regions.end()) {
354 Selection::toggle (framepos_t start, framepos_t end)
356 clear_objects(); //enforce object/range exclusivity
358 AudioRangeComparator cmp;
360 /* XXX this implementation is incorrect */
362 time.push_back (AudioRange (start, end, ++next_time_id));
372 Selection::add (boost::shared_ptr<Playlist> pl)
374 clear_time(); //enforce object/range exclusivity
375 clear_tracks(); //enforce object/track exclusivity
377 if (find (playlists.begin(), playlists.end(), pl) == playlists.end()) {
379 playlists.push_back(pl);
385 Selection::add (const list<boost::shared_ptr<Playlist> >& pllist)
387 clear_time(); //enforce object/range exclusivity
388 clear_tracks(); //enforce object/track exclusivity
390 bool changed = false;
392 for (list<boost::shared_ptr<Playlist> >::const_iterator i = pllist.begin(); i != pllist.end(); ++i) {
393 if (find (playlists.begin(), playlists.end(), (*i)) == playlists.end()) {
395 playlists.push_back (*i);
406 Selection::add (const TrackViewList& track_list)
408 clear_objects(); //enforce object/range exclusivity
410 TrackViewList added = tracks.add (track_list);
412 if (!added.empty()) {
413 for (TrackViewList::iterator x = added.begin(); x != added.end(); ++x) {
414 (*x)->set_selected (true);
416 if (!_no_tracks_changed) {
423 Selection::add (TimeAxisView* track)
425 clear_objects(); //enforce object/range exclusivity
428 track->set_selected (true);
429 tr.push_back (track);
434 Selection::add (const MidiNoteSelection& midi_list)
436 clear_time(); //enforce object/range exclusivity
437 clear_tracks(); //enforce object/track exclusivity
439 const MidiNoteSelection::const_iterator b = midi_list.begin();
440 const MidiNoteSelection::const_iterator e = midi_list.end();
442 if (!midi_list.empty()) {
443 midi_notes.insert (midi_notes.end(), b, e);
449 Selection::add (MidiCutBuffer* midi)
451 /* we take ownership of the MCB */
453 if (find (midi_notes.begin(), midi_notes.end(), midi) == midi_notes.end()) {
454 midi_notes.push_back (midi);
460 Selection::add (vector<RegionView*>& v)
462 clear_time(); //enforce object/range exclusivity
463 clear_tracks(); //enforce object/track exclusivity
465 /* XXX This method or the add (const RegionSelection&) needs to go
468 bool changed = false;
470 for (vector<RegionView*>::iterator i = v.begin(); i != v.end(); ++i) {
471 if (find (regions.begin(), regions.end(), (*i)) == regions.end()) {
472 changed = regions.add ((*i));
482 Selection::add (const RegionSelection& rs)
484 clear_time(); //enforce object/range exclusivity
485 clear_tracks(); //enforce object/track exclusivity
487 /* XXX This method or the add (const vector<RegionView*>&) needs to go
490 bool changed = false;
492 for (RegionSelection::const_iterator i = rs.begin(); i != rs.end(); ++i) {
493 if (find (regions.begin(), regions.end(), (*i)) == regions.end()) {
494 changed = regions.add ((*i));
504 Selection::add (RegionView* r)
506 clear_time(); //enforce object/range exclusivity
507 clear_tracks(); //enforce object/track exclusivity
509 if (find (regions.begin(), regions.end(), r) == regions.end()) {
510 bool changed = regions.add (r);
518 Selection::add (MidiRegionView* mrv)
520 clear_time(); //enforce object/range exclusivity
521 clear_tracks(); //enforce object/track exclusivity
523 if (find (midi_regions.begin(), midi_regions.end(), mrv) == midi_regions.end()) {
524 midi_regions.push_back (mrv);
525 /* XXX should we do this? */
526 MidiRegionsChanged ();
531 Selection::add (framepos_t start, framepos_t end)
533 clear_objects(); //enforce object/range exclusivity
535 AudioRangeComparator cmp;
537 /* XXX this implementation is incorrect */
539 time.push_back (AudioRange (start, end, ++next_time_id));
549 Selection::move_time (framecnt_t distance)
555 for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
556 (*i).start += distance;
557 (*i).end += distance;
564 Selection::replace (uint32_t sid, framepos_t start, framepos_t end)
566 clear_objects(); //enforce object/range exclusivity
568 for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
569 if ((*i).id == sid) {
571 time.push_back (AudioRange(start,end, sid));
573 /* don't consolidate here */
576 AudioRangeComparator cmp;
586 Selection::add (boost::shared_ptr<Evoral::ControlList> cl)
588 clear_time(); //enforce object/range exclusivity
589 clear_tracks(); //enforce object/track exclusivity
591 boost::shared_ptr<ARDOUR::AutomationList> al
592 = boost::dynamic_pointer_cast<ARDOUR::AutomationList>(cl);
594 warning << "Programming error: Selected list is not an ARDOUR::AutomationList" << endmsg;
597 if (find (lines.begin(), lines.end(), al) == lines.end()) {
598 lines.push_back (al);
604 Selection::remove (TimeAxisView* track)
606 list<TimeAxisView*>::iterator i;
607 if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) {
608 track->set_selected (false);
610 if (!_no_tracks_changed) {
617 Selection::remove (const TrackViewList& track_list)
619 bool changed = false;
621 for (TrackViewList::const_iterator i = track_list.begin(); i != track_list.end(); ++i) {
623 TrackViewList::iterator x = find (tracks.begin(), tracks.end(), *i);
624 if (x != tracks.end()) {
625 (*i)->set_selected (false);
632 if (!_no_tracks_changed) {
639 Selection::remove (ControlPoint* p)
641 PointSelection::iterator i = find (points.begin(), points.end(), p);
642 if (i != points.end ()) {
648 Selection::remove (const MidiNoteSelection& midi_list)
650 bool changed = false;
652 for (MidiNoteSelection::const_iterator i = midi_list.begin(); i != midi_list.end(); ++i) {
654 MidiNoteSelection::iterator x;
656 if ((x = find (midi_notes.begin(), midi_notes.end(), (*i))) != midi_notes.end()) {
657 midi_notes.erase (x);
668 Selection::remove (MidiCutBuffer* midi)
670 MidiNoteSelection::iterator x;
672 if ((x = find (midi_notes.begin(), midi_notes.end(), midi)) != midi_notes.end()) {
673 /* remember that we own the MCB */
675 midi_notes.erase (x);
681 Selection::remove (boost::shared_ptr<Playlist> track)
683 list<boost::shared_ptr<Playlist> >::iterator i;
684 if ((i = find (playlists.begin(), playlists.end(), track)) != playlists.end()) {
691 Selection::remove (const list<boost::shared_ptr<Playlist> >& pllist)
693 bool changed = false;
695 for (list<boost::shared_ptr<Playlist> >::const_iterator i = pllist.begin(); i != pllist.end(); ++i) {
697 list<boost::shared_ptr<Playlist> >::iterator x;
699 if ((x = find (playlists.begin(), playlists.end(), (*i))) != playlists.end()) {
711 Selection::remove (RegionView* r)
713 if (regions.remove (r)) {
719 Selection::remove (MidiRegionView* mrv)
721 MidiRegionSelection::iterator x;
723 if ((x = find (midi_regions.begin(), midi_regions.end(), mrv)) != midi_regions.end()) {
724 midi_regions.erase (x);
725 MidiRegionsChanged ();
731 Selection::remove (uint32_t selection_id)
737 for (list<AudioRange>::iterator i = time.begin(); i != time.end(); ++i) {
738 if ((*i).id == selection_id) {
748 Selection::remove (framepos_t /*start*/, framepos_t /*end*/)
753 Selection::remove (boost::shared_ptr<ARDOUR::AutomationList> ac)
755 AutomationSelection::iterator i;
756 if ((i = find (lines.begin(), lines.end(), ac)) != lines.end()) {
763 Selection::set (TimeAxisView* track)
765 clear_objects(); //enforce object/range exclusivity
771 Selection::set (const TrackViewList& track_list)
773 clear_objects(); //enforce object/range exclusivity
779 Selection::set (const MidiNoteSelection& midi_list)
781 clear_time (); //enforce region/object exclusivity
782 clear_tracks(); //enforce object/track exclusivity
788 Selection::set (boost::shared_ptr<Playlist> playlist)
790 clear_time (); //enforce region/object exclusivity
791 clear_tracks(); //enforce object/track exclusivity
797 Selection::set (const list<boost::shared_ptr<Playlist> >& pllist)
799 clear_time(); //enforce region/object exclusivity
805 Selection::set (const RegionSelection& rs)
807 clear_time(); //enforce region/object exclusivity
808 clear_tracks(); //enforce object/track exclusivity
811 RegionsChanged(); /* EMIT SIGNAL */
815 Selection::set (MidiRegionView* mrv)
817 clear_time(); //enforce region/object exclusivity
818 clear_tracks(); //enforce object/track exclusivity
824 Selection::set (RegionView* r, bool /*also_clear_tracks*/)
826 clear_time(); //enforce region/object exclusivity
827 clear_tracks(); //enforce object/track exclusivity
833 Selection::set (vector<RegionView*>& v)
835 clear_time(); //enforce region/object exclusivity
836 clear_tracks(); //enforce object/track exclusivity
842 /** Set the start and end time of the time selection, without changing
843 * the list of tracks it applies to.
846 Selection::set (framepos_t start, framepos_t end)
848 clear_objects(); //enforce region/object exclusivity
851 if ((start == 0 && end == 0) || end < start) {
856 time.push_back (AudioRange (start, end, ++next_time_id));
858 /* reuse the first entry, and remove all the rest */
860 while (time.size() > 1) {
863 time.front().start = start;
864 time.front().end = end;
871 return time.front().id;
874 /** Set the start and end of the range selection. If more than one range
875 * is currently selected, the start of the earliest range and the end of the
876 * latest range are set. If no range is currently selected, this method
877 * selects a single range from start to end.
879 * @param start New start time.
880 * @param end New end time.
883 Selection::set_preserving_all_ranges (framepos_t start, framepos_t end)
885 clear_objects(); //enforce region/object exclusivity
887 if ((start == 0 && end == 0) || (end < start)) {
892 time.push_back (AudioRange (start, end, ++next_time_id));
894 time.sort (AudioRangeComparator ());
895 time.front().start = start;
896 time.back().end = end;
905 Selection::set (boost::shared_ptr<Evoral::ControlList> ac)
907 clear_time(); //enforce region/object exclusivity
908 clear_tracks(); //enforce object/track exclusivity
915 Selection::selected (Marker* m)
917 return find (markers.begin(), markers.end(), m) != markers.end();
921 Selection::selected (TimeAxisView* tv)
923 return tv->get_selected ();
927 Selection::selected (RegionView* rv)
929 return find (regions.begin(), regions.end(), rv) != regions.end();
933 Selection::selected (ControlPoint* cp)
935 return find (points.begin(), points.end(), cp) != points.end();
939 Selection::empty (bool internal_selection)
941 bool object_level_empty = regions.empty () &&
944 playlists.empty () &&
947 playlists.empty () &&
952 if (!internal_selection) {
953 return object_level_empty;
956 /* this is intended to really only apply when using a Selection
960 return object_level_empty && midi_notes.empty() && points.empty();
964 Selection::toggle (ControlPoint* cp)
966 clear_time(); //enforce region/object exclusivity
967 clear_tracks(); //enforce object/track exclusivity
969 cp->set_selected (!cp->get_selected ());
970 PointSelection::iterator i = find (points.begin(), points.end(), cp);
971 if (i == points.end()) {
972 points.push_back (cp);
977 PointsChanged (); /* EMIT SIGNAL */
981 Selection::toggle (vector<ControlPoint*> const & cps)
983 clear_time(); //enforce region/object exclusivity
984 clear_tracks(); //enforce object/track exclusivity
986 for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
992 Selection::toggle (list<Selectable*> const & selectables)
994 clear_time(); //enforce region/object exclusivity
995 clear_tracks(); //enforce object/track exclusivity
999 vector<RegionView*> rvs;
1000 vector<ControlPoint*> cps;
1002 for (std::list<Selectable*>::const_iterator i = selectables.begin(); i != selectables.end(); ++i) {
1003 if ((rv = dynamic_cast<RegionView*> (*i)) != 0) {
1005 } else if ((cp = dynamic_cast<ControlPoint*> (*i)) != 0) {
1008 fatal << _("programming error: ")
1009 << X_("unknown selectable type passed to Selection::toggle()")
1011 abort(); /*NOTREACHED*/
1025 Selection::set (list<Selectable*> const & selectables)
1027 clear_time (); //enforce region/object exclusivity
1028 clear_tracks(); //enforce object/track exclusivity
1035 Selection::add (PointSelection const & s)
1037 clear_time (); //enforce region/object exclusivity
1038 clear_tracks(); //enforce object/track exclusivity
1040 for (PointSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
1041 points.push_back (*i);
1046 Selection::add (list<Selectable*> const & selectables)
1048 clear_time (); //enforce region/object exclusivity
1049 clear_tracks(); //enforce object/track exclusivity
1053 vector<RegionView*> rvs;
1054 vector<ControlPoint*> cps;
1056 for (std::list<Selectable*>::const_iterator i = selectables.begin(); i != selectables.end(); ++i) {
1057 if ((rv = dynamic_cast<RegionView*> (*i)) != 0) {
1059 } else if ((cp = dynamic_cast<ControlPoint*> (*i)) != 0) {
1062 fatal << _("programming error: ")
1063 << X_("unknown selectable type passed to Selection::add()")
1065 abort(); /*NOTREACHED*/
1079 Selection::clear_points ()
1081 if (!points.empty()) {
1088 Selection::add (ControlPoint* cp)
1090 clear_time (); //enforce region/object exclusivity
1091 clear_tracks(); //enforce object/track exclusivity
1093 cp->set_selected (true);
1094 points.push_back (cp);
1095 PointsChanged (); /* EMIT SIGNAL */
1099 Selection::add (vector<ControlPoint*> const & cps)
1101 clear_time (); //enforce region/object exclusivity
1102 clear_tracks(); //enforce object/track exclusivity
1104 for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
1105 (*i)->set_selected (true);
1106 points.push_back (*i);
1108 PointsChanged (); /* EMIT SIGNAL */
1112 Selection::set (ControlPoint* cp)
1114 clear_time (); //enforce region/object exclusivity
1115 clear_tracks(); //enforce object/track exclusivity
1117 if (cp->get_selected()) {
1121 for (uint32_t i = 0; i < cp->line().npoints(); ++i) {
1122 cp->line().nth (i)->set_selected (false);
1130 Selection::set (Marker* m)
1132 clear_time (); //enforce region/object exclusivity
1133 clear_tracks(); //enforce object/track exclusivity
1140 Selection::toggle (Marker* m)
1142 MarkerSelection::iterator i;
1144 if ((i = find (markers.begin(), markers.end(), m)) == markers.end()) {
1152 Selection::remove (Marker* m)
1154 MarkerSelection::iterator i;
1156 if ((i = find (markers.begin(), markers.end(), m)) != markers.end()) {
1163 Selection::add (Marker* m)
1165 clear_time (); //enforce region/object exclusivity
1166 clear_tracks(); //enforce object/track exclusivity
1168 if (find (markers.begin(), markers.end(), m) == markers.end()) {
1169 markers.push_back (m);
1175 Selection::add (const list<Marker*>& m)
1177 clear_time (); //enforce region/object exclusivity
1178 clear_tracks(); //enforce object/track exclusivity
1180 markers.insert (markers.end(), m.begin(), m.end());
1188 MarkerSelection::range (framepos_t& s, framepos_t& e)
1193 for (MarkerSelection::iterator i = begin(); i != end(); ++i) {
1195 if ((*i)->position() < s) {
1196 s = (*i)->position();
1199 if ((*i)->position() > e) {
1200 e = (*i)->position();
1204 s = std::min (s, e);
1205 e = std::max (s, e);
1209 Selection::get_state () const
1211 /* XXX: not complete; just sufficient to get track selection state
1212 so that re-opening plugin windows for editor mixer strips works
1216 XMLNode* node = new XMLNode (X_("Selection"));
1218 for (TrackSelection::const_iterator i = tracks.begin(); i != tracks.end(); ++i) {
1219 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
1220 AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (*i);
1222 XMLNode* t = node->add_child (X_("RouteView"));
1223 t->add_property (X_("id"), atoi (rtv->route()->id().to_s().c_str()));
1225 XMLNode* t = node->add_child (X_("AutomationView"));
1226 t->add_property (X_("id"), atoi (atv->parent_route()->id().to_s().c_str()));
1227 t->add_property (X_("parameter"), EventTypeMap::instance().to_symbol (atv->parameter ()));
1231 for (RegionSelection::const_iterator i = regions.begin(); i != regions.end(); ++i) {
1232 XMLNode* r = node->add_child (X_("Region"));
1233 r->add_property (X_("id"), atoi ((*i)->region ()->id ().to_s ().c_str()));
1237 for (TimeSelection::const_iterator i = time.begin(); i != time.end(); ++i) {
1238 XMLNode* t = node->add_child (X_("AudioRange"));
1239 snprintf(buf, sizeof(buf), "%ld", (*i).start);
1240 t->add_property (X_("start"), string(buf));
1241 snprintf(buf, sizeof(buf), "%ld", (*i).end);
1242 t->add_property (X_("end"), string(buf));
1245 for (MarkerSelection::const_iterator i = markers.begin(); i != markers.end(); ++i) {
1246 XMLNode* t = node->add_child (X_("Marker"));
1249 Location* loc = editor->find_location_from_marker (*i, is_start);
1251 t->add_property (X_("id"), atoi (loc->id().to_s().c_str()));
1252 t->add_property (X_("start"), is_start ? X_("yes") : X_("no"));
1259 Selection::set_state (XMLNode const & node, int)
1261 if (node.name() != X_("Selection")) {
1270 XMLNodeList children = node.children ();
1271 for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
1272 if ((*i)->name() == X_("RouteView")) {
1274 XMLProperty* prop_id = (*i)->property (X_("id"));
1276 PBD::ID id (prop_id->value ());
1277 RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
1282 } else if ((*i)->name() == X_("Region")) {
1283 XMLProperty* prop_id = (*i)->property (X_("id"));
1285 PBD::ID id (prop_id->value ());
1288 editor->get_regionviews_by_id (id, rs);
1294 regionviews are being constructed - stash the region IDs
1295 so we can identify them in Editor::region_view_added ()
1297 regions.pending.push_back (id);
1300 } else if ((*i)->name() == X_("AudioRange")) {
1301 XMLProperty* prop_start = (*i)->property (X_("start"));
1302 XMLProperty* prop_end = (*i)->property (X_("end"));
1304 assert (prop_start);
1307 framepos_t s (atol (prop_start->value ().c_str()));
1308 framepos_t e (atol (prop_end->value ().c_str()));
1310 set_preserving_all_ranges (s, e);
1312 } else if ((*i)->name() == X_("AutomationView")) {
1314 XMLProperty* prop_id = (*i)->property (X_("id"));
1315 XMLProperty* prop_parameter = (*i)->property (X_("parameter"));
1318 assert (prop_parameter);
1320 PBD::ID id (prop_id->value ());
1321 RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
1324 boost::shared_ptr<AutomationTimeAxisView> atv = rtv->automation_child (EventTypeMap::instance().from_symbol (prop_parameter->value ()));
1326 /* the automation could be for an entity that was never saved
1327 in the session file. Don't freak out if we can't find
1336 } else if ((*i)->name() == X_("Marker")) {
1338 XMLProperty* prop_id = (*i)->property (X_("id"));
1339 XMLProperty* prop_start = (*i)->property (X_("start"));
1341 assert (prop_start);
1343 PBD::ID id (prop_id->value ());
1344 Marker* m = editor->find_marker_from_location_id (id, string_is_affirmative (prop_start->value ()));
1357 Selection::remove_regions (TimeAxisView* t)
1359 RegionSelection::iterator i = regions.begin();
1360 while (i != regions.end ()) {
1361 RegionSelection::iterator tmp = i;
1364 if (&(*i)->get_time_axis_view() == t) {
1373 Selection::block_tracks_changed (bool yn)
1375 _no_tracks_changed = yn;