+samplepos_t
+RegionSelection::start () const
+{
+ samplepos_t s = max_samplepos;
+ for (RegionSelection::const_iterator i = begin(); i != end(); ++i) {
+ s = min (s, (*i)->region()->position ());
+ }
+
+ if (s == max_samplepos) {
+ return 0;
+ }
+
+ return s;
+}
+
+samplepos_t
+RegionSelection::end_sample () const
+{
+ samplepos_t e = 0;
+ for (RegionSelection::const_iterator i = begin(); i != end(); ++i) {
+ e = max (e, (*i)->region()->last_sample ());
+ }
+
+ return e;
+}
+
+/** @return the playlists that the regions in the selection are on */
+set<boost::shared_ptr<Playlist> >
+RegionSelection::playlists () const
+{
+ set<boost::shared_ptr<Playlist> > pl;
+ for (RegionSelection::const_iterator i = begin(); i != end(); ++i) {
+ pl.insert ((*i)->region()->playlist ());
+ }
+
+ return pl;
+}
+
+size_t
+RegionSelection::n_midi_regions () const
+{
+ size_t count = 0;
+
+ for (const_iterator r = begin(); r != end(); ++r) {
+ MidiRegionView* const mrv = dynamic_cast<MidiRegionView*> (*r);
+ if (mrv) {
+ ++count;
+ }
+ }
+
+ return count;
+}
+
+ARDOUR::RegionList
+RegionSelection::regionlist () const
+{
+ ARDOUR::RegionList rl;
+ for (const_iterator r = begin (); r != end (); ++r) {
+ rl.push_back ((*r)->region ());
+ }
+ return rl;
+}