From 10db824461e3bd8eb0661ddfb35da283192e8c29 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 16 Jun 2017 23:44:29 +0200 Subject: Use Stripable::Sorter in libs --- libs/ardour/ardour/session.h | 4 --- libs/ardour/ardour/session_route.h | 6 ++--- libs/ardour/session.cc | 34 +++---------------------- libs/surfaces/faderport8/faderport8.cc | 46 +--------------------------------- 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, boost::shared_ptr b); - }; - void notify_presentation_info_change (); template 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), 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(); } -struct PresentationOrderSorter { - bool operator() (boost::shared_ptr a, boost::shared_ptr 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 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); @@ -5633,18 +5617,6 @@ Session::cancel_audition () } } -bool -Session::RoutePublicOrderSorter::operator() (boost::shared_ptr a, boost::shared_ptr 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 { 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 s) { return 0 != r->the_instrument (); } -struct FP8SortByNewDisplayOrder -{ - // return strict (a < b) - bool operator () (const boost::shared_ptr & a, const boost::shared_ptr & 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 */ -- cgit v1.2.3