X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fregion_selection.cc;h=2a3a3074595ba3544ed43c7c210552b2a6921b8b;hb=da32ae4e1f25780d4513bf25b9be35ae2b84ac6b;hp=8ad7502414632acb873632296c19426d6499ceb9;hpb=fc5be662befcbf973db2f21066b1b1883da7acc8;p=ardour.git diff --git a/gtk2_ardour/region_selection.cc b/gtk2_ardour/region_selection.cc index 8ad7502414..2a3a307459 100644 --- a/gtk2_ardour/region_selection.cc +++ b/gtk2_ardour/region_selection.cc @@ -21,6 +21,7 @@ #include "ardour/region.h" #include "gui_thread.h" +#include "midi_region_view.h" #include "region_view.h" #include "region_selection.h" #include "time_axis_view.h" @@ -33,7 +34,7 @@ using namespace PBD; */ RegionSelection::RegionSelection () { - RegionView::RegionViewGoingAway.connect (death_connection, MISSING_INVALIDATOR, ui_bind (&RegionSelection::remove_it, this, _1), gui_context()); + RegionView::RegionViewGoingAway.connect (death_connection, MISSING_INVALIDATOR, boost::bind (&RegionSelection::remove_it, this, _1), gui_context()); } /** Copy constructor. @@ -42,7 +43,7 @@ RegionSelection::RegionSelection () RegionSelection::RegionSelection (const RegionSelection& other) : std::list() { - RegionView::RegionViewGoingAway.connect (death_connection, MISSING_INVALIDATOR, ui_bind (&RegionSelection::remove_it, this, _1), gui_context()); + RegionView::RegionViewGoingAway.connect (death_connection, MISSING_INVALIDATOR, boost::bind (&RegionSelection::remove_it, this, _1), gui_context()); for (RegionSelection::const_iterator i = other.begin(); i != other.end(); ++i) { add (*i); @@ -73,6 +74,7 @@ void RegionSelection::clear_all() { clear(); + pending.clear (); _bylayer.clear(); } @@ -87,7 +89,7 @@ bool RegionSelection::contains (RegionView* rv) const /** Add a region to the selection. * @param rv Region to add. - * @return false if we already had the region or if it cannot be added, + * @return false if we already had the region or if it cannot be added, * otherwise true. */ bool @@ -137,7 +139,7 @@ RegionSelection::remove (RegionView* rv) // remove from layer sorted list _bylayer.remove (rv); - + erase (r); return true; } @@ -260,7 +262,7 @@ RegionSelection::start () const if (s == max_framepos) { return 0; } - + return s; } @@ -269,8 +271,45 @@ RegionSelection::end_frame () const { framepos_t e = 0; for (RegionSelection::const_iterator i = begin(); i != end(); ++i) { - e = max (e, (*i)->region()->position () + (*i)->region()->length ()); + e = max (e, (*i)->region()->last_frame ()); } return e; } + +/** @return the playlists that the regions in the selection are on */ +set > +RegionSelection::playlists () const +{ + set > 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 (*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; +}