From f2dbcec61d22f6e5aa483c9c787b660e691f85ad Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 17 Nov 2009 00:30:42 +0000 Subject: The matrix used to highlight connections on click-hold on a row or column label; now this happens, without a click, on any mouseover. Also mouseover a bundle name highlights everything connected to that bundle. Some cleanups along the way. git-svn-id: svn://localhost/ardour2/branches/3.0@6102 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_matrix_column_labels.cc | 95 +++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 25 deletions(-) (limited to 'gtk2_ardour/port_matrix_column_labels.cc') diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc index 5dcb710e7e..cfe6453fc7 100644 --- a/gtk2_ardour/port_matrix_column_labels.cc +++ b/gtk2_ardour/port_matrix_column_labels.cc @@ -215,11 +215,19 @@ PortMatrixColumnLabels::parent_to_component_y (double y) const } void -PortMatrixColumnLabels::mouseover_changed (PortMatrixNode const &) +PortMatrixColumnLabels::mouseover_changed (list const &) { - clear_channel_highlights (); - if (_body->mouseover().column.bundle && _body->mouseover().row.bundle) { - add_channel_highlight (_body->mouseover().column); + list const m = _body->mouseover (); + for (list::const_iterator i = m.begin(); i != m.end(); ++i) { + + ARDOUR::BundleChannel c = i->column; + ARDOUR::BundleChannel r = i->row; + + if (c.bundle && r.bundle) { + add_channel_highlight (c); + } else if (c.bundle) { + _body->highlight_associated_channels (_matrix->column_index(), c); + } } } @@ -447,46 +455,49 @@ PortMatrixColumnLabels::queue_draw_for (ARDOUR::BundleChannel const & bc) } } -void -PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t) +pair, ARDOUR::BundleChannel> +PortMatrixColumnLabels::position_to_group_and_channel (double p, double o, PortGroupList const * groups) const { uint32_t cx = 0; uint32_t const gh = _highest_group_name + 2 * name_pad(); bool group_name = false; if (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM) { - if (y > (_height - gh)) { + if (o > (_height - gh)) { group_name = true; - cx = x; + cx = p; } else { - cx = x - (_height - gh - y) * tan (angle ()); + cx = p - (_height - gh - o) * tan (angle ()); } } else { - if (y < gh) { + if (o < gh) { group_name = true; - cx = x - _overhang; + cx = p - _overhang; } else { - cx = x - (_height - y) * tan (angle ()); + cx = p - (_height - o) * tan (angle ()); } } - pair, ARDOUR::BundleChannel> gc = position_to_group_and_channel (cx / grid_spacing(), _matrix->columns()); + pair, ARDOUR::BundleChannel> w = PortMatrixComponent::position_to_group_and_channel (cx, o, groups); - if (b == 1) { + if (group_name) { + w.second.bundle.reset (); + } - if (group_name && gc.first) { - gc.first->set_visible (!gc.first->visible ()); - } else if (gc.second.bundle) { - _body->highlight_associated_channels (_matrix->column_index(), gc.second); - } + return w; +} - } else if (b == 3) { +void +PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t) +{ + pair, ARDOUR::BundleChannel> gc = position_to_group_and_channel (x, y, _matrix->columns()); - _matrix->popup_menu ( - gc, - make_pair (boost::shared_ptr (), ARDOUR::BundleChannel ()), - t - ); + if (b == 3) { + _matrix->popup_menu ( + gc, + make_pair (boost::shared_ptr (), ARDOUR::BundleChannel ()), + t + ); } } @@ -555,3 +566,37 @@ PortMatrixColumnLabels::draw_extra (cairo_t* cr) } } + +void +PortMatrixColumnLabels::motion (double x, double y) +{ + pair, ARDOUR::BundleChannel> const w = position_to_group_and_channel (x, y, _matrix->columns()); + + if (w.second.bundle == 0) { + _body->set_mouseover (PortMatrixNode ()); + return; + } + + uint32_t const bh = _highest_group_name + _longest_channel_name * sin (angle ()) + _highest_text / cos (angle ()); + + if ( + (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM && y > bh) || + (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT && y < (_height - bh)) + ) { + + /* if the mouse is over a bundle name, highlight all channels in the bundle */ + + list n; + + for (uint32_t i = 0; i < w.second.bundle->nchannels(); ++i) { + ARDOUR::BundleChannel const bc (w.second.bundle, i); + n.push_back (PortMatrixNode (ARDOUR::BundleChannel (), bc)); + } + + _body->set_mouseover (n); + + } else { + + _body->set_mouseover (PortMatrixNode (ARDOUR::BundleChannel (), w.second)); + } +} -- cgit v1.2.3