Connect Script Manager "Edit" -> Lua Scripting Window
[ardour.git] / gtk2_ardour / region_selection.cc
index 8c3a641941851ca8b0fcfbc3f2675814312d31c8..3161b01007b0f54e3c88eb6f9c840556f2b1f5bc 100644 (file)
@@ -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*>()
 {
-       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();
 }
 
@@ -137,7 +139,7 @@ RegionSelection::remove (RegionView* rv)
 
                // remove from layer sorted list
                _bylayer.remove (rv);
-
+               pending.remove (rv->region()->id());
                erase (r);
                return true;
        }
@@ -269,7 +271,7 @@ 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;
@@ -286,3 +288,28 @@ RegionSelection::playlists () const
 
        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;
+}