summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_matrix.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-07-01 01:14:14 +0000
committerCarl Hetherington <carl@carlh.net>2010-07-01 01:14:14 +0000
commit92e412661772e6b9c83109b7ee4996f4c040d3f4 (patch)
tree1f1006c61d03b6b68855d812561d931606ff84b3 /gtk2_ardour/port_matrix.cc
parentaad230da6937358b11976c1db3986575b2e412a0 (diff)
Allow port matrix to show both audio and midi ports at the same time, and use that facility for route IO selectors.
git-svn-id: svn://localhost/ardour2/branches/3.0@7344 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_matrix.cc')
-rw-r--r--gtk2_ardour/port_matrix.cc54
1 files changed, 36 insertions, 18 deletions
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index dc7730c823..4486cfb30d 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -259,7 +259,7 @@ PortMatrix::disassociate_all ()
for (PortGroup::BundleList::iterator k = b.begin(); k != b.end(); ++k) {
for (uint32_t l = 0; l < (*k)->bundle->nchannels().n_total(); ++l) {
- if ((*i)->bundle->channel_type(j) != _type || (*k)->bundle->channel_type(l) != _type) {
+ if (!should_show ((*i)->bundle->channel_type(j)) || !should_show ((*k)->bundle->channel_type(l))) {
continue;
}
@@ -285,8 +285,8 @@ void
PortMatrix::select_arrangement ()
{
uint32_t const N[2] = {
- _ports[0].total_channels().get(_type),
- _ports[1].total_channels().get(_type)
+ count_of_our_type (_ports[0].total_channels()),
+ count_of_our_type (_ports[1].total_channels())
};
/* The list with the most channels goes on left or right, so that the most channel
@@ -389,13 +389,14 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
bool can_add_or_rename = false;
- if (can_add_channel (bc[dim].bundle)) {
- snprintf (buf, sizeof (buf), _("Add %s"), channel_noun().c_str());
- sub.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::add_channel_proxy), w)));
- can_add_or_rename = true;
+ for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
+ if (should_show (*i)) {
+ snprintf (buf, sizeof (buf), _("Add %s %s"), (*i).to_i18n_string(), channel_noun().c_str());
+ sub.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::add_channel_proxy), w, *i)));
+ can_add_or_rename = true;
+ }
}
-
if (can_rename_channels (bc[dim].bundle)) {
snprintf (
buf, sizeof (buf), _("Rename '%s'..."),
@@ -425,14 +426,14 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
);
for (uint32_t i = 0; i < bc[dim].bundle->nchannels().n_total(); ++i) {
- if (bc[dim].bundle->channel_type(i) == _type) {
+ if (should_show (bc[dim].bundle->channel_type(i))) {
add_remove_option (sub, w, i);
}
}
}
}
- if (_show_only_bundles || bc[dim].bundle->nchannels().get(_type) <= 1) {
+ if (_show_only_bundles || count_of_our_type (bc[dim].bundle->nchannels()) <= 1) {
snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str());
sub.push_back (
MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, bc[dim].channel, dim))
@@ -449,7 +450,7 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
);
for (uint32_t i = 0; i < bc[dim].bundle->nchannels().n_total(); ++i) {
- if (bc[dim].bundle->channel_type(i) == _type) {
+ if (should_show (bc[dim].bundle->channel_type(i))) {
add_disassociate_option (sub, w, dim, i);
}
}
@@ -508,7 +509,7 @@ PortMatrix::disassociate_all_on_bundle (boost::weak_ptr<Bundle> bundle, int dim)
}
for (uint32_t i = 0; i < sb->nchannels().n_total(); ++i) {
- if (sb->channel_type(i) == _type) {
+ if (should_show (sb->channel_type(i))) {
disassociate_all_on_channel (bundle, i, dim);
}
}
@@ -527,7 +528,7 @@ PortMatrix::disassociate_all_on_channel (boost::weak_ptr<Bundle> bundle, uint32_
for (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
- if ((*i)->bundle->channel_type(j) != _type) {
+ if (should_show ((*i)->bundle->channel_type(j))) {
continue;
}
@@ -634,12 +635,12 @@ PortMatrix::can_add_channel (boost::shared_ptr<Bundle> b) const
}
void
-PortMatrix::add_channel (boost::shared_ptr<Bundle> b)
+PortMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
{
boost::shared_ptr<IO> io = io_from_bundle (b);
if (io) {
- io->add_port ("", this, _type);
+ io->add_port ("", this, t);
}
}
@@ -671,21 +672,21 @@ PortMatrix::remove_all_channels (boost::weak_ptr<Bundle> w)
}
for (uint32_t i = 0; i < b->nchannels().n_total(); ++i) {
- if (b->channel_type(i) == _type) {
+ if (should_show (b->channel_type(i))) {
remove_channel (ARDOUR::BundleChannel (b, i));
}
}
}
void
-PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w)
+PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w, DataType t)
{
boost::shared_ptr<Bundle> b = w.lock ();
if (!b) {
return;
}
- add_channel (b);
+ add_channel (b, t);
}
void
@@ -856,3 +857,20 @@ PortMatrix::channel_noun () const
{
return _("channel");
}
+
+/** @return true if this matrix should show bundles / ports of type \t */
+bool
+PortMatrix::should_show (DataType t) const
+{
+ return (_type == DataType::NIL || t == _type);
+}
+
+uint32_t
+PortMatrix::count_of_our_type (ChanCount c) const
+{
+ if (_type == DataType::NIL) {
+ return c.n_total ();
+ }
+
+ return c.get (_type);
+}