remove "edit" property from track/bus groups; use "select" property which should...
[ardour.git] / libs / ardour / region.cc
index efaa104d351bef9f33f4281163e769395b2a8552..c74ce4e41998ec82797f64c6c0112e9a6ee5ce01 100644 (file)
 #include <algorithm>
 #include <sstream>
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 #include "pbd/xml++.h"
-#include "pbd/stacktrace.h"
-#include "pbd/enumwriter.h"
 
 #include "ardour/debug.h"
-#include "ardour/file_source.h"
 #include "ardour/filter.h"
 #include "ardour/playlist.h"
 #include "ardour/playlist_source.h"
@@ -38,9 +35,7 @@
 #include "ardour/region_factory.h"
 #include "ardour/session.h"
 #include "ardour/source.h"
-#include "ardour/source_factory.h"
 #include "ardour/tempo.h"
-#include "ardour/utils.h"
 
 #include "i18n.h"
 
@@ -49,6 +44,7 @@ using namespace ARDOUR;
 using namespace PBD;
 
 namespace ARDOUR {
+       class Progress;
        namespace Properties {
                PBD::PropertyDescriptor<bool> muted;
                PBD::PropertyDescriptor<bool> opaque;
@@ -1654,3 +1650,33 @@ Region::set_start_internal (framecnt_t s)
 {
        _start = s;
 }
+
+framepos_t
+Region::earliest_possible_position () const
+{
+       if (_start > _position) {
+               return 0;
+       } else {
+               return _position - _start;
+       }
+}
+
+framecnt_t
+Region::latest_possible_frame () const
+{
+       framecnt_t minlen = max_framecnt;
+
+       for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) {
+               /* non-audio regions have a length that may vary based on their
+                * position, so we have to pass it in the call.
+                */
+               minlen = min (minlen, (*i)->length (_position));
+       }
+
+       /* the latest possible last frame is determined by the current
+        * position, plus the shortest source extent past _start.
+        */
+
+       return _position + (minlen - _start) - 1;
+}
+