Cleanup to previous commit.
authorCarl Hetherington <carl@carlh.net>
Sat, 18 Jul 2009 02:27:36 +0000 (02:27 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 18 Jul 2009 02:27:36 +0000 (02:27 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5376 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/port_matrix_grid.cc
gtk2_ardour/port_matrix_grid.h

index 06c1925ec9ab1f444efbdf1e252767fedba9e832..66bf09aaa72f56bc9f3e022936f1b9b2b3d0e6ea 100644 (file)
@@ -289,6 +289,73 @@ PortMatrixGrid::button_press (double x, double y, int b, uint32_t t)
        }
 }
 
+void
+PortMatrixGrid::set_association (PortMatrixNode node)
+{
+       if (_matrix->show_only_bundles()) {
+                               
+               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);
+                               _matrix->set_state (c, true);
+                       }
+               }
+               
+       } else {
+               
+               if (node.row.bundle && node.column.bundle) {
+                       
+                       ARDOUR::BundleChannel c[2];
+                       c[_matrix->row_index()] = node.row;
+                       c[_matrix->column_index()] = node.column;
+                       _matrix->set_state (c, true);
+               }
+       }
+}
+
+void
+PortMatrixGrid::toggle_association (PortMatrixNode node)
+{
+       if (_matrix->show_only_bundles()) {
+                               
+               PortMatrixNode::State const s = bundle_to_bundle_state (node.column.bundle, node.row.bundle);
+               
+               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);
+                               }
+                       }
+               }
+               
+       } else {
+               
+               if (node.row.bundle && node.column.bundle) {
+                       
+                       ARDOUR::BundleChannel c[2];
+                       c[_matrix->row_index()] = node.row;
+                       c[_matrix->column_index()] = node.column;
+                       
+                       PortMatrixNode::State const s = _matrix->get_state (c);
+                       
+                       if (s == PortMatrixNode::ASSOCIATED || s == PortMatrixNode::NOT_ASSOCIATED) {
+                               bool const n = !(s == PortMatrixNode::ASSOCIATED);
+                               _matrix->set_state (c, n);
+                       }
+                       
+               }
+       }
+}
+
 void
 PortMatrixGrid::button_release (double x, double y, int b, uint32_t t)
 {
@@ -298,71 +365,17 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t t)
 
                        list<PortMatrixNode> const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y);
 
-                       if (_matrix->show_only_bundles()) {
-                               /* XXX: err... */
-                       } else {
-                               for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
-
-                                       ARDOUR::BundleChannel c[2];
-                                       c[_matrix->row_index()] = i->row;
-                                       c[_matrix->column_index()] = i->column;
-
-                                       PortMatrixNode::State const s = _matrix->get_state (c);
-
-                                       if (s == PortMatrixNode::ASSOCIATED || s == PortMatrixNode::NOT_ASSOCIATED) {
-                                               bool const n = !(s == PortMatrixNode::ASSOCIATED);
-                                               _matrix->set_state (c, n);
-                                       }
-                               }
+                       for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
+                               set_association (*i);
                        }
 
-                       require_render ();
-                       _body->queue_draw ();
-
                } else {
 
-                       PortMatrixNode const node = position_to_node (x / grid_spacing(), y / grid_spacing());
-                       
-                       if (_matrix->show_only_bundles()) {
-                               
-                               PortMatrixNode::State const s = bundle_to_bundle_state (node.column.bundle, node.row.bundle);
-                               
-                               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);
-                                               }
-                                       }
-                               }
-                               
-                       } else {
-                               
-                               if (node.row.bundle && node.column.bundle) {
-                                       
-                                       ARDOUR::BundleChannel c[2];
-                                       c[_matrix->row_index()] = node.row;
-                                       c[_matrix->column_index()] = node.column;
-                                       
-                                       PortMatrixNode::State const s = _matrix->get_state (c);
-                                       
-                                       if (s == PortMatrixNode::ASSOCIATED || s == PortMatrixNode::NOT_ASSOCIATED) {
-                                               
-                                               bool const n = !(s == PortMatrixNode::ASSOCIATED);
-                                               _matrix->set_state (c, n);
-                                       }
-                                       
-                               }
-                       }
-                       
-                       require_render ();
-                       _body->queue_draw ();
+                       toggle_association (position_to_node (x / grid_spacing(), y / grid_spacing()));
                }
+
+               require_render ();
+               _body->queue_draw ();
        }
 
        _dragging = false;
index 22050ece87415d0da91da5554628a32b9306a13d..22abe5fe43ffa6ef1c4e8e40ab82a84b73f0698c 100644 (file)
@@ -64,6 +64,8 @@ private:
        void draw_unknown_indicator (cairo_t *, uint32_t, uint32_t);
        PortMatrixNode::State bundle_to_bundle_state (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::Bundle>) const;
        std::list<PortMatrixNode> nodes_on_line (int, int, int, int) const;
+       void toggle_association (PortMatrixNode node);
+       void set_association (PortMatrixNode node);
 
        bool _dragging;
        bool _moved;