- int g = 0;
- for (PortGroupList::const_iterator i = _body->row_ports().begin(); i != _body->row_ports().end(); ++i) {
-
- if (!(*i)->visible() || ((*i)->bundles().empty() && (*i)->ports.empty()) ) {
- continue;
- }
-
- /* compute height of this group */
- double h = 0;
- for (ARDOUR::BundleList::const_iterator j = (*i)->bundles().begin(); j != (*i)->bundles().end(); ++j) {
- h += (*j)->nchannels() * row_height();
- }
- h += (*i)->ports.size() * row_height();
-
- /* rectangle */
- set_source_rgb (cr, get_a_group_colour (g));
- double const rw = _highest_group_name + 2 * name_pad();
- cairo_rectangle (cr, x, y, rw, h);
- cairo_fill (cr);
-
- /* hence what abbreviation (or not) we need for the group name */
- std::pair<std::string, double> display = display_port_name (cr, (*i)->name, h);
-
- /* plot it */
- set_source_rgb (cr, text_colour());
- cairo_move_to (cr, x + rw - name_pad(), y + (h + display.second) / 2);
- cairo_save (cr);
- cairo_rotate (cr, - M_PI / 2);
- cairo_show_text (cr, display.first.c_str());
- cairo_restore (cr);
-
- y += h;
- ++g;
- }
-
- /* BUNDLE NAMES */
-
- x = 0;
- if (_location == LEFT) {
- x = _highest_group_name + 2 * name_pad();
- } else if (_location == RIGHT) {
- x = _longest_port_name + name_pad() * 2;
- }
-
- y = 0;
- ARDOUR::BundleList const r = _body->row_ports().bundles();
- for (ARDOUR::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
-
- Gdk::Color const colour = get_a_bundle_colour (i - r.begin ());
- set_source_rgb (cr, colour);
- cairo_rectangle (cr, x, y, _longest_bundle_name + name_pad() * 2, row_height() * (*i)->nchannels());
- cairo_fill_preserve (cr);
- set_source_rgb (cr, background_colour());
- cairo_set_line_width (cr, label_border_width ());
- cairo_stroke (cr);
-
- double off = 0;
- if ((*i)->nchannels () > 0) {
- /* use the extent of our first channel name so that the bundle name is vertically aligned with it */
- cairo_text_extents_t ext;
- cairo_text_extents (cr, (*i)->channel_name(0).c_str(), &ext);
- off = (row_height() - ext.height) / 2;
+ int N = 0;
+ int M = 0;
+
+ PortGroup::BundleList const & bundles = _matrix->visible_rows()->bundles ();
+ for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
+ render_bundle_name (cr, background_colour (), (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (N), 0, y, (*i)->bundle);
+
+ if (!_matrix->show_only_bundles()) {
+ for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
+
+ if (!_matrix->should_show ((*i)->bundle->channel_type(j))) {
+ continue;
+ }
+
+ Gdk::Color c = (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (M);
+ render_channel_name (cr, background_colour (), c, 0, y, ARDOUR::BundleChannel ((*i)->bundle, j));
+ y += grid_spacing();
+ ++M;
+ }