Fix CheckOption crash on session-reload
[ardour.git] / gtk2_ardour / route_sorter.h
index c203afa188b301217154549ea8b0dc746b4a3304..fb7f574d720a4026160236c1466ce325fa4074ad 100644 (file)
 #include <stdint.h>
 #include <vector>
 
-namespace ARDOUR {
-       class Route;
-}
+#include "ardour/stripable.h"
 
-struct RoutePlusOrderKey {
-    boost::shared_ptr<ARDOUR::Route> route; /* we don't really need this, but its handy to keep around */
+/* This is used to keep numerical tree-order in sync
+ * with Stripable ordering (mixer_ui.cc editor_routes.cc)
+ */
+
+struct TreeOrderKey {
     uint32_t old_display_order;
-    uint32_t new_display_order;
+               boost::shared_ptr<ARDOUR::Stripable> stripable;
 
-    RoutePlusOrderKey (boost::shared_ptr<ARDOUR::Route> r, uint32_t ok, uint32_t nk)
-           : route (r)
-           , old_display_order (ok)
-           , new_display_order (nk) {}
+       TreeOrderKey (uint32_t ok, boost::shared_ptr<ARDOUR::Stripable> s)
+               : old_display_order (ok)
+               , stripable (s)
+       {}
 };
 
-typedef std::vector<RoutePlusOrderKey> OrderKeySortedRoutes;
+typedef std::vector<TreeOrderKey> TreeOrderKeys;
 
-struct SortByNewDisplayOrder {
-    bool operator() (const RoutePlusOrderKey& a, const RoutePlusOrderKey& b) {
-           return a.new_display_order < b.new_display_order;
-    }
+struct TreeOrderKeySorter
+{
+       bool operator() (const TreeOrderKey& ok_a, const TreeOrderKey& ok_b)
+       {
+               boost::shared_ptr<ARDOUR::Stripable> const& a = ok_a.stripable;
+               boost::shared_ptr<ARDOUR::Stripable> const& b = ok_b.stripable;
+               return ARDOUR::Stripable::Sorter () (a, b);
+       }
 };
 
 #endif /* __gtk2_ardour_route_sorter_h__ */