Fix crash on mouseover.
git-svn-id: svn://localhost/ardour2/branches/3.0@8236 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
4a9a5dea26
commit
fb0097ca79
@ -939,3 +939,69 @@ PortMatrix::count_of_our_type (ChanCount c) const
|
|||||||
|
|
||||||
return c.get (_type);
|
return c.get (_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PortMatrixNode::State
|
||||||
|
PortMatrix::get_association (PortMatrixNode node) const
|
||||||
|
{
|
||||||
|
if (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 (!should_show (node.row.bundle->channel_type(i)) || !should_show (node.column.bundle->channel_type(j))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARDOUR::BundleChannel c[2];
|
||||||
|
c[column_index()] = ARDOUR::BundleChannel (node.row.bundle, i);
|
||||||
|
c[row_index()] = ARDOUR::BundleChannel (node.column.bundle, j);
|
||||||
|
|
||||||
|
PortMatrixNode::State const s = 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[column_index()] = node.column;
|
||||||
|
c[row_index()] = node.row;
|
||||||
|
return get_state (c);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NOTREACHED */
|
||||||
|
return PortMatrixNode::NOT_ASSOCIATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -127,6 +127,8 @@ public:
|
|||||||
bool should_show (ARDOUR::DataType) const;
|
bool should_show (ARDOUR::DataType) const;
|
||||||
uint32_t count_of_our_type (ARDOUR::ChanCount) const;
|
uint32_t count_of_our_type (ARDOUR::ChanCount) const;
|
||||||
|
|
||||||
|
PortMatrixNode::State get_association (PortMatrixNode) const;
|
||||||
|
|
||||||
/** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
|
/** @param c Channels; where c[0] is from _ports[0] and c[1] is from _ports[1].
|
||||||
* @param s New state.
|
* @param s New state.
|
||||||
*/
|
*/
|
||||||
|
@ -476,9 +476,12 @@ PortMatrixBody::highlight_associated_channels (int dim, ARDOUR::BundleChannel h)
|
|||||||
if (!_matrix->should_show ((*i)->bundle->channel_type(j))) {
|
if (!_matrix->should_show ((*i)->bundle->channel_type(j))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bc[1 - dim] = ARDOUR::BundleChannel ((*i)->bundle, j);
|
bc[1 - dim] = ARDOUR::BundleChannel ((*i)->bundle, j);
|
||||||
if (_matrix->get_state (bc) == PortMatrixNode::ASSOCIATED) {
|
|
||||||
|
PortMatrixNode n (bc[0], bc[1]);
|
||||||
|
|
||||||
|
if (_matrix->get_association(n) != PortMatrixNode::NOT_ASSOCIATED) {
|
||||||
if (dim == _matrix->column_index()) {
|
if (dim == _matrix->column_index()) {
|
||||||
_row_labels->add_channel_highlight (bc[1 - dim]);
|
_row_labels->add_channel_highlight (bc[1 - dim]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -143,7 +143,7 @@ PortMatrixGrid::render (cairo_t* cr)
|
|||||||
|
|
||||||
for (PortGroup::BundleList::const_iterator j = row_bundles.begin(); j != row_bundles.end(); ++j) {
|
for (PortGroup::BundleList::const_iterator j = row_bundles.begin(); j != row_bundles.end(); ++j) {
|
||||||
|
|
||||||
PortMatrixNode::State s = get_association (PortMatrixNode (
|
PortMatrixNode::State s = _matrix->get_association (PortMatrixNode (
|
||||||
ARDOUR::BundleChannel ((*i)->bundle, 0),
|
ARDOUR::BundleChannel ((*i)->bundle, 0),
|
||||||
ARDOUR::BundleChannel ((*j)->bundle, 0)
|
ARDOUR::BundleChannel ((*j)->bundle, 0)
|
||||||
));
|
));
|
||||||
@ -299,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
|
void
|
||||||
PortMatrixGrid::set_association (PortMatrixNode node, bool s)
|
PortMatrixGrid::set_association (PortMatrixNode node, bool s)
|
||||||
{
|
{
|
||||||
@ -408,7 +343,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint
|
|||||||
list<PortMatrixNode> const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y);
|
list<PortMatrixNode> const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y);
|
||||||
|
|
||||||
if (!p.empty()) {
|
if (!p.empty()) {
|
||||||
PortMatrixNode::State const s = get_association (p.front());
|
PortMatrixNode::State const s = _matrix->get_association (p.front());
|
||||||
for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
|
for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
|
||||||
set_association (*i, toggle_state (s));
|
set_association (*i, toggle_state (s));
|
||||||
}
|
}
|
||||||
@ -424,7 +359,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint
|
|||||||
PortMatrixNode const n = position_to_node (x, y);
|
PortMatrixNode const n = position_to_node (x, y);
|
||||||
if (n.row.bundle && n.column.bundle) {
|
if (n.row.bundle && n.column.bundle) {
|
||||||
if (s == (PortMatrixNode::State) 0) {
|
if (s == (PortMatrixNode::State) 0) {
|
||||||
s = get_association (n);
|
s = _matrix->get_association (n);
|
||||||
}
|
}
|
||||||
set_association (n, toggle_state (s));
|
set_association (n, toggle_state (s));
|
||||||
} else {
|
} else {
|
||||||
@ -438,7 +373,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint
|
|||||||
|
|
||||||
PortMatrixNode const n = position_to_node (x, y);
|
PortMatrixNode const n = position_to_node (x, y);
|
||||||
if (n.row.bundle && n.column.bundle) {
|
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));
|
set_association (n, toggle_state (s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,7 +428,7 @@ PortMatrixGrid::draw_extra (cairo_t* cr)
|
|||||||
|
|
||||||
if (!p.empty()) {
|
if (!p.empty()) {
|
||||||
|
|
||||||
bool const s = toggle_state (get_association (p.front()));
|
bool const s = toggle_state (_matrix->get_association (p.front()));
|
||||||
|
|
||||||
for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
|
for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
|
||||||
if (s) {
|
if (s) {
|
||||||
|
@ -64,7 +64,6 @@ private:
|
|||||||
void draw_empty_square (cairo_t *, uint32_t, uint32_t);
|
void draw_empty_square (cairo_t *, uint32_t, uint32_t);
|
||||||
void draw_non_connectable_indicator (cairo_t *, uint32_t, uint32_t);
|
void draw_non_connectable_indicator (cairo_t *, uint32_t, uint32_t);
|
||||||
std::list<PortMatrixNode> nodes_on_line (int, int, int, int) const;
|
std::list<PortMatrixNode> nodes_on_line (int, int, int, int) const;
|
||||||
PortMatrixNode::State get_association (PortMatrixNode) const;
|
|
||||||
void set_association (PortMatrixNode, bool);
|
void set_association (PortMatrixNode, bool);
|
||||||
bool toggle_state (PortMatrixNode::State) const;
|
bool toggle_state (PortMatrixNode::State) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user