From dbb0b9ca4f82ea8e3829cfeb009b9746c3d6f0dc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 10 Nov 2009 03:16:57 +0000 Subject: Various adjustments to user bundle handling, with the general aim of allowing the user to create meaningful bundles with respect to their sound card an outboard setup, and having those user bundles take priority over ardour-generated ones. git-svn-id: svn://localhost/ardour2/branches/3.0@6050 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_group.cc | 52 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'gtk2_ardour/port_group.cc') diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 240e03eb0f..fceb143d34 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -53,7 +53,7 @@ PortGroup::PortGroup (std::string const & n) void PortGroup::add_bundle (boost::shared_ptr b) { - add_bundle (b, boost::shared_ptr ()); + add_bundle_internal (b, boost::shared_ptr (), false, Gdk::Color ()); } /** Add a bundle to a group. @@ -62,38 +62,45 @@ PortGroup::add_bundle (boost::shared_ptr b) void PortGroup::add_bundle (boost::shared_ptr b, boost::shared_ptr io) { - assert (b.get()); - - BundleRecord r; - r.bundle = b; - r.io = io; - r.has_colour = false; - r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed)); - - _bundles.push_back (r); - - Changed (); + add_bundle_internal (b, io, false, Gdk::Color ()); } /** Add a bundle to a group. * @param b Bundle. - * @param c Colour to represent the group with. + * @param c Colour to represent the bundle with. */ void PortGroup::add_bundle (boost::shared_ptr b, boost::shared_ptr io, Gdk::Color c) +{ + add_bundle_internal (b, io, true, c); +} + +void +PortGroup::add_bundle_internal (boost::shared_ptr b, boost::shared_ptr io, bool has_colour, Gdk::Color colour) { assert (b.get()); + /* don't add this bundle if we already have one with the same ports */ + + BundleList::iterator i = _bundles.begin (); + while (i != _bundles.end() && b->has_same_ports (i->bundle) == false) { + ++i; + } + + if (i != _bundles.end ()) { + return; + } + BundleRecord r; r.bundle = b; r.io = io; - r.colour = c; - r.has_colour = true; + r.colour = colour; + r.has_colour = has_colour; r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed)); _bundles.push_back (r); - Changed (); + Changed (); } void @@ -281,15 +288,24 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs) } } - /* Bundles owned by the session */ + /* Bundles owned by the session; add user bundles first, then normal ones, so + that UserBundles that offer the same ports as a normal bundle get priority + */ boost::shared_ptr b = session.bundles (); + for (BundleList::iterator i = b->begin(); i != b->end(); ++i) { - if ((*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { + if (boost::dynamic_pointer_cast (*i) && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { system->add_bundle (*i); } } + for (BundleList::iterator i = b->begin(); i != b->end(); ++i) { + if (boost::dynamic_pointer_cast (*i) == 0 && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { + system->add_bundle (*i); + } + } + /* Ardour stuff */ if (!inputs && _type == DataType::AUDIO) { -- cgit v1.2.3