+
+bool
+PortMatrixBody::on_leave_notify_event (GdkEventCrossing* ev)
+{
+ if (ev->type == GDK_LEAVE_NOTIFY) {
+ set_mouseover (PortMatrixNode ());
+ }
+
+ return true;
+}
+
+bool
+PortMatrixBody::on_motion_notify_event (GdkEventMotion* ev)
+{
+ if (Gdk::Region (_grid->parent_rectangle()).point_in (ev->x, ev->y)) {
+ _grid->mouseover_event (
+ _grid->parent_to_component_x (ev->x),
+ _grid->parent_to_component_y (ev->y)
+ );
+ _mouse_over_grid = true;
+ } else {
+ if (_mouse_over_grid) {
+ set_mouseover (PortMatrixNode ());
+ _mouse_over_grid = false;
+ }
+ }
+
+ return true;
+}
+
+void
+PortMatrixBody::set_mouseover (PortMatrixNode const & n)
+{
+ if (n == _mouseover) {
+ return;
+ }
+
+ PortMatrixNode old = _mouseover;
+ _mouseover = n;
+
+ _grid->mouseover_changed (old);
+ _row_labels->mouseover_changed (old);
+ _column_labels->mouseover_changed (old);
+}
+
+
+
+void
+PortMatrixBody::highlight_associated_channels (int dim, uint32_t N)
+{
+ ARDOUR::BundleChannel bc[2];
+
+ ARDOUR::BundleList const a = _matrix->ports(dim)->bundles ();
+ for (ARDOUR::BundleList::const_iterator i = a.begin(); i != a.end(); ++i) {
+ if (N < (*i)->nchannels ()) {
+ bc[dim] = ARDOUR::BundleChannel (*i, N);
+ break;
+ } else {
+ N -= (*i)->nchannels ();
+ }
+ }
+
+ if (!bc[dim].bundle) {
+ return;
+ }
+
+ if (dim == _matrix->column_index()) {
+ _column_labels->add_channel_highlight (bc[dim]);
+ } else {
+ _row_labels->add_channel_highlight (bc[dim]);
+ }
+
+ ARDOUR::BundleList const b = _matrix->ports(1 - dim)->bundles ();
+
+ for (ARDOUR::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
+ for (uint32_t j = 0; j < (*i)->nchannels(); ++j) {
+ bc[1 - dim] = ARDOUR::BundleChannel (*i, j);
+ if (_matrix->get_state (bc) == PortMatrix::ASSOCIATED) {
+ if (dim == _matrix->column_index()) {
+ _row_labels->add_channel_highlight (bc[1 - dim]);
+ } else {
+ _column_labels->add_channel_highlight (bc[1 - dim]);
+ }
+ }
+ }
+ }
+}
+
+void
+PortMatrixBody::set_cairo_clip (cairo_t* cr, Gdk::Rectangle const & r) const
+{
+ cairo_rectangle (cr, r.get_x(), r.get_y(), r.get_width(), r.get_height());
+ cairo_clip (cr);
+}
+
+void
+PortMatrixBody::component_size_changed ()
+{
+ compute_rectangles ();
+ _matrix->setup_scrollbars ();
+}
+