summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_group.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-11-10 03:16:57 +0000
committerCarl Hetherington <carl@carlh.net>2009-11-10 03:16:57 +0000
commitdbb0b9ca4f82ea8e3829cfeb009b9746c3d6f0dc (patch)
tree2419b9eb122cf19a28940ea115c2d9630d0a22cc /gtk2_ardour/port_group.cc
parentda03bc931b4c82497fb4b02003804c18768c56b6 (diff)
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
Diffstat (limited to 'gtk2_ardour/port_group.cc')
-rw-r--r--gtk2_ardour/port_group.cc52
1 files changed, 34 insertions, 18 deletions
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<Bundle> b)
{
- add_bundle (b, boost::shared_ptr<IO> ());
+ add_bundle_internal (b, boost::shared_ptr<IO> (), false, Gdk::Color ());
}
/** Add a bundle to a group.
@@ -62,38 +62,45 @@ PortGroup::add_bundle (boost::shared_ptr<Bundle> b)
void
PortGroup::add_bundle (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> 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<Bundle> b, boost::shared_ptr<IO> io, Gdk::Color c)
{
+ add_bundle_internal (b, io, true, c);
+}
+
+void
+PortGroup::add_bundle_internal (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> 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<BundleList> 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<UserBundle> (*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<UserBundle> (*i) == 0 && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) {
+ system->add_bundle (*i);
+ }
+ }
+
/* Ardour stuff */
if (!inputs && _type == DataType::AUDIO) {