From 2d4358ddb5e9cf3cd21b603b74dc999aaebf53a2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 10 Jun 2016 13:50:19 -0400 Subject: Various changes to PresentationInfo and a small consolidation of sorters. The semantics for sorting PresentationInfo are up to the caller, not the PresentationInfo object, so operator<() was removed and callers specifically invoke ::order() for sorting. --- gtk2_ardour/group_tabs.cc | 16 ++----------- gtk2_ardour/meterbridge.cc | 21 ++++++++-------- gtk2_ardour/meterbridge.h | 2 +- libs/ardour/ardour/presentation_info.h | 32 ++++++++----------------- libs/ardour/ardour/stripable.h | 13 +++++----- libs/ardour/presentation_info.cc | 1 + libs/ardour/session.cc | 24 ++++++++++++++----- libs/ardour/session_midi.cc | 15 +++++++----- libs/surfaces/mackie/mackie_control_protocol.cc | 6 ++--- 9 files changed, 61 insertions(+), 69 deletions(-) diff --git a/gtk2_ardour/group_tabs.cc b/gtk2_ardour/group_tabs.cc index 06e50f274b..f7ceb9e996 100644 --- a/gtk2_ardour/group_tabs.cc +++ b/gtk2_ardour/group_tabs.cc @@ -663,18 +663,6 @@ GroupTabs::un_subgroup (RouteGroup* g) g->destroy_subgroup (); } -struct CollectSorter { - bool operator () (boost::shared_ptr a, boost::shared_ptr b) { - return a->presentation_info () < b->presentation_info(); - } -}; - -struct OrderSorter { - bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - return a->presentation_info() < b->presentation_info(); - } -}; - /** Collect all members of a RouteGroup so that they are together in the Editor or Mixer. * @param g Group to collect. */ @@ -682,12 +670,12 @@ void GroupTabs::collect (RouteGroup* g) { boost::shared_ptr group_routes = g->route_list (); - group_routes->sort (CollectSorter ()); + group_routes->sort (Stripable::PresentationOrderSorter()); int const N = group_routes->size (); RouteList::iterator i = group_routes->begin (); boost::shared_ptr routes = _session->get_routes (); - routes->sort (OrderSorter ()); + routes->sort (Stripable::PresentationOrderSorter()); RouteList::const_iterator j = routes->begin (); int diff = 0; diff --git a/gtk2_ardour/meterbridge.cc b/gtk2_ardour/meterbridge.cc index f687d0c72d..07553ced18 100644 --- a/gtk2_ardour/meterbridge.cc +++ b/gtk2_ardour/meterbridge.cc @@ -401,14 +401,16 @@ Meterbridge::on_scroll() struct PresentationInfoRouteSorter { bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - if (a->is_master()) { - /* master before everything else */ - return true; - } else if (b->is_master()) { - /* everything else before b */ + if (a->is_master() || a->is_monitor()) { + /* "a" is a special route (master, monitor, etc), and comes + * last in the mixer ordering + */ return false; + } else if (b->is_master() || b->is_monitor()) { + /* everything comes before b */ + return true; } - return a->presentation_info() < b->presentation_info(); + return a->presentation_info().order() < b->presentation_info().order(); } }; @@ -434,12 +436,11 @@ Meterbridge::set_session (Session* s) _show_master = _session->config.get_show_master_on_meterbridge(); _show_midi = _session->config.get_show_midi_on_meterbridge(); - PresentationInfoRouteSorter sorter; boost::shared_ptr routes = _session->get_routes(); - RouteList copy(*routes); - copy.sort(sorter); - add_strips(copy); + RouteList copy (*routes); + copy.sort (PresentationInfoRouteSorter()); + add_strips (copy); _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::add_strips, this, _1), gui_context()); _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::update_title, this), gui_context()); diff --git a/gtk2_ardour/meterbridge.h b/gtk2_ardour/meterbridge.h index 5e06907917..a1715b2633 100644 --- a/gtk2_ardour/meterbridge.h +++ b/gtk2_ardour/meterbridge.h @@ -107,7 +107,7 @@ class Meterbridge : /* everything comes before b */ return true; } - return a->presentation_info() < b->presentation_info (); + return a->presentation_info().order() < b->presentation_info().order(); } }; diff --git a/libs/ardour/ardour/presentation_info.h b/libs/ardour/ardour/presentation_info.h index 8a3c367448..91238e6537 100644 --- a/libs/ardour/ardour/presentation_info.h +++ b/libs/ardour/ardour/presentation_info.h @@ -128,6 +128,7 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful StatusMask = (Selected|Hidden) }; + static const Flag AllStripables; /* mask to use for any route or VCA (but not auditioner) */ static const Flag AllRoutes; /* mask to use for any route include master+monitor, but not auditioner */ static const Flag Route; /* mask for any route (bus or track */ static const Flag Track; /* mask to use for any track */ @@ -142,6 +143,7 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful static const order_t max_order; + PresentationInfo::Flag flags() const { return _flags; } order_t order() const { return _order; } color_t color() const { return _color; } @@ -150,8 +152,7 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful void set_color (color_t); void set_selected (bool yn); void set_hidden (bool yn); - - PresentationInfo::Flag flags() const { return _flags; } + void set_flags (Flag f) { _flags = f; } bool order_set() const { return _flags & OrderSet; } @@ -159,18 +160,6 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful bool selected() const { return _flags & Selected; } bool special() const { return _flags & (MasterOut|MonitorOut|Auditioner); } - void set_flag (PresentationInfo::Flag f) { - _flags = PresentationInfo::Flag (_flags | f); - } - - void unset_flag (PresentationInfo::Flag f) { - _flags = PresentationInfo::Flag (_flags & ~f); - } - - void set_flags (Flag f) { - _flags = f; - } - bool flag_match (Flag f) const { /* no flags, match all */ @@ -209,6 +198,13 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful return true; } + if (f == AllStripables && (_flags & AllStripables)) { + /* any kind of stripable, but not auditioner. Ask for that + specifically. + */ + return true; + } + /* compare without status mask - we already checked that above */ @@ -218,14 +214,6 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful int set_state (XMLNode const&, int); XMLNode& get_state (); - bool operator< (PresentationInfo const& other) const { - return order() < other.order(); - } - - bool match (PresentationInfo const& other) const { - return (_order == other.order()) && flag_match (other.flags()); - } - bool operator==(PresentationInfo const& other) { return (_order == other.order()) && (_flags == other.flags()); } diff --git a/libs/ardour/ardour/stripable.h b/libs/ardour/ardour/stripable.h index 5447d8322b..8ad02c98b3 100644 --- a/libs/ardour/ardour/stripable.h +++ b/libs/ardour/ardour/stripable.h @@ -79,6 +79,12 @@ class LIBARDOUR_API Stripable : public SessionObject { void set_presentation_order (PresentationInfo::order_t, bool notify_class_listeners = true); void set_presentation_order_explicit (PresentationInfo::order_t); + struct PresentationOrderSorter { + bool operator() (boost::shared_ptr a, boost::shared_ptr b) { + return a->presentation_info().order() < b->presentation_info().order(); + } + }; + /* gui's call this for their own purposes. */ PBD::Signal2 gui_changed; @@ -179,13 +185,6 @@ class LIBARDOUR_API Stripable : public SessionObject { PresentationInfo _presentation_info; }; -struct PresentationInfoSorter { - bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - return a->presentation_info() < b->presentation_info(); - } -}; - - } #endif /* __libardour_stripable_h__ */ diff --git a/libs/ardour/presentation_info.cc b/libs/ardour/presentation_info.cc index cfed463d83..4fdbd4111a 100644 --- a/libs/ardour/presentation_info.cc +++ b/libs/ardour/presentation_info.cc @@ -52,6 +52,7 @@ const PresentationInfo::Flag PresentationInfo::Bus = PresentationInfo::Flag (Pre const PresentationInfo::Flag PresentationInfo::Track = PresentationInfo::Flag (PresentationInfo::AudioTrack|PresentationInfo::MidiTrack); const PresentationInfo::Flag PresentationInfo::Route = PresentationInfo::Flag (PresentationInfo::Bus|PresentationInfo::Track); const PresentationInfo::Flag PresentationInfo::AllRoutes = PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::MasterOut|PresentationInfo::MonitorOut); +const PresentationInfo::Flag PresentationInfo::AllStripables = PresentationInfo::Flag (PresentationInfo::AllRoutes|PresentationInfo::VCA); void PresentationInfo::make_property_quarks () diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 6b8c7f3ed8..88c958495e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4225,11 +4225,23 @@ Session::get_remote_nth_route (PresentationInfo::order_t n) const return boost::dynamic_pointer_cast (get_remote_nth_stripable (n, PresentationInfo::Route)); } -struct GlobalPresentationOrderSorter { - bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - return a->presentation_info() < b->presentation_info(); +boost::shared_ptr +Session::get_nth_stripable (PresentationInfo::order_t n) const +{ + StripableList sl; + + get_stripables (sl); + + for (StripableList::const_iterator s = sl.begin(); s != sl.end(); ++s) { + if ((*s)->presentation_info().order() == n) { + return *s; + } } -}; + + /* there is no nth stripable */ + + return boost::shared_ptr(); +} boost::shared_ptr Session::get_remote_nth_stripable (PresentationInfo::order_t n, PresentationInfo::Flag flags) const @@ -4238,7 +4250,7 @@ Session::get_remote_nth_stripable (PresentationInfo::order_t n, PresentationInfo PresentationInfo::order_t match_cnt = 0; get_stripables (sl); - sl.sort (GlobalPresentationOrderSorter()); + sl.sort (Stripable::PresentationOrderSorter()); for (StripableList::const_iterator s = sl.begin(); s != sl.end(); ++s) { if ((*s)->presentation_info().flag_match (flags)) { @@ -5370,7 +5382,7 @@ Session::RoutePublicOrderSorter::operator() (boost::shared_ptr a, boost:: if (b->is_monitor()) { return false; } - return a->presentation_info() < b->presentation_info(); + return a->presentation_info().order() < b->presentation_info().order(); } bool diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index f3a8d7dd81..e53970840b 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -338,21 +338,24 @@ Session::mmc_shuttle (MIDI::MachineControl &/*mmc*/, float speed, bool forw) boost::shared_ptr Session::get_midi_nth_route_by_id (PresentationInfo::order_t n) const { - PresentationInfo id (PresentationInfo::Flag (0)); + PresentationInfo::Flag f; if (n == 318) { - id.set_flags (PresentationInfo::MasterOut); + f = PresentationInfo::MasterOut; } else if (n == 319) { - id.set_flags (PresentationInfo::MonitorOut); + f = PresentationInfo::MonitorOut; } else { - id = PresentationInfo (n, PresentationInfo::Route); + f = PresentationInfo::Route; } boost::shared_ptr r = routes.reader (); + PresentationInfo::order_t match_cnt = 0; for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { - if ((*i)->presentation_info().match (id)) { - return *i; + if ((*i)->presentation_info().flag_match (f)) { + if (match_cnt++ == n) { + return *i; + } } } diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 86af49cc09..40897761df 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -246,17 +246,17 @@ struct StripableByPresentationOrder { bool operator () (const boost::shared_ptr & a, const boost::shared_ptr & b) const { - return a->presentation_info() < b->presentation_info(); + return a->presentation_info().order() < b->presentation_info().order(); } bool operator () (const Stripable & a, const Stripable & b) const { - return a.presentation_info() < b.presentation_info(); + return a.presentation_info().order() < b.presentation_info().order(); } bool operator () (const Stripable * a, const Stripable * b) const { - return a->presentation_info() < b->presentation_info(); + return a->presentation_info().order() < b->presentation_info().order(); } }; -- cgit v1.2.3