summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-06-16 23:44:29 +0200
committerRobin Gareus <robin@gareus.org>2017-06-17 04:36:28 +0200
commit10db824461e3bd8eb0661ddfb35da283192e8c29 (patch)
tree8c1a954193147b548dbbc4de8e70cc304a2cab7c
parent867a0f5228ae7b9ad3d05142e58762d4f7ef3936 (diff)
Use Stripable::Sorter in libs
-rw-r--r--libs/ardour/ardour/session.h4
-rw-r--r--libs/ardour/ardour/session_route.h6
-rw-r--r--libs/ardour/session.cc34
-rw-r--r--libs/surfaces/faderport8/faderport8.cc46
4 files changed, 7 insertions, 83 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 2209fb268a..8217f45149 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -312,10 +312,6 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
return _bundles.reader ();
}
- struct LIBARDOUR_API RoutePublicOrderSorter {
- bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b);
- };
-
void notify_presentation_info_change ();
template<class T> void foreach_route (T *obj, void (T::*func)(Route&), bool sort = true);
diff --git a/libs/ardour/ardour/session_route.h b/libs/ardour/ardour/session_route.h
index 22bfc1f032..b7eadac7d2 100644
--- a/libs/ardour/ardour/session_route.h
+++ b/libs/ardour/ardour/session_route.h
@@ -36,7 +36,7 @@ Session::foreach_route (T *obj, void (T::*func)(Route&), bool sort)
RouteList public_order (*r);
if (sort) {
- public_order.sort (RoutePublicOrderSorter());
+ public_order.sort (Stripable::Sorter ());
}
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
@@ -51,7 +51,7 @@ Session::foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>), bool
RouteList public_order (*r);
if (sort) {
- public_order.sort (RoutePublicOrderSorter());
+ public_order.sort (Stripable::Sorter ());
}
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
@@ -66,7 +66,7 @@ Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1, bool sort)
RouteList public_order (*r);
if (sort) {
- public_order.sort (RoutePublicOrderSorter());
+ public_order.sort (Stripable::Sorter ());
}
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 80586acac3..6c2cbd3601 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4469,7 +4469,7 @@ Session::get_remote_nth_stripable (PresentationInfo::order_t n, PresentationInfo
PresentationInfo::order_t match_cnt = 0;
get_stripables (sl);
- sl.sort (Stripable::PresentationOrderSorter());
+ sl.sort (Stripable::Sorter());
for (StripableList::const_iterator s = sl.begin(); s != sl.end(); ++s) {
@@ -4501,26 +4501,11 @@ Session::get_remote_nth_stripable (PresentationInfo::order_t n, PresentationInfo
return boost::shared_ptr<Stripable>();
}
-struct PresentationOrderSorter {
- bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
- if (a->presentation_info().special() && !b->presentation_info().special()) {
- /* a is not ordered, b is; b comes before a */
- return false;
- } else if (!b->presentation_info().order_set() && a->presentation_info().order_set()) {
- /* b is not ordered, a is; a comes before b */
- return true;
- } else {
- return a->presentation_info().order() < b->presentation_info().order();
- }
- }
-};
-
boost::shared_ptr<Route>
Session::route_by_selected_count (uint32_t id) const
{
RouteList r (*(routes.reader ()));
- PresentationOrderSorter sorter;
- r.sort (sorter);
+ r.sort (Stripable::Sorter());
RouteList::iterator i;
@@ -4542,8 +4527,7 @@ Session::reassign_track_numbers ()
int64_t tn = 0;
int64_t bn = 0;
RouteList r (*(routes.reader ()));
- PresentationOrderSorter sorter;
- r.sort (sorter);
+ r.sort (Stripable::Sorter());
StateProtector sp (this);
@@ -5634,18 +5618,6 @@ Session::cancel_audition ()
}
bool
-Session::RoutePublicOrderSorter::operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b)
-{
- if (a->is_monitor()) {
- return true;
- }
- if (b->is_monitor()) {
- return false;
- }
- return a->presentation_info().order() < b->presentation_info().order();
-}
-
-bool
Session::is_auditioning () const
{
/* can be called before we have an auditioner object */
diff --git a/libs/surfaces/faderport8/faderport8.cc b/libs/surfaces/faderport8/faderport8.cc
index 33d5b6e36d..d01c48f57f 100644
--- a/libs/surfaces/faderport8/faderport8.cc
+++ b/libs/surfaces/faderport8/faderport8.cc
@@ -834,50 +834,6 @@ static bool flt_instrument (boost::shared_ptr<Stripable> s) {
return 0 != r->the_instrument ();
}
-struct FP8SortByNewDisplayOrder
-{
- // return strict (a < b)
- bool operator () (const boost::shared_ptr<Stripable> & a, const boost::shared_ptr<Stripable> & b) const
- {
- if (a->presentation_info().flags () == b->presentation_info().flags ()) {
- return a->presentation_info().order() < b->presentation_info().order();
- }
-
- int cmp_a = 0;
- int cmp_b = 0;
-
- // see also gtk2_ardour/route_sorter.h
- if (a->presentation_info().flags () & ARDOUR::PresentationInfo::VCA) {
- cmp_a = 2;
- }
-#ifdef MIXBUS
- else if (a->presentation_info().flags () & ARDOUR::PresentationInfo::MasterOut) {
- cmp_a = 3;
- }
- else if (a->presentation_info().flags () & ARDOUR::PresentationInfo::Mixbus || a->mixbus()) {
- cmp_a = 1;
- }
-#endif
-
- if (b->presentation_info().flags () & ARDOUR::PresentationInfo::VCA) {
- cmp_b = 2;
- }
-#ifdef MIXBUS
- else if (b->presentation_info().flags () & ARDOUR::PresentationInfo::MasterOut) {
- cmp_b = 3;
- }
- else if (b->presentation_info().flags () & ARDOUR::PresentationInfo::Mixbus || b->mixbus()) {
- cmp_b = 1;
- }
-#endif
-
- if (cmp_a == cmp_b) {
- return a->presentation_info().order() < b->presentation_info().order();
- }
- return cmp_a < cmp_b;
- }
-};
-
void
FaderPort8::filter_stripables (StripableList& strips) const
{
@@ -941,7 +897,7 @@ FaderPort8::filter_stripables (StripableList& strips) const
strips.push_back (*s);
}
}
- strips.sort (FP8SortByNewDisplayOrder());
+ strips.sort (Stripable::Sorter());
}
/* Track/Pan mode: assign stripable to strips */