diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-06-10 13:50:19 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-06-10 13:57:18 -0400 |
commit | 2d4358ddb5e9cf3cd21b603b74dc999aaebf53a2 (patch) | |
tree | 156fb8fa0d0e182cacece8d112cb4dec3fd3f5aa /libs | |
parent | 3eaa6c038988776e3bab441b84de45b2a8364130 (diff) |
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.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/presentation_info.h | 32 | ||||
-rw-r--r-- | libs/ardour/ardour/stripable.h | 13 | ||||
-rw-r--r-- | libs/ardour/presentation_info.cc | 1 | ||||
-rw-r--r-- | libs/ardour/session.cc | 24 | ||||
-rw-r--r-- | libs/ardour/session_midi.cc | 15 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 6 |
6 files changed, 47 insertions, 44 deletions
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<Stripable> a, boost::shared_ptr<Stripable> b) { + return a->presentation_info().order() < b->presentation_info().order(); + } + }; + /* gui's call this for their own purposes. */ PBD::Signal2<void,std::string,void*> gui_changed; @@ -179,13 +185,6 @@ class LIBARDOUR_API Stripable : public SessionObject { PresentationInfo _presentation_info; }; -struct PresentationInfoSorter { - bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> 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<Route> (get_remote_nth_stripable (n, PresentationInfo::Route)); } -struct GlobalPresentationOrderSorter { - bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) { - return a->presentation_info() < b->presentation_info(); +boost::shared_ptr<Stripable> +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<Stripable>(); +} boost::shared_ptr<Stripable> 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<Route> 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<Route> 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<RouteList> 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<Stripable> & a, const boost::shared_ptr<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(); } 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(); } }; |