void
PortMatrixGrid::compute_dimensions ()
{
- if (_matrix->visible_columns() == 0) {
- _width = 0;
- } else {
+ if (_matrix->visible_columns()) {
_width = group_size (_matrix->visible_columns()) * grid_spacing ();
+ } else {
+ _width = 0;
}
- if (_matrix->visible_rows() == 0) {
- _height = 0;
- } else {
+ if (_matrix->visible_rows()) {
_height = group_size (_matrix->visible_rows()) * grid_spacing ();
+ } else {
+ _height = 0;
}
}
if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width());
- for (uint32_t j = 0; j < i->bundle->nchannels(); ++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);
if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width());
- for (uint32_t j = 0; j < i->bundle->nchannels(); ++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);
++N;
}
- /* ASSOCIATION INDICATORS */
+ /* ASSOCIATION INDICATORS and NON-CONNECTABLE INDICATORS */
+
+ /* we draw a grey square in a matrix box if the two ports that intersect at that box
+ cannot be connected because they are of different types (MIDI vs. audio)
+ */
uint32_t bx = 0;
uint32_t by = 0;
for (PortGroup::BundleList::const_iterator j = row_bundles.begin(); j != row_bundles.end(); ++j) {
PortMatrixNode::State s = get_association (PortMatrixNode (
- ARDOUR::BundleChannel (i->bundle, 0),
- ARDOUR::BundleChannel (j->bundle, 0)
+ ARDOUR::BundleChannel ((*i)->bundle, 0),
+ ARDOUR::BundleChannel ((*j)->bundle, 0)
));
switch (s) {
case PortMatrixNode::ASSOCIATED:
for (PortGroup::BundleList::const_iterator j = row_bundles.begin(); j != row_bundles.end(); ++j) {
x = bx;
- for (uint32_t k = 0; k < i->bundle->nchannels (); ++k) {
+ for (uint32_t k = 0; k < (*i)->bundle->nchannels().n_total(); ++k) {
y = by;
- for (uint32_t l = 0; l < j->bundle->nchannels (); ++l) {
+ for (uint32_t l = 0; l < (*j)->bundle->nchannels().n_total(); ++l) {
- ARDOUR::BundleChannel c[2];
- c[_matrix->column_index()] = ARDOUR::BundleChannel (i->bundle, k);
- c[_matrix->row_index()] = ARDOUR::BundleChannel (j->bundle, l);
-
- PortMatrixNode::State const s = _matrix->get_state (c);
-
- switch (s) {
- case PortMatrixNode::ASSOCIATED:
- draw_association_indicator (cr, x, y);
- break;
+ if (!_matrix->should_show ((*i)->bundle->channel_type(k)) || !_matrix->should_show ((*j)->bundle->channel_type(l))) {
+ continue;
+ }
- case PortMatrixNode::NOT_ASSOCIATED:
- break;
+ ARDOUR::BundleChannel c[2];
+ c[_matrix->column_index()] = ARDOUR::BundleChannel ((*i)->bundle, k);
+ c[_matrix->row_index()] = ARDOUR::BundleChannel ((*j)->bundle, l);
- default:
- break;
+ if (c[0].bundle->channel_type (c[0].channel) != c[1].bundle->channel_type (c[1].channel)) {
+ /* these two channels are of different types */
+ draw_non_connectable_indicator (cr, x, y);
+ } else {
+ /* these two channels might be associated */
+ PortMatrixNode::State const s = _matrix->get_state (c);
+
+ switch (s) {
+ case PortMatrixNode::ASSOCIATED:
+ draw_association_indicator (cr, x, y);
+ break;
+
+ case PortMatrixNode::NOT_ASSOCIATED:
+ break;
+
+ default:
+ break;
+ }
}
y += grid_spacing();
x += grid_spacing();
}
- by += j->bundle->nchannels () * grid_spacing();
+ by += _matrix->count_of_our_type ((*j)->bundle->nchannels()) * grid_spacing();
}
- bx += i->bundle->nchannels () * grid_spacing();
+ bx += _matrix->count_of_our_type ((*i)->bundle->nchannels()) * grid_spacing();
}
}
}
cairo_fill (cr);
}
+/** Draw a square to indicate that two channels in a matrix cannot be associated
+ * with each other.
+ */
+void
+PortMatrixGrid::draw_non_connectable_indicator (cairo_t* cr, uint32_t x, uint32_t y)
+{
+ set_source_rgb (cr, non_connectable_colour ());
+ cairo_rectangle (
+ cr,
+ x + thick_grid_line_width(),
+ y + thick_grid_line_width(),
+ grid_spacing() - 2 * thick_grid_line_width(),
+ grid_spacing() - 2 * thick_grid_line_width()
+ );
+ cairo_fill (cr);
+}
+
PortMatrixNode
PortMatrixGrid::position_to_node (double x, double y) const
{
bool have_diagonal_association = false;
bool have_diagonal_not_association = false;
- for (uint32_t i = 0; i < node.row.bundle->nchannels (); ++i) {
+ for (uint32_t i = 0; i < node.row.bundle->nchannels().n_total(); ++i) {
- for (uint32_t j = 0; j < node.column.bundle->nchannels (); ++j) {
+ for (uint32_t j = 0; j < node.column.bundle->nchannels().n_total(); ++j) {
+
+ if (!_matrix->should_show (node.row.bundle->channel_type(i)) || !_matrix->should_show (node.column.bundle->channel_type(j))) {
+ continue;
+ }
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (node.row.bundle, i);
{
if (_matrix->show_only_bundles()) {
- for (uint32_t i = 0; i < node.column.bundle->nchannels(); ++i) {
- for (uint32_t j = 0; j < node.row.bundle->nchannels(); ++j) {
+ 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 (!_matrix->should_show (node.column.bundle->channel_type(i)) || !_matrix->should_show (node.row.bundle->channel_type(j))) {
+ continue;
+ }
+
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (node.column.bundle, i);
c[_matrix->row_index()] = ARDOUR::BundleChannel (node.row.bundle, j);