summaryrefslogtreecommitdiff
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
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
-rw-r--r--gtk2_ardour/bundle_manager.cc7
-rw-r--r--gtk2_ardour/bundle_manager.h2
-rw-r--r--gtk2_ardour/io_selector.cc2
-rw-r--r--gtk2_ardour/port_group.cc54
-rw-r--r--gtk2_ardour/port_matrix.cc54
-rw-r--r--gtk2_ardour/port_matrix.h9
-rw-r--r--gtk2_ardour/port_matrix_body.cc14
-rw-r--r--gtk2_ardour/port_matrix_column_labels.cc12
-rw-r--r--gtk2_ardour/port_matrix_component.cc6
-rw-r--r--gtk2_ardour/port_matrix_grid.cc14
-rw-r--r--gtk2_ardour/port_matrix_row_labels.cc10
-rw-r--r--libs/ardour/ardour/data_type.h10
-rw-r--r--libs/ardour/ardour/io.h2
-rw-r--r--libs/ardour/io.cc38
14 files changed, 148 insertions, 86 deletions
diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc
index 66e985e808..9916f80581 100644
--- a/gtk2_ardour/bundle_manager.cc
+++ b/gtk2_ardour/bundle_manager.cc
@@ -107,7 +107,7 @@ BundleEditorMatrix::can_add_channel (boost::shared_ptr<Bundle> b) const
}
void
-BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b)
+BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b, DataType t)
{
if (b == _bundle) {
@@ -118,13 +118,12 @@ BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b)
return;
}
- /* XXX: allow user to specify type */
- _bundle->add_channel (d.get_name(), DataType::AUDIO);
+ _bundle->add_channel (d.get_name(), t);
setup_ports (OURS);
} else {
- PortMatrix::add_channel (b);
+ PortMatrix::add_channel (b, t);
}
}
diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h
index 0bad5b2108..e946b98b74 100644
--- a/gtk2_ardour/bundle_manager.h
+++ b/gtk2_ardour/bundle_manager.h
@@ -41,7 +41,7 @@ class BundleEditorMatrix : public PortMatrix
bool can_add_channel (boost::shared_ptr<ARDOUR::Bundle>) const;
- void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
+ void add_channel (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
void remove_channel (ARDOUR::BundleChannel);
bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc
index cc5ae58224..eff2583c42 100644
--- a/gtk2_ardour/io_selector.cc
+++ b/gtk2_ardour/io_selector.cc
@@ -43,7 +43,7 @@ using namespace ARDOUR;
using namespace Gtk;
IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session* session, boost::shared_ptr<ARDOUR::IO> io)
- : PortMatrix (p, session, io->default_type())
+ : PortMatrix (p, session, DataType::NIL)
, _io (io)
{
/* signal flow from 0 to 1 */
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index ffa27d783a..7990eded89 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -295,7 +295,9 @@ PortGroupList::maybe_add_processor_to_list (
}
-/** Gather bundles from around the system and put them in this PortGroupList */
+/** Gather bundles from around the system and put them in this PortGroupList.
+ * @param type Type of bundles to collect, or NIL for all types.
+ */
void
PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inputs, bool allow_dups)
{
@@ -371,25 +373,26 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
/* Ardour stuff */
- if (!inputs && type == DataType::AUDIO) {
+ if (!inputs && (type == DataType::AUDIO || type == DataType::NIL)) {
ardour->add_bundle (session->the_auditioner()->output()->bundle());
ardour->add_bundle (session->click_io()->bundle());
}
/* Now find all other ports that we haven't thought of yet */
- std::vector<std::string> extra_system;
- std::vector<std::string> extra_other;
+ std::vector<std::string> extra_system[DataType::num_types];
+ std::vector<std::string> extra_other[DataType::num_types];
- const char **ports = session->engine().get_ports ("", type.to_jack_type(), inputs ?
- JackPortIsInput : JackPortIsOutput);
+ const char ** ports = 0;
+ if (type == DataType::NIL) {
+ ports = session->engine().get_ports ("", "", inputs ? JackPortIsInput : JackPortIsOutput);
+ } else {
+ ports = session->engine().get_ports ("", type.to_jack_type(), inputs ? JackPortIsInput : JackPortIsOutput);
+ }
+
if (ports) {
int n = 0;
- string client_matching_string;
-
- client_matching_string = session->engine().client_name();
- client_matching_string += ':';
while (ports[n]) {
@@ -411,12 +414,18 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
continue;
}
- if (port_has_prefix (p, "system:") ||
- port_has_prefix (p, "alsa_pcm") ||
- port_has_prefix (p, "ardour:")) {
- extra_system.push_back (p);
- } else {
- extra_other.push_back (p);
+ /* can't use the audio engine for this as we are looking at non-Ardour ports */
+
+ jack_port_t* jp = jack_port_by_name (session->engine().jack(), p.c_str());
+ if (jp) {
+ DataType t (jack_port_type (jp));
+ if (t != DataType::NIL) {
+ if (port_has_prefix (p, "system:") || port_has_prefix (p, "alsa_pcm") || port_has_prefix (p, "ardour:")) {
+ extra_system[t].push_back (p);
+ } else {
+ extra_other[t].push_back (p);
+ }
+ }
}
}
@@ -426,13 +435,16 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
free (ports);
}
- if (!extra_system.empty()) {
- boost::shared_ptr<Bundle> b = make_bundle_from_ports (extra_system, type, inputs);
- system->add_bundle (b);
+ 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));
+ }
}
- if (!extra_other.empty()) {
- other->add_bundle (make_bundle_from_ports (extra_other, type, inputs));
+ 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));
+ }
}
if (!allow_dups) {
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);
+}
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index 52e2f1663b..a67292829b 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -124,6 +124,9 @@ public:
std::pair<uint32_t, uint32_t> max_size () const;
+ bool should_show (ARDOUR::DataType) const;
+ uint32_t count_of_our_type (ARDOUR::ChanCount) const;
+
/** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
* @param s New state.
*/
@@ -136,7 +139,7 @@ public:
virtual bool list_is_global (int) const = 0;
virtual bool can_add_channel (boost::shared_ptr<ARDOUR::Bundle>) const;
- virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
+ virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
virtual bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
virtual void remove_channel (ARDOUR::BundleChannel);
virtual void remove_all_channels (boost::weak_ptr<ARDOUR::Bundle>);
@@ -171,7 +174,7 @@ private:
void routes_changed ();
void reconnect_to_routes ();
void select_arrangement ();
- void add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>);
+ void add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
void disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle>, uint32_t, int);
@@ -192,7 +195,7 @@ private:
Gtk::Window* _parent;
- /// port type that we are working with
+ /// port type that we are working with, or NIL if we are working with all of them
ARDOUR::DataType _type;
PBD::ScopedConnectionList _route_connections;
PBD::ScopedConnectionList _changed_connections;
diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc
index df92c51e5e..73eae929b9 100644
--- a/gtk2_ardour/port_matrix_body.cc
+++ b/gtk2_ardour/port_matrix_body.cc
@@ -77,15 +77,19 @@ PortMatrixBody::on_expose_event (GdkEventExpose* event)
cairo_rectangle (cr, 0, 0, _alloc_width, _alloc_height);
cairo_fill (cr);
- stringstream t;
- t << _("There are no ") << (_matrix->type() == ARDOUR::DataType::AUDIO ? _("audio") : _("MIDI")) << _(" ports to connect.");
+ string t;
+ if (_matrix->type() == ARDOUR::DataType::NIL) {
+ t = _("There are no ports to connect.");
+ } else {
+ t = string_compose (_("There are no %1 ports to connect."), _matrix->type().to_i18n_string());
+ }
cairo_text_extents_t ext;
- cairo_text_extents (cr, t.str().c_str(), &ext);
+ cairo_text_extents (cr, t.c_str(), &ext);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_move_to (cr, (_alloc_width - ext.width) / 2, (_alloc_height + ext.height) / 2);
- cairo_show_text (cr, t.str().c_str ());
+ cairo_show_text (cr, t.c_str ());
cairo_destroy (cr);
@@ -469,7 +473,7 @@ PortMatrixBody::highlight_associated_channels (int dim, ARDOUR::BundleChannel h)
for (PortGroup::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
- if ((*i)->bundle->channel_type(j) != _matrix->type()) {
+ if (!_matrix->should_show ((*i)->bundle->channel_type(j))) {
continue;
}
diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc
index fa1989f914..fe5158588f 100644
--- a/gtk2_ardour/port_matrix_column_labels.cc
+++ b/gtk2_ardour/port_matrix_column_labels.cc
@@ -64,7 +64,7 @@ PortMatrixColumnLabels::compute_dimensions ()
for (uint32_t k = 0; k < (*j)->bundle->nchannels().n_total(); ++k) {
- if ((*j)->bundle->channel_type(k) != _matrix->type()) {
+ if (!_matrix->should_show ((*j)->bundle->channel_type(k))) {
continue;
}
@@ -139,7 +139,7 @@ PortMatrixColumnLabels::render (cairo_t* cr)
if (_matrix->show_only_bundles()) {
x += grid_spacing();
} else {
- x += (*i)->bundle->nchannels().get(_matrix->type()) * grid_spacing();
+ x += _matrix->count_of_our_type ((*i)->bundle->nchannels()) * grid_spacing();
}
++N;
@@ -155,7 +155,7 @@ PortMatrixColumnLabels::render (cairo_t* cr)
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
- if ((*i)->bundle->channel_type(j) != _matrix->type()) {
+ if (!_matrix->should_show ((*i)->bundle->channel_type(j))) {
continue;
}
@@ -263,7 +263,7 @@ PortMatrixColumnLabels::render_bundle_name (
if (_matrix->show_only_bundles()) {
w = grid_spacing ();
} else {
- w = b->nchannels().get(_matrix->type()) * grid_spacing();
+ w = _matrix->count_of_our_type (b->nchannels()) * grid_spacing();
}
double x_ = xoff;
@@ -361,7 +361,7 @@ PortMatrixColumnLabels::render_channel_name (
);
}
- if (bc.bundle->nchannels().get(_matrix->type()) > 1) {
+ if (_matrix->count_of_our_type (bc.bundle->nchannels()) > 1) {
/* only plot the name if the bundle has more than one channel;
the name of a single channel is assumed to be redundant */
@@ -489,7 +489,7 @@ PortMatrixColumnLabels::motion (double x, double y)
for (uint32_t i = 0; i < w.bundle->nchannels().n_total(); ++i) {
- if (w.bundle->channel_type(i) != _matrix->type()) {
+ if (!_matrix->should_show (w.bundle->channel_type(i))) {
continue;
}
diff --git a/gtk2_ardour/port_matrix_component.cc b/gtk2_ardour/port_matrix_component.cc
index 720acce862..b2425dcef4 100644
--- a/gtk2_ardour/port_matrix_component.cc
+++ b/gtk2_ardour/port_matrix_component.cc
@@ -132,7 +132,7 @@ PortMatrixComponent::group_size (boost::shared_ptr<const PortGroup> g) const
s = bundles.size();
} else {
for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
- s += (*i)->bundle->nchannels().get (_matrix->type());
+ s += _matrix->count_of_our_type ((*i)->bundle->nchannels());
}
}
@@ -169,7 +169,7 @@ PortMatrixComponent::channel_to_position (ARDOUR::BundleChannel bc, boost::share
if (_matrix->show_only_bundles()) {
p += 1;
} else {
- p += (*i)->bundle->nchannels().get (_matrix->type());
+ p += _matrix->count_of_our_type ((*i)->bundle->nchannels());
}
}
@@ -195,7 +195,7 @@ PortMatrixComponent::position_to_channel (double p, double, boost::shared_ptr<co
} else {
- uint32_t const s = (*j)->bundle->nchannels().get (_matrix->type());
+ uint32_t const s = _matrix->count_of_our_type ((*j)->bundle->nchannels());
if (p < s) {
return ARDOUR::BundleChannel ((*j)->bundle, p);
} else {
diff --git a/gtk2_ardour/port_matrix_grid.cc b/gtk2_ardour/port_matrix_grid.cc
index 572b278f79..f4ca28fcd2 100644
--- a/gtk2_ardour/port_matrix_grid.cc
+++ b/gtk2_ardour/port_matrix_grid.cc
@@ -81,7 +81,7 @@ PortMatrixGrid::render (cairo_t* cr)
if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width());
- for (uint32_t j = 0; j < (*i)->bundle->nchannels().get(_matrix->type()); ++j) {
+ for (uint32_t j = 0; j < _matrix->count_of_our_type ((*i)->bundle->nchannels()); ++j) {
x += grid_spacing ();
cairo_move_to (cr, x, 0);
cairo_line_to (cr, x, _height);
@@ -111,7 +111,7 @@ PortMatrixGrid::render (cairo_t* cr)
if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width());
- for (uint32_t j = 0; j < (*i)->bundle->nchannels().get(_matrix->type()); ++j) {
+ for (uint32_t j = 0; j < _matrix->count_of_our_type ((*i)->bundle->nchannels()); ++j) {
y += grid_spacing ();
cairo_move_to (cr, 0, y);
cairo_line_to (cr, _width, y);
@@ -174,7 +174,7 @@ PortMatrixGrid::render (cairo_t* cr)
y = by;
for (uint32_t l = 0; l < (*j)->bundle->nchannels().n_total(); ++l) {
- if ((*i)->bundle->channel_type(k) != _matrix->type() || (*j)->bundle->channel_type(l) != _matrix->type()) {
+ if (!_matrix->should_show ((*i)->bundle->channel_type(k)) || !_matrix->should_show ((*j)->bundle->channel_type(l))) {
continue;
}
@@ -202,10 +202,10 @@ PortMatrixGrid::render (cairo_t* cr)
x += grid_spacing();
}
- by += (*j)->bundle->nchannels().get(_matrix->type()) * grid_spacing();
+ by += _matrix->count_of_our_type ((*j)->bundle->nchannels()) * grid_spacing();
}
- bx += (*i)->bundle->nchannels().get(_matrix->type()) * grid_spacing();
+ bx += _matrix->count_of_our_type ((*i)->bundle->nchannels()) * grid_spacing();
}
}
}
@@ -285,7 +285,7 @@ PortMatrixGrid::get_association (PortMatrixNode node) const
for (uint32_t j = 0; j < node.column.bundle->nchannels().n_total(); ++j) {
- if (node.row.bundle->channel_type(i) != _matrix->type() || node.column.bundle->channel_type(j) != _matrix->type()) {
+ if (!_matrix->should_show (node.row.bundle->channel_type(i)) || !_matrix->should_show (node.column.bundle->channel_type(j))) {
continue;
}
@@ -345,7 +345,7 @@ PortMatrixGrid::set_association (PortMatrixNode node, bool s)
for (uint32_t i = 0; i < node.column.bundle->nchannels().n_total(); ++i) {
for (uint32_t j = 0; j < node.row.bundle->nchannels().n_total(); ++j) {
- if (node.column.bundle->channel_type(i) != _matrix->type() || node.row.bundle->channel_type(j) != _matrix->type()) {
+ if (!_matrix->should_show (node.column.bundle->channel_type(i)) || !_matrix->should_show (node.row.bundle->channel_type(j))) {
continue;
}
diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc
index 30317f5619..9468744837 100644
--- a/gtk2_ardour/port_matrix_row_labels.cc
+++ b/gtk2_ardour/port_matrix_row_labels.cc
@@ -56,7 +56,7 @@ PortMatrixRowLabels::compute_dimensions ()
for (uint32_t k = 0; k < (*j)->bundle->nchannels().n_total(); ++k) {
- if ((*j)->bundle->channel_type(k) != _matrix->type()) {
+ if (!_matrix->should_show ((*j)->bundle->channel_type(k))) {
continue;
}
@@ -117,7 +117,7 @@ PortMatrixRowLabels::render (cairo_t* cr)
if (!_matrix->show_only_bundles()) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
- if ((*i)->bundle->channel_type(j) != _matrix->type()) {
+ if (!_matrix->should_show ((*i)->bundle->channel_type(j))) {
continue;
}
@@ -215,7 +215,7 @@ PortMatrixRowLabels::render_bundle_name (
{
double const x = bundle_name_x ();
- int const n = _matrix->show_only_bundles() ? 1 : b->nchannels().get(_matrix->type());
+ int const n = _matrix->show_only_bundles() ? 1 : _matrix->count_of_our_type (b->nchannels());
set_source_rgb (cr, bg_colour);
cairo_rectangle (cr, xoff + x, yoff, _longest_bundle_name + name_pad() * 2, grid_spacing() * n);
cairo_fill_preserve (cr);
@@ -248,7 +248,7 @@ PortMatrixRowLabels::render_channel_name (
cairo_text_extents (cr, bc.bundle->channel_name(bc.channel).c_str(), &ext);
double const off = (grid_spacing() - ext.height) / 2;
- if (bc.bundle->nchannels().get(_matrix->type()) > 1) {
+ if (_matrix->count_of_our_type (bc.bundle->nchannels()) > 1) {
/* only plot the name if the bundle has more than one channel;
the name of a single channel is assumed to be redundant */
@@ -335,7 +335,7 @@ PortMatrixRowLabels::motion (double x, double y)
for (uint32_t i = 0; i < w.bundle->nchannels().n_total(); ++i) {
- if (w.bundle->channel_type(i) != _matrix->type()) {
+ if (!_matrix->should_show (w.bundle->channel_type(i))) {
continue;
}
diff --git a/libs/ardour/ardour/data_type.h b/libs/ardour/ardour/data_type.h
index 36114b29a9..07ba7c60ef 100644
--- a/libs/ardour/ardour/data_type.h
+++ b/libs/ardour/ardour/data_type.h
@@ -23,6 +23,8 @@
#include <string>
#include <jack/jack.h>
+#include "i18n.h"
+
namespace ARDOUR {
@@ -88,6 +90,14 @@ public:
}
}
+ const char* to_i18n_string() const {
+ switch (_symbol) {
+ case AUDIO: return _("audio");
+ case MIDI: return _("MIDI");
+ default: return _("unknown");
+ }
+ }
+
inline operator uint32_t() const { return (uint32_t)_symbol; }
/** DataType iterator, for writing generic loops that iterate over all
diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h
index 72815c17cc..7475dbb203 100644
--- a/libs/ardour/ardour/io.h
+++ b/libs/ardour/ardour/io.h
@@ -218,7 +218,7 @@ class IO : public SessionObject, public Latent
int32_t find_port_hole (const char* base);
void setup_bundle ();
- std::string bundle_channel_name (uint32_t, uint32_t) const;
+ std::string bundle_channel_name (uint32_t, uint32_t, DataType) const;
};
} // namespace ARDOUR
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index 0cc61e1044..338705d633 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -1340,10 +1340,17 @@ IO::setup_bundle ()
snprintf(buf, sizeof (buf), _("%s out"), _name.val().c_str());
}
_bundle->set_name (buf);
- uint32_t const ni = _ports.num_ports();
- for (uint32_t i = 0; i < ni; ++i) {
- _bundle->add_channel (bundle_channel_name (i, ni), _ports.port(i)->type());
- _bundle->set_port (i, _session.engine().make_port_name_non_relative (_ports.port(i)->name()));
+
+ int c = 0;
+ for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
+
+ uint32_t const N = _ports.count().get (*i);
+ for (uint32_t j = 0; j < N; ++j) {
+ _bundle->add_channel (bundle_channel_name (j, N, *i), *i);
+ _bundle->set_port (c, _session.engine().make_port_name_non_relative (_ports.port(*i, j)->name()));
+ ++c;
+ }
+
}
_bundle->resume_signals ();
@@ -1397,18 +1404,27 @@ IO::UserBundleInfo::UserBundleInfo (IO* io, boost::shared_ptr<UserBundle> b)
}
std::string
-IO::bundle_channel_name (uint32_t c, uint32_t n) const
+IO::bundle_channel_name (uint32_t c, uint32_t n, DataType t) const
{
char buf[32];
- switch (n) {
- case 1:
- return _("mono");
- case 2:
- return c == 0 ? _("L") : _("R");
- default:
+ if (t == DataType::AUDIO) {
+
+ switch (n) {
+ case 1:
+ return _("mono");
+ case 2:
+ return c == 0 ? _("L") : _("R");
+ default:
+ snprintf (buf, sizeof(buf), _("%d"), (c + 1));
+ return buf;
+ }
+
+ } else {
+
snprintf (buf, sizeof(buf), _("%d"), (c + 1));
return buf;
+
}
return "";