X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fport_matrix_grid.cc;h=96e9cb949ca905e038c43cef37946eaba8ddd5cb;hb=40e2a6b16b47acf1f19a31f5e6d1cd463c45e1b6;hp=f4ca28fcd2da1b55c975ad884b1a91a212993ce3;hpb=92e412661772e6b9c83109b7ee4996f4c040d3f4;p=ardour.git diff --git a/gtk2_ardour/port_matrix_grid.cc b/gtk2_ardour/port_matrix_grid.cc index f4ca28fcd2..96e9cb949c 100644 --- a/gtk2_ardour/port_matrix_grid.cc +++ b/gtk2_ardour/port_matrix_grid.cc @@ -127,7 +127,11 @@ PortMatrixGrid::render (cairo_t* cr) ++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; @@ -139,9 +143,9 @@ PortMatrixGrid::render (cairo_t* cr) 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) + PortMatrixNode::State s = _matrix->get_association (PortMatrixNode ( + ARDOUR::BundleChannel ((*j)->bundle, 0), + ARDOUR::BundleChannel ((*i)->bundle, 0) )); switch (s) { case PortMatrixNode::ASSOCIATED: @@ -182,18 +186,24 @@ PortMatrixGrid::render (cairo_t* cr) 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; - - case PortMatrixNode::NOT_ASSOCIATED: - break; - - 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(); @@ -241,6 +251,23 @@ PortMatrixGrid::draw_empty_square (cairo_t* cr, uint32_t x, uint32_t y) 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 { @@ -272,71 +299,6 @@ PortMatrixGrid::button_press (double x, double y, int b, uint32_t t, guint) } } -PortMatrixNode::State -PortMatrixGrid::get_association (PortMatrixNode node) const -{ - if (_matrix->show_only_bundles()) { - - bool have_off_diagonal_association = false; - bool have_diagonal_association = false; - bool have_diagonal_not_association = false; - - for (uint32_t i = 0; i < node.row.bundle->nchannels().n_total(); ++i) { - - 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); - c[_matrix->row_index()] = ARDOUR::BundleChannel (node.column.bundle, j); - - PortMatrixNode::State const s = _matrix->get_state (c); - - switch (s) { - case PortMatrixNode::ASSOCIATED: - if (i == j) { - have_diagonal_association = true; - } else { - have_off_diagonal_association = true; - } - break; - - case PortMatrixNode::NOT_ASSOCIATED: - if (i == j) { - have_diagonal_not_association = true; - } - break; - - default: - break; - } - } - } - - if (have_diagonal_association && !have_off_diagonal_association && !have_diagonal_not_association) { - return PortMatrixNode::ASSOCIATED; - } else if (!have_diagonal_association && !have_off_diagonal_association) { - return PortMatrixNode::NOT_ASSOCIATED; - } - - return PortMatrixNode::PARTIAL; - - } else { - - ARDOUR::BundleChannel c[2]; - c[_matrix->column_index()] = node.column; - c[_matrix->row_index()] = node.row; - return _matrix->get_state (c); - - } - - /* NOTREACHED */ - return PortMatrixNode::NOT_ASSOCIATED; -} - void PortMatrixGrid::set_association (PortMatrixNode node, bool s) { @@ -381,7 +343,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint list const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y); if (!p.empty()) { - PortMatrixNode::State const s = get_association (p.front()); + PortMatrixNode::State const s = _matrix->get_association (p.front()); for (list::const_iterator i = p.begin(); i != p.end(); ++i) { set_association (*i, toggle_state (s)); } @@ -397,7 +359,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint PortMatrixNode const n = position_to_node (x, y); if (n.row.bundle && n.column.bundle) { if (s == (PortMatrixNode::State) 0) { - s = get_association (n); + s = _matrix->get_association (n); } set_association (n, toggle_state (s)); } else { @@ -411,7 +373,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint PortMatrixNode const n = position_to_node (x, y); if (n.row.bundle && n.column.bundle) { - PortMatrixNode::State const s = get_association (n); + PortMatrixNode::State const s = _matrix->get_association (n); set_association (n, toggle_state (s)); } } @@ -466,7 +428,7 @@ PortMatrixGrid::draw_extra (cairo_t* cr) if (!p.empty()) { - bool const s = toggle_state (get_association (p.front())); + bool const s = toggle_state (_matrix->get_association (p.front())); for (list::const_iterator i = p.begin(); i != p.end(); ++i) { if (s) {