Fix a few SNAFUs with the port matrix after recent changes.
authorCarl Hetherington <carl@carlh.net>
Sun, 14 Aug 2011 18:12:33 +0000 (18:12 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 14 Aug 2011 18:12:33 +0000 (18:12 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9992 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/port_matrix_column_labels.cc
gtk2_ardour/port_matrix_grid.cc

index eba2fffddf632f10e0da4f4c2d5560021267518b..30ff67b9b2bdb7d3d1007bbe92aff12b728ff157 100644 (file)
@@ -133,18 +133,8 @@ PortMatrixColumnLabels::render (cairo_t* cr)
        PortGroup::BundleList const & bundles = _matrix->visible_columns()->bundles ();
        for (PortGroup::BundleList::const_iterator i = bundles.begin (); i != bundles.end(); ++i) {
 
-               bool should_show_this_bundle = false;
-               for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
-                       if (_matrix->should_show ((*i)->bundle->channel_type (j))) {
-                               should_show_this_bundle = true;
-                               break;
-                       }
-               }
-
-               if (should_show_this_bundle) {
-                       Gdk::Color c = (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (N);
-                       render_bundle_name (cr, background_colour (), c, x, 0, (*i)->bundle);
-               }
+               Gdk::Color c = (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (N);
+               render_bundle_name (cr, background_colour (), c, x, 0, (*i)->bundle);
 
                if (_matrix->show_only_bundles()) {
                        x += grid_spacing();
@@ -163,17 +153,18 @@ PortMatrixColumnLabels::render (cairo_t* cr)
 
                for (PortGroup::BundleList::const_iterator i = bundles.begin (); i != bundles.end(); ++i) {
 
-                       for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
-
-                               if (!_matrix->should_show ((*i)->bundle->channel_type(j))) {
-                                       continue;
-                               }
+                       uint32_t const C = _matrix->count_of_our_type ((*i)->bundle->nchannels ());
 
+                       for (uint32_t j = 0; j < C; ++j) {
                                Gdk::Color c = (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (N);
                                render_channel_name (cr, background_colour (), c, x, 0, ARDOUR::BundleChannel ((*i)->bundle, j));
                                x += grid_spacing();
                        }
 
+                       if (C == 0) {
+                               x += grid_spacing ();
+                       }
+
                        ++N;
                }
        }
@@ -497,12 +488,9 @@ PortMatrixColumnLabels::motion (double x, double y)
 
                list<PortMatrixNode> n;
 
-               for (uint32_t i = 0; i < w.bundle->nchannels().n_total(); ++i) {
-
-                       if (!_matrix->should_show (w.bundle->channel_type(i))) {
-                               continue;
-                       }
+               uint32_t const N = _matrix->count_of_our_type (w.bundle->nchannels ());
 
+               for (uint32_t i = 0; i < N; ++i) {
                        ARDOUR::BundleChannel const bc (w.bundle, i);
                        n.push_back (PortMatrixNode (ARDOUR::BundleChannel (), bc));
                }
index b87f560984539c0a5b560f2d0d0a82bd51e7ff21..fa394de8ef6860142a0b725599e474ad6b4f8429 100644 (file)
@@ -217,15 +217,25 @@ PortMatrixGrid::render (cairo_t* cr)
                                                y += grid_spacing();
                                        }
 
-                                       if ((*j)->bundle->nchannels() == ARDOUR::ChanCount::ZERO) {
+                                       if (_matrix->count_of_our_type ((*j)->bundle->nchannels()) == 0) {
+                                               /* the *j bundle has no channels of our type, so it will have a dummy
+                                                  one which needs to be marked non-connectable.
+                                               */
                                                draw_non_connectable_indicator (cr, x, y);
                                        }
                                        
                                        x += grid_spacing();
                                }
 
-                               if ((*i)->bundle->nchannels() == ARDOUR::ChanCount::ZERO) {
-                                       draw_non_connectable_indicator (cr, x, y);
+                               if (_matrix->count_of_our_type ((*i)->bundle->nchannels()) == 0) {
+                                       /* draw non-connectable indicators for the case where the *i bundle
+                                          has no channels of our type (and hence has 1 dummy channel)
+                                       */
+                                       y = by;
+                                       for (uint32_t l = 0; l < _matrix->count_of_our_type_min_1 ((*j)->bundle->nchannels()); ++l) {
+                                               draw_non_connectable_indicator (cr, x, y);
+                                               y += grid_spacing ();
+                                       }
                                }
 
                                by += _matrix->count_of_our_type_min_1 ((*j)->bundle->nchannels()) * grid_spacing();