-
- 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);
+
+ _matrix->set_state (c, s);
+ }
+ }
+}
+
+void
+PortMatrixGrid::button_release (double x, double y, GdkEventButton* ev)
+{
+ if (ev->button == 1) {
+
+ if (x != -1) {
+
+ if (_dragging && _moved) {
+
+ if (_drag_valid) {
+ list<PortMatrixNode> const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y);
+
+ if (!p.empty()) {
+ PortMatrixNode::State const s = _matrix->get_association (p.front());
+ for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
+ set_association (*i, toggle_state (s));
+ }
+ }
+ }
+
+ } else {
+
+ if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
+ /* associate/disassociate things diagonally down and right until we run out */
+ PortMatrixNode::State s = (PortMatrixNode::State) 0;
+ while (1) {
+ PortMatrixNode const n = position_to_node (x, y);
+ if (n.row.bundle && n.column.bundle) {
+ if (s == (PortMatrixNode::State) 0) {
+ s = _matrix->get_association (n);
+ }
+ set_association (n, toggle_state (s));
+ } else {
+ break;
+ }
+ x += grid_spacing ();
+ y += grid_spacing ();
+ }
+
+ } else {
+
+ PortMatrixNode const n = position_to_node (x, y);
+ if (n.row.bundle && n.column.bundle) {
+ PortMatrixNode::State const s = _matrix->get_association (n);
+ set_association (n, toggle_state (s));
+ }
+ }