Add a dedicated export method to MidiRegion
[ardour.git] / libs / ardour / ardour / region_sorters.h
index ca09f194b1abe0b261da669dc86b535a4a08dce4..3afd66bf3ca9613ef61a639d120e9c0e2fb411b4 100644 (file)
 
 namespace ARDOUR {
 
-struct RegionSortByPosition {
-    bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
-           return a->position() < b->position();
-    }
-};
-
-struct RegionSortByLastLayerOp {
-    bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
-           return a->last_layer_op() < b->last_layer_op();
-    }
+struct LIBARDOUR_API RegionSortByPosition {
+       bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
+               return a->position() < b->position();
+       }
 };
 
-struct RegionSortByLayer {
-    bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
-           return a->layer() < b->layer();
-    }
+struct LIBARDOUR_API RegionSortByLayer {
+       bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
+               return a->layer() < b->layer();
+       }
 };
 
-struct RegionSortByLayerWithPending {
-       bool operator () (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
-
-               double p = a->layer ();
-               if (a->pending_explicit_relayer()) {
-                       p += 0.5;
-               }
-
-               double q = b->layer ();
-               if (b->pending_explicit_relayer()) {
-                       q += 0.5;
-               }
-
-               return p < q;
+/* sort by RegionSortByLayerAndPosition()
+ * is equivalent to
+ * stable_sort by RegionSortByPosition();
+ * stable_sort by RegionSortByLayer();
+ */
+struct LIBARDOUR_API RegionSortByLayerAndPosition {
+       bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
+               return
+                          (a->layer() < b->layer()  && a->position() < b->position())
+                       || (a->layer() == b->layer() && a->position() < b->position());
        }
 };
 
-} // namespace 
+} // namespace
 
 #endif /* __libardour_region_sorters_h__ */