summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_group.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-07-29 19:25:26 +0000
committerCarl Hetherington <carl@carlh.net>2010-07-29 19:25:26 +0000
commit66760a574a1fc0ccc8a798c2900a717c134838ea (patch)
treef9c576c0e5a647914a2f9c736efd6f9359ee87db /gtk2_ardour/port_group.cc
parent21fd76ef9a0c1856e5f91c394214e244265a0f86 (diff)
Don't display empty tabs in the port matrix.
git-svn-id: svn://localhost/ardour2/branches/3.0@7521 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_group.cc')
-rw-r--r--gtk2_ardour/port_group.cc85
1 files changed, 70 insertions, 15 deletions
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 0af3c24ed9..1382826b90 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -311,8 +311,8 @@ public:
}
};
-/** Gather bundles from around the system and put them in this PortGroupList.
- * @param type Type of bundles to collect, or NIL for all types.
+/** Gather ports from around the system and put them in this PortGroupList.
+ * @param type Type of ports to collect, or NIL for all types.
*/
void
PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inputs, bool allow_dups)
@@ -356,7 +356,11 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
/* Sort RouteIOs by the routes' editor order keys */
route_ios.sort (RouteIOsComparator ());
- /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup */
+ /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup.
+ Note that if the RouteIO's bundles are multi-type, we may make new Bundles
+ with only the ports of one type.
+ */
+
for (list<RouteIOs>::iterator i = route_ios.begin(); i != route_ios.end(); ++i) {
TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (i->route);
@@ -367,12 +371,15 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
} else {
g = bus;
}
-
+
for (list<boost::shared_ptr<IO> >::iterator j = i->ios.begin(); j != i->ios.end(); ++j) {
- if (tv) {
- g->add_bundle ((*j)->bundle(), *j, tv->color ());
- } else {
- g->add_bundle ((*j)->bundle(), *j);
+ boost::shared_ptr<Bundle> b = bundle_for_type ((*j)->bundle(), type);
+ if (b) {
+ if (tv) {
+ g->add_bundle (b, *j, tv->color ());
+ } else {
+ g->add_bundle (b, *j);
+ }
}
}
}
@@ -385,21 +392,34 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
if (boost::dynamic_pointer_cast<UserBundle> (*i) && (*i)->ports_are_inputs() == inputs) {
- system->add_bundle (*i, allow_dups);
+ boost::shared_ptr<Bundle> b = bundle_for_type (*i, type);
+ if (b) {
+ system->add_bundle (b, allow_dups);
+ }
}
}
for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0 && (*i)->ports_are_inputs() == inputs) {
- system->add_bundle (*i, allow_dups);
+ boost::shared_ptr<Bundle> b = bundle_for_type (*i, type);
+ if (b) {
+ system->add_bundle (b, allow_dups);
+ }
}
}
/* Ardour stuff */
- if (!inputs && (type == DataType::AUDIO || type == DataType::NIL)) {
- ardour->add_bundle (session->the_auditioner()->output()->bundle());
- ardour->add_bundle (session->click_io()->bundle());
+ if (!inputs) {
+ boost::shared_ptr<Bundle> b = bundle_for_type (session->the_auditioner()->output()->bundle(), type);
+ if (b) {
+ ardour->add_bundle (b);
+ }
+
+ b = bundle_for_type (session->click_io()->bundle(), type);
+ if (b) {
+ ardour->add_bundle (b);
+ }
}
/* Now find all other ports that we haven't thought of yet */
@@ -461,13 +481,21 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
if (!extra_system[*i].empty()) {
- system->add_bundle (make_bundle_from_ports (extra_system[*i], *i, inputs));
+ boost::shared_ptr<Bundle> b = make_bundle_from_ports (extra_system[*i], *i, inputs);
+ boost::shared_ptr<Bundle> bt = bundle_for_type (b, type);
+ if (bt) {
+ system->add_bundle (bt);
+ }
}
}
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
if (!extra_other[*i].empty()) {
- other->add_bundle (make_bundle_from_ports (extra_other[*i], *i, inputs));
+ boost::shared_ptr<Bundle> b = make_bundle_from_ports (extra_other[*i], *i, inputs);
+ boost::shared_ptr<Bundle> bt = bundle_for_type (b, type);
+ if (bt) {
+ other->add_bundle (bt);
+ }
}
}
@@ -682,3 +710,30 @@ PortGroupList::empty () const
return (i == _groups.end());
}
+/** Take a bundle, and either return it, if it contains only ports of type \a t,
+ * or return a new bundle with those ports from \a b which are of type \a t.
+ * Note that t == NIL is taken to mean "all types".
+ */
+boost::shared_ptr<Bundle>
+PortGroupList::bundle_for_type (boost::shared_ptr<Bundle> b, DataType t) const
+{
+ /* We are asked for a bundle with all types, so that's easy */
+ if (t == DataType::NIL) {
+ return b;
+ }
+
+ if (b->nchannels().get(t) == b->nchannels().n_total()) {
+ /* All channels on b are of the correct type, so just return b */
+ return b;
+ }
+
+ /* We must build a new bundle */
+ boost::shared_ptr<Bundle> n;
+ for (uint32_t i = 0; i < b->nchannels().n_total(); ++i) {
+ if (b->channel_type(i) == t) {
+ n->add_channel (b->channel_name (i), t, b->channel_ports (i));
+ }
+ }
+
+ return n;
+}