2009-01-20 09:46:00 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002-2009 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <cairo/cairo.h>
|
|
|
|
#include "ardour/bundle.h"
|
2009-01-25 01:47:11 -05:00
|
|
|
#include "ardour/types.h"
|
2009-01-20 09:46:00 -05:00
|
|
|
#include "port_matrix_grid.h"
|
|
|
|
#include "port_matrix.h"
|
2009-02-04 12:05:26 -05:00
|
|
|
#include "port_matrix_body.h"
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
using namespace std;
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
PortMatrixGrid::PortMatrixGrid (PortMatrix* m, PortMatrixBody* b)
|
|
|
|
: PortMatrixComponent (m, b)
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixGrid::compute_dimensions ()
|
|
|
|
{
|
|
|
|
_width = 0;
|
2009-07-17 18:54:45 -04:00
|
|
|
for (PortGroupList::List::const_iterator i = _matrix->columns()->begin(); i != _matrix->columns()->end(); ++i) {
|
|
|
|
_width += group_width (*i);
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_height = 0;
|
2009-07-17 18:54:45 -04:00
|
|
|
for (PortGroupList::List::const_iterator i = _matrix->rows()->begin(); i != _matrix->rows()->end(); ++i) {
|
|
|
|
_height += group_height (*i);
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixGrid::render (cairo_t* cr)
|
|
|
|
{
|
|
|
|
set_source_rgb (cr, background_colour());
|
|
|
|
cairo_rectangle (cr, 0, 0, _width, _height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
uint32_t x = 0;
|
|
|
|
for (PortGroupList::List::const_iterator c = _matrix->columns()->begin(); c != _matrix->columns()->end(); ++c) {
|
|
|
|
|
|
|
|
uint32_t y = 0;
|
|
|
|
for (PortGroupList::List::const_iterator r = _matrix->rows()->begin(); r != _matrix->rows()->end(); ++r) {
|
|
|
|
|
|
|
|
if ((*c)->visible() && (*r)->visible()) {
|
|
|
|
render_group_pair (cr, *r, *c, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
y += group_height (*r);
|
|
|
|
}
|
|
|
|
|
|
|
|
x += group_width (*c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixGrid::render_group_pair (cairo_t* cr, boost::shared_ptr<const PortGroup> row, boost::shared_ptr<const PortGroup> column, uint32_t const x, uint32_t const y)
|
|
|
|
{
|
|
|
|
PortGroup::BundleList const & row_bundles = row->bundles();
|
|
|
|
PortGroup::BundleList const & column_bundles = column->bundles();
|
|
|
|
|
|
|
|
/* unfortunately we need to compute the height of the row group here */
|
|
|
|
uint32_t height = group_height (row);
|
|
|
|
|
|
|
|
uint32_t tx = x;
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
/* VERTICAL GRID LINES */
|
|
|
|
|
|
|
|
set_source_rgb (cr, grid_colour());
|
2009-07-17 09:18:58 -04:00
|
|
|
uint32_t N = 0;
|
2009-07-17 18:54:45 -04:00
|
|
|
|
|
|
|
for (PortGroup::BundleList::const_iterator i = column_bundles.begin(); i != column_bundles.end(); ++i) {
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
cairo_set_line_width (cr, thick_grid_line_width());
|
|
|
|
cairo_move_to (cr, tx, y);
|
|
|
|
cairo_line_to (cr, tx, y + height);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
if (!_matrix->show_only_bundles()) {
|
|
|
|
cairo_set_line_width (cr, thin_grid_line_width());
|
2009-07-17 18:54:45 -04:00
|
|
|
for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
|
|
|
|
tx += column_width ();
|
|
|
|
cairo_move_to (cr, tx, y);
|
|
|
|
cairo_line_to (cr, tx, y + height);
|
2009-05-03 10:31:42 -04:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
2009-07-17 18:54:45 -04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
tx += column_width ();
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
++N;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t const width = tx - x;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
uint32_t ty = y;
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
/* HORIZONTAL GRID LINES */
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
N = 0;
|
2009-07-17 18:54:45 -04:00
|
|
|
for (PortGroup::BundleList::const_iterator i = row_bundles.begin(); i != row_bundles.end(); ++i) {
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, thick_grid_line_width());
|
|
|
|
cairo_move_to (cr, x, ty);
|
|
|
|
cairo_line_to (cr, x + width, ty);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
if (!_matrix->show_only_bundles()) {
|
|
|
|
cairo_set_line_width (cr, thin_grid_line_width());
|
2009-07-17 18:54:45 -04:00
|
|
|
for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
|
|
|
|
ty += row_height ();
|
|
|
|
cairo_move_to (cr, x, ty);
|
|
|
|
cairo_line_to (cr, x + width, ty);
|
2009-05-03 10:31:42 -04:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
ty += row_height ();
|
2009-07-17 09:18:58 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
}
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
++N;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
/* ASSOCIATION INDICATORS */
|
|
|
|
|
|
|
|
uint32_t bx = x;
|
|
|
|
uint32_t by = y;
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
if (_matrix->show_only_bundles()) {
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
for (PortGroup::BundleList::const_iterator i = column_bundles.begin(); i != column_bundles.end(); ++i) {
|
|
|
|
by = y;
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
for (PortGroup::BundleList::const_iterator j = row_bundles.begin(); j != row_bundles.end(); ++j) {
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
PortMatrixNode::State s = bundle_to_bundle_state (i->bundle, j->bundle);
|
2009-05-03 10:31:42 -04:00
|
|
|
switch (s) {
|
|
|
|
case PortMatrixNode::UNKNOWN:
|
|
|
|
draw_unknown_indicator (cr, bx, by);
|
|
|
|
break;
|
|
|
|
case PortMatrixNode::ASSOCIATED:
|
|
|
|
draw_association_indicator (cr, bx, by);
|
|
|
|
break;
|
|
|
|
case PortMatrixNode::PARTIAL:
|
|
|
|
draw_association_indicator (cr, bx, by, 0.5);
|
|
|
|
break;
|
2009-05-13 17:34:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
by += row_height();
|
|
|
|
}
|
|
|
|
|
|
|
|
bx += column_width();
|
2009-07-17 18:54:45 -04:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
} else {
|
2009-01-30 10:08:09 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
for (PortGroup::BundleList::const_iterator i = column_bundles.begin(); i != column_bundles.end(); ++i) {
|
|
|
|
by = y;
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
for (PortGroup::BundleList::const_iterator j = row_bundles.begin(); j != row_bundles.end(); ++j) {
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
tx = bx;
|
2009-07-17 09:18:58 -04:00
|
|
|
for (uint32_t k = 0; k < i->bundle->nchannels (); ++k) {
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
ty = by;
|
2009-07-17 09:18:58 -04:00
|
|
|
for (uint32_t l = 0; l < j->bundle->nchannels (); ++l) {
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
ARDOUR::BundleChannel c[2];
|
2009-07-17 09:18:58 -04:00
|
|
|
c[_matrix->column_index()] = ARDOUR::BundleChannel (i->bundle, k);
|
|
|
|
c[_matrix->row_index()] = ARDOUR::BundleChannel (j->bundle, l);
|
2009-05-03 10:31:42 -04:00
|
|
|
|
|
|
|
PortMatrixNode::State const s = _matrix->get_state (c);
|
|
|
|
|
|
|
|
switch (s) {
|
|
|
|
case PortMatrixNode::ASSOCIATED:
|
2009-07-17 18:54:45 -04:00
|
|
|
draw_association_indicator (cr, tx, ty);
|
2009-05-03 10:31:42 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PortMatrixNode::UNKNOWN:
|
2009-07-17 18:54:45 -04:00
|
|
|
draw_unknown_indicator (cr, tx, ty);
|
2009-05-03 10:31:42 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PortMatrixNode::NOT_ASSOCIATED:
|
|
|
|
break;
|
2009-07-17 18:54:45 -04:00
|
|
|
|
2009-05-13 17:34:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
ty += row_height();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
tx += column_width();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
by += j->bundle->nchannels () * row_height();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
bx += i->bundle->nchannels () * column_width();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
void
|
|
|
|
PortMatrixGrid::draw_association_indicator (cairo_t* cr, uint32_t x, uint32_t y, double p)
|
|
|
|
{
|
|
|
|
set_source_rgba (cr, association_colour(), 0.5);
|
|
|
|
cairo_arc (
|
|
|
|
cr,
|
|
|
|
x + column_width() / 2,
|
|
|
|
y + column_width() / 2,
|
|
|
|
(column_width() - (2 * connection_indicator_pad())) / 2,
|
|
|
|
0,
|
|
|
|
p * 2 * M_PI
|
|
|
|
);
|
|
|
|
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixGrid::draw_unknown_indicator (cairo_t* cr, uint32_t x, uint32_t y)
|
|
|
|
{
|
|
|
|
set_source_rgba (cr, unknown_colour(), 0.5);
|
|
|
|
cairo_rectangle (
|
|
|
|
cr,
|
|
|
|
x + thick_grid_line_width(),
|
|
|
|
y + thick_grid_line_width(),
|
|
|
|
column_width() - 2 * thick_grid_line_width(),
|
|
|
|
row_height() - 2 * thick_grid_line_width()
|
|
|
|
);
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
PortMatrixNode
|
|
|
|
PortMatrixGrid::position_to_node (double x, double y) const
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-01-26 23:21:13 -05:00
|
|
|
return PortMatrixNode (
|
2009-07-17 18:54:45 -04:00
|
|
|
y_position_to_group_and_channel (y).second,
|
|
|
|
x_position_to_group_and_channel (x).second
|
2009-01-26 23:21:13 -05:00
|
|
|
);
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel>
|
|
|
|
PortMatrixGrid::x_position_to_group_and_channel (double x) const
|
2009-01-26 23:21:13 -05:00
|
|
|
{
|
2009-07-17 18:54:45 -04:00
|
|
|
PortGroupList::List::const_iterator i = _matrix->columns()->begin();
|
2009-01-26 23:21:13 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
while (i != _matrix->columns()->end()) {
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
uint32_t const gw = group_width (*i);
|
|
|
|
|
|
|
|
if (x < gw) {
|
|
|
|
|
|
|
|
/* it's in this group */
|
|
|
|
|
|
|
|
PortGroup::BundleList const & bundles = (*i)->bundles ();
|
|
|
|
for (PortGroup::BundleList::const_iterator j = bundles.begin(); j != bundles.end(); ++j) {
|
|
|
|
|
|
|
|
if (_matrix->show_only_bundles()) {
|
|
|
|
|
|
|
|
if (x < column_width()) {
|
|
|
|
return make_pair (*i, ARDOUR::BundleChannel (j->bundle, 0));
|
|
|
|
} else {
|
|
|
|
x -= column_width ();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
uint32_t const w = j->bundle->nchannels () * column_width ();
|
|
|
|
if (x < w) {
|
|
|
|
return make_pair (*i, ARDOUR::BundleChannel (j->bundle, x / column_width()));
|
|
|
|
} else {
|
|
|
|
x -= w;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-05-03 10:31:42 -04:00
|
|
|
|
|
|
|
}
|
2009-07-17 18:54:45 -04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
x -= gw;
|
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
2009-07-17 18:54:45 -04:00
|
|
|
|
|
|
|
++i;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
2009-07-17 18:54:45 -04:00
|
|
|
|
|
|
|
return make_pair (boost::shared_ptr<PortGroup> (), ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), 0));
|
2009-01-26 23:21:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
double
|
|
|
|
PortMatrixGrid::channel_position (
|
2009-01-30 10:08:09 -05:00
|
|
|
ARDOUR::BundleChannel bc,
|
2009-07-17 09:18:58 -04:00
|
|
|
PortGroup::BundleList const& bundles,
|
2009-01-26 23:21:13 -05:00
|
|
|
double inc) const
|
|
|
|
{
|
|
|
|
double p = 0;
|
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
PortGroup::BundleList::const_iterator i = bundles.begin ();
|
|
|
|
while (i != bundles.end() && i->bundle != bc.bundle) {
|
2009-05-03 10:31:42 -04:00
|
|
|
|
|
|
|
if (_matrix->show_only_bundles()) {
|
|
|
|
p += inc;
|
|
|
|
} else {
|
2009-07-17 09:18:58 -04:00
|
|
|
p += inc * i->bundle->nchannels();
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
++i;
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
if (i == bundles.end()) {
|
|
|
|
return 0;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
p += inc * bc.channel;
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-17 18:54:45 -04:00
|
|
|
PortMatrixGrid::button_press (double x, double y, int b, uint32_t t)
|
2009-01-26 23:21:13 -05:00
|
|
|
{
|
2009-07-17 18:54:45 -04:00
|
|
|
if (b == 1) {
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
PortMatrixNode const node = position_to_node (x, y);
|
|
|
|
|
|
|
|
if (_matrix->show_only_bundles()) {
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
PortMatrixNode::State const s = bundle_to_bundle_state (node.column.bundle, node.row.bundle);
|
2009-01-23 20:17:26 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
for (uint32_t i = 0; i < node.column.bundle->nchannels(); ++i) {
|
|
|
|
for (uint32_t j = 0; j < node.row.bundle->nchannels(); ++j) {
|
|
|
|
|
|
|
|
ARDOUR::BundleChannel c[2];
|
|
|
|
c[_matrix->column_index()] = ARDOUR::BundleChannel (node.column.bundle, i);
|
|
|
|
c[_matrix->row_index()] = ARDOUR::BundleChannel (node.row.bundle, j);
|
|
|
|
if (s == PortMatrixNode::NOT_ASSOCIATED || s == PortMatrixNode::PARTIAL) {
|
|
|
|
_matrix->set_state (c, i == j);
|
|
|
|
} else {
|
|
|
|
_matrix->set_state (c, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
if (node.row.bundle && node.column.bundle) {
|
2009-05-03 10:31:42 -04:00
|
|
|
|
|
|
|
ARDOUR::BundleChannel c[2];
|
|
|
|
c[_matrix->row_index()] = node.row;
|
|
|
|
c[_matrix->column_index()] = node.column;
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
PortMatrixNode::State const s = _matrix->get_state (c);
|
|
|
|
|
|
|
|
if (s == PortMatrixNode::ASSOCIATED || s == PortMatrixNode::NOT_ASSOCIATED) {
|
|
|
|
|
|
|
|
bool const n = !(s == PortMatrixNode::ASSOCIATED);
|
|
|
|
|
|
|
|
ARDOUR::BundleChannel c[2];
|
|
|
|
c[_matrix->row_index()] = node.row;
|
|
|
|
c[_matrix->column_index()] = node.column;
|
|
|
|
|
|
|
|
_matrix->set_state (c, n);
|
|
|
|
}
|
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
2009-01-23 20:17:26 -05:00
|
|
|
}
|
2009-07-17 18:54:45 -04:00
|
|
|
|
|
|
|
require_render ();
|
|
|
|
_body->queue_draw ();
|
2009-05-03 10:31:42 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
} else if (b == 3) {
|
|
|
|
|
|
|
|
_matrix->popup_menu (x_position_to_group_and_channel (x), y_position_to_group_and_channel (y), t);
|
|
|
|
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
void
|
|
|
|
PortMatrixGrid::draw_extra (cairo_t* cr)
|
|
|
|
{
|
|
|
|
set_source_rgba (cr, mouseover_line_colour(), 0.3);
|
|
|
|
cairo_set_line_width (cr, mouseover_line_width());
|
|
|
|
|
2009-01-27 13:56:06 -05:00
|
|
|
double const x = component_to_parent_x (
|
2009-01-30 10:08:09 -05:00
|
|
|
channel_position (_body->mouseover().column, _matrix->columns()->bundles(), column_width()) + column_width() / 2
|
2009-01-27 13:56:06 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
double const y = component_to_parent_y (
|
2009-01-30 10:08:09 -05:00
|
|
|
channel_position (_body->mouseover().row, _matrix->rows()->bundles(), row_height()) + row_height() / 2
|
2009-01-27 13:56:06 -05:00
|
|
|
);
|
|
|
|
|
2009-01-26 23:21:13 -05:00
|
|
|
if (_body->mouseover().row.bundle) {
|
|
|
|
|
2009-01-27 13:56:06 -05:00
|
|
|
cairo_move_to (cr, x, y);
|
2009-01-30 10:08:09 -05:00
|
|
|
if (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM) {
|
2009-01-27 13:56:06 -05:00
|
|
|
cairo_line_to (cr, component_to_parent_x (0), y);
|
2009-01-30 10:08:09 -05:00
|
|
|
} else if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
|
2009-01-27 13:56:06 -05:00
|
|
|
cairo_line_to (cr, _parent_rectangle.get_x() + _parent_rectangle.get_width(), y);
|
|
|
|
}
|
2009-01-26 23:21:13 -05:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_body->mouseover().column.bundle) {
|
|
|
|
|
2009-01-27 13:56:06 -05:00
|
|
|
cairo_move_to (cr, x, y);
|
2009-01-30 10:08:09 -05:00
|
|
|
if (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM) {
|
2009-01-27 13:56:06 -05:00
|
|
|
cairo_line_to (cr, x, _parent_rectangle.get_y() + _parent_rectangle.get_height());
|
2009-01-30 10:08:09 -05:00
|
|
|
} else if (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT) {
|
2009-01-27 13:56:06 -05:00
|
|
|
cairo_line_to (cr, x, component_to_parent_y (0));
|
|
|
|
}
|
2009-01-26 23:21:13 -05:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixGrid::mouseover_changed (PortMatrixNode const& old)
|
|
|
|
{
|
|
|
|
queue_draw_for (old);
|
|
|
|
queue_draw_for (_body->mouseover());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixGrid::mouseover_event (double x, double y)
|
|
|
|
{
|
|
|
|
_body->set_mouseover (position_to_node (x, y));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortMatrixGrid::queue_draw_for (PortMatrixNode const &n)
|
|
|
|
{
|
|
|
|
if (n.row.bundle) {
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
double const y = channel_position (n.row, _matrix->rows()->bundles(), row_height());
|
2009-01-26 23:21:13 -05:00
|
|
|
_body->queue_draw_area (
|
|
|
|
_parent_rectangle.get_x(),
|
|
|
|
component_to_parent_y (y),
|
|
|
|
_parent_rectangle.get_width(),
|
|
|
|
row_height()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n.column.bundle) {
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
double const x = channel_position (n.column, _matrix->columns()->bundles(), column_width());
|
2009-01-26 23:21:13 -05:00
|
|
|
|
|
|
|
_body->queue_draw_area (
|
|
|
|
component_to_parent_x (x),
|
|
|
|
_parent_rectangle.get_y(),
|
|
|
|
column_width(),
|
|
|
|
_parent_rectangle.get_height()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
PortMatrixGrid::component_to_parent_x (double x) const
|
|
|
|
{
|
|
|
|
return x - _body->xoffset() + _parent_rectangle.get_x();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
PortMatrixGrid::parent_to_component_x (double x) const
|
|
|
|
{
|
|
|
|
return x + _body->xoffset() - _parent_rectangle.get_x();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
PortMatrixGrid::component_to_parent_y (double y) const
|
|
|
|
{
|
|
|
|
return y - _body->yoffset() + _parent_rectangle.get_y();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
PortMatrixGrid::parent_to_component_y (double y) const
|
|
|
|
{
|
|
|
|
return y + _body->yoffset() - _parent_rectangle.get_y();
|
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
PortMatrixNode::State
|
|
|
|
PortMatrixGrid::bundle_to_bundle_state (boost::shared_ptr<ARDOUR::Bundle> a, boost::shared_ptr<ARDOUR::Bundle> b) const
|
|
|
|
{
|
|
|
|
bool have_unknown = false;
|
|
|
|
bool have_off_diagonal_association = false;
|
|
|
|
bool have_diagonal_association = false;
|
|
|
|
bool have_diagonal_not_association = false;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < a->nchannels (); ++i) {
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < b->nchannels (); ++j) {
|
|
|
|
|
|
|
|
ARDOUR::BundleChannel c[2];
|
|
|
|
c[_matrix->column_index()] = ARDOUR::BundleChannel (a, i);
|
|
|
|
c[_matrix->row_index()] = ARDOUR::BundleChannel (b, 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::UNKNOWN:
|
|
|
|
have_unknown = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PortMatrixNode::NOT_ASSOCIATED:
|
|
|
|
if (i == j) {
|
|
|
|
have_diagonal_not_association = true;
|
|
|
|
}
|
|
|
|
break;
|
2009-05-13 17:34:09 -04:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (have_unknown) {
|
|
|
|
return PortMatrixNode::UNKNOWN;
|
|
|
|
} else 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|